1 /* 2 * Copyright 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.bluetooth; 17 18 import androidx.test.filters.MediumTest; 19 import androidx.test.runner.AndroidJUnit4; 20 21 import org.junit.Assert; 22 import org.junit.Test; 23 import org.junit.runner.RunWith; 24 25 import java.io.File; 26 import java.io.IOException; 27 28 /** 29 * Test Bluetooth's ability to write to the different directories that it 30 * is supposed to own 31 */ 32 @MediumTest 33 @RunWith(AndroidJUnit4.class) 34 public class FileSystemWriteTest { 35 @Test testBluetoothDirWrite()36 public void testBluetoothDirWrite() { 37 try { 38 File file = new File("/data/misc/bluetooth/test.file"); 39 Assert.assertTrue("File not created", file.createNewFile()); 40 file.delete(); 41 } catch (IOException e) { 42 Assert.fail("Exception creating file /data/misc/bluetooth/test.file: " + e); 43 } 44 } 45 46 @Test testBluedroidDirWrite()47 public void testBluedroidDirWrite() { 48 try { 49 File file = new File("/data/misc/bluedroid/test.file"); 50 Assert.assertTrue("File not created", file.createNewFile()); 51 file.delete(); 52 } catch (IOException e) { 53 Assert.fail("Exception creating file /data/misc/bluedroid/test.file: " + e); 54 } 55 } 56 57 @Test testBluetoothLogsDirWrite()58 public void testBluetoothLogsDirWrite() { 59 try { 60 File file = new File("/data/misc/bluetooth/logs/test.file"); 61 Assert.assertTrue("File not created", file.createNewFile()); 62 file.delete(); 63 } catch (IOException e) { 64 Assert.fail("Exception creating file /data/misc/bluetooth/logs/test.file: " + e); 65 } 66 } 67 } 68