Change screenshot test to use RNG

Test: atest -c SettingsScreenshotRNGTests
 -- --test-arg
 com.android.tradefed.testtype.IsolatedHostTest:java-flags:
 -Drobolectric.graphicsMode=NATIVE
Fixes: 314807258
Change-Id: I4fa533c19d0b1386a7a4649ed88e3814816c1899
diff --git a/tests/screenshot/Android.bp b/tests/screenshot/Android.bp
index e20b5d3..5989381 100644
--- a/tests/screenshot/Android.bp
+++ b/tests/screenshot/Android.bp
@@ -29,42 +29,46 @@
         "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"],
+}
+
+// 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",
-    data: [":ScreenshotTestStub"],
+    java_resource_dirs: ["config"],
 }
diff --git a/tests/screenshot/AndroidManifest.xml b/tests/screenshot/AndroidManifest.xml
index 9cbc882..6c8bb88 100644
--- a/tests/screenshot/AndroidManifest.xml
+++ b/tests/screenshot/AndroidManifest.xml
@@ -16,32 +16,13 @@
 -->
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    package="com.android.settings.tests.screenshot"
-    >
-
-    <application android:debuggable="true">
-        <provider
-            android:name="com.android.settings.slices.SettingsSliceProvider"
-            android:authorities="com.android.settings.tests.screenshot.disabled"
-            android:enabled="false"
-            tools:node="remove"
-            tools:replace="android:authorities" />
-
-    </application>
-
-    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
-    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
-    <uses-permission android:name="android.permission.READ_LOGS" />
-    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
-    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
+        xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
+        coreApp="true"
+        package="com.android.settings">
     <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
 
-    <instrumentation
-        android:name="androidx.test.runner.AndroidJUnitRunner"
-        android:label="Android Settings Screenshot tests"
-        android:targetPackage="com.android.settings.tests.screenshot" />
+    <application>
+        <activity android:name="com.android.settings.test.screenshot.ContainerActivity" android:exported="true" />
+    </application>
 
-</manifest>
+</manifest>
\ No newline at end of file
diff --git a/tests/screenshot/AndroidTest.xml b/tests/screenshot/AndroidTest.xml
deleted file mode 100644
index 7496ffd..0000000
--- a/tests/screenshot/AndroidTest.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<!--
-  ~ 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.
-  -->
-
-<configuration description="Runs settings screendiff tests.">
-    <option name="test-suite-tag" value="apct-instrumentation" />
-    <option name="test-suite-tag" value="apct" />
-    <target_preparer class="com.android.tradefed.targetprep.DeviceSetup">
-        <option name="optimized-property-setting" value="true" />
-    </target_preparer>
-    <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
-        <option name="cleanup-apks" value="true" />
-        <option name="test-file-name" value="SettingsScreenshotTests.apk" />
-    </target_preparer>
-    <metrics_collector class="com.android.tradefed.device.metric.FilePullerLogCollector">
-        <option name="directory-keys"
-            value="/data/user/0/com.android.settings.tests.screenshot/" />
-        <option name="collect-on-run-ended-only" value="true" />
-    </metrics_collector>
-    <test class="com.android.tradefed.testtype.AndroidJUnitTest">
-        <option name="package" value="com.android.settings.tests.screenshot" />
-        <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
-    </test>
-</configuration>
diff --git "a/tests/screenshot/assets/pixel_4a_\0505g\051/fp_enroll_intro.png" "b/tests/screenshot/assets/pixel_4a_\0505g\051/fp_enroll_intro.png"
deleted file mode 100644
index 1129250..0000000
--- "a/tests/screenshot/assets/pixel_4a_\0505g\051/fp_enroll_intro.png"
+++ /dev/null
Binary files 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 0000000..308ab55
--- /dev/null
+++ b/tests/screenshot/assets/robolectric/fp_enroll_intro.png
Binary files differ
diff --git a/tests/screenshot/config/robolectric.properties b/tests/screenshot/config/robolectric.properties
new file mode 100644
index 0000000..88443e3
--- /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 0000000..a505ef5
--- /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