| 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; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 }); | 219 }); |
| 220 } | 220 } |
| 221 | 221 |
| 222 private void waitUntilAppDetailsRetrieved(final int numExpected) throws Exce
ption { | 222 private void waitUntilAppDetailsRetrieved(final int numExpected) throws Exce
ption { |
| 223 CriteriaHelper.pollUiThread(new Criteria() { | 223 CriteriaHelper.pollUiThread(new Criteria() { |
| 224 @Override | 224 @Override |
| 225 public boolean isSatisfied() { | 225 public boolean isSatisfied() { |
| 226 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); | 226 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); |
| 227 return mDetailsDelegate.mNumRetrieved == numExpected | 227 return mDetailsDelegate.mNumRetrieved == numExpected |
| 228 && !manager.isFetcherActiveForTesting(); | 228 && !manager.isActiveForTesting(); |
| 229 } | 229 } |
| 230 }); | 230 }); |
| 231 } | 231 } |
| 232 | 232 |
| 233 private void waitUntilAppBannerInfoBarAppears(final String title) throws Exc
eption { | 233 private void waitUntilAppBannerInfoBarAppears(final String title) throws Exc
eption { |
| 234 CriteriaHelper.pollUiThread(new Criteria() { | 234 CriteriaHelper.pollUiThread(new Criteria() { |
| 235 @Override | 235 @Override |
| 236 public boolean isSatisfied() { | 236 public boolean isSatisfied() { |
| 237 List<InfoBar> infobars = getInfoBars(); | 237 List<InfoBar> infobars = getInfoBars(); |
| 238 if (infobars.size() != 1) return false; | 238 if (infobars.size() != 1) return false; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 public void triggerWebAppBanner(String url, String expectedTitle) throws Exc
eption { | 307 public void triggerWebAppBanner(String url, String expectedTitle) throws Exc
eption { |
| 308 // Visit the site in a new tab. | 308 // Visit the site in a new tab. |
| 309 loadUrlInNewTab("about:blank"); | 309 loadUrlInNewTab("about:blank"); |
| 310 new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(url); | 310 new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(url); |
| 311 | 311 |
| 312 CriteriaHelper.pollUiThread(new Criteria() { | 312 CriteriaHelper.pollUiThread(new Criteria() { |
| 313 @Override | 313 @Override |
| 314 public boolean isSatisfied() { | 314 public boolean isSatisfied() { |
| 315 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); | 315 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); |
| 316 return !manager.isFetcherActiveForTesting(); | 316 return !manager.isActiveForTesting(); |
| 317 } | 317 } |
| 318 }); | 318 }); |
| 319 waitUntilNoInfoBarsExist(); | 319 waitUntilNoInfoBarsExist(); |
| 320 | 320 |
| 321 // Indicate a day has passed, then revisit the page to show the banner. | 321 // Indicate a day has passed, then revisit the page to show the banner. |
| 322 AppBannerManager.setTimeDeltaForTesting(1); | 322 AppBannerManager.setTimeDeltaForTesting(1); |
| 323 new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(url); | 323 new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(url); |
| 324 CriteriaHelper.pollUiThread(new Criteria() { | 324 CriteriaHelper.pollUiThread(new Criteria() { |
| 325 @Override | 325 @Override |
| 326 public boolean isSatisfied() { | 326 public boolean isSatisfied() { |
| 327 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); | 327 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); |
| 328 return !manager.isFetcherActiveForTesting(); | 328 return !manager.isActiveForTesting(); |
| 329 } | 329 } |
| 330 }); | 330 }); |
| 331 waitUntilAppBannerInfoBarAppears(expectedTitle); | 331 waitUntilAppBannerInfoBarAppears(expectedTitle); |
| 332 } | 332 } |
| 333 | 333 |
| 334 @SmallTest | 334 @SmallTest |
| 335 @Feature({"AppBanners"}) | 335 @Feature({"AppBanners"}) |
| 336 public void testFullNativeInstallPathwayFromId() throws Exception { | 336 public void testFullNativeInstallPathwayFromId() throws Exception { |
| 337 runFullNativeInstallPathway(mNativeAppUrl, NATIVE_APP_BLANK_REFERRER); | 337 runFullNativeInstallPathway(mNativeAppUrl, NATIVE_APP_BLANK_REFERRER); |
| 338 } | 338 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 WebappDataStorage.setFactoryForTests(dataStorageFactory); | 477 WebappDataStorage.setFactoryForTests(dataStorageFactory); |
| 478 | 478 |
| 479 // Visit the site in a new tab. | 479 // Visit the site in a new tab. |
| 480 loadUrlInNewTab("about:blank"); | 480 loadUrlInNewTab("about:blank"); |
| 481 new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(mWebApp
Url); | 481 new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(mWebApp
Url); |
| 482 | 482 |
| 483 CriteriaHelper.pollUiThread(new Criteria() { | 483 CriteriaHelper.pollUiThread(new Criteria() { |
| 484 @Override | 484 @Override |
| 485 public boolean isSatisfied() { | 485 public boolean isSatisfied() { |
| 486 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); | 486 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); |
| 487 return !manager.isFetcherActiveForTesting(); | 487 return !manager.isActiveForTesting(); |
| 488 } | 488 } |
| 489 }); | 489 }); |
| 490 waitUntilNoInfoBarsExist(); | 490 waitUntilNoInfoBarsExist(); |
| 491 | 491 |
| 492 // Add the animation listener in. | 492 // Add the animation listener in. |
| 493 InfoBarContainer container = getActivity().getActivityTab().getInfoBarCo
ntainer(); | 493 InfoBarContainer container = getActivity().getActivityTab().getInfoBarCo
ntainer(); |
| 494 final InfobarListener listener = new InfobarListener(); | 494 final InfobarListener listener = new InfobarListener(); |
| 495 container.setAnimationListener(listener); | 495 container.setAnimationListener(listener); |
| 496 | 496 |
| 497 // Indicate a day has passed, then revisit the page to show the banner. | 497 // Indicate a day has passed, then revisit the page to show the banner. |
| 498 AppBannerManager.setTimeDeltaForTesting(1); | 498 AppBannerManager.setTimeDeltaForTesting(1); |
| 499 new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(mWebApp
Url); | 499 new TabLoadObserver(getActivity().getActivityTab()).fullyLoadUrl(mWebApp
Url); |
| 500 CriteriaHelper.pollUiThread(new Criteria() { | 500 CriteriaHelper.pollUiThread(new Criteria() { |
| 501 @Override | 501 @Override |
| 502 public boolean isSatisfied() { | 502 public boolean isSatisfied() { |
| 503 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); | 503 AppBannerManager manager = getActivity().getActivityTab().getApp
BannerManager(); |
| 504 return !manager.isFetcherActiveForTesting(); | 504 return !manager.isActiveForTesting(); |
| 505 } | 505 } |
| 506 }); | 506 }); |
| 507 waitUntilAppBannerInfoBarAppears(WEB_APP_TITLE); | 507 waitUntilAppBannerInfoBarAppears(WEB_APP_TITLE); |
| 508 CriteriaHelper.pollUiThread(new Criteria() { | 508 CriteriaHelper.pollUiThread(new Criteria() { |
| 509 @Override | 509 @Override |
| 510 public boolean isSatisfied() { | 510 public boolean isSatisfied() { |
| 511 return listener.mDoneAnimating; | 511 return listener.mDoneAnimating; |
| 512 } | 512 } |
| 513 }); | 513 }); |
| 514 | 514 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 526 } | 526 } |
| 527 }); | 527 }); |
| 528 | 528 |
| 529 // Test that bitmap sizes match expectations. | 529 // Test that bitmap sizes match expectations. |
| 530 int idealSize = getActivity().getResources().getDimensionPixelSize( | 530 int idealSize = getActivity().getResources().getDimensionPixelSize( |
| 531 R.dimen.webapp_splash_image_size_ideal); | 531 R.dimen.webapp_splash_image_size_ideal); |
| 532 assertEquals(idealSize, dataStorageFactory.mSplashImage.getWidth()); | 532 assertEquals(idealSize, dataStorageFactory.mSplashImage.getWidth()); |
| 533 assertEquals(idealSize, dataStorageFactory.mSplashImage.getHeight()); | 533 assertEquals(idealSize, dataStorageFactory.mSplashImage.getHeight()); |
| 534 } | 534 } |
| 535 } | 535 } |
| OLD | NEW |