@Override public void setUp() throws Exception { // Plant RecordingTabModelSelector as the TabModelSelector used in Main. The factory has to // be set before super.setUp(), as super.setUp() creates Main and consequently the // TabModelSelector. ThreadUtils.runOnUiThreadBlocking( new Runnable() { @Override public void run() { TabWindowManager.getInstance() .setTabModelSelectorFactory( new TabModelSelectorFactory() { @Override public TabModelSelector buildSelector( ChromeActivity activity, WindowAndroid windowAndroid, int selectorIndex) { return new RecordingTabModelSelector( activity, selectorIndex, windowAndroid); } }); } }); super.setUp(); }
@Override protected void setUp() throws Exception { mPackageManager = new TestPackageManager(); AppBannerManager.setIsEnabledForTesting(true); AppBannerInfoBarDelegateAndroid.setPackageManagerForTesting(mPackageManager); super.setUp(); // Must be set after native has loaded. mDetailsDelegate = new MockAppDetailsDelegate(); ThreadUtils.runOnUiThreadBlocking( new Runnable() { @Override public void run() { AppBannerManager.setAppDetailsDelegate(mDetailsDelegate); } }); AppBannerManager.disableSecureSchemeCheckForTesting(); // Navigations in this test are all of type ui::PAGE_TRANSITION_LINK, i.e. indirect. // Force indirect navigations to be worth the same as direct for testing. AppBannerManager.forceEngagementWeightsForTesting(1, 1); }