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
This commit is contained in:
Joshua McCloskey
2023-12-04 20:58:38 +00:00
committed by Joshua Mccloskey
parent e6b9290a0e
commit f055c2e374
7 changed files with 91 additions and 89 deletions

View File

@@ -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"],
}

View File

@@ -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>

View File

@@ -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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -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

View File

@@ -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
}
}