| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.banners; | 5 package org.chromium.chrome.browser.banners; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.app.Instrumentation.ActivityMonitor; | 8 import android.app.Instrumentation.ActivityMonitor; |
| 9 import android.app.Instrumentation.ActivityResult; | 9 import android.app.Instrumentation.ActivityResult; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| 11 import android.content.Intent; | 11 import android.content.Intent; |
| 12 import android.content.IntentFilter; | 12 import android.content.IntentFilter; |
| 13 import android.content.pm.PackageInfo; | 13 import android.content.pm.PackageInfo; |
| 14 import android.graphics.Bitmap; | 14 import android.graphics.Bitmap; |
| 15 import android.support.test.filters.MediumTest; | 15 import android.support.test.filters.MediumTest; |
| 16 import android.support.test.filters.SmallTest; | 16 import android.support.test.filters.SmallTest; |
| 17 import android.test.mock.MockPackageManager; | 17 import android.test.mock.MockPackageManager; |
| 18 import android.text.TextUtils; | 18 import android.text.TextUtils; |
| 19 import android.view.View; | 19 import android.view.View; |
| 20 import android.widget.Button; | 20 import android.widget.Button; |
| 21 import android.widget.TextView; | 21 import android.widget.TextView; |
| 22 | 22 |
| 23 import org.chromium.base.ThreadUtils; | 23 import org.chromium.base.ThreadUtils; |
| 24 import org.chromium.base.test.util.DisabledTest; |
| 24 import org.chromium.base.test.util.Feature; | 25 import org.chromium.base.test.util.Feature; |
| 25 import org.chromium.chrome.R; | 26 import org.chromium.chrome.R; |
| 26 import org.chromium.chrome.browser.ShortcutHelper; | 27 import org.chromium.chrome.browser.ShortcutHelper; |
| 27 import org.chromium.chrome.browser.engagement.SiteEngagementService; | 28 import org.chromium.chrome.browser.engagement.SiteEngagementService; |
| 28 import org.chromium.chrome.browser.infobar.AppBannerInfoBarAndroid; | 29 import org.chromium.chrome.browser.infobar.AppBannerInfoBarAndroid; |
| 29 import org.chromium.chrome.browser.infobar.AppBannerInfoBarDelegateAndroid; | 30 import org.chromium.chrome.browser.infobar.AppBannerInfoBarDelegateAndroid; |
| 30 import org.chromium.chrome.browser.infobar.InfoBar; | 31 import org.chromium.chrome.browser.infobar.InfoBar; |
| 31 import org.chromium.chrome.browser.infobar.InfoBarContainer; | 32 import org.chromium.chrome.browser.infobar.InfoBarContainer; |
| 32 import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationList
ener; | 33 import org.chromium.chrome.browser.infobar.InfoBarContainer.InfoBarAnimationList
ener; |
| 33 import org.chromium.chrome.browser.profiles.Profile; | 34 import org.chromium.chrome.browser.profiles.Profile; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 waitUntilNoInfoBarsExist(); | 412 waitUntilNoInfoBarsExist(); |
| 412 | 413 |
| 413 // Wait two weeks until revisiting the page, which should pop up the ban
ner. | 414 // Wait two weeks until revisiting the page, which should pop up the ban
ner. |
| 414 AppBannerManager.setTimeDeltaForTesting(15); | 415 AppBannerManager.setTimeDeltaForTesting(15); |
| 415 new TabLoadObserver(getActivity().getActivityTab()) | 416 new TabLoadObserver(getActivity().getActivityTab()) |
| 416 .fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED); | 417 .fullyLoadUrl(mNativeAppUrl, PageTransition.TYPED); |
| 417 waitUntilAppDetailsRetrieved(5); | 418 waitUntilAppDetailsRetrieved(5); |
| 418 waitUntilAppBannerInfoBarAppears(NATIVE_APP_TITLE); | 419 waitUntilAppBannerInfoBarAppears(NATIVE_APP_TITLE); |
| 419 } | 420 } |
| 420 | 421 |
| 421 @MediumTest | 422 // @MediumTest |
| 422 @Feature({"AppBanners"}) | 423 // @Feature({"AppBanners"}) |
| 424 @DisabledTest |
| 423 public void testBannerAppearsThenDoesNotAppearAgainForCustomTime() throws Ex
ception { | 425 public void testBannerAppearsThenDoesNotAppearAgainForCustomTime() throws Ex
ception { |
| 424 AppBannerManager.setDaysAfterDismissAndIgnoreForTesting(7, 7); | 426 AppBannerManager.setDaysAfterDismissAndIgnoreForTesting(7, 7); |
| 425 triggerWebAppBanner(mWebAppUrl, WEB_APP_TITLE, false); | 427 triggerWebAppBanner(mWebAppUrl, WEB_APP_TITLE, false); |
| 426 | 428 |
| 427 // Revisit the page to make the banner go away, but don't explicitly dis
miss it. | 429 // Revisit the page to make the banner go away, but don't explicitly dis
miss it. |
| 428 // This hides the banner for two weeks. | 430 // This hides the banner for two weeks. |
| 429 new TabLoadObserver(getActivity().getActivityTab()) | 431 new TabLoadObserver(getActivity().getActivityTab()) |
| 430 .fullyLoadUrl(mWebAppUrl, PageTransition.TYPED); | 432 .fullyLoadUrl(mWebAppUrl, PageTransition.TYPED); |
| 431 waitUntilNoInfoBarsExist(); | 433 waitUntilNoInfoBarsExist(); |
| 432 | 434 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 }); | 597 }); |
| 596 | 598 |
| 597 // Test that bitmap sizes match expectations. | 599 // Test that bitmap sizes match expectations. |
| 598 int idealSize = getActivity().getResources().getDimensionPixelSize( | 600 int idealSize = getActivity().getResources().getDimensionPixelSize( |
| 599 R.dimen.webapp_splash_image_size_ideal); | 601 R.dimen.webapp_splash_image_size_ideal); |
| 600 Bitmap splashImage = ShortcutHelper.decodeBitmapFromString(dataStorageFa
ctory.mSplashImage); | 602 Bitmap splashImage = ShortcutHelper.decodeBitmapFromString(dataStorageFa
ctory.mSplashImage); |
| 601 assertEquals(idealSize, splashImage.getWidth()); | 603 assertEquals(idealSize, splashImage.getWidth()); |
| 602 assertEquals(idealSize, splashImage.getHeight()); | 604 assertEquals(idealSize, splashImage.getHeight()); |
| 603 } | 605 } |
| 604 } | 606 } |
| OLD | NEW |