Loading packages/SystemUI/tests/src/com/android/systemui/SysUIRunner.java +9 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class SysUIRunner extends BlockJUnit4ClassRunner { @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return UiThreadStatement.shouldRunOnUiThread(method) ? new UiThreadStatement( return shouldRunOnUiThread(method) ? new UiThreadStatement( methodInvokerInt(method, test), true) : methodInvokerInt(method, test); } Loading Loading @@ -84,4 +84,12 @@ public class SysUIRunner extends BlockJUnit4ClassRunner { private long getTimeout(Test annotation) { return annotation == null ? 0L : annotation.timeout(); } public boolean shouldRunOnUiThread(FrameworkMethod method) { if (mKlass.getAnnotation(UiThreadTest.class) != null) { return true; } else { return UiThreadStatement.shouldRunOnUiThread(method); } } } packages/SystemUI/tests/src/com/android/systemui/UiThreadTest.java 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * 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; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * When applied to a class, all tests, befores, and afters will behave as if * they have @UiThreadTest applied to them. */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface UiThreadTest { } packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java +4 −22 Original line number Diff line number Diff line Loading @@ -37,11 +37,12 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.Display; import com.android.systemui.SysUIRunner; import com.android.systemui.UiThreadTest; import com.android.systemui.statusbar.phone.DozeParameters; import org.junit.Before; Loading @@ -49,7 +50,8 @@ import org.junit.Test; import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidJUnit4.class) @RunWith(SysUIRunner.class) @UiThreadTest public class DozeMachineTest { DozeMachine mMachine; Loading @@ -72,7 +74,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testInitialize_initializesParts() { mMachine.requestState(INITIALIZED); Loading @@ -80,7 +81,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testInitialize_goesToDoze() { when(mParamsMock.getAlwaysOn()).thenReturn(false); Loading @@ -91,7 +91,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testInitialize_goesToAod() { when(mParamsMock.getAlwaysOn()).thenReturn(true); Loading @@ -102,7 +101,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testPulseDone_goesToDoze() { when(mParamsMock.getAlwaysOn()).thenReturn(false); mMachine.requestState(INITIALIZED); Loading @@ -116,7 +114,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testPulseDone_goesToAoD() { when(mParamsMock.getAlwaysOn()).thenReturn(true); mMachine.requestState(INITIALIZED); Loading @@ -130,7 +127,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testFinished_staysFinished() { mMachine.requestState(INITIALIZED); mMachine.requestState(FINISH); Loading @@ -143,7 +139,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testFinish_finishesService() { mMachine.requestState(INITIALIZED); Loading @@ -153,7 +148,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeLock_heldInTransition() { doAnswer((inv) -> { assertTrue(mWakeLockFake.isHeld()); Loading @@ -164,7 +158,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeLock_heldInPulseStates() { mMachine.requestState(INITIALIZED); Loading @@ -176,7 +169,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeLock_notHeldInDozeStates() { mMachine.requestState(INITIALIZED); Loading @@ -188,7 +180,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeLock_releasedAfterPulse() { mMachine.requestState(INITIALIZED); Loading @@ -201,7 +192,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testPulseDuringPulse_doesntCrash() { mMachine.requestState(INITIALIZED); Loading @@ -213,7 +203,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testSuppressingPulse_doesntCrash() { mMachine.requestState(INITIALIZED); Loading @@ -223,7 +212,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_offInDoze() { mMachine.requestState(INITIALIZED); Loading @@ -233,7 +221,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_onInAod() { mMachine.requestState(INITIALIZED); Loading @@ -243,7 +230,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_onInPulse() { mMachine.requestState(INITIALIZED); Loading @@ -254,7 +240,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_offInRequestPulseWithoutAoD() { mMachine.requestState(INITIALIZED); Loading @@ -265,7 +250,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_onInRequestPulseWithoutAoD() { mMachine.requestState(INITIALIZED); Loading @@ -276,7 +260,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testTransitions_canRequestTransitions() { mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE); Loading @@ -291,7 +274,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeUp_wakesUp() { mMachine.wakeUp(); Loading packages/SystemUI/tests/src/com/android/systemui/notification/PropertyAnimatorTest.java +4 −15 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui.notification; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.support.test.annotation.UiThreadTest; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.SmallTest; Loading @@ -28,7 +27,9 @@ import android.util.Property; import android.view.View; import android.view.animation.Interpolator; import com.android.systemui.SysUIRunner; import com.android.systemui.SysuiTestCase; import com.android.systemui.UiThreadTest; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.stack.AnimationFilter; import com.android.systemui.statusbar.stack.AnimationProperties; Loading @@ -49,7 +50,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @SmallTest @RunWith(AndroidJUnit4.class) @RunWith(SysUIRunner.class) @UiThreadTest public class PropertyAnimatorTest extends SysuiTestCase { private View mView; Loading Loading @@ -106,13 +108,11 @@ public class PropertyAnimatorTest extends SysuiTestCase { @Before @UiThreadTest public void setUp() { mView = new View(getContext()); } @Test @UiThreadTest public void testAnimationStarted() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -121,7 +121,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testNoAnimationStarted() { mAnimationFilter.reset(); PropertyAnimator.startAnimation(mView, mProperty, 200, mAnimationProperties); Loading @@ -129,7 +128,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testEndValueUpdated() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -139,7 +137,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testStartTagUpdated() { mEffectiveProperty.set(mView, 100f); mAnimationFilter.reset(); Loading @@ -150,7 +147,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testValueIsSetUnAnimated() { mAnimationFilter.reset(); PropertyAnimator.startAnimation(mView, mProperty, 200f, mAnimationProperties); Loading @@ -158,7 +154,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testAnimationToRightValueUpdated() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -171,7 +166,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testAnimationToRightValueUpdateAnimated() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -185,7 +179,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testStartTagShiftedWhenChanging() { mEffectiveProperty.set(mView, 100f); mAnimationFilter.reset(); Loading @@ -198,7 +191,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testUsingDuration() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -210,7 +202,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testUsingDelay() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -222,7 +213,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testUsingInterpolator() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -234,7 +224,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testUsingListener() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +5 −31 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ import android.content.pm.ParceledListSlice; import android.graphics.drawable.Drawable; import android.service.notification.StatusBarNotification; import android.support.test.InstrumentationRegistry; import android.support.test.annotation.UiThreadTest; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; Loading @@ -55,7 +54,10 @@ import android.widget.Switch; import android.widget.TextView; import com.android.internal.util.CharSequences; import com.android.systemui.R; import com.android.systemui.SysUIRunner; import com.android.systemui.SysuiTestCase; import com.android.systemui.UiThreadTest; import org.junit.Before; import org.junit.runner.RunWith; import org.junit.Test; Loading @@ -65,7 +67,8 @@ import java.util.Collections; import java.util.concurrent.CountDownLatch; @SmallTest @RunWith(AndroidJUnit4.class) @RunWith(SysUIRunner.class) @UiThreadTest public class NotificationInfoTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "test_package"; private static final String TEST_CHANNEL = "test_channel"; Loading @@ -79,7 +82,6 @@ public class NotificationInfoTest extends SysuiTestCase { mock(StatusBarNotification.class); @Before @UiThreadTest public void setUp() throws Exception { // Inflate the layout final LayoutInflater layoutInflater = Loading Loading @@ -116,7 +118,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsTextApplicationName() throws Exception { when(mMockPackageManager.getApplicationLabel(any())).thenReturn("App Name"); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -126,7 +127,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsPackageIcon() throws Exception { final Drawable iconDrawable = mock(Drawable.class); when(mMockPackageManager.getApplicationIcon(any(ApplicationInfo.class))) Loading @@ -138,7 +138,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_GroupNameHiddenIfNoGroup() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -150,7 +149,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsGroupNameIfNonNull() throws Exception { mNotificationChannel.setGroup("test_group_id"); final NotificationChannelGroup notificationChannelGroup = Loading @@ -169,7 +167,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsGroupName_resId() throws Exception { when(mMockPackageManager.getText(eq(TEST_PACKAGE_NAME), eq(R.string.legacy_vpn_name), anyObject())).thenReturn( Loading @@ -191,7 +188,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsTextChannelName() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -200,7 +196,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsTextChannelName_resId() throws Exception { when(mMockPackageManager.getText(eq(TEST_PACKAGE_NAME), eq(R.string.notification_menu_accessibility), anyObject())).thenReturn( Loading @@ -216,7 +211,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsOnClickListenerForSettings() throws Exception { final CountDownLatch latch = new CountDownLatch(1); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -231,7 +225,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SettingsTextWithOneChannel() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, (View v, int appUid) -> {}, null, Loading @@ -242,7 +235,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SettingsTextWithMultipleChannels() throws Exception { when(mMockINotificationManager.getNumNotificationChannelsForPackage( eq(TEST_PACKAGE_NAME), anyInt(), anyBoolean())).thenReturn(2); Loading @@ -255,7 +247,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsOnClickListenerForDone() throws Exception { final CountDownLatch latch = new CountDownLatch(1); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -270,7 +261,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_NumChannelsTextHiddenWhenDefaultChannel() throws Exception { final NotificationChannel defaultChannel = new NotificationChannel( NotificationChannel.DEFAULT_CHANNEL_ID, TEST_CHANNEL_NAME, Loading @@ -283,7 +273,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_NumChannelsTextDisplaysWhenNotDefaultChannel() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -295,7 +284,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_NumChannelsTextScalesWithNumberOfChannels() throws Exception { when(mMockINotificationManager.getNumNotificationChannelsForPackage( Loading @@ -308,7 +296,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testbindNotification_ChannelDisabledTextGoneWhenNotDisabled() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -318,7 +305,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testbindNotification_ChannelDisabledTextVisibleWhenDisabled() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_NONE); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -333,7 +319,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testHasImportanceChanged_DefaultsToFalse() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -341,7 +326,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testHasImportanceChanged_ReturnsTrueAfterChannelDisabled() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -353,7 +337,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_DoesNotUpdateNotificationChannel() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -362,7 +345,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testDoesNotUpdateNotificationChannelAfterImportanceChanged() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -375,7 +357,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testHandleCloseControls_DoesNotUpdateNotificationChannelIfUnchanged() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -387,7 +368,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testHandleCloseControls_DoesNotUpdateNotificationChannelIfUnspecified() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_UNSPECIFIED); Loading @@ -400,7 +380,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledSwitchOnByDefault() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -411,7 +390,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledButtonOffWhenAlreadyBanned() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_NONE); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -422,7 +400,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledSwitchVisibleByDefault() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -433,7 +410,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledSwitchInvisibleIfNonBlockable() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -445,7 +421,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledSwitchChangedCallsUpdateNotificationChannel() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -460,7 +435,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testCloseControlsDoesNotUpdateIfSaveIsFalse() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading Loading
packages/SystemUI/tests/src/com/android/systemui/SysUIRunner.java +9 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public class SysUIRunner extends BlockJUnit4ClassRunner { @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return UiThreadStatement.shouldRunOnUiThread(method) ? new UiThreadStatement( return shouldRunOnUiThread(method) ? new UiThreadStatement( methodInvokerInt(method, test), true) : methodInvokerInt(method, test); } Loading Loading @@ -84,4 +84,12 @@ public class SysUIRunner extends BlockJUnit4ClassRunner { private long getTimeout(Test annotation) { return annotation == null ? 0L : annotation.timeout(); } public boolean shouldRunOnUiThread(FrameworkMethod method) { if (mKlass.getAnnotation(UiThreadTest.class) != null) { return true; } else { return UiThreadStatement.shouldRunOnUiThread(method); } } }
packages/SystemUI/tests/src/com/android/systemui/UiThreadTest.java 0 → 100644 +29 −0 Original line number Diff line number Diff line /* * 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; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * When applied to a class, all tests, befores, and afters will behave as if * they have @UiThreadTest applied to them. */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface UiThreadTest { }
packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java +4 −22 Original line number Diff line number Diff line Loading @@ -37,11 +37,12 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.support.test.annotation.UiThreadTest; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import android.view.Display; import com.android.systemui.SysUIRunner; import com.android.systemui.UiThreadTest; import com.android.systemui.statusbar.phone.DozeParameters; import org.junit.Before; Loading @@ -49,7 +50,8 @@ import org.junit.Test; import org.junit.runner.RunWith; @SmallTest @RunWith(AndroidJUnit4.class) @RunWith(SysUIRunner.class) @UiThreadTest public class DozeMachineTest { DozeMachine mMachine; Loading @@ -72,7 +74,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testInitialize_initializesParts() { mMachine.requestState(INITIALIZED); Loading @@ -80,7 +81,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testInitialize_goesToDoze() { when(mParamsMock.getAlwaysOn()).thenReturn(false); Loading @@ -91,7 +91,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testInitialize_goesToAod() { when(mParamsMock.getAlwaysOn()).thenReturn(true); Loading @@ -102,7 +101,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testPulseDone_goesToDoze() { when(mParamsMock.getAlwaysOn()).thenReturn(false); mMachine.requestState(INITIALIZED); Loading @@ -116,7 +114,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testPulseDone_goesToAoD() { when(mParamsMock.getAlwaysOn()).thenReturn(true); mMachine.requestState(INITIALIZED); Loading @@ -130,7 +127,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testFinished_staysFinished() { mMachine.requestState(INITIALIZED); mMachine.requestState(FINISH); Loading @@ -143,7 +139,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testFinish_finishesService() { mMachine.requestState(INITIALIZED); Loading @@ -153,7 +148,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeLock_heldInTransition() { doAnswer((inv) -> { assertTrue(mWakeLockFake.isHeld()); Loading @@ -164,7 +158,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeLock_heldInPulseStates() { mMachine.requestState(INITIALIZED); Loading @@ -176,7 +169,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeLock_notHeldInDozeStates() { mMachine.requestState(INITIALIZED); Loading @@ -188,7 +180,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeLock_releasedAfterPulse() { mMachine.requestState(INITIALIZED); Loading @@ -201,7 +192,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testPulseDuringPulse_doesntCrash() { mMachine.requestState(INITIALIZED); Loading @@ -213,7 +203,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testSuppressingPulse_doesntCrash() { mMachine.requestState(INITIALIZED); Loading @@ -223,7 +212,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_offInDoze() { mMachine.requestState(INITIALIZED); Loading @@ -233,7 +221,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_onInAod() { mMachine.requestState(INITIALIZED); Loading @@ -243,7 +230,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_onInPulse() { mMachine.requestState(INITIALIZED); Loading @@ -254,7 +240,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_offInRequestPulseWithoutAoD() { mMachine.requestState(INITIALIZED); Loading @@ -265,7 +250,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testScreen_onInRequestPulseWithoutAoD() { mMachine.requestState(INITIALIZED); Loading @@ -276,7 +260,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testTransitions_canRequestTransitions() { mMachine.requestState(INITIALIZED); mMachine.requestState(DOZE); Loading @@ -291,7 +274,6 @@ public class DozeMachineTest { } @Test @UiThreadTest public void testWakeUp_wakesUp() { mMachine.wakeUp(); Loading
packages/SystemUI/tests/src/com/android/systemui/notification/PropertyAnimatorTest.java +4 −15 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui.notification; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.support.test.annotation.UiThreadTest; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.SmallTest; Loading @@ -28,7 +27,9 @@ import android.util.Property; import android.view.View; import android.view.animation.Interpolator; import com.android.systemui.SysUIRunner; import com.android.systemui.SysuiTestCase; import com.android.systemui.UiThreadTest; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.stack.AnimationFilter; import com.android.systemui.statusbar.stack.AnimationProperties; Loading @@ -49,7 +50,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @SmallTest @RunWith(AndroidJUnit4.class) @RunWith(SysUIRunner.class) @UiThreadTest public class PropertyAnimatorTest extends SysuiTestCase { private View mView; Loading Loading @@ -106,13 +108,11 @@ public class PropertyAnimatorTest extends SysuiTestCase { @Before @UiThreadTest public void setUp() { mView = new View(getContext()); } @Test @UiThreadTest public void testAnimationStarted() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -121,7 +121,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testNoAnimationStarted() { mAnimationFilter.reset(); PropertyAnimator.startAnimation(mView, mProperty, 200, mAnimationProperties); Loading @@ -129,7 +128,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testEndValueUpdated() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -139,7 +137,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testStartTagUpdated() { mEffectiveProperty.set(mView, 100f); mAnimationFilter.reset(); Loading @@ -150,7 +147,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testValueIsSetUnAnimated() { mAnimationFilter.reset(); PropertyAnimator.startAnimation(mView, mProperty, 200f, mAnimationProperties); Loading @@ -158,7 +154,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testAnimationToRightValueUpdated() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -171,7 +166,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testAnimationToRightValueUpdateAnimated() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -185,7 +179,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testStartTagShiftedWhenChanging() { mEffectiveProperty.set(mView, 100f); mAnimationFilter.reset(); Loading @@ -198,7 +191,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testUsingDuration() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -210,7 +202,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testUsingDelay() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -222,7 +213,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testUsingInterpolator() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading @@ -234,7 +224,6 @@ public class PropertyAnimatorTest extends SysuiTestCase { } @Test @UiThreadTest public void testUsingListener() { mAnimationFilter.reset(); mAnimationFilter.animate(mProperty.getProperty()); Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +5 −31 Original line number Diff line number Diff line Loading @@ -44,7 +44,6 @@ import android.content.pm.ParceledListSlice; import android.graphics.drawable.Drawable; import android.service.notification.StatusBarNotification; import android.support.test.InstrumentationRegistry; import android.support.test.annotation.UiThreadTest; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; Loading @@ -55,7 +54,10 @@ import android.widget.Switch; import android.widget.TextView; import com.android.internal.util.CharSequences; import com.android.systemui.R; import com.android.systemui.SysUIRunner; import com.android.systemui.SysuiTestCase; import com.android.systemui.UiThreadTest; import org.junit.Before; import org.junit.runner.RunWith; import org.junit.Test; Loading @@ -65,7 +67,8 @@ import java.util.Collections; import java.util.concurrent.CountDownLatch; @SmallTest @RunWith(AndroidJUnit4.class) @RunWith(SysUIRunner.class) @UiThreadTest public class NotificationInfoTest extends SysuiTestCase { private static final String TEST_PACKAGE_NAME = "test_package"; private static final String TEST_CHANNEL = "test_channel"; Loading @@ -79,7 +82,6 @@ public class NotificationInfoTest extends SysuiTestCase { mock(StatusBarNotification.class); @Before @UiThreadTest public void setUp() throws Exception { // Inflate the layout final LayoutInflater layoutInflater = Loading Loading @@ -116,7 +118,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsTextApplicationName() throws Exception { when(mMockPackageManager.getApplicationLabel(any())).thenReturn("App Name"); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -126,7 +127,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsPackageIcon() throws Exception { final Drawable iconDrawable = mock(Drawable.class); when(mMockPackageManager.getApplicationIcon(any(ApplicationInfo.class))) Loading @@ -138,7 +138,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_GroupNameHiddenIfNoGroup() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -150,7 +149,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsGroupNameIfNonNull() throws Exception { mNotificationChannel.setGroup("test_group_id"); final NotificationChannelGroup notificationChannelGroup = Loading @@ -169,7 +167,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsGroupName_resId() throws Exception { when(mMockPackageManager.getText(eq(TEST_PACKAGE_NAME), eq(R.string.legacy_vpn_name), anyObject())).thenReturn( Loading @@ -191,7 +188,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsTextChannelName() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -200,7 +196,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsTextChannelName_resId() throws Exception { when(mMockPackageManager.getText(eq(TEST_PACKAGE_NAME), eq(R.string.notification_menu_accessibility), anyObject())).thenReturn( Loading @@ -216,7 +211,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsOnClickListenerForSettings() throws Exception { final CountDownLatch latch = new CountDownLatch(1); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -231,7 +225,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SettingsTextWithOneChannel() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, (View v, int appUid) -> {}, null, Loading @@ -242,7 +235,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SettingsTextWithMultipleChannels() throws Exception { when(mMockINotificationManager.getNumNotificationChannelsForPackage( eq(TEST_PACKAGE_NAME), anyInt(), anyBoolean())).thenReturn(2); Loading @@ -255,7 +247,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_SetsOnClickListenerForDone() throws Exception { final CountDownLatch latch = new CountDownLatch(1); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -270,7 +261,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_NumChannelsTextHiddenWhenDefaultChannel() throws Exception { final NotificationChannel defaultChannel = new NotificationChannel( NotificationChannel.DEFAULT_CHANNEL_ID, TEST_CHANNEL_NAME, Loading @@ -283,7 +273,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_NumChannelsTextDisplaysWhenNotDefaultChannel() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -295,7 +284,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_NumChannelsTextScalesWithNumberOfChannels() throws Exception { when(mMockINotificationManager.getNumNotificationChannelsForPackage( Loading @@ -308,7 +296,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testbindNotification_ChannelDisabledTextGoneWhenNotDisabled() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -318,7 +305,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testbindNotification_ChannelDisabledTextVisibleWhenDisabled() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_NONE); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -333,7 +319,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testHasImportanceChanged_DefaultsToFalse() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -341,7 +326,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testHasImportanceChanged_ReturnsTrueAfterChannelDisabled() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -353,7 +337,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testBindNotification_DoesNotUpdateNotificationChannel() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mMockStatusBarNotification, mNotificationChannel, null, null, null); Loading @@ -362,7 +345,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testDoesNotUpdateNotificationChannelAfterImportanceChanged() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -375,7 +357,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testHandleCloseControls_DoesNotUpdateNotificationChannelIfUnchanged() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -387,7 +368,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testHandleCloseControls_DoesNotUpdateNotificationChannelIfUnspecified() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_UNSPECIFIED); Loading @@ -400,7 +380,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledSwitchOnByDefault() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -411,7 +390,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledButtonOffWhenAlreadyBanned() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_NONE); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -422,7 +400,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledSwitchVisibleByDefault() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -433,7 +410,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledSwitchInvisibleIfNonBlockable() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -445,7 +421,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testEnabledSwitchChangedCallsUpdateNotificationChannel() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading @@ -460,7 +435,6 @@ public class NotificationInfoTest extends SysuiTestCase { } @Test @UiThreadTest public void testCloseControlsDoesNotUpdateIfSaveIsFalse() throws Exception { mNotificationChannel.setImportance(NotificationManager.IMPORTANCE_LOW); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading