Loading services/tests/mockingservicestests/Android.mk 0 → 100644 +45 −0 Original line number Diff line number Diff line # 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) services/tests/mockingservicestests/AndroidManifest.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?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> services/tests/mockingservicestests/AndroidTest.xml 0 → 100644 +32 −0 Original line number Diff line number Diff line <?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> services/tests/servicestests/src/com/android/server/AppStateTrackerTest.java→services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java +12 −11 Original line number Diff line number Diff line Loading @@ -60,8 +60,6 @@ import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.provider.Settings.Global; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.test.mock.MockContentResolver; import android.util.ArraySet; import android.util.Pair; Loading @@ -87,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) Loading Loading @@ -682,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)); Loading @@ -693,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)); Loading @@ -701,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)); Loading @@ -709,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)); Loading Loading @@ -753,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. Loading Loading @@ -796,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); // ------------------------------------------------------------------------- Loading Loading
services/tests/mockingservicestests/Android.mk 0 → 100644 +45 −0 Original line number Diff line number Diff line # 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)
services/tests/mockingservicestests/AndroidManifest.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?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>
services/tests/mockingservicestests/AndroidTest.xml 0 → 100644 +32 −0 Original line number Diff line number Diff line <?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>
services/tests/servicestests/src/com/android/server/AppStateTrackerTest.java→services/tests/mockingservicestests/src/com/android/server/AppStateTrackerTest.java +12 −11 Original line number Diff line number Diff line Loading @@ -60,8 +60,6 @@ import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.provider.Settings.Global; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.test.mock.MockContentResolver; import android.util.ArraySet; import android.util.Pair; Loading @@ -87,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) Loading Loading @@ -682,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)); Loading @@ -693,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)); Loading @@ -701,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)); Loading @@ -709,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)); Loading Loading @@ -753,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. Loading Loading @@ -796,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); // ------------------------------------------------------------------------- Loading