diff options
Diffstat (limited to 'packages/SystemUI/shared/tests')
5 files changed, 0 insertions, 359 deletions
diff --git a/packages/SystemUI/shared/tests/Android.mk b/packages/SystemUI/shared/tests/Android.mk deleted file mode 100644 index 02774c946596..000000000000 --- a/packages/SystemUI/shared/tests/Android.mk +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2017 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_USE_AAPT2 := true -LOCAL_MODULE_TAGS := tests - -LOCAL_JACK_FLAGS := --multi-dex native -LOCAL_DX_FLAGS := --multi-dex - -LOCAL_PROTOC_OPTIMIZE_TYPE := nano -LOCAL_PROTOC_FLAGS := -I$(LOCAL_PATH)/.. -LOCAL_PROTO_JAVA_OUTPUT_PARAMS := optional_field_style=accessors - -LOCAL_PACKAGE_NAME := SystemUISharedLibTests -LOCAL_PRIVATE_PLATFORM_APIS := true -LOCAL_COMPATIBILITY_SUITE := device-tests - -# Add local path sources as well as shared lib sources -LOCAL_SRC_FILES := $(call all-java-files-under, src) - -LOCAL_STATIC_JAVA_LIBRARIES := \ - SystemUISharedLib \ - metrics-helper-lib \ - android-support-test \ - mockito-target-inline-minus-junit4 \ - SystemUI-proto \ - SystemUI-tags \ - testables \ - truth-prebuilt \ - -LOCAL_MULTILIB := both - -LOCAL_JNI_SHARED_LIBRARIES := \ - libdexmakerjvmtiagent \ - libmultiplejvmtiagentsinterferenceagent - -LOCAL_JAVA_LIBRARIES := android.test.runner telephony-common - -# sign this with platform cert, so this test is allowed to inject key events into -# UI it doesn't own. This is necessary to allow screenshots to be taken -LOCAL_CERTIFICATE := platform - -ifeq ($(EXCLUDE_SYSTEMUI_TESTS),) - include $(BUILD_PACKAGE) -endif diff --git a/packages/SystemUI/shared/tests/AndroidManifest.xml b/packages/SystemUI/shared/tests/AndroidManifest.xml deleted file mode 100644 index 5974b76c6c5c..000000000000 --- a/packages/SystemUI/shared/tests/AndroidManifest.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2017 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.systemui.shared.tests"> - - <uses-permission android:name="android.permission.READ_FRAME_BUFFER" /> - - <application android:debuggable="true"> - <uses-library android:name="android.test.runner" /> - </application> - - <instrumentation android:name="android.testing.TestableInstrumentation" - android:targetPackage="com.android.systemui.shared.tests" - android:label="Tests for SystemUISharedLib"> - </instrumentation> -</manifest> diff --git a/packages/SystemUI/shared/tests/AndroidTest.xml b/packages/SystemUI/shared/tests/AndroidTest.xml deleted file mode 100644 index b3de8368deec..000000000000 --- a/packages/SystemUI/shared/tests/AndroidTest.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2017 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 Tests for SystemUISharedLib."> - <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup"> - <option name="test-file-name" value="SystemUISharedLibTests.apk" /> - </target_preparer> - - <option name="test-suite-tag" value="apct" /> - <option name="test-suite-tag" value="framework-base-presubmit" /> - <option name="test-tag" value="SystemUISharedLibTests" /> - <test class="com.android.tradefed.testtype.AndroidJUnitTest" > - <option name="package" value="com.android.systemui.shared.tests" /> - <option name="runner" value="android.testing.TestableInstrumentation" /> - </test> -</configuration> diff --git a/packages/SystemUI/shared/tests/src/com/android/systemui/shared/SysuiSharedLibTestCase.java b/packages/SystemUI/shared/tests/src/com/android/systemui/shared/SysuiSharedLibTestCase.java deleted file mode 100644 index 04b341e38c04..000000000000 --- a/packages/SystemUI/shared/tests/src/com/android/systemui/shared/SysuiSharedLibTestCase.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2014 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.systemui.shared; - -import android.content.Context; -import android.os.Handler; -import android.os.Looper; -import android.os.MessageQueue; -import android.support.test.InstrumentationRegistry; - -import org.junit.After; -import org.junit.Before; - -/** - * Base class that does System UI Shared Lib specific setup. - */ -public abstract class SysuiSharedLibTestCase { - - private static final String TAG = "SysuiSharedLibTestCase"; - - private Handler mHandler; - private Context mContext = InstrumentationRegistry.getContext(); - - @Before - public void SysuiSetup() throws Exception { - // Enable shared class loader to test package-private classes/methods - System.setProperty("dexmaker.share_classloader", "true"); - } - - @After - public void SysuiTeardown() { - // Do nothing - } - - public Context getContext() { - return mContext; - } - - protected void waitForIdleSync() { - if (mHandler == null) { - mHandler = new Handler(Looper.getMainLooper()); - } - waitForIdleSync(mHandler); - } - - public static void waitForIdleSync(Handler h) { - validateThread(h.getLooper()); - Idler idler = new Idler(null); - h.getLooper().getQueue().addIdleHandler(idler); - // Ensure we are non-idle, so the idle handler can run. - h.post(new EmptyRunnable()); - idler.waitForIdle(); - } - - private static final void validateThread(Looper l) { - if (Looper.myLooper() == l) { - throw new RuntimeException( - "This method can not be called from the looper being synced"); - } - } - - public static final class EmptyRunnable implements Runnable { - public void run() { - } - } - - public static final class Idler implements MessageQueue.IdleHandler { - private final Runnable mCallback; - private boolean mIdle; - - public Idler(Runnable callback) { - mCallback = callback; - mIdle = false; - } - - @Override - public boolean queueIdle() { - if (mCallback != null) { - mCallback.run(); - } - synchronized (this) { - mIdle = true; - notifyAll(); - } - return false; - } - - public void waitForIdle() { - synchronized (this) { - while (!mIdle) { - try { - wait(); - } catch (InterruptedException e) { - } - } - } - } - } -} diff --git a/packages/SystemUI/shared/tests/src/com/android/systemui/shared/recents/model/HighResThumbnailLoaderTest.java b/packages/SystemUI/shared/tests/src/com/android/systemui/shared/recents/model/HighResThumbnailLoaderTest.java deleted file mode 100644 index 3b647c12c0b4..000000000000 --- a/packages/SystemUI/shared/tests/src/com/android/systemui/shared/recents/model/HighResThumbnailLoaderTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (C) 2017 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.systemui.shared.recents.model; - -import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.anyBoolean; -import static org.mockito.Mockito.anyInt; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import android.content.ComponentName; -import android.os.Looper; -import android.support.test.filters.SmallTest; -import android.support.test.runner.AndroidJUnit4; - -import com.android.systemui.shared.SysuiSharedLibTestCase; -import com.android.systemui.shared.recents.model.Task.TaskKey; -import com.android.systemui.shared.system.ActivityManagerWrapper; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -/** - * runtest --path frameworks/base/packages/SystemUI/shared/tests/src/com/android/systemui/shared/recents/model/HighResThumbnailLoaderTest.java - */ -@SmallTest -@RunWith(AndroidJUnit4.class) -public class HighResThumbnailLoaderTest extends SysuiSharedLibTestCase { - - private HighResThumbnailLoader mLoader; - - @Mock - private ActivityManagerWrapper mMockActivityManagerWrapper; - @Mock - private Task mTask; - - private ThumbnailData mThumbnailData = new ThumbnailData(); - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - mLoader = new HighResThumbnailLoader(mMockActivityManagerWrapper, Looper.getMainLooper(), - false /* reducedResolution */); - mTask.key = new TaskKey(0, WINDOWING_MODE_UNDEFINED, null, null, 0, 0); - when(mMockActivityManagerWrapper.getTaskThumbnail(anyInt(), anyBoolean())) - .thenReturn(mThumbnailData); - mLoader.setVisible(true); - mLoader.setTaskLoadQueueIdle(true); - } - - @Test - public void testLoading() throws Exception { - mLoader.setVisible(true); - assertTrue(mLoader.isLoading()); - mLoader.setVisible(false); - assertFalse(mLoader.isLoading()); - mLoader.setVisible(true); - mLoader.setFlingingFast(true); - assertFalse(mLoader.isLoading()); - mLoader.setFlingingFast(false); - assertTrue(mLoader.isLoading()); - mLoader.setFlingingFast(false); - mLoader.setTaskLoadQueueIdle(false); - assertFalse(mLoader.isLoading()); - mLoader.setTaskLoadQueueIdle(true); - assertTrue(mLoader.isLoading()); - } - - @Test - public void testLoad() throws Exception { - mLoader.onTaskVisible(mTask); - mLoader.waitForLoaderIdle(); - waitForIdleSync(); - verify(mTask).notifyTaskDataLoaded(mThumbnailData, null); - } - - @Test - public void testFlinging_notLoaded() throws Exception { - mLoader.setFlingingFast(true); - mLoader.onTaskVisible(mTask); - mLoader.waitForLoaderIdle(); - waitForIdleSync(); - verify(mTask, never()).notifyTaskDataLoaded(mThumbnailData, null); - } - - /** - * Tests whether task is loaded after stopping to fling - */ - @Test - public void testAfterFlinging() throws Exception { - mLoader.setFlingingFast(true); - mLoader.onTaskVisible(mTask); - mLoader.setFlingingFast(false); - mLoader.waitForLoaderIdle(); - waitForIdleSync(); - verify(mTask).notifyTaskDataLoaded(mThumbnailData, null); - } - - @Test - public void testAlreadyLoaded() throws Exception { - mTask.thumbnail = new ThumbnailData(); - mTask.thumbnail.reducedResolution = false; - mLoader.onTaskVisible(mTask); - mLoader.waitForLoaderIdle(); - waitForIdleSync(); - verify(mTask, never()).notifyTaskDataLoaded(mThumbnailData, null); - } -} |