Merge "Clear mocks in tests"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2cda351f21
@@ -44,8 +44,10 @@ import com.android.systemui.settings.UserTracker;
|
||||
import com.android.systemui.statusbar.SmartReplyController;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -120,11 +122,15 @@ public abstract class SysuiTestCase {
|
||||
TestableLooper.get(this).processAllMessages();
|
||||
}
|
||||
disallowTestableLooperAsMainThread();
|
||||
SystemUIFactory.cleanup();
|
||||
mContext.cleanUpReceivers(this.getClass().getSimpleName());
|
||||
mFakeBroadcastDispatcher.cleanUpReceivers(this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void mockitoTearDown() {
|
||||
Mockito.framework().clearInlineMocks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests are run on the TestableLooper; however, there are parts of SystemUI that assert that
|
||||
* the code is run from the main looper. Therefore, we allow the TestableLooper to pass these
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntryB
|
||||
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
|
||||
import com.android.systemui.statusbar.policy.HeadsUpManagerLogger;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -86,6 +87,7 @@ public class AlertingNotificationManagerTest extends SysuiTestCase {
|
||||
super(mock(HeadsUpManagerLogger.class));
|
||||
mMinimumDisplayTime = TEST_MINIMUM_DISPLAY_TIME;
|
||||
mAutoDismissNotificationDecay = TEST_AUTO_DISMISS_TIME;
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = mTestHandler;
|
||||
}
|
||||
|
||||
@@ -145,6 +147,11 @@ public class AlertingNotificationManagerTest extends SysuiTestCase {
|
||||
mAlertingNotificationManager = createAlertingNotificationManager();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mTestHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowNotification_addsEntry() {
|
||||
mAlertingNotificationManager.showNotification(mEntry);
|
||||
|
||||
@@ -60,6 +60,7 @@ import com.android.systemui.util.time.FakeSystemClock;
|
||||
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -131,6 +132,11 @@ public class NotificationLoggerLegacyTest extends SysuiTestCase {
|
||||
verify(mNotifPipeline, never()).addCollectionListener(any());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mLogger.mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnChildLocationsChangedReportsVisibilityChanged() throws Exception {
|
||||
NotificationVisibility[] newlyVisibleKeys = {
|
||||
@@ -281,6 +287,7 @@ public class NotificationLoggerLegacyTest extends SysuiTestCase {
|
||||
mNotificationPanelLoggerFake
|
||||
);
|
||||
mBarService = barService;
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
// Make this on the current thread so we can wait for it during tests.
|
||||
mHandler = Handler.createAsync(Looper.myLooper());
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ import com.android.systemui.util.time.FakeSystemClock;
|
||||
|
||||
import com.google.android.collect.Lists;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -132,6 +133,11 @@ public class NotificationLoggerTest extends SysuiTestCase {
|
||||
verify(mNotifPipeline).addCollectionListener(any());
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mLogger.mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnChildLocationsChangedReportsVisibilityChanged() throws Exception {
|
||||
NotificationVisibility[] newlyVisibleKeys = {
|
||||
@@ -282,6 +288,7 @@ public class NotificationLoggerTest extends SysuiTestCase {
|
||||
mNotificationPanelLoggerFake
|
||||
);
|
||||
mBarService = barService;
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
// Make this on the current thread so we can wait for it during tests.
|
||||
mHandler = Handler.createAsync(Looper.myLooper());
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.Handler;
|
||||
import android.os.UserHandle;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.testing.TestableLooper;
|
||||
@@ -139,6 +140,8 @@ public class NotificationTestHelper {
|
||||
mock(NotificationGroupManagerLegacy.class),
|
||||
mock(ConfigurationControllerImpl.class)
|
||||
);
|
||||
mHeadsUpManager.mHandler.removeCallbacksAndMessages(null);
|
||||
mHeadsUpManager.mHandler = new Handler(mTestLooper.getLooper());
|
||||
mGroupMembershipManager.setHeadsUpManager(mHeadsUpManager);
|
||||
mIconManager = new IconManager(
|
||||
mock(CommonNotifCollection.class),
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
|
||||
import com.android.systemui.statusbar.policy.ConfigurationController;
|
||||
import com.android.systemui.statusbar.policy.HeadsUpManagerLogger;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
@@ -115,9 +116,15 @@ public class HeadsUpManagerPhoneTest extends AlertingNotificationManagerTest {
|
||||
mConfigurationController
|
||||
);
|
||||
super.setUp();
|
||||
mHeadsUpManager.mHandler.removeCallbacksAndMessages(null);
|
||||
mHeadsUpManager.mHandler = mTestHandler;
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mTestHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSnooze() {
|
||||
mHeadsUpManager.showNotification(mEntry);
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.android.systemui.statusbar.policy.HeadsUpManager;
|
||||
import com.android.systemui.statusbar.policy.HeadsUpManagerLogger;
|
||||
import com.android.wm.shell.bubbles.Bubbles;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -111,6 +112,11 @@ public class NotificationGroupAlertTransferHelperTest extends SysuiTestCase {
|
||||
mHeadsUpManager.addListener(mGroupAlertTransferHelper);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mHeadsUpManager.mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
private void mockHasHeadsUpContentView(NotificationEntry entry,
|
||||
boolean hasHeadsUpContentView) {
|
||||
RowContentBindParams params = new RowContentBindParams();
|
||||
|
||||
@@ -148,6 +148,7 @@ import com.android.systemui.util.time.FakeSystemClock;
|
||||
import com.android.systemui.wallet.controller.QuickAccessWalletController;
|
||||
import com.android.wm.shell.animation.FlingAnimationUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -366,6 +367,7 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
||||
private List<View.OnAttachStateChangeListener> mOnAttachStateChangeListeners;
|
||||
private FalsingManagerFake mFalsingManager = new FalsingManagerFake();
|
||||
private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
||||
private Handler mMainHandler;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -483,9 +485,11 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
||||
.thenReturn(true);
|
||||
reset(mView);
|
||||
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
mNotificationPanelViewController = new NotificationPanelViewController(mView,
|
||||
mResources,
|
||||
new Handler(Looper.getMainLooper()),
|
||||
mMainHandler,
|
||||
mLayoutInflater,
|
||||
mFeatureFlags,
|
||||
coordinator, expansionHandler, mDynamicPrivacyController, mKeyguardBypassController,
|
||||
@@ -560,6 +564,12 @@ public class NotificationPanelViewControllerTest extends SysuiTestCase {
|
||||
.setHeadsUpAppearanceController(mock(HeadsUpAppearanceController.class));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mNotificationPanelViewController.cancelHeightAnimator();
|
||||
mMainHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetPanelScrimMinFraction() {
|
||||
mNotificationPanelViewController.setPanelScrimMinFraction(0.5f);
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.android.systemui.statusbar.AlertingNotificationManager;
|
||||
import com.android.systemui.statusbar.AlertingNotificationManagerTest;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -77,9 +78,15 @@ public class HeadsUpManagerTest extends AlertingNotificationManagerTest {
|
||||
|
||||
mHeadsUpManager = new TestableHeadsUpManager(mContext);
|
||||
super.setUp();
|
||||
mHeadsUpManager.mHandler.removeCallbacksAndMessages(null);
|
||||
mHeadsUpManager.mHandler = mTestHandler;
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mTestHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowNotification_autoDismissesWithAccessibilityTimeout() {
|
||||
doReturn(TEST_A11Y_AUTO_DISMISS_TIME).when(mAccessibilityMgr)
|
||||
|
||||
Reference in New Issue
Block a user