diff --git a/tests/screenshot/Android.bp b/tests/screenshot/Android.bp index e20b5d34e93..59893816813 100644 --- a/tests/screenshot/Android.bp +++ b/tests/screenshot/Android.bp @@ -29,42 +29,46 @@ android_app { "androidx.fragment_fragment", "androidx.test.runner", "androidx.test.core", - ], - uses_libs: ["org.apache.http.legacy"], - - aaptflags: ["--extra-packages com.android.settings"], - manifest: "AndroidManifest.xml", -} - -android_test { - name: "SettingsScreenshotTests", - platform_apis: true, - certificate: "platform", - test_suites: ["device-tests"], - srcs: [ - "src/**/*.kt", - ], - static_libs: [ - "androidx.fragment_fragment-testing", - "androidx.fragment_fragment", "androidx.test.rules", "androidx.test.ext.junit", "platform-screenshot-diff-core", "Settings-testutils2", - "androidx.test.core", "androidx.test.espresso.core", "kotlinx-coroutines-android", "androidx.lifecycle_lifecycle-runtime-testing", "kotlinx_coroutines_test", - "Settings-core", - "androidx.test.runner", ], uses_libs: ["org.apache.http.legacy"], - compile_multilib: "both", + aaptflags: ["--extra-packages com.android.settings"], manifest: "AndroidManifest.xml", - test_config: "AndroidTest.xml", - use_embedded_native_libs: false, - asset_dirs: ["assets"], - instrumentation_for: "ScreenshotTestStub", - data: [":ScreenshotTestStub"], +} + +// This is a RNG (Robolectric native graphics) test target. +android_robolectric_test { + name: "SettingsScreenshotRNGTests", + srcs: [ + "src/**/*.kt", + ], + test_suites: ["general-tests"], + + // Do not add any libraries here, instead add them to the ScreenshotTestStub + static_libs: [ + "androidx.compose.runtime_runtime", + "androidx.test.uiautomator_uiautomator", + "androidx.test.ext.junit", + "inline-mockito-robolectric-prebuilt", + "platform-parametric-runner-lib", + "uiautomator-helpers", + + ], + libs: [ + "android.test.runner", + "android.test.base", + "android.test.mock", + "truth", + ], + + upstream: true, + instrumentation_for: "ScreenshotTestStub", + java_resource_dirs: ["config"], } diff --git a/tests/screenshot/AndroidManifest.xml b/tests/screenshot/AndroidManifest.xml index 9cbc882f002..6c8bb882104 100644 --- a/tests/screenshot/AndroidManifest.xml +++ b/tests/screenshot/AndroidManifest.xml @@ -16,32 +16,13 @@ --> - - - - - - - - - - - - - + xmlns:androidprv="http://schemas.android.com/apk/prv/res/android" + coreApp="true" + package="com.android.settings"> - + + + - + \ No newline at end of file diff --git a/tests/screenshot/AndroidTest.xml b/tests/screenshot/AndroidTest.xml deleted file mode 100644 index 7496ffd6991..00000000000 --- a/tests/screenshot/AndroidTest.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - diff --git a/tests/screenshot/assets/pixel_4a_(5g)/fp_enroll_intro.png b/tests/screenshot/assets/pixel_4a_(5g)/fp_enroll_intro.png deleted file mode 100644 index 1129250974e..00000000000 Binary files a/tests/screenshot/assets/pixel_4a_(5g)/fp_enroll_intro.png and /dev/null differ diff --git a/tests/screenshot/assets/robolectric/fp_enroll_intro.png b/tests/screenshot/assets/robolectric/fp_enroll_intro.png new file mode 100644 index 00000000000..308ab559292 Binary files /dev/null and b/tests/screenshot/assets/robolectric/fp_enroll_intro.png differ diff --git a/tests/screenshot/config/robolectric.properties b/tests/screenshot/config/robolectric.properties new file mode 100644 index 00000000000..88443e37c53 --- /dev/null +++ b/tests/screenshot/config/robolectric.properties @@ -0,0 +1,16 @@ +# Copyright (C) 2023 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +sdk=NEWEST_SDK +graphicsMode=NATIVE \ No newline at end of file diff --git a/tests/screenshot/src/com/android/settings/tests/screenshot/ContainerActivity.kt b/tests/screenshot/src/com/android/settings/tests/screenshot/ContainerActivity.kt new file mode 100644 index 00000000000..a505ef594ed --- /dev/null +++ b/tests/screenshot/src/com/android/settings/tests/screenshot/ContainerActivity.kt @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.tests.screenshot + +import android.os.Bundle +import androidx.fragment.app.FragmentActivity +import androidx.fragment.app.FragmentContainerView + +/** + * This activity is a container for all RNG (Robolectric Native Graphic) Settings screenshot tests. + */ +class ContainerActivity : FragmentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val contentView = FragmentContainerView(this) + contentView.setId(CONTAINER_VIEW_ID) + setContentView(contentView) + } + + companion object { + const val CONTAINER_VIEW_ID = 1234 + } +} \ No newline at end of file