Share constants among tests for ProfileVerifier
Shared some constants around tests. This is a follow up for aosp/2254555
Test: ./gradlew :profileinstaller:integration-tests:profile-verification:cC
Bug: 253441746
Change-Id: Iee3ce13ea8ad619405fc5b247b8a041230a620ed
diff --git a/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationOnUnsupportedApiVersions.kt b/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationOnUnsupportedApiVersions.kt
index e7af5ff..834bffec 100644
--- a/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationOnUnsupportedApiVersions.kt
+++ b/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationOnUnsupportedApiVersions.kt
@@ -48,7 +48,7 @@
@Test
fun unsupportedApiWithInitializer() = withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
- install(apkName = APK_WITH_INITIALIZER, withProfile = false)
+ install(apkName = APK_WITH_INITIALIZER_V1, withProfile = false)
start(ACTIVITY_NAME)
evaluateUI {
profileInstalled(RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION)
@@ -59,7 +59,7 @@
@Test
fun unsupportedApiWithoutInitializer() = withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
- install(apkName = APK_WITHOUT_INITIALIZER, withProfile = false)
+ install(apkName = APK_WITHOUT_INITIALIZER_V1, withProfile = false)
start(ACTIVITY_NAME)
evaluateUI {
profileInstalled(RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION)
@@ -67,18 +67,4 @@
hasCurrentProfile(false)
}
}
-
- companion object {
- private const val PACKAGE_NAME_WITH_INITIALIZER =
- "androidx.profileinstaller.integration.profileverification.target"
- private const val PACKAGE_NAME_WITHOUT_INITIALIZER =
- "androidx.profileinstaller.integration.profileverification.target.no_initializer"
- private const val ACTIVITY_NAME =
- ".SampleActivity"
-
- private const val APK_WITHOUT_INITIALIZER =
- "profile-verification-sample-no-initializer-v1-release.apk"
- private const val APK_WITH_INITIALIZER =
- "profile-verification-sample-v1-release.apk"
- }
}
\ No newline at end of file
diff --git a/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationTestWithProfileInstallerInitializer.kt b/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationTestWithProfileInstallerInitializer.kt
index 190a008..20cff54 100644
--- a/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationTestWithProfileInstallerInitializer.kt
+++ b/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationTestWithProfileInstallerInitializer.kt
@@ -16,6 +16,8 @@
package androidx.profileinstaller.integration.profileverification
+import androidx.profileinstaller.ProfileVerifier.CompilationStatus.RESULT_CODE_COMPILED_WITH_PROFILE
+import androidx.profileinstaller.ProfileVerifier.CompilationStatus.RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION
import androidx.profileinstaller.ProfileVersion
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
@@ -44,41 +46,41 @@
class ProfileVerificationTestWithProfileInstallerInitializer {
@Before
- fun setUp() = withPackageName(PACKAGE_NAME) {
+ fun setUp() = withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
// Note that this test fails on emulator api 30 (b/251540646)
assumeTrue(!isApi30)
uninstall()
}
@After
- fun tearDown() = withPackageName(PACKAGE_NAME) {
+ fun tearDown() = withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
uninstall()
}
@Test
- fun installNewApp() = withPackageName(PACKAGE_NAME) {
+ fun installNewApp() = withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
// Install without reference profile
- install(apkName = V1_APK, withProfile = false)
+ install(apkName = APK_WITH_INITIALIZER_V1, withProfile = false)
// Start
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
hasReferenceProfile(false)
hasCurrentProfile(true)
}
}
@Test
- fun installNewAppAndWaitForCompilation() = withPackageName(PACKAGE_NAME) {
+ fun installNewAppAndWaitForCompilation() = withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
// Install without reference profile
- install(apkName = V1_APK, withProfile = false)
+ install(apkName = APK_WITH_INITIALIZER_V1, withProfile = false)
// Start once to install profile
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
hasReferenceProfile(false)
hasCurrentProfile(true)
}
@@ -87,7 +89,7 @@
// Start again, should still be awaiting compilation
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
hasReferenceProfile(false)
hasCurrentProfile(true)
}
@@ -99,7 +101,7 @@
// Start again to check profile is compiled
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(false)
}
@@ -107,132 +109,123 @@
// Profile should still be compiled
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(false)
}
}
@Test
- fun installAppWithReferenceProfile() = withPackageName(PACKAGE_NAME) {
+ fun installAppWithReferenceProfile() = withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
// Install with reference profile.
- install(apkName = V1_APK, withProfile = true)
+ install(apkName = APK_WITH_INITIALIZER_V1, withProfile = true)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(true)
}
}
@Test
- fun updateFromReferenceProfileToReferenceProfile() = withPackageName(PACKAGE_NAME) {
+ fun updateFromReferenceProfileToReferenceProfile() =
+ withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
- // Install without reference profile
- install(apkName = V1_APK, withProfile = true)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(COMPILED)
- hasReferenceProfile(true)
- hasCurrentProfile(true)
- }
-
- // Updates adding reference profile
- install(apkName = V2_APK, withProfile = true)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(COMPILED)
- hasReferenceProfile(true)
- hasCurrentProfile(true)
- }
- }
-
- @Test
- fun updateFromNoReferenceProfileToReferenceProfile() = withPackageName(PACKAGE_NAME) {
-
- // Install without reference profile
- install(apkName = V2_APK, withProfile = false)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
- hasReferenceProfile(false)
- hasCurrentProfile(true)
- }
-
- // Updates adding reference profile
- install(apkName = V3_APK, withProfile = true)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(COMPILED)
- hasReferenceProfile(true)
- hasCurrentProfile(true)
- }
- }
-
- @Test
- fun updateFromReferenceProfileToNoReferenceProfile() = withPackageName(PACKAGE_NAME) {
-
- // Install with reference profile
- install(apkName = V1_APK, withProfile = true)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(COMPILED)
- hasReferenceProfile(true)
- hasCurrentProfile(true)
- }
-
- // Updates removing reference profile
- install(apkName = V2_APK, withProfile = false)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
- hasReferenceProfile(false)
- hasCurrentProfile(true)
- }
- }
-
- @Test
- fun installWithReferenceProfileThenUpdateNoProfileThenUpdateProfileAgain() =
- withPackageName(PACKAGE_NAME) {
-
- // Install with reference profile
- install(apkName = V1_APK, withProfile = true)
+ // Install without reference profile
+ install(apkName = APK_WITH_INITIALIZER_V1, withProfile = true)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
+ hasReferenceProfile(true)
+ hasCurrentProfile(true)
+ }
+
+ // Updates adding reference profile
+ install(apkName = APK_WITH_INITIALIZER_V2, withProfile = true)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
+ hasReferenceProfile(true)
+ hasCurrentProfile(true)
+ }
+ }
+
+ @Test
+ fun updateFromNoReferenceProfileToReferenceProfile() =
+ withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
+
+ // Install without reference profile
+ install(apkName = APK_WITH_INITIALIZER_V2, withProfile = false)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
+ hasReferenceProfile(false)
+ hasCurrentProfile(true)
+ }
+
+ // Updates adding reference profile
+ install(apkName = APK_WITH_INITIALIZER_V3, withProfile = true)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
+ hasReferenceProfile(true)
+ hasCurrentProfile(true)
+ }
+ }
+
+ @Test
+ fun updateFromReferenceProfileToNoReferenceProfile() =
+ withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
+
+ // Install with reference profile
+ install(apkName = APK_WITH_INITIALIZER_V1, withProfile = true)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(true)
}
// Updates removing reference profile
- install(apkName = V2_APK, withProfile = false)
+ install(apkName = APK_WITH_INITIALIZER_V2, withProfile = false)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
+ hasReferenceProfile(false)
+ hasCurrentProfile(true)
+ }
+ }
+
+ @Test
+ fun installWithReferenceProfileThenUpdateNoProfileThenUpdateProfileAgain() =
+ withPackageName(PACKAGE_NAME_WITH_INITIALIZER) {
+
+ // Install with reference profile
+ install(apkName = APK_WITH_INITIALIZER_V1, withProfile = true)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
+ hasReferenceProfile(true)
+ hasCurrentProfile(true)
+ }
+
+ // Updates removing reference profile
+ install(apkName = APK_WITH_INITIALIZER_V2, withProfile = false)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
hasReferenceProfile(false)
hasCurrentProfile(true)
}
// Reinstall with reference profile
- install(apkName = V3_APK, withProfile = true)
+ install(apkName = APK_WITH_INITIALIZER_V3, withProfile = true)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(true)
}
}
-
- companion object {
- private const val PACKAGE_NAME =
- "androidx.profileinstaller.integration.profileverification.target"
- private const val ACTIVITY_NAME =
- ".SampleActivity"
-
- // Note that these version differ only for version code 1..3 to allow update
- private const val V1_APK = "profile-verification-sample-v1-release.apk"
- private const val V2_APK = "profile-verification-sample-v2-release.apk"
- private const val V3_APK = "profile-verification-sample-v3-release.apk"
- }
}
diff --git a/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationTestWithoutProfileInstallerInitializer.kt b/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationTestWithoutProfileInstallerInitializer.kt
index c83ac77..cca5f12 100644
--- a/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationTestWithoutProfileInstallerInitializer.kt
+++ b/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/ProfileVerificationTestWithoutProfileInstallerInitializer.kt
@@ -16,6 +16,9 @@
package androidx.profileinstaller.integration.profileverification
+import androidx.profileinstaller.ProfileVerifier.CompilationStatus.RESULT_CODE_COMPILED_WITH_PROFILE
+import androidx.profileinstaller.ProfileVerifier.CompilationStatus.RESULT_CODE_NO_PROFILE
+import androidx.profileinstaller.ProfileVerifier.CompilationStatus.RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION
import androidx.profileinstaller.ProfileVersion
import androidx.test.filters.LargeTest
import androidx.test.filters.SdkSuppress
@@ -46,40 +49,40 @@
class ProfileVerificationTestWithoutProfileInstallerInitializer {
@Before
- fun setUp() = withPackageName(PACKAGE_NAME) {
+ fun setUp() = withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
// Note that this test fails on emulator api 30 (b/251540646)
assumeTrue(!isApi30)
uninstall()
}
@After
- fun tearDown() = withPackageName(PACKAGE_NAME) {
+ fun tearDown() = withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
uninstall()
}
@Test
- fun installNewAppWithoutReferenceProfile() = withPackageName(PACKAGE_NAME) {
+ fun installNewAppWithoutReferenceProfile() = withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
// Install without reference profile
- install(apkName = V1_APK, withProfile = false)
+ install(apkName = APK_WITHOUT_INITIALIZER_V1, withProfile = false)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(NONE)
+ profileInstalled(RESULT_CODE_NO_PROFILE)
hasReferenceProfile(false)
hasCurrentProfile(false)
}
}
@Test
- fun installNewAppAndWaitForCompilation() = withPackageName(PACKAGE_NAME) {
+ fun installNewAppAndWaitForCompilation() = withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
// Install without reference profile
- install(apkName = V1_APK, withProfile = false)
+ install(apkName = APK_WITHOUT_INITIALIZER_V1, withProfile = false)
// Start once to check there is no profile
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(NONE)
+ profileInstalled(RESULT_CODE_NO_PROFILE)
hasReferenceProfile(false)
hasCurrentProfile(false)
}
@@ -88,7 +91,7 @@
// Start again to check there is no profile
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(NONE)
+ profileInstalled(RESULT_CODE_NO_PROFILE)
hasReferenceProfile(false)
hasCurrentProfile(false)
}
@@ -100,7 +103,7 @@
// Start again to check there it's now awaiting compilation
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
hasReferenceProfile(false)
hasCurrentProfile(true)
}
@@ -109,7 +112,7 @@
// Start again to check there it's now awaiting compilation
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
hasReferenceProfile(false)
hasCurrentProfile(true)
}
@@ -121,7 +124,7 @@
// Start again to check profile is compiled
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(false)
}
@@ -129,137 +132,140 @@
// Start again to check profile is compiled
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(false)
}
}
@Test
- fun installAppWithReferenceProfile() = withPackageName(PACKAGE_NAME) {
+ fun installAppWithReferenceProfile() = withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
// Install with reference profile
- install(apkName = V1_APK, withProfile = true)
+ install(apkName = APK_WITHOUT_INITIALIZER_V1, withProfile = true)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(false)
}
}
@Test
- fun updateFromNoReferenceProfileToReferenceProfile() = withPackageName(PACKAGE_NAME) {
+ fun updateFromNoReferenceProfileToReferenceProfile() =
+ withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
- // Install without reference profile
- install(apkName = V2_APK, withProfile = false)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(NONE)
- hasReferenceProfile(false)
- hasCurrentProfile(false)
- }
-
- // Updates adding reference profile
- install(apkName = V3_APK, withProfile = true)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(COMPILED)
- hasReferenceProfile(true)
- hasCurrentProfile(false)
- }
- }
-
- @Test
- fun updateFromReferenceProfileToNoReferenceProfile() = withPackageName(PACKAGE_NAME) {
-
- // Install with reference profile
- install(apkName = V1_APK, withProfile = true)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(COMPILED)
- hasReferenceProfile(true)
- hasCurrentProfile(false)
- }
-
- // Updates removing reference profile
- install(apkName = V2_APK, withProfile = false)
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(NONE)
- hasReferenceProfile(false)
- hasCurrentProfile(false)
- }
- }
-
- @Test
- fun installWithReferenceProfileThenUpdateNoProfileThenUpdateProfileAgain() =
- withPackageName(PACKAGE_NAME) {
-
- // Install with reference profile
- install(apkName = V1_APK, withProfile = true)
+ // Install without reference profile
+ install(apkName = APK_WITHOUT_INITIALIZER_V2, withProfile = false)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_NO_PROFILE)
+ hasReferenceProfile(false)
+ hasCurrentProfile(false)
+ }
+
+ // Updates adding reference profile
+ install(apkName = APK_WITHOUT_INITIALIZER_V3, withProfile = true)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
+ hasReferenceProfile(true)
+ hasCurrentProfile(false)
+ }
+ }
+
+ @Test
+ fun updateFromReferenceProfileToNoReferenceProfile() =
+ withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
+
+ // Install with reference profile
+ install(apkName = APK_WITHOUT_INITIALIZER_V1, withProfile = true)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(false)
}
// Updates removing reference profile
- install(apkName = V2_APK, withProfile = false)
+ install(apkName = APK_WITHOUT_INITIALIZER_V2, withProfile = false)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(NONE)
+ profileInstalled(RESULT_CODE_NO_PROFILE)
+ hasReferenceProfile(false)
+ hasCurrentProfile(false)
+ }
+ }
+
+ @Test
+ fun installWithReferenceProfileThenUpdateNoProfileThenUpdateProfileAgain() =
+ withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
+
+ // Install with reference profile
+ install(apkName = APK_WITHOUT_INITIALIZER_V1, withProfile = true)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
+ hasReferenceProfile(true)
+ hasCurrentProfile(false)
+ }
+
+ // Updates removing reference profile
+ install(apkName = APK_WITHOUT_INITIALIZER_V2, withProfile = false)
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_NO_PROFILE)
hasReferenceProfile(false)
hasCurrentProfile(false)
}
// Reinstall with reference profile
- install(apkName = V3_APK, withProfile = true)
+ install(apkName = APK_WITHOUT_INITIALIZER_V3, withProfile = true)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(false)
}
}
@Test
- fun forceInstallCurrentProfileThroughBroadcastReceiver() = withPackageName(PACKAGE_NAME) {
+ fun forceInstallCurrentProfileThroughBroadcastReceiver() =
+ withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
- // Install without reference profile
- install(apkName = V1_APK, withProfile = false)
+ // Install without reference profile
+ install(apkName = APK_WITHOUT_INITIALIZER_V1, withProfile = false)
- // Start and assess there is no profile
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(NONE)
- hasReferenceProfile(false)
- hasCurrentProfile(false)
+ // Start and assess there is no profile
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_NO_PROFILE)
+ hasReferenceProfile(false)
+ hasCurrentProfile(false)
+ }
+ stop()
+
+ // Force update through broadcast receiver
+ broadcastProfileInstallAction()
+
+ // Start and assess there is a current profile
+ start(ACTIVITY_NAME)
+ evaluateUI {
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
+ hasReferenceProfile(false)
+ hasCurrentProfile(true)
+ }
}
- stop()
-
- // Force update through broadcast receiver
- broadcastProfileInstallAction()
-
- // Start and assess there is a current profile
- start(ACTIVITY_NAME)
- evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
- hasReferenceProfile(false)
- hasCurrentProfile(true)
- }
- }
@Test
fun forceInstallCurrentProfileThroughBroadcastReceiverAndUpdateWithReference() =
- withPackageName(PACKAGE_NAME) {
+ withPackageName(PACKAGE_NAME_WITHOUT_INITIALIZER) {
// Install without reference profile, start and assess there is no profile
- install(apkName = V1_APK, withProfile = false)
+ install(apkName = APK_WITHOUT_INITIALIZER_V1, withProfile = false)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(NONE)
+ profileInstalled(RESULT_CODE_NO_PROFILE)
hasReferenceProfile(false)
hasCurrentProfile(false)
}
@@ -271,39 +277,27 @@
// Start again and assess there is a current profile now installed
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(AWAITING_COMPILATION)
+ profileInstalled(RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION)
hasReferenceProfile(false)
hasCurrentProfile(true)
}
// Update to v2 and assert that the current profile was uninstalled
- install(apkName = V2_APK, withProfile = false)
+ install(apkName = APK_WITHOUT_INITIALIZER_V2, withProfile = false)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(NONE)
+ profileInstalled(RESULT_CODE_NO_PROFILE)
hasReferenceProfile(false)
hasCurrentProfile(false)
}
// Update to v3 with reference profile and assess this is correctly recognized
- install(apkName = V3_APK, withProfile = true)
+ install(apkName = APK_WITHOUT_INITIALIZER_V3, withProfile = true)
start(ACTIVITY_NAME)
evaluateUI {
- profileInstalled(COMPILED)
+ profileInstalled(RESULT_CODE_COMPILED_WITH_PROFILE)
hasReferenceProfile(true)
hasCurrentProfile(false)
}
}
-
- companion object {
- private const val PACKAGE_NAME =
- "androidx.profileinstaller.integration.profileverification.target.no_initializer"
- private const val ACTIVITY_NAME =
- ".SampleActivity"
-
- // Note that these version differ only for version code 1..3 to allow update
- private const val V1_APK = "profile-verification-sample-no-initializer-v1-release.apk"
- private const val V2_APK = "profile-verification-sample-no-initializer-v2-release.apk"
- private const val V3_APK = "profile-verification-sample-no-initializer-v3-release.apk"
- }
}
diff --git a/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/TestManager.kt b/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/TestManager.kt
index d289ce0..fc1796d 100644
--- a/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/TestManager.kt
+++ b/profileinstaller/integration-tests/profile-verification/src/androidTest/java/androidx/profileinstaller/integration/profileverification/TestManager.kt
@@ -23,9 +23,6 @@
import androidx.concurrent.futures.DirectExecutor
import androidx.profileinstaller.DeviceProfileWriter
import androidx.profileinstaller.ProfileInstaller
-import androidx.profileinstaller.ProfileVerifier.CompilationStatus.RESULT_CODE_COMPILED_WITH_PROFILE
-import androidx.profileinstaller.ProfileVerifier.CompilationStatus.RESULT_CODE_NO_PROFILE
-import androidx.profileinstaller.ProfileVerifier.CompilationStatus.RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
@@ -288,14 +285,6 @@
}
}
-val isApi30 by lazy { Build.VERSION.SDK_INT == Build.VERSION_CODES.R }
-
-const val COMPILED = RESULT_CODE_COMPILED_WITH_PROFILE
-const val AWAITING_COMPILATION = RESULT_CODE_PROFILE_ENQUEUED_FOR_COMPILATION
-const val NONE = RESULT_CODE_NO_PROFILE
-
-private fun <T> T?.throwIfNull(message: String): T = this ?: throw Exception(message)
-
private val EMPTY_DIAGNOSTICS: ProfileInstaller.DiagnosticsCallback =
object : ProfileInstaller.DiagnosticsCallback {
private val TAG = "ProfileVerifierDiagnosticsCallback"
@@ -307,3 +296,19 @@
Log.d(TAG, "onResultReceived: $code")
}
}
+
+private fun <T> T?.throwIfNull(message: String): T = this ?: throw Exception(message)
+
+val isApi30 by lazy { Build.VERSION.SDK_INT == Build.VERSION_CODES.R }
+
+const val PACKAGE_NAME_WITH_INITIALIZER =
+ "androidx.profileinstaller.integration.profileverification.target"
+const val PACKAGE_NAME_WITHOUT_INITIALIZER =
+ "androidx.profileinstaller.integration.profileverification.target.no_initializer"
+const val ACTIVITY_NAME = ".SampleActivity"
+const val APK_WITH_INITIALIZER_V1 = "profile-verification-sample-v1-release.apk"
+const val APK_WITH_INITIALIZER_V2 = "profile-verification-sample-v2-release.apk"
+const val APK_WITH_INITIALIZER_V3 = "profile-verification-sample-v3-release.apk"
+const val APK_WITHOUT_INITIALIZER_V1 = "profile-verification-sample-no-initializer-v1-release.apk"
+const val APK_WITHOUT_INITIALIZER_V2 = "profile-verification-sample-no-initializer-v2-release.apk"
+const val APK_WITHOUT_INITIALIZER_V3 = "profile-verification-sample-no-initializer-v3-release.apk"
\ No newline at end of file
diff --git a/profileinstaller/profileinstaller/src/main/java/androidx/profileinstaller/ProfileVerifier.java b/profileinstaller/profileinstaller/src/main/java/androidx/profileinstaller/ProfileVerifier.java
index 671e131..267b498 100644
--- a/profileinstaller/profileinstaller/src/main/java/androidx/profileinstaller/ProfileVerifier.java
+++ b/profileinstaller/profileinstaller/src/main/java/androidx/profileinstaller/ProfileVerifier.java
@@ -64,6 +64,8 @@
* Note that {@link ProfileVerifier} requires {@link Build.VERSION_CODES#P} due to a permission
* issue: the reference profile folder is not accessible to pre api 28. When calling this api on
* unsupported api, {@link #getCompilationStatusAsync()} returns
+ * {@link CompilationStatus#RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION}. The same permission issue
+ * exists also on {@link Build.VERSION_CODES#R} so also in that case the api returns
* {@link CompilationStatus#RESULT_CODE_ERROR_UNSUPPORTED_API_VERSION}.
*/
public final class ProfileVerifier {