| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.support.test.filters.MediumTest; | 8 import android.support.test.filters.MediumTest; |
| 9 | 9 |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 private Tab mTab; | 52 private Tab mTab; |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * Subclass of {@link WebApkUpdateManager} which notifies the {@link Callbac
kHelper} passed to | 55 * Subclass of {@link WebApkUpdateManager} which notifies the {@link Callbac
kHelper} passed to |
| 56 * the constructor when it has been determined whether an update is needed. | 56 * the constructor when it has been determined whether an update is needed. |
| 57 */ | 57 */ |
| 58 private static class TestWebApkUpdateManager extends WebApkUpdateManager { | 58 private static class TestWebApkUpdateManager extends WebApkUpdateManager { |
| 59 private CallbackHelper mWaiter; | 59 private CallbackHelper mWaiter; |
| 60 private boolean mNeedsUpdate = false; | 60 private boolean mNeedsUpdate = false; |
| 61 | 61 |
| 62 public TestWebApkUpdateManager(CallbackHelper waiter) { | 62 public TestWebApkUpdateManager(CallbackHelper waiter, WebappDataStorage
storage) { |
| 63 super(null); | 63 super(null, storage); |
| 64 mWaiter = waiter; | 64 mWaiter = waiter; |
| 65 } | 65 } |
| 66 | 66 |
| 67 @Override | 67 @Override |
| 68 public void onWebManifestForInitialUrlNotWebApkCompatible() { | 68 public void onWebManifestForInitialUrlNotWebApkCompatible() { |
| 69 super.onWebManifestForInitialUrlNotWebApkCompatible(); | 69 super.onWebManifestForInitialUrlNotWebApkCompatible(); |
| 70 mWaiter.notifyCalled(); | 70 mWaiter.notifyCalled(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 @Override | 73 @Override |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 140 } |
| 141 | 141 |
| 142 @Override | 142 @Override |
| 143 public void startMainActivity() throws InterruptedException { | 143 public void startMainActivity() throws InterruptedException { |
| 144 startMainActivityOnBlankPage(); | 144 startMainActivityOnBlankPage(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 /** Checks whether a WebAPK update is needed. */ | 147 /** Checks whether a WebAPK update is needed. */ |
| 148 private boolean checkUpdateNeeded(final CreationData creationData) throws Ex
ception { | 148 private boolean checkUpdateNeeded(final CreationData creationData) throws Ex
ception { |
| 149 CallbackHelper waiter = new CallbackHelper(); | 149 CallbackHelper waiter = new CallbackHelper(); |
| 150 final TestWebApkUpdateManager updateManager = new TestWebApkUpdateManage
r(waiter); | 150 WebappDataStorage storage = WebappRegistry.getInstance().getWebappDataSt
orage(WEBAPK_ID); |
| 151 final TestWebApkUpdateManager updateManager = new TestWebApkUpdateManage
r(waiter, storage); |
| 151 | 152 |
| 152 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 153 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 153 @Override | 154 @Override |
| 154 public void run() { | 155 public void run() { |
| 155 WebApkInfo info = WebApkInfo.create(WEBAPK_ID, "", creationData.
scope, null, | 156 WebApkInfo info = WebApkInfo.create(WEBAPK_ID, "", creationData.
scope, null, |
| 156 creationData.name, creationData.shortName, creationData.
displayMode, | 157 creationData.name, creationData.shortName, creationData.
displayMode, |
| 157 creationData.orientation, 0, creationData.themeColor, | 158 creationData.orientation, 0, creationData.themeColor, |
| 158 creationData.backgroundColor, "", WebApkVersion.CURRENT_
SHELL_APK_VERSION, | 159 creationData.backgroundColor, "", WebApkVersion.CURRENT_
SHELL_APK_VERSION, |
| 159 creationData.manifestUrl, creationData.startUrl, | 160 creationData.manifestUrl, creationData.startUrl, |
| 160 creationData.iconUrlToMurmur2HashMap); | 161 creationData.iconUrlToMurmur2HashMap); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // URL canonicalization should replace "%62" with 'b'. | 195 // URL canonicalization should replace "%62" with 'b'. |
| 195 CreationData creationData = defaultCreationData(mTestServer); | 196 CreationData creationData = defaultCreationData(mTestServer); |
| 196 creationData.startUrl = mTestServer.getURL( | 197 creationData.startUrl = mTestServer.getURL( |
| 197 "/chrome/test/data/banners/manifest_%62est_page.html"); | 198 "/chrome/test/data/banners/manifest_%62est_page.html"); |
| 198 | 199 |
| 199 WebappTestPage.navigateToPageWithServiceWorkerAndManifest( | 200 WebappTestPage.navigateToPageWithServiceWorkerAndManifest( |
| 200 mTestServer, mTab, WEBAPK_MANIFEST_URL); | 201 mTestServer, mTab, WEBAPK_MANIFEST_URL); |
| 201 assertTrue(checkUpdateNeeded(creationData)); | 202 assertTrue(checkUpdateNeeded(creationData)); |
| 202 } | 203 } |
| 203 } | 204 } |
| OLD | NEW |