Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/banners/AppBannerManagerTest.java

Issue 2853573002: Convert ChromeTabbedActivityTestCaseBase children to JUnit4 (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/banners/AppBannerManagerTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/banners/AppBannerManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/banners/AppBannerManagerTest.java
index 77ab29e38797e83adc7a00029a766868d828018a..5878c7e1ea87420076551aaee5944d5188eae7b8 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/banners/AppBannerManagerTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/banners/AppBannerManagerTest.java
@@ -12,6 +12,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
+import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
import android.test.mock.MockPackageManager;
@@ -20,10 +21,19 @@ import android.view.View;
import android.widget.Button;
import android.widget.TextView;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.RecordHistogram;
+import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ShortcutHelper;
import org.chromium.chrome.browser.engagement.SiteEngagementService;
import org.chromium.chrome.browser.infobar.AppBannerInfoBarAndroid;
@@ -35,7 +45,9 @@ import org.chromium.chrome.browser.infobar.InfoBarContainerLayout.Item;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.webapps.WebappDataStorage;
-import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
+import org.chromium.chrome.test.ChromeActivityTestRule;
+import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
+import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.util.InfoBarUtil;
import org.chromium.chrome.test.util.browser.TabLoadObserver;
import org.chromium.chrome.test.util.browser.TabTitleObserver;
@@ -53,7 +65,13 @@ import java.util.concurrent.Callable;
/**
* Tests the app banners.
*/
-public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
+@RunWith(ChromeJUnit4ClassRunner.class)
+@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
+ ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
+public class AppBannerManagerTest {
+ @Rule
+ public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
+
private static final String NATIVE_APP_PATH =
"/chrome/test/data/banners/play_app_test_page.html";
@@ -148,7 +166,7 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
@Override
public void updateSplashScreenImage(String splashScreenImage) {
- assertNull(mSplashImage);
+ Assert.assertNull(mSplashImage);
mSplashImage = splashScreenImage;
}
}
@@ -174,13 +192,8 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
private EmbeddedTestServer mTestServer;
private String mWebAppUrl;
- @Override
- public void startMainActivity() throws InterruptedException {
- startMainActivityOnBlankPage();
- }
-
- @Override
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
mPackageManager = new TestPackageManager();
AppBannerManager.setIsSupported(true);
AppBannerInfoBarDelegateAndroid.setPackageManagerForTesting(mPackageManager);
@@ -191,8 +204,7 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
}
});
- super.setUp();
-
+ mActivityTestRule.startMainActivityOnBlankPage();
// Must be set after native has loaded.
mDetailsDelegate = new MockAppDetailsDelegate();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@@ -203,15 +215,15 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
});
AppBannerManager.setTotalEngagementForTesting(10);
- mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
+ mTestServer = EmbeddedTestServer.createAndStartServer(
+ InstrumentationRegistry.getInstrumentation().getContext());
mNativeAppUrl = mTestServer.getURL(NATIVE_APP_PATH);
mWebAppUrl = mTestServer.getURL(WEB_APP_PATH);
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
mTestServer.stopAndDestroyServer();
- super.tearDown();
}
private void resetEngagementForUrl(final String url, final double engagement) {
@@ -228,7 +240,8 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
- AppBannerManager manager = getActivity().getActivityTab().getAppBannerManager();
+ AppBannerManager manager =
+ mActivityTestRule.getActivity().getActivityTab().getAppBannerManager();
return mDetailsDelegate.mNumRetrieved == numExpected
&& !manager.isActiveForTesting();
}
@@ -239,7 +252,7 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
- List<InfoBar> infobars = getInfoBars();
+ List<InfoBar> infobars = mActivityTestRule.getInfoBars();
if (infobars.size() != 1) return false;
if (!(infobars.get(0) instanceof AppBannerInfoBarAndroid)) return false;
@@ -254,17 +267,20 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
private void runFullNativeInstallPathway(String url, String expectedReferrer) throws Exception {
// Visit a site that requests a banner.
resetEngagementForUrl(url, 0);
- new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(url, PageTransition.TYPED);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
+ .fullyLoadUrl(url, PageTransition.TYPED);
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Update engagement, then revisit the page to get the banner to appear.
resetEngagementForUrl(url, 10);
- InfoBarContainer container = getActivity().getActivityTab().getInfoBarContainer();
+ InfoBarContainer container =
+ mActivityTestRule.getActivity().getActivityTab().getInfoBarContainer();
final InfobarListener listener = new InfobarListener();
container.addAnimationListener(listener);
- new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(url, PageTransition.TYPED);
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
+ .fullyLoadUrl(url, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(1);
- assertEquals(mDetailsDelegate.mReferrer, expectedReferrer);
+ Assert.assertEquals(mDetailsDelegate.mReferrer, expectedReferrer);
waitUntilAppBannerInfoBarAppears(NATIVE_APP_TITLE);
CriteriaHelper.pollUiThread(new Criteria() {
@Override
@@ -277,22 +293,24 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
InfoBar infobar = container.getInfoBarsForTesting().get(0);
final Button button =
(Button) infobar.getView().findViewById(R.id.button_primary);
- assertEquals(NATIVE_APP_INSTALL_TEXT, button.getText());
+ Assert.assertEquals(NATIVE_APP_INSTALL_TEXT, button.getText());
// Click the button to trigger the install.
final ActivityMonitor activityMonitor = new ActivityMonitor(
new IntentFilter(INSTALL_ACTION), new ActivityResult(Activity.RESULT_OK, null),
true);
- getInstrumentation().addMonitor(activityMonitor);
+ InstrumentationRegistry.getInstrumentation().addMonitor(activityMonitor);
TouchCommon.singleClickView(button);
// Wait for the infobar to register that the app is installing.
final String installingText =
- getInstrumentation().getTargetContext().getString(R.string.app_banner_installing);
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getString(
+ R.string.app_banner_installing);
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
- return getInstrumentation().checkMonitorHit(activityMonitor, 1)
+ return InstrumentationRegistry.getInstrumentation().checkMonitorHit(
+ activityMonitor, 1)
&& TextUtils.equals(button.getText(), installingText);
}
});
@@ -300,7 +318,8 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
// Say that the package is installed. Infobar should say that the app is ready to open.
mPackageManager.isInstalled = true;
final String openText =
- getInstrumentation().getTargetContext().getString(R.string.app_banner_open);
+ InstrumentationRegistry.getInstrumentation().getTargetContext().getString(
+ R.string.app_banner_open);
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
@@ -313,30 +332,35 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
throws Exception {
// Visit the site in a new tab.
resetEngagementForUrl(url, 0);
- loadUrlInNewTab("about:blank");
- new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(url, PageTransition.TYPED);
+ mActivityTestRule.loadUrlInNewTab("about:blank");
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
+ .fullyLoadUrl(url, PageTransition.TYPED);
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
- AppBannerManager manager = getActivity().getActivityTab().getAppBannerManager();
+ AppBannerManager manager =
+ mActivityTestRule.getActivity().getActivityTab().getAppBannerManager();
return !manager.isActiveForTesting();
}
});
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Add the animation listener in.
- InfoBarContainer container = getActivity().getActivityTab().getInfoBarContainer();
+ InfoBarContainer container =
+ mActivityTestRule.getActivity().getActivityTab().getInfoBarContainer();
final InfobarListener listener = new InfobarListener();
container.addAnimationListener(listener);
// Update engagement, then revisit the page to get the banner to appear.
resetEngagementForUrl(url, 10);
- new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(url, PageTransition.TYPED);
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
+ .fullyLoadUrl(url, PageTransition.TYPED);
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
- AppBannerManager manager = getActivity().getActivityTab().getAppBannerManager();
+ AppBannerManager manager =
+ mActivityTestRule.getActivity().getActivityTab().getAppBannerManager();
return !manager.isActiveForTesting();
}
});
@@ -357,12 +381,14 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
TouchCommon.singleClickView(button);
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testFullNativeInstallPathwayFromId() throws Exception {
runFullNativeInstallPathway(mNativeAppUrl, NATIVE_APP_BLANK_REFERRER);
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testFullNativeInstallPathwayFromUrl() throws Exception {
@@ -370,50 +396,52 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
mTestServer.getURL(NATIVE_APP_URL_WITH_MANIFEST_PATH), NATIVE_APP_REFERRER);
}
+ @Test
@MediumTest
@Feature({"AppBanners"})
public void testBannerAppearsThenDoesNotAppearAgainForWeeks() throws Exception {
// Visit a site that requests a banner.
resetEngagementForUrl(mNativeAppUrl, 0);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Update engagement, then revisit the page.
resetEngagementForUrl(mNativeAppUrl, 10);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(1);
waitUntilAppBannerInfoBarAppears(NATIVE_APP_TITLE);
// Revisit the page to make the banner go away, but don't explicitly dismiss it.
// This hides the banner for two weeks.
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(2);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Wait a week until revisiting the page.
AppBannerManager.setTimeDeltaForTesting(7);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(3);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
AppBannerManager.setTimeDeltaForTesting(8);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(4);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Wait two weeks until revisiting the page, which should pop up the banner.
AppBannerManager.setTimeDeltaForTesting(15);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(5);
waitUntilAppBannerInfoBarAppears(NATIVE_APP_TITLE);
}
+ @Test
@MediumTest
@Feature({"AppBanners"})
public void testBannerAppearsThenDoesNotAppearAgainForCustomTime() throws Exception {
@@ -422,32 +450,34 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
// Revisit the page to make the banner go away, but don't explicitly dismiss it.
// This hides the banner for two weeks.
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mWebAppUrl, PageTransition.TYPED);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Wait a week until revisiting the page. This should allow the banner.
AppBannerManager.setTimeDeltaForTesting(7);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mWebAppUrl, PageTransition.TYPED);
waitUntilAppBannerInfoBarAppears(WEB_APP_TITLE);
}
+ @Test
@MediumTest
@Feature({"AppBanners"})
public void testBlockedBannerDoesNotAppearAgainForMonths() throws Exception {
// Visit a site that requests a banner.
resetEngagementForUrl(mNativeAppUrl, 0);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Update engagement, then revisit the page.
resetEngagementForUrl(mNativeAppUrl, 10);
- InfoBarContainer container = getActivity().getActivityTab().getInfoBarContainer();
+ InfoBarContainer container =
+ mActivityTestRule.getActivity().getActivityTab().getInfoBarContainer();
final InfobarListener listener = new InfobarListener();
container.addAnimationListener(listener);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(1);
waitUntilAppBannerInfoBarAppears(NATIVE_APP_TITLE);
@@ -462,29 +492,30 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
ArrayList<InfoBar> infobars = container.getInfoBarsForTesting();
View close = infobars.get(0).getView().findViewById(R.id.infobar_close_button);
TouchCommon.singleClickView(close);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Waiting two months shouldn't be long enough.
AppBannerManager.setTimeDeltaForTesting(61);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(2);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
AppBannerManager.setTimeDeltaForTesting(62);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(3);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Waiting three months should allow banners to reappear.
AppBannerManager.setTimeDeltaForTesting(91);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
waitUntilAppDetailsRetrieved(4);
waitUntilAppBannerInfoBarAppears(NATIVE_APP_TITLE);
}
+ @Test
@MediumTest
@Feature({"AppBanners"})
public void testBlockedBannerDoesNotAppearAgainForCustomTime() throws Exception {
@@ -492,10 +523,11 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
// Update engagement, then visit a page which triggers a banner.
resetEngagementForUrl(mWebAppUrl, 10);
- InfoBarContainer container = getActivity().getActivityTab().getInfoBarContainer();
+ InfoBarContainer container =
+ mActivityTestRule.getActivity().getActivityTab().getInfoBarContainer();
final InfobarListener listener = new InfobarListener();
container.addAnimationListener(listener);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mWebAppUrl, PageTransition.TYPED);
waitUntilAppBannerInfoBarAppears(WEB_APP_TITLE);
@@ -509,22 +541,23 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
ArrayList<InfoBar> infobars = container.getInfoBarsForTesting();
View close = infobars.get(0).getView().findViewById(R.id.infobar_close_button);
TouchCommon.singleClickView(close);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
// Waiting seven days should be long enough.
AppBannerManager.setTimeDeltaForTesting(7);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mWebAppUrl, PageTransition.TYPED);
waitUntilAppBannerInfoBarAppears(WEB_APP_TITLE);
}
+ @Test
@MediumTest
@Feature({"AppBanners"})
public void testBitmapFetchersCanOverlapWithoutCrashing() throws Exception {
// Visit a site that requests a banner rapidly and repeatedly.
resetEngagementForUrl(mNativeAppUrl, 10);
for (int i = 1; i <= 10; i++) {
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED);
final Integer iteration = Integer.valueOf(i);
@@ -537,6 +570,7 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
}
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testWebAppBannerAppears() throws Exception {
@@ -546,20 +580,22 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
ThreadUtils.runOnUiThread(new Runnable() {
@Override
public void run() {
- AppBannerManager manager = getActivity().getActivityTab().getAppBannerManager();
+ AppBannerManager manager =
+ mActivityTestRule.getActivity().getActivityTab().getAppBannerManager();
manager.recordMenuItemAddToHomescreen();
- assertEquals(1,
+ Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"Webapp.InstallabilityCheckStatus.MenuItemAddToHomescreen", 5));
manager.recordMenuOpen();
- assertEquals(1,
+ Assert.assertEquals(1,
RecordHistogram.getHistogramValueCountForTesting(
"Webapp.InstallabilityCheckStatus.MenuOpen", 5));
}
});
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testWebAppBannerDoesNotAppearAfterInstall() throws Exception {
@@ -567,11 +603,12 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
// The banner should not reshow after the site has been installed.
AppBannerManager.setTimeDeltaForTesting(100);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mWebAppUrl, PageTransition.TYPED);
- InfoBarUtil.waitUntilNoInfoBarsExist(getInfoBars());
+ InfoBarUtil.waitUntilNoInfoBarsExist(mActivityTestRule.getInfoBars());
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testBannerFallsBackToShortName() throws Exception {
@@ -580,56 +617,62 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
WEB_APP_SHORT_TITLE, false);
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testAppInstalledEvent() throws Exception {
triggerWebAppBanner(mWebAppUrl, WEB_APP_TITLE, true);
// The appinstalled event should fire (and cause the title to change).
- Tab tab = getActivity().getActivityTab();
+ Tab tab = mActivityTestRule.getActivity().getActivityTab();
new TabTitleObserver(tab, "Got appinstalled").waitForTitleUpdate(3);
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testBannerAppearsImmediatelyWithSufficientEngagement() throws Exception {
// Visit the site in a new tab with sufficient engagement and verify it appears.
resetEngagementForUrl(mWebAppUrl, 10);
- loadUrlInNewTab("about:blank");
+ mActivityTestRule.loadUrlInNewTab("about:blank");
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mWebAppUrl, PageTransition.TYPED);
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
- AppBannerManager manager = getActivity().getActivityTab().getAppBannerManager();
+ AppBannerManager manager =
+ mActivityTestRule.getActivity().getActivityTab().getAppBannerManager();
return !manager.isActiveForTesting();
}
});
waitUntilAppBannerInfoBarAppears(WEB_APP_TITLE);
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testBannerDoesNotAppearInIncognito() throws Exception {
// Visit the site in an incognito tab and verify it doesn't appear.
resetEngagementForUrl(mWebAppUrl, 10);
- loadUrlInNewTab("about:blank", true);
+ mActivityTestRule.loadUrlInNewTab("about:blank", true);
- new TabLoadObserver(getActivity().getActivityTab())
+ new TabLoadObserver(mActivityTestRule.getActivity().getActivityTab())
.fullyLoadUrl(mWebAppUrl, PageTransition.TYPED);
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
- AppBannerManager manager = getActivity().getActivityTab().getAppBannerManager();
+ AppBannerManager manager =
+ mActivityTestRule.getActivity().getActivityTab().getAppBannerManager();
return !manager.isActiveForTesting();
}
});
- assertTrue(getInfoBars().isEmpty());
+ Assert.assertTrue(mActivityTestRule.getInfoBars().isEmpty());
}
+ @Test
@SmallTest
@Feature({"AppBanners"})
public void testWebAppSplashscreenIsDownloaded() throws Exception {
@@ -648,10 +691,10 @@ public class AppBannerManagerTest extends ChromeTabbedActivityTestBase {
});
// Test that bitmap sizes match expectations.
- int idealSize = getActivity().getResources().getDimensionPixelSize(
+ int idealSize = mActivityTestRule.getActivity().getResources().getDimensionPixelSize(
R.dimen.webapp_splash_image_size_ideal);
Bitmap splashImage = ShortcutHelper.decodeBitmapFromString(dataStorageFactory.mSplashImage);
- assertEquals(idealSize, splashImage.getWidth());
- assertEquals(idealSize, splashImage.getHeight());
+ Assert.assertEquals(idealSize, splashImage.getWidth());
+ Assert.assertEquals(idealSize, splashImage.getHeight());
}
}

Powered by Google App Engine
This is Rietveld 408576698