From 55422c7517a9913d419682aa394fbf254899ca9d Mon Sep 17 00:00:00 2001 From: Raff Tsai Date: Wed, 5 Feb 2020 18:32:33 +0800 Subject: [PATCH] Add TEST_MAPPING to schedule auto test Test: atest :postsubmit Change-Id: Ied8e241ef223ea5e87ca6ee0f04f4128c51ddb87 Merged-In: I0847d1dea352d0e3b87b1bb95d5c2600a80a7438 --- TEST_MAPPING | 15 ++++++ tests/perftests/Android.bp | 22 +++++++++ tests/perftests/AndroidManifest.xml | 29 +++++++++++ .../tests/perf/LaunchSettingsTest.java | 48 +++++++++++++++++++ 4 files changed, 114 insertions(+) create mode 100644 TEST_MAPPING create mode 100644 tests/perftests/Android.bp create mode 100644 tests/perftests/AndroidManifest.xml create mode 100644 tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java diff --git a/TEST_MAPPING b/TEST_MAPPING new file mode 100644 index 00000000000..4865e19248b --- /dev/null +++ b/TEST_MAPPING @@ -0,0 +1,15 @@ +{ + "postsubmit": [ + { + "name": "SettingsUnitTests", + "options": [ + { + "exclude-annotation": "androidx.test.filters.FlakyTest" + } + ] + }, + { + "name": "SettingsPerfTests" + } + ] +} diff --git a/tests/perftests/Android.bp b/tests/perftests/Android.bp new file mode 100644 index 00000000000..1ba5d9c432a --- /dev/null +++ b/tests/perftests/Android.bp @@ -0,0 +1,22 @@ +android_test { + name: "SettingsPerfTests", + + certificate: "platform", + + libs: [ + "android.test.runner", + ], + + static_libs: [ + "androidx.test.rules", + "ub-uiautomator", + ], + + // Include all test java files. + srcs: ["src/**/*.java"], + + platform_apis: true, + test_suites: ["device-tests"], + + instrumentation_for: "Settings", +} diff --git a/tests/perftests/AndroidManifest.xml b/tests/perftests/AndroidManifest.xml new file mode 100644 index 00000000000..4ce6a54048c --- /dev/null +++ b/tests/perftests/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + diff --git a/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java b/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java new file mode 100644 index 00000000000..5140be2db91 --- /dev/null +++ b/tests/perftests/src/com/android/settings/tests/perf/LaunchSettingsTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2020 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.perf; + +import android.app.Instrumentation; +import android.os.Bundle; + +import androidx.test.InstrumentationRegistry; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class LaunchSettingsTest { + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testReportMetrics() throws Exception { + Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); + final Bundle result = new Bundle(); + result.putString("LaunchSettingsTest_metric_key1", "1000"); + result.putString("LaunchSettingsTest_metric_key2", "5000"); + instrumentation.sendStatus(0, result); + } +}