OSDN Git Service

Add test to verify all sysui tests extend the right stuff
authorJason Monk <jmonk@google.com>
Tue, 23 May 2017 14:42:59 +0000 (10:42 -0400)
committerJason Monk <jmonk@google.com>
Thu, 25 May 2017 19:18:06 +0000 (15:18 -0400)
And then make it pass.

Test: runtest systemui
Fixes: 38500852
Change-Id: I377164219e4a4f4d1a99f11ef06da03c2b527eb0

43 files changed:
packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java [new file with mode: 0644]
packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockAccessibilityDelegateTest.java
packages/SystemUI/tests/src/com/android/systemui/DependencyTest.java
packages/SystemUI/tests/src/com/android/systemui/SysuiTestCase.java
packages/SystemUI/tests/src/com/android/systemui/doze/DozeMachineTest.java
packages/SystemUI/tests/src/com/android/systemui/doze/DozeScreenStatePreventingAdapterTest.java
packages/SystemUI/tests/src/com/android/systemui/doze/DozeTriggersTest.java
packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java
packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityTest.java
packages/SystemUI/tests/src/com/android/systemui/plugins/VersionInfoTest.java
packages/SystemUI/tests/src/com/android/systemui/qs/QSDetailTest.java
packages/SystemUI/tests/src/com/android/systemui/qs/QSFooterTest.java
packages/SystemUI/tests/src/com/android/systemui/qs/QSFragmentTest.java
packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.java
packages/SystemUI/tests/src/com/android/systemui/qs/customize/TileAdapterTest.java
packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSIconViewImplTest.java
packages/SystemUI/tests/src/com/android/systemui/qs/tileimpl/QSTileImplTest.java
packages/SystemUI/tests/src/com/android/systemui/settings/CurrentUserTrackerTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/CommandQueueTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/ExpandableNotificationRowTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationContentViewTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationCustomViewWrapperTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationMenuRowTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationInflaterTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationViewWrapperTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/VisualStabilityManagerTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/AutoTileManagerTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CollapsedStatusBarFragmentTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/DozeParametersTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NavigationBarFragmentTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarIconControllerTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/BluetoothControllerImplTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/CallbackHandlerTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/ExtensionControllerTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/KeyButtonViewTest.java
packages/SystemUI/tests/src/com/android/systemui/statusbar/stack/NotificationChildrenContainerTest.java
packages/SystemUI/tests/src/com/android/systemui/util/leak/GarbageMonitorTest.java
packages/SystemUI/tests/src/com/android/systemui/util/leak/LeakDetectorTest.java
packages/SystemUI/tests/src/com/android/systemui/util/leak/LeakReporterTest.java
packages/SystemUI/tests/src/com/android/systemui/util/leak/ReferenceTestUtilsTest.java
packages/SystemUI/tests/src/com/android/systemui/util/leak/WeakIdentityHashMapTest.java
packages/SystemUI/tests/src/com/android/systemui/util/wakelock/SettableWakeLockTest.java
packages/SystemUI/tests/src/com/android/systemui/util/wakelock/WakeLockTest.java

