Loading core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java +67 −32 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); mTestUtils.disable(adapter); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("enable iteration " + (i + 1) + " of " + iterations); Loading @@ -78,7 +79,9 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.undiscoverable(adapter); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("discoverable iteration " + (i + 1) + " of " + iterations); Loading @@ -99,7 +102,9 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.stopScan(adapter); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("scan iteration " + (i + 1) + " of " + iterations); Loading @@ -116,7 +121,9 @@ public class BluetoothStressTest extends InstrumentationTestCase { public void testEnablePan() { int iterations = BluetoothTestRunner.sEnablePanIterations; BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.disablePan(adapter); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("testEnablePan iteration " + (i + 1) + " of " Loading @@ -141,13 +148,15 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPairAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.unpair(adapter, device); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("pair iteration " + (i + 1) + " of " + iterations); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.unpair(adapter, device); } mTestUtils.disable(adapter); Loading @@ -162,13 +171,15 @@ public class BluetoothStressTest extends InstrumentationTestCase { public void testAcceptPair() { int iterations = BluetoothTestRunner.sPairIterations; BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPairAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.unpair(adapter, device); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("acceptPair iteration " + (i + 1) + " of " + iterations); mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.unpair(adapter, device); } mTestUtils.disable(adapter); Loading @@ -187,15 +198,20 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sA2dpAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.A2DP, null); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("connectA2dp iteration " + (i + 1) + " of " + iterations); mTestUtils.connectProfile(adapter, device, BluetoothProfile.A2DP); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.A2DP); mTestUtils.connectProfile(adapter, device, BluetoothProfile.A2DP, String.format("connectA2dp(device=%s)", device)); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.A2DP, String.format("disconnectA2dp(device=%s)", device)); } mTestUtils.unpair(adapter, device); Loading @@ -215,15 +231,20 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sHeadsetAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET, null); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("connectHeadset iteration " + (i + 1) + " of " + iterations); mTestUtils.connectProfile(adapter, device, BluetoothProfile.HEADSET); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET); mTestUtils.connectProfile(adapter, device, BluetoothProfile.HEADSET, String.format("connectHeadset(device=%s)", device)); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET, String.format("disconnectHeadset(device=%s)", device)); } mTestUtils.unpair(adapter, device); Loading @@ -243,15 +264,20 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sInputAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE, null); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("connectInput iteration " + (i + 1) + " of " + iterations); mTestUtils.connectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE); mTestUtils.connectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE, String.format("connectInput(device=%s)", device)); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE, String.format("disconnectInput(device=%s)", device)); } mTestUtils.unpair(adapter, device); Loading @@ -271,10 +297,12 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPanAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("connectPan iteration " + (i + 1) + " of " + iterations); Loading @@ -299,11 +327,14 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPanAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.disablePan(adapter); mTestUtils.enablePan(adapter); mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("incomingPanConnection iteration " + (i + 1) + " of " Loading @@ -330,11 +361,15 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sHeadsetAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.connectProfile(adapter, device, BluetoothProfile.HEADSET); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET, null); mTestUtils.connectProfile(adapter, device, BluetoothProfile.HEADSET, null); mTestUtils.stopSco(adapter, device); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("startStopSco iteration " + (i + 1) + " of " + iterations); Loading @@ -342,7 +377,7 @@ public class BluetoothStressTest extends InstrumentationTestCase { mTestUtils.stopSco(adapter, device); } mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET, null); mTestUtils.unpair(adapter, device); mTestUtils.disable(adapter); } Loading core/tests/coretests/src/android/bluetooth/BluetoothTestRunner.java +15 −40 Original line number Diff line number Diff line Loading @@ -65,14 +65,9 @@ public class BluetoothTestRunner extends InstrumentationTestRunner { public static int sConnectPanIterations = 100; public static int sStartStopScoIterations = 100; public static String sPairAddress = ""; public static String sHeadsetAddress = ""; public static String sA2dpAddress = ""; public static String sInputAddress = ""; public static String sPanAddress = ""; public static byte[] sPairPin = {'1', '2', '3', '4'}; public static int sPairPasskey = 123456; public static String sDeviceAddress = ""; public static byte[] sDevicePairPin = {'1', '2', '3', '4'}; public static int sDevicePairPasskey = 123456; @Override public TestSuite getAllTests() { Loading Loading @@ -177,40 +172,24 @@ public class BluetoothTestRunner extends InstrumentationTestRunner { // Invalid argument, fall back to default value } } val = arguments.getString("pair_address"); if (val != null) { sPairAddress = val; } val = arguments.getString("headset_address"); if (val != null) { sHeadsetAddress = val; } val = arguments.getString("a2dp_address"); val = arguments.getString("device_address"); if (val != null) { sA2dpAddress = val; sDeviceAddress = val; } val = arguments.getString("input_address"); val = arguments.getString("device_pair_pin"); if (val != null) { sInputAddress = val; byte[] pin = BluetoothDevice.convertPinToBytes(val); if (pin != null) { sDevicePairPin = pin; } val = arguments.getString("pan_address"); if (val != null) { sPanAddress = val; } val = arguments.getString("pair_pin"); if (val != null) { sPairPin = BluetoothDevice.convertPinToBytes(val); } val = arguments.getString("pair_passkey"); val = arguments.getString("device_pair_passkey"); if (val != null) { try { sPairPasskey = Integer.parseInt(val); sDevicePairPasskey = Integer.parseInt(val); } catch (NumberFormatException e) { // Invalid argument, fall back to default value } Loading @@ -225,13 +204,9 @@ public class BluetoothTestRunner extends InstrumentationTestRunner { Log.i(TAG, String.format("connect_input_iterations=%d", sConnectInputIterations)); Log.i(TAG, String.format("connect_pan_iterations=%d", sConnectPanIterations)); Log.i(TAG, String.format("start_stop_sco_iterations=%d", sStartStopScoIterations)); Log.i(TAG, String.format("pair_address=%s", sPairAddress)); Log.i(TAG, String.format("a2dp_address=%s", sA2dpAddress)); Log.i(TAG, String.format("headset_address=%s", sHeadsetAddress)); Log.i(TAG, String.format("input_address=%s", sInputAddress)); Log.i(TAG, String.format("pan_address=%s", sPanAddress)); Log.i(TAG, String.format("pair_pin=%s", new String(sPairPin))); Log.i(TAG, String.format("pair_passkey=%d", sPairPasskey)); Log.i(TAG, String.format("device_address=%s", sDeviceAddress)); Log.i(TAG, String.format("device_pair_pin=%s", new String(sDevicePairPin))); Log.i(TAG, String.format("device_pair_passkey=%d", sDevicePairPasskey)); // Call onCreate last since we want to set the static variables first. super.onCreate(arguments); Loading core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java +138 −166 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/tests/coretests/src/android/bluetooth/BluetoothStressTest.java +67 −32 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); mTestUtils.disable(adapter); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("enable iteration " + (i + 1) + " of " + iterations); Loading @@ -78,7 +79,9 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.undiscoverable(adapter); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("discoverable iteration " + (i + 1) + " of " + iterations); Loading @@ -99,7 +102,9 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.stopScan(adapter); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("scan iteration " + (i + 1) + " of " + iterations); Loading @@ -116,7 +121,9 @@ public class BluetoothStressTest extends InstrumentationTestCase { public void testEnablePan() { int iterations = BluetoothTestRunner.sEnablePanIterations; BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.disablePan(adapter); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("testEnablePan iteration " + (i + 1) + " of " Loading @@ -141,13 +148,15 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPairAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.unpair(adapter, device); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("pair iteration " + (i + 1) + " of " + iterations); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.unpair(adapter, device); } mTestUtils.disable(adapter); Loading @@ -162,13 +171,15 @@ public class BluetoothStressTest extends InstrumentationTestCase { public void testAcceptPair() { int iterations = BluetoothTestRunner.sPairIterations; BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPairAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.unpair(adapter, device); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("acceptPair iteration " + (i + 1) + " of " + iterations); mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.unpair(adapter, device); } mTestUtils.disable(adapter); Loading @@ -187,15 +198,20 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sA2dpAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.A2DP, null); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("connectA2dp iteration " + (i + 1) + " of " + iterations); mTestUtils.connectProfile(adapter, device, BluetoothProfile.A2DP); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.A2DP); mTestUtils.connectProfile(adapter, device, BluetoothProfile.A2DP, String.format("connectA2dp(device=%s)", device)); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.A2DP, String.format("disconnectA2dp(device=%s)", device)); } mTestUtils.unpair(adapter, device); Loading @@ -215,15 +231,20 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sHeadsetAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET, null); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("connectHeadset iteration " + (i + 1) + " of " + iterations); mTestUtils.connectProfile(adapter, device, BluetoothProfile.HEADSET); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET); mTestUtils.connectProfile(adapter, device, BluetoothProfile.HEADSET, String.format("connectHeadset(device=%s)", device)); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET, String.format("disconnectHeadset(device=%s)", device)); } mTestUtils.unpair(adapter, device); Loading @@ -243,15 +264,20 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sInputAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE, null); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("connectInput iteration " + (i + 1) + " of " + iterations); mTestUtils.connectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE); mTestUtils.connectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE, String.format("connectInput(device=%s)", device)); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.INPUT_DEVICE, String.format("disconnectInput(device=%s)", device)); } mTestUtils.unpair(adapter, device); Loading @@ -271,10 +297,12 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPanAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("connectPan iteration " + (i + 1) + " of " + iterations); Loading @@ -299,11 +327,14 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sPanAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.disablePan(adapter); mTestUtils.enablePan(adapter); mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.unpair(adapter, device); mTestUtils.acceptPair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("incomingPanConnection iteration " + (i + 1) + " of " Loading @@ -330,11 +361,15 @@ public class BluetoothStressTest extends InstrumentationTestCase { } BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sHeadsetAddress); BluetoothDevice device = adapter.getRemoteDevice(BluetoothTestRunner.sDeviceAddress); mTestUtils.disable(adapter); mTestUtils.enable(adapter); mTestUtils.pair(adapter, device, BluetoothTestRunner.sPairPasskey, BluetoothTestRunner.sPairPin); mTestUtils.connectProfile(adapter, device, BluetoothProfile.HEADSET); mTestUtils.unpair(adapter, device); mTestUtils.pair(adapter, device, BluetoothTestRunner.sDevicePairPasskey, BluetoothTestRunner.sDevicePairPin); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET, null); mTestUtils.connectProfile(adapter, device, BluetoothProfile.HEADSET, null); mTestUtils.stopSco(adapter, device); for (int i = 0; i < iterations; i++) { mTestUtils.writeOutput("startStopSco iteration " + (i + 1) + " of " + iterations); Loading @@ -342,7 +377,7 @@ public class BluetoothStressTest extends InstrumentationTestCase { mTestUtils.stopSco(adapter, device); } mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET); mTestUtils.disconnectProfile(adapter, device, BluetoothProfile.HEADSET, null); mTestUtils.unpair(adapter, device); mTestUtils.disable(adapter); } Loading
core/tests/coretests/src/android/bluetooth/BluetoothTestRunner.java +15 −40 Original line number Diff line number Diff line Loading @@ -65,14 +65,9 @@ public class BluetoothTestRunner extends InstrumentationTestRunner { public static int sConnectPanIterations = 100; public static int sStartStopScoIterations = 100; public static String sPairAddress = ""; public static String sHeadsetAddress = ""; public static String sA2dpAddress = ""; public static String sInputAddress = ""; public static String sPanAddress = ""; public static byte[] sPairPin = {'1', '2', '3', '4'}; public static int sPairPasskey = 123456; public static String sDeviceAddress = ""; public static byte[] sDevicePairPin = {'1', '2', '3', '4'}; public static int sDevicePairPasskey = 123456; @Override public TestSuite getAllTests() { Loading Loading @@ -177,40 +172,24 @@ public class BluetoothTestRunner extends InstrumentationTestRunner { // Invalid argument, fall back to default value } } val = arguments.getString("pair_address"); if (val != null) { sPairAddress = val; } val = arguments.getString("headset_address"); if (val != null) { sHeadsetAddress = val; } val = arguments.getString("a2dp_address"); val = arguments.getString("device_address"); if (val != null) { sA2dpAddress = val; sDeviceAddress = val; } val = arguments.getString("input_address"); val = arguments.getString("device_pair_pin"); if (val != null) { sInputAddress = val; byte[] pin = BluetoothDevice.convertPinToBytes(val); if (pin != null) { sDevicePairPin = pin; } val = arguments.getString("pan_address"); if (val != null) { sPanAddress = val; } val = arguments.getString("pair_pin"); if (val != null) { sPairPin = BluetoothDevice.convertPinToBytes(val); } val = arguments.getString("pair_passkey"); val = arguments.getString("device_pair_passkey"); if (val != null) { try { sPairPasskey = Integer.parseInt(val); sDevicePairPasskey = Integer.parseInt(val); } catch (NumberFormatException e) { // Invalid argument, fall back to default value } Loading @@ -225,13 +204,9 @@ public class BluetoothTestRunner extends InstrumentationTestRunner { Log.i(TAG, String.format("connect_input_iterations=%d", sConnectInputIterations)); Log.i(TAG, String.format("connect_pan_iterations=%d", sConnectPanIterations)); Log.i(TAG, String.format("start_stop_sco_iterations=%d", sStartStopScoIterations)); Log.i(TAG, String.format("pair_address=%s", sPairAddress)); Log.i(TAG, String.format("a2dp_address=%s", sA2dpAddress)); Log.i(TAG, String.format("headset_address=%s", sHeadsetAddress)); Log.i(TAG, String.format("input_address=%s", sInputAddress)); Log.i(TAG, String.format("pan_address=%s", sPanAddress)); Log.i(TAG, String.format("pair_pin=%s", new String(sPairPin))); Log.i(TAG, String.format("pair_passkey=%d", sPairPasskey)); Log.i(TAG, String.format("device_address=%s", sDeviceAddress)); Log.i(TAG, String.format("device_pair_pin=%s", new String(sDevicePairPin))); Log.i(TAG, String.format("device_pair_passkey=%d", sDevicePairPasskey)); // Call onCreate last since we want to set the static variables first. super.onCreate(arguments); Loading
core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java +138 −166 File changed.Preview size limit exceeded, changes collapsed. Show changes