diff options
| -rw-r--r-- | services/tests/mockingservicestests/Android.mk | 45 | ||||
| -rw-r--r-- | services/tests/mockingservicestests/AndroidManifest.xml | 28 | ||||
| -rw-r--r-- | services/tests/mockingservicestests/AndroidTest.xml | 32 | ||||
| -rw-r--r-- | services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java (renamed from services/tests/servicestests/src/com/android/server/AppStateTrackerTest.java) | 24 |
4 files changed, 117 insertions, 12 deletions
diff --git a/services/tests/mockingservicestests/Android.mk b/services/tests/mockingservicestests/Android.mk new file mode 100644 index 000000000000..34de9dfb7ad6 --- /dev/null +++ b/services/tests/mockingservicestests/Android.mk @@ -0,0 +1,45 @@ +# Copyright (C) 2018 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. + +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_STATIC_JAVA_LIBRARIES := \ + services.core \ + services.devicepolicy \ + frameworks-base-testutils \ + androidx-test \ + mockito-target-extended-minus-junit4 \ + ShortcutManagerTestUtils \ + compatibility-device-util \ + truth-prebuilt + +LOCAL_JAVA_LIBRARIES := \ + android.test.mock + +LOCAL_JNI_SHARED_LIBRARIES := \ + libdexmakerjvmtiagent \ + libstaticjvmtiagent + +LOCAL_PACKAGE_NAME := FrameworksMockingServicesTests +LOCAL_PRIVATE_PLATFORM_APIS := true +LOCAL_COMPATIBILITY_SUITE := device-tests + +LOCAL_PROGUARD_ENABLED := disabled + +include $(BUILD_PACKAGE) diff --git a/services/tests/mockingservicestests/AndroidManifest.xml b/services/tests/mockingservicestests/AndroidManifest.xml new file mode 100644 index 000000000000..247e446d1bfc --- /dev/null +++ b/services/tests/mockingservicestests/AndroidManifest.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2018 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. +--> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.frameworks.mockingservicestests"> + + <application android:debuggable="true"> + <uses-library android:name="android.test.runner" /> + </application> + + <instrumentation + android:name="androidx.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.frameworks.mockingservicestests" + android:label="Frameworks Mocking Services Tests" /> +</manifest> diff --git a/services/tests/mockingservicestests/AndroidTest.xml b/services/tests/mockingservicestests/AndroidTest.xml new file mode 100644 index 000000000000..adfee96d4e28 --- /dev/null +++ b/services/tests/mockingservicestests/AndroidTest.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2018 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 Frameworks Services Tests."> + <option name="test-suite-tag" value="apct" /> + <option name="test-suite-tag" value="apct-instrumentation" /> + + <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller"> + <option name="cleanup-apks" value="true" /> + <option name="test-file-name" value="FrameworksMockingServicesTests.apk" /> + </target_preparer> + + <option name="test-tag" value="FrameworksMockingServicesTests" /> + + <test class="com.android.tradefed.testtype.AndroidJUnitTest" > + <option name="package" value="com.android.frameworks.mockingservicestests" /> + <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" /> + <option name="hidden-api-checks" value="false"/> + </test> +</configuration> diff --git a/services/tests/servicestests/src/com/android/server/AppStateTrackerTest.java b/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java index 910aad7fd86e..c8e67820ce46 100644 --- a/services/tests/servicestests/src/com/android/server/AppStateTrackerTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java @@ -64,9 +64,6 @@ import android.test.mock.MockContentResolver; import android.util.ArraySet; import android.util.Pair; -import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; - import com.android.internal.app.IAppOpsCallback; import com.android.internal.app.IAppOpsService; import com.android.server.AppStateTracker.Listener; @@ -88,11 +85,14 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + /** * Tests for {@link AppStateTracker} * * Run with: - atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/AppStateTrackerTest.java + atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java */ @SmallTest @RunWith(AndroidJUnit4.class) @@ -683,10 +683,10 @@ public class AppStateTrackerTest { //-------------------------------------------------- List<OpEntry> entries = new ArrayList<>(); - entries.add(new AppOpsManager.OpEntry( + entries.add(new OpEntry( AppOpsManager.OP_ACCESS_NOTIFICATIONS, AppOpsManager.MODE_IGNORED, 0, 0, 0, 0, null)); - entries.add(new AppOpsManager.OpEntry( + entries.add(new OpEntry( AppStateTracker.TARGET_OP, AppOpsManager.MODE_IGNORED, 0, 0, 0, 0, null)); @@ -694,7 +694,7 @@ public class AppStateTrackerTest { //-------------------------------------------------- entries = new ArrayList<>(); - entries.add(new AppOpsManager.OpEntry( + entries.add(new OpEntry( AppStateTracker.TARGET_OP, AppOpsManager.MODE_IGNORED, 0, 0, 0, 0, null)); @@ -702,7 +702,7 @@ public class AppStateTrackerTest { //-------------------------------------------------- entries = new ArrayList<>(); - entries.add(new AppOpsManager.OpEntry( + entries.add(new OpEntry( AppStateTracker.TARGET_OP, AppOpsManager.MODE_ALLOWED, 0, 0, 0, 0, null)); @@ -710,10 +710,10 @@ public class AppStateTrackerTest { //-------------------------------------------------- entries = new ArrayList<>(); - entries.add(new AppOpsManager.OpEntry( + entries.add(new OpEntry( AppStateTracker.TARGET_OP, AppOpsManager.MODE_IGNORED, 0, 0, 0, 0, null)); - entries.add(new AppOpsManager.OpEntry( + entries.add(new OpEntry( AppOpsManager.OP_ACCESS_NOTIFICATIONS, AppOpsManager.MODE_IGNORED, 0, 0, 0, 0, null)); @@ -754,7 +754,7 @@ public class AppStateTrackerTest { final AppStateTrackerTestable instance = newInstance(); callStart(instance); - AppStateTracker.Listener l = mock(AppStateTracker.Listener.class); + Listener l = mock(Listener.class); instance.addListener(l); // Power save on. @@ -797,7 +797,7 @@ public class AppStateTrackerTest { final AppStateTrackerTestable instance = newInstance(); callStart(instance); - AppStateTracker.Listener l = mock(AppStateTracker.Listener.class); + Listener l = mock(Listener.class); instance.addListener(l); // ------------------------------------------------------------------------- |