diff --git a/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java b/packages/SystemUI/tests/src/com/android/AAAPlusPlusVerifySysuiRequiredTestPropertiesTest.java
new file mode 100644 (file)
index 0000000..b597868
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertFalse;
+
+import android.support.test.filters.LargeTest;
+import android.support.test.filters.MediumTest;
+import android.support.test.filters.SmallTest;
+import android.support.test.internal.runner.ClassPathScanner;
+import android.support.test.internal.runner.ClassPathScanner.ChainedClassNameFilter;
+import android.support.test.internal.runner.ClassPathScanner.ExternalClassNameFilter;
+import android.support.test.internal.runner.TestLoader;
+import android.testing.AndroidTestingRunner;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.android.systemui.SysuiBaseFragmentTest;
+import com.android.systemui.SysuiTestCase;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * This is named AAAPlusPlusVerifySysuiRequiredTestPropertiesTest for two reasons.
+ * a) Its so awesome it deserves an AAA++
+ * b) It should run first to draw attention to itself.
+ *
+ * For trues though: this test verifies that all the sysui tests extend the right classes.
+ * This matters because including tests with different context implementations in the same
+ * test suite causes errors, such as the incorrect settings provider being cached.
+ * For an example, see {@link com.android.systemui.DependencyTest}.
+ */
+@RunWith(AndroidTestingRunner.class)
+@SmallTest
+public class AAAPlusPlusVerifySysuiRequiredTestPropertiesTest extends SysuiTestCase {
+
+    private static final String TAG = "AAA++VerifyTest";
+
+    private static final Class[] BASE_CLS_WHITELIST = {
+            SysuiTestCase.class,
+            SysuiBaseFragmentTest.class,
+    };
+
+    private static final Class[] SUPPORTED_SIZES = {
+            SmallTest.class,
+            MediumTest.class,
+            LargeTest.class,
+            android.test.suitebuilder.annotation.SmallTest.class,
+            android.test.suitebuilder.annotation.MediumTest.class,
+            android.test.suitebuilder.annotation.LargeTest.class,
+    };
+
+    @Test
+    public void testAllClassInheritance() {
+        boolean anyClassWrong = false;
+        TestLoader loader = new TestLoader();
+        for (String className : getClassNamesFromClassPath()) {
+            Class<?> cls = loader.loadIfTest(className);
+            if (cls == null) continue;
+
+            boolean hasParent = false;
+            for (Class<?> parent : BASE_CLS_WHITELIST) {
+                if (parent.isAssignableFrom(cls)) {
+                    hasParent = true;
+                    break;
+                }
+            }
+            boolean hasSize = hasSize(cls);
+            if (!hasSize) {
+                anyClassWrong = true;
+                Log.e(TAG, cls.getName() + " does not have size annotation, such as @SmallTest");
+            }
+            if (!hasParent) {
+                anyClassWrong = true;
+                Log.e(TAG, cls.getName() + " does not extend any of " + getClsStr());
+            }
+        }
+
+        assertFalse("All sysui test classes must have size and extend one of " + getClsStr(),
+                anyClassWrong);
+    }
+
+    private boolean hasSize(Class<?> cls) {
+        for (int i = 0; i < SUPPORTED_SIZES.length; i++) {
+            if (cls.getDeclaredAnnotation(SUPPORTED_SIZES[i]) != null) return true;
+        }
+        return false;
+    }
+
+    private Collection<String> getClassNamesFromClassPath() {
+        ClassPathScanner scanner = new ClassPathScanner(mContext.getPackageCodePath());
+
+        ChainedClassNameFilter filter = new ChainedClassNameFilter();
+
+        filter.add(new ExternalClassNameFilter());
+        filter.add(s -> s.startsWith("com.android.systemui")
+                || s.startsWith("com.android.keyguard"));
+        try {
+            return scanner.getClassPathEntries(filter);
+        } catch (IOException e) {
+            Log.e(TAG, "Failed to scan classes", e);
+        }
+        return Collections.emptyList();
+    }
+
+    private String getClsStr() {
+        return TextUtils.join(",", Arrays.asList(BASE_CLS_WHITELIST)
+                .stream().map(cls -> cls.getSimpleName()).toArray());
+    }
+}
index 1c9f813..855adb4 100644 (file)
@@ -19,26 +19,26 @@ package com.android.keyguard;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-import android.content.Context;
-import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
 import android.text.TextUtils;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 import android.widget.TextView;
 
+import com.android.systemui.SysuiTestCase;
+
 import org.junit.Before;
 import org.junit.Test;
 
 import java.util.List;
 
