Weaken assertion in CDM test
Don't assume device has no prior CDM associations
Bug: 181714305
Test: presubmit
Change-Id: I5681ba564c8d92f54df4c283a19fe82a55fb5de0
diff --git a/tests/tests/os/src/android/os/cts/CompanionDeviceManagerTest.kt b/tests/tests/os/src/android/os/cts/CompanionDeviceManagerTest.kt
index ee035bd..0620626 100644
--- a/tests/tests/os/src/android/os/cts/CompanionDeviceManagerTest.kt
+++ b/tests/tests/os/src/android/os/cts/CompanionDeviceManagerTest.kt
@@ -36,7 +36,8 @@
import com.android.compatibility.common.util.children
import com.android.compatibility.common.util.click
import org.hamcrest.CoreMatchers.containsString
-import org.hamcrest.Matchers.hasSize
+import org.hamcrest.Matchers.empty
+import org.hamcrest.Matchers.not
import org.junit.Assert.assertThat
import org.junit.Assume.assumeTrue
import org.junit.Before
@@ -148,9 +149,9 @@
device!!.click()
eventually {
- assertThat(getAssociatedDevices(packageName), hasSize(1))
+ assertThat(getAssociatedDevices(packageName), not(empty()))
}
- val deviceAddress = getAssociatedDevices(packageName)[0]
+ val deviceAddress = getAssociatedDevices(packageName).last()
runShellCommandOrThrow("cmd companiondevice simulate_connect $deviceAddress")
assertPermission(packageName, "android.permission.CALL_PHONE", PERMISSION_GRANTED)