diff options
author | Eric Rowe <erowe@google.com> | 2010-11-15 17:05:40 -0800 |
---|---|---|
committer | Eric Rowe <erowe@google.com> | 2010-11-15 17:09:46 -0800 |
commit | b49aa60829ab8fadec2f4c0661271100691d8225 (patch) | |
tree | 7c483f2705ad429fdbbc58f32e54e5eaa8a9b8cf /core/tests | |
parent | 23c067692be74c4fcd50cea48f9d469ba5288213 (diff) | |
download | frameworks_base-b49aa60829ab8fadec2f4c0661271100691d8225.zip frameworks_base-b49aa60829ab8fadec2f4c0661271100691d8225.tar.gz frameworks_base-b49aa60829ab8fadec2f4c0661271100691d8225.tar.bz2 |
Remove asserts in bluetooth test utils
Certain checks were causing the test to fail due to a race condition.
Bug: b/3198566
Change-Id: I9389a1936f6032939851922c052ef8ed32e5283b
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java b/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java index 2027398..29dee34 100644 --- a/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java +++ b/core/tests/coretests/src/android/bluetooth/BluetoothTestUtils.java @@ -137,7 +137,6 @@ public class BluetoothTestUtils extends Assert { @Override public void onReceive(Context context, Intent intent) { - Log.i("BT", intent.toString()); if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(intent.getAction())) { setFiredFlag(DISCOVERY_STARTED_FLAG); } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(intent.getAction())) { @@ -203,7 +202,7 @@ public class BluetoothTestUtils extends Assert { if (BluetoothDevice.ACTION_PAIRING_REQUEST.equals(intent.getAction())) { int varient = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, -1); assertNotSame(-1, varient); - switch(varient) { + switch (varient) { case BluetoothDevice.PAIRING_VARIANT_PIN: mDevice.setPin(mPin); break; @@ -252,7 +251,7 @@ public class BluetoothTestUtils extends Assert { mDevice = device; mProfile = profile; - switch(mProfile) { + switch (mProfile) { case BluetoothProfile.A2DP: mConnectionAction = BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED; break; @@ -384,11 +383,14 @@ public class BluetoothTestUtils extends Assert { mask = 0; // Don't check for received intents since we might have missed them. break; case BluetoothAdapter.STATE_OFF: - case BluetoothAdapter.STATE_TURNING_OFF: assertFalse(adapter.isEnabled()); start = System.currentTimeMillis(); assertTrue(adapter.enable()); break; + case BluetoothAdapter.STATE_TURNING_OFF: + start = System.currentTimeMillis(); + assertTrue(adapter.enable()); + break; default: removeReceiver(receiver); fail(String.format("enable() invalid state: state=%d", state)); @@ -410,7 +412,6 @@ public class BluetoothTestUtils extends Assert { return; } } else { - assertFalse(adapter.isEnabled()); assertEquals(BluetoothAdapter.STATE_TURNING_ON, state); } sleep(POLL_TIME); @@ -437,7 +438,6 @@ public class BluetoothTestUtils extends Assert { case BluetoothAdapter.STATE_TURNING_ON: assertFalse(adapter.isEnabled()); start = System.currentTimeMillis(); - assertTrue(adapter.disable()); break; case BluetoothAdapter.STATE_ON: assertTrue(adapter.isEnabled()); @@ -470,7 +470,6 @@ public class BluetoothTestUtils extends Assert { return; } } else { - assertFalse(adapter.isEnabled()); assertEquals(BluetoothAdapter.STATE_TURNING_OFF, state); } sleep(POLL_TIME); @@ -665,7 +664,6 @@ public class BluetoothTestUtils extends Assert { assertTrue(adapter.getBondedDevices().contains(device)); return; default: - removeReceiver(receiver); fail(String.format("%s invalid state: device=%s, state=%d", methodName, device, state)); @@ -803,7 +801,7 @@ public class BluetoothTestUtils extends Assert { long finish = receiver.getCompletedTime(); if (start != -1 && finish != -1) { writeOutput(String.format("connectProfile() completed in %d ms: " - +"device=%s, profile=%d", (finish - start), device, profile)); + + "device=%s, profile=%d", (finish - start), device, profile)); } else { writeOutput(String.format("connectProfile() completed: device=%s, " + "profile=%d", device, profile)); @@ -872,7 +870,7 @@ public class BluetoothTestUtils extends Assert { long finish = receiver.getCompletedTime(); if (start != -1 && finish != -1) { writeOutput(String.format("disconnectProfile() completed in %d ms: " - +"device=%s, profile=%d", (finish - start), device, profile)); + + "device=%s, profile=%d", (finish - start), device, profile)); } else { writeOutput(String.format("disconnectProfile() completed: device=%s, " + "profile=%d", device, profile)); @@ -949,14 +947,12 @@ public class BluetoothTestUtils extends Assert { long s = System.currentTimeMillis(); switch (profile) { case BluetoothProfile.A2DP: - while (mA2dp != null - && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) { + while (mA2dp != null && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) { sleep(POLL_TIME); } return mA2dp; case BluetoothProfile.HEADSET: - while (mHeadset != null - && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) { + while (mHeadset != null && System.currentTimeMillis() - s < CONNECT_PROXY_TIMEOUT) { sleep(POLL_TIME); } return mHeadset; |