-public class KeyguardClockAccessibilityDelegateTest {
+@SmallTest
+public class KeyguardClockAccessibilityDelegateTest extends SysuiTestCase {
 
-    private Context mContext;
     private TextView mView;
 
     @Before
     public void setUp() throws Exception {
-        mContext = InstrumentationRegistry.getContext();
         mView = new TextView(mContext);
         mView.setText(R.string.keyguard_widget_12_hours_format);
         mView.setContentDescription(mContext.getString(R.string.keyguard_widget_12_hours_format));
index c297ae8..3426e11 100644 (file)
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
 import android.os.Looper;
+import android.support.test.filters.SmallTest;
 
 import com.android.systemui.Dependency.DependencyKey;
 import com.android.systemui.statusbar.policy.FlashlightController;
@@ -30,6 +31,7 @@ import org.junit.Test;
 
 import java.io.PrintWriter;
 
+@SmallTest
 public class DependencyTest extends SysuiTestCase {
 
     public static final DependencyKey<Dumpable> DUMPABLE = new DependencyKey<>("dumpable");
index 0aac1c0..9b67529 100644 (file)
@@ -20,6 +20,7 @@ import android.os.Handler;
 import android.os.Looper;
 import android.os.MessageQueue;
 import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
 import android.testing.LeakCheck;
 import android.util.Log;
 
index d203602..7519b2d 100644 (file)
@@ -43,6 +43,7 @@ import android.testing.AndroidTestingRunner;
 import android.view.Display;
 
 import com.android.internal.hardware.AmbientDisplayConfiguration;
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.util.wakelock.WakeLockFake;
 
 import android.testing.UiThreadTest;
@@ -54,7 +55,7 @@ import org.junit.runner.RunWith;
 @SmallTest
 @RunWith(AndroidTestingRunner.class)
 @UiThreadTest
-public class DozeMachineTest {
+public class DozeMachineTest extends SysuiTestCase {
 
     DozeMachine mMachine;
 
index ada8ac0..720e9f0 100644 (file)
@@ -25,13 +25,14 @@ import static org.mockito.Mockito.when;
 import android.support.test.filters.SmallTest;
 import android.view.Display;
 
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.phone.DozeParameters;
 
 import org.junit.Before;
 import org.junit.Test;
 
 @SmallTest
-public class DozeScreenStatePreventingAdapterTest {
+public class DozeScreenStatePreventingAdapterTest extends SysuiTestCase {
 
     private DozeMachine.Service mInner;
     private DozeScreenStatePreventingAdapter mWrapper;
index 8934460..97d9080 100644 (file)
@@ -32,6 +32,7 @@ import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
 import com.android.internal.hardware.AmbientDisplayConfiguration;
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.phone.DozeParameters;
 import com.android.systemui.util.wakelock.WakeLock;
 import com.android.systemui.util.wakelock.WakeLockFake;
@@ -44,8 +45,7 @@ import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class DozeTriggersTest {
-    private Context mContext;
+public class DozeTriggersTest extends SysuiTestCase {
     private DozeTriggers mTriggers;
     private DozeMachine mMachine;
     private DozeHostFake mHost;
@@ -65,7 +65,6 @@ public class DozeTriggersTest {
     @Before
     public void setUp() throws Exception {
         mInstrumentation = InstrumentationRegistry.getInstrumentation();
-        mContext = InstrumentationRegistry.getContext();
         mMachine = mock(DozeMachine.class);
         mHost = new DozeHostFake();
         mConfig = DozeConfigurationUtil.createMockConfig();
index 0f2878b..5fb0a3e 100644 (file)
@@ -40,6 +40,7 @@ import android.os.UserHandle;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.keyguard.WorkLockActivity;
 import com.android.systemui.keyguard.WorkLockActivityController;
 import com.android.systemui.recents.misc.SystemServicesProxy;
@@ -58,7 +59,7 @@ import org.mockito.MockitoAnnotations;
  */
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class WorkLockActivityControllerTest {
+public class WorkLockActivityControllerTest extends SysuiTestCase {
     private static final int USER_ID = 333;
     private static final int TASK_ID = 444;
 
index 9b868db..9f3573f 100644 (file)
@@ -33,6 +33,7 @@ import android.content.Intent;
 import android.graphics.Color;
 import android.os.Looper;
 
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.keyguard.WorkLockActivity;
 
 import org.junit.Before;
@@ -46,7 +47,7 @@ import org.mockito.MockitoAnnotations;
  */
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class WorkLockActivityTest {
+public class WorkLockActivityTest extends SysuiTestCase {
     private static final @UserIdInt int USER_ID = 270;
     private static final String TASK_LABEL = "task label";
 
index 9849800..0b4d9b5 100644 (file)
@@ -17,6 +17,8 @@ package com.android.systemui.plugins;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
+import android.support.test.filters.SmallTest;
+
 import com.android.systemui.SysuiTestCase;
 import com.android.systemui.plugins.VersionInfo.InvalidVersionException;
 import com.android.systemui.plugins.annotations.Requires;
@@ -28,6 +30,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 
+@SmallTest
 public class VersionInfoTest extends SysuiTestCase {
 
     @Rule
index 0a945ab..7cbe985 100644 (file)
@@ -23,7 +23,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.support.test.filters.FlakyTest;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
@@ -45,7 +45,7 @@ import org.junit.runner.RunWith;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper
-@FlakyTest
+@SmallTest
 public class QSDetailTest extends SysuiTestCase {
 
     private MetricsLogger mMetricsLogger;
index 09c5725..402b12d 100644 (file)
@@ -20,7 +20,7 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import android.support.test.filters.FlakyTest;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
@@ -40,7 +40,7 @@ import org.junit.runner.RunWith;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper
-@FlakyTest
+@SmallTest
 public class QSFooterTest extends LeakCheckedTest {
 
     private QSFooter mFooter;
index 601d4e2..0b7da1f 100644 (file)
@@ -29,6 +29,7 @@ import com.android.systemui.Dependency;
 import com.android.systemui.R;
 
 import android.os.Parcelable;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 
 import com.android.systemui.SysuiBaseFragmentTest;
@@ -50,7 +51,7 @@ import android.widget.FrameLayout;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper(setAsMainLooper = true)
-@FlakyTest
+@SmallTest
 public class QSFragmentTest extends SysuiBaseFragmentTest {
 
     private MetricsLogger mMockMetricsLogger;
index 5f6fc33..e5ff866 100644 (file)
@@ -16,10 +16,10 @@ package com.android.systemui.qs;
 
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
-import android.support.test.filters.FlakyTest;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
@@ -38,7 +38,7 @@ import java.util.Collections;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper
-@FlakyTest
+@SmallTest
 public class QSPanelTest extends SysuiTestCase {
 
     private MetricsLogger mMetricsLogger;
index 6e7d99e..0239ab0 100644 (file)
@@ -18,6 +18,7 @@ import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
@@ -33,6 +34,7 @@ import java.util.Collections;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper
+@SmallTest
 public class TileAdapterTest extends SysuiTestCase {
 
     private TileAdapter mTileAdapter;
index 59483f2..f9f4f49 100644 (file)
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.when;
 import android.content.res.ColorStateList;
 import android.graphics.drawable.Drawable;
 import android.service.quicksettings.Tile;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.UiThreadTest;
 import android.widget.ImageView;
@@ -39,6 +40,7 @@ import org.mockito.ArgumentMatcher;
 
 @RunWith(AndroidTestingRunner.class)
 @UiThreadTest
+@SmallTest
 public class QSIconViewImplTest extends SysuiTestCase {
 
     private QSIconViewImpl mIconView;
index 9ed9d28..0500a54 100644 (file)
@@ -30,6 +30,7 @@ import static org.mockito.Mockito.when;
 
 import android.content.Intent;
 import android.metrics.LogMaker;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
@@ -48,6 +49,7 @@ import org.mockito.ArgumentMatcher;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper
+@SmallTest
 public class QSTileImplTest extends SysuiTestCase {
 
     public static final int POSITION = 14;
index 9e15a05..17d7a41 100644 (file)
@@ -17,6 +17,7 @@
 package com.android.systemui.settings;
 
 import android.content.Intent;
+import android.support.test.filters.SmallTest;
 
 import com.android.systemui.SysuiTestCase;
 
@@ -26,6 +27,7 @@ import org.junit.Test;
 /**
  * Testing functionality of the current user tracker
  */
+@SmallTest
 public class CurrentUserTrackerTest extends SysuiTestCase {
 
     private CurrentUserTracker mTracker;
index c13d13b..8cacb4b 100644 (file)
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
 import android.content.ComponentName;
 import android.graphics.Rect;
 import android.os.Bundle;
+import android.support.test.filters.SmallTest;
 
 import com.android.internal.statusbar.StatusBarIcon;
 import com.android.systemui.SysuiTestCase;
@@ -31,6 +32,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+@SmallTest
 public class CommandQueueTest extends SysuiTestCase {
 
     private CommandQueue mCommandQueue;
index a3a0a6f..1161987 100644 (file)
@@ -29,6 +29,7 @@ import android.support.test.runner.AndroidJUnit4;
 import android.view.View;
 
 import com.android.systemui.statusbar.stack.NotificationChildrenContainer;
+import com.android.systemui.SysuiTestCase;
 
 import org.junit.Assert;
 import org.junit.Before;
@@ -38,16 +39,13 @@ import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-@FlakyTest
-public class ExpandableNotificationRowTest {
+public class ExpandableNotificationRowTest extends SysuiTestCase {
 
-    private Context mContext;
     private ExpandableNotificationRow mGroup;
     private NotificationTestHelper mNotificationTestHelper;
 
     @Before
     public void setUp() throws Exception {
-        mContext = InstrumentationRegistry.getTargetContext();
         mNotificationTestHelper = new NotificationTestHelper(mContext);
         mGroup = mNotificationTestHelper.createGroup();
     }
index fecf901..8dcc408 100644 (file)
@@ -35,18 +35,17 @@ import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.spy;
 
+import com.android.systemui.SysuiTestCase;
+
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-@FlakyTest
-public class NotificationContentViewTest {
+public class NotificationContentViewTest extends SysuiTestCase {
 
     NotificationContentView mView;
-    Context mContext;
 
     @Before
     @UiThreadTest
     public void setup() {
-        mContext = InstrumentationRegistry.getTargetContext();
         mView = new NotificationContentView(mContext, null);
         ExpandableNotificationRow row = new ExpandableNotificationRow(mContext, null);
         ExpandableNotificationRow mockRow = spy(row);
index 00f2b18..fc9b608 100644 (file)
@@ -26,6 +26,7 @@ import android.view.View;
 import android.widget.RemoteViews;
 
 import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.notification.NotificationCustomViewWrapper;
 import com.android.systemui.statusbar.notification.NotificationViewWrapper;
 
@@ -37,16 +38,13 @@ import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-@FlakyTest
-public class NotificationCustomViewWrapperTest {
+public class NotificationCustomViewWrapperTest extends SysuiTestCase {
 
-    private Context mContext;
     private ExpandableNotificationRow mRow;
 
     @Before
     @UiThreadTest
     public void setUp() {
-        mContext = InstrumentationRegistry.getTargetContext();
         mRow = new ExpandableNotificationRow(mContext, null);
     }
 
index 9249df6..e0d8042 100644 (file)
@@ -16,6 +16,7 @@ package com.android.systemui.statusbar;
 
 import static junit.framework.Assert.assertTrue;
 
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
@@ -30,6 +31,7 @@ import org.junit.runner.RunWith;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper(setAsMainLooper = true)
+@SmallTest
 public class NotificationMenuRowTest extends LeakCheckedTest {
 
     @Before
index f9f40a6..33de3ad 100644 (file)
@@ -33,6 +33,7 @@ import android.support.test.runner.AndroidJUnit4;
 import android.widget.RemoteViews;
 
 import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.ExpandableNotificationRow;
 import com.android.systemui.statusbar.NotificationData;
 import com.android.systemui.statusbar.NotificationTestHelper;
@@ -47,17 +48,14 @@ import java.util.concurrent.CountDownLatch;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-@FlakyTest
-public class NotificationInflaterTest {
+public class NotificationInflaterTest extends SysuiTestCase {
 
-    private Context mContext;
     private NotificationInflater mNotificationInflater;
     private Notification.Builder mBuilder;
     private ExpandableNotificationRow mRow;
 
     @Before
     public void setUp() throws Exception {
-        mContext = InstrumentationRegistry.getTargetContext();
         mBuilder = new Notification.Builder(mContext).setSmallIcon(
                 R.drawable.ic_person)
                 .setContentTitle("Title")
index 7a72afd..ebeb24c 100644 (file)
@@ -18,9 +18,11 @@ package com.android.systemui.statusbar.notification;
 
 import android.content.Context;
 import android.support.test.InstrumentationRegistry;
+import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 import android.view.View;
 
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.ExpandableNotificationRow;
 
 import org.junit.Before;
@@ -28,14 +30,8 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @RunWith(AndroidJUnit4.class)
-public class NotificationViewWrapperTest {
-
-    private Context mContext;
-
-    @Before
-    public void setUp() throws Exception {
-        mContext = InstrumentationRegistry.getTargetContext();
-    }
+@SmallTest
+public class NotificationViewWrapperTest extends SysuiTestCase {
 
     @Test
     public void constructor_doesntUseViewContext() throws Exception {
index e4c4373..95ce0d8 100644 (file)
@@ -20,6 +20,7 @@ import android.service.notification.StatusBarNotification;
 import android.support.test.runner.AndroidJUnit4;
 import android.test.suitebuilder.annotation.SmallTest;
 
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.ExpandableNotificationRow;
 import com.android.systemui.statusbar.NotificationData;
 import com.android.systemui.statusbar.notification.VisibilityLocationProvider;
@@ -37,7 +38,7 @@ import static org.mockito.Mockito.when;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class VisualStabilityManagerTest {
+public class VisualStabilityManagerTest extends SysuiTestCase {
 
     private VisualStabilityManager mVisualStabilityManager = new VisualStabilityManager();
     private VisualStabilityManager.Callback mCallback = mock(VisualStabilityManager.Callback.class);
index e41a827..0937ce2 100644 (file)
@@ -22,6 +22,8 @@ import static org.mockito.Mockito.verify;
 import com.android.internal.app.NightDisplayController;
 import com.android.systemui.Prefs;
 import com.android.systemui.Prefs.Key;
+
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import com.android.systemui.SysuiTestCase;
 import com.android.systemui.qs.QSTileHost;
@@ -33,6 +35,7 @@ import org.junit.runner.RunWith;
 import org.mockito.Mockito;
 
 @RunWith(AndroidTestingRunner.class)
+@SmallTest
 public class AutoTileManagerTest extends SysuiTestCase {
 
     private QSTileHost mQsTileHost;
index 6ddbffc..66524cc 100644 (file)
@@ -21,6 +21,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import android.app.StatusBarManager;
+import android.support.test.filters.SmallTest;
 import android.view.View;
 import android.view.ViewPropertyAnimator;
 
@@ -39,6 +40,7 @@ import org.mockito.Mockito;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper(setAsMainLooper = true)
+@SmallTest
 public class CollapsedStatusBarFragmentTest extends SysuiBaseFragmentTest {
 
     private NotificationIconAreaController mMockNotificiationAreaController;
index ee10440..e89ff97 100644 (file)
@@ -18,6 +18,8 @@ package com.android.systemui.statusbar.phone;
 
 import android.support.test.runner.AndroidJUnit4;
 import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.phone.DozeParameters.IntInOutMatcher;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -28,7 +30,7 @@ import static junit.framework.Assert.fail;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class DozeParametersTest {
+public class DozeParametersTest extends SysuiTestCase {
 
     @Test
     public void test_inOutMatcher_defaultIn() {
index 53d842a..a120cec 100644 (file)
@@ -20,6 +20,7 @@ import static org.mockito.Mockito.when;
 
 import android.content.Context;
 import android.os.Looper;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.LeakCheck.Tracker;
 import android.view.Display;
@@ -46,6 +47,7 @@ import org.mockito.stubbing.Answer;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper(setAsMainLooper = true)
+@SmallTest
 public class NavigationBarFragmentTest extends SysuiBaseFragmentTest {
 
     public NavigationBarFragmentTest() {
index ecae39a..5db7792 100644 (file)
@@ -18,6 +18,7 @@ import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper.RunWithLooper;
 import android.view.ViewGroup;
@@ -36,6 +37,7 @@ import org.junit.runner.RunWith;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper
+@SmallTest
 public class StatusBarIconControllerTest extends LeakCheckedTest {
 
     @Before
index f516d74..2eb9560 100644 (file)
@@ -20,6 +20,7 @@ import static org.mockito.Mockito.when;
 
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothProfile;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
@@ -40,6 +41,7 @@ import java.util.List;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper
+@SmallTest
 public class BluetoothControllerImplTest extends SysuiTestCase {
 
     private LocalBluetoothManager mMockBluetoothManager;
index 3ed1681..cb20639 100644 (file)
@@ -20,6 +20,7 @@ import android.support.test.runner.AndroidJUnit4;
 import android.telephony.SubscriptionInfo;
 import android.test.suitebuilder.annotation.SmallTest;
 import com.android.systemui.R;
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.policy.NetworkController.EmergencyListener;
 import com.android.systemui.statusbar.policy.NetworkController.IconState;
 import com.android.systemui.statusbar.policy.NetworkController.SignalCallback;
@@ -40,7 +41,7 @@ import static org.mockito.Matchers.eq;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class CallbackHandlerTest {
+public class CallbackHandlerTest extends SysuiTestCase {
 
     private CallbackHandler mHandler;
     private HandlerThread mHandlerThread;
index 3e79a04..3d79d5b 100644 (file)
@@ -20,6 +20,8 @@ import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
+import android.support.test.filters.SmallTest;
+
 import com.android.systemui.Dependency;
 import com.android.systemui.SysuiTestCase;
 import com.android.systemui.plugins.OverlayPlugin;
@@ -34,6 +36,7 @@ import org.junit.Test;
 import java.util.Map;
 import java.util.function.Consumer;
 
+@SmallTest
 public class ExtensionControllerTest extends SysuiTestCase {
 
     private PluginManager mPluginManager;
index 21fddf2..f859235 100644 (file)
@@ -21,6 +21,7 @@ import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.FIELD_
 import static org.mockito.ArgumentMatchers.argThat;
 
 import android.metrics.LogMaker;
+import android.support.test.filters.SmallTest;
 import android.testing.AndroidTestingRunner;
 import android.testing.TestableLooper;
 import android.testing.TestableLooper.RunWithLooper;
@@ -40,6 +41,7 @@ import java.util.Objects;
 
 @RunWith(AndroidTestingRunner.class)
 @RunWithLooper
+@SmallTest
 public class KeyButtonViewTest extends SysuiTestCase {
 
     private KeyButtonView mKeyButtonView;
index 4932ba1..e6c8815 100644 (file)
@@ -25,6 +25,7 @@ import android.support.test.runner.AndroidJUnit4;
 import android.view.NotificationHeaderView;
 import android.view.View;
 
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.statusbar.ExpandableNotificationRow;
 import com.android.systemui.statusbar.NotificationTestHelper;
 
@@ -36,17 +37,14 @@ import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-@FlakyTest
-public class NotificationChildrenContainerTest {
+public class NotificationChildrenContainerTest extends SysuiTestCase {
 
-    private Context mContext;
     private ExpandableNotificationRow mGroup;
     private int mId;
     private NotificationTestHelper mNotificationTestHelper;
 
     @Before
     public void setUp() throws Exception {
-        mContext = InstrumentationRegistry.getTargetContext();
         mNotificationTestHelper = new NotificationTestHelper(mContext);
         mGroup = mNotificationTestHelper.createGroup();
     }
index 9a825c1..a3b258f 100644 (file)
@@ -27,13 +27,15 @@ import static org.mockito.Mockito.when;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.systemui.SysuiTestCase;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class GarbageMonitorTest {
+public class GarbageMonitorTest extends SysuiTestCase {
 
     private LeakReporter mLeakReporter;
     private TrackedGarbage mTrackedGarbage;
index 11722fe..f1965a2 100644 (file)
@@ -20,6 +20,7 @@ package com.android.systemui.util.leak;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.util.leak.ReferenceTestUtils.CollectionWaiter;
 
 import org.junit.Before;
@@ -35,7 +36,7 @@ import java.util.Collection;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class LeakDetectorTest {
+public class LeakDetectorTest extends SysuiTestCase {
 
     private LeakDetector mLeakDetector;
 
index 1194849..6711ce8 100644 (file)
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 
 import android.app.NotificationManager;
+import android.support.test.filters.MediumTest;
 import android.support.test.runner.AndroidJUnit4;
 
 import com.android.systemui.SysuiTestCase;
@@ -38,6 +39,7 @@ import java.io.File;
 import java.io.PrintWriter;
 
 @RunWith(AndroidJUnit4.class)
+@MediumTest
 public class LeakReporterTest extends SysuiTestCase {
 
     private LeakDetector mLeakDetector;
index 9da67b7..b8a3e39 100644 (file)
@@ -21,12 +21,14 @@ import static org.junit.Assert.assertEquals;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.systemui.SysuiTestCase;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class ReferenceTestUtilsTest {
+public class ReferenceTestUtilsTest extends SysuiTestCase {
 
     @Test
     public void testCollectionWaiter_doesntBlockIndefinitely() {
index fb1c1aa..9787df9 100644 (file)
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.systemui.SysuiTestCase;
 import com.android.systemui.util.leak.ReferenceTestUtils.CollectionWaiter;
 
 import org.junit.Before;
@@ -31,7 +32,7 @@ import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class WeakIdentityHashMapTest {
+public class WeakIdentityHashMapTest extends SysuiTestCase {
 
     WeakIdentityHashMap<Object, Object> mMap;
 
index f6692eb..39316ed 100644 (file)
@@ -24,13 +24,15 @@ import static org.junit.Assert.assertFalse;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.systemui.SysuiTestCase;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class SettableWakeLockTest {
+public class SettableWakeLockTest extends SysuiTestCase {
 
     private WakeLockFake mFake;
     private SettableWakeLock mSettable;
index 5394499..9b7c597 100644 (file)
@@ -25,6 +25,8 @@ import android.support.test.InstrumentationRegistry;
 import android.support.test.filters.SmallTest;
 import android.support.test.runner.AndroidJUnit4;
 
+import com.android.systemui.SysuiTestCase;
+
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -32,7 +34,7 @@ import org.junit.runner.RunWith;
 
 @SmallTest
 @RunWith(AndroidJUnit4.class)
-public class WakeLockTest {
+public class WakeLockTest extends SysuiTestCase {
 
     WakeLock mWakeLock;
     PowerManager.WakeLock mInner;