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.webapps; | 5 package org.chromium.chrome.browser.webapps; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.graphics.Bitmap; | 10 import android.graphics.Bitmap; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 public String getFullscreenAction() { | 89 public String getFullscreenAction() { |
90 return WEBAPP_ACTION_NAME; | 90 return WEBAPP_ACTION_NAME; |
91 } | 91 } |
92 | 92 |
93 public void clearBroadcastedIntent() { | 93 public void clearBroadcastedIntent() { |
94 mBroadcastedIntent = null; | 94 mBroadcastedIntent = null; |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 private static class TestDataStorageFactory extends WebappDataStorage.Factor
y { | 98 private static class TestDataStorageFactory extends WebappDataStorage.Factor
y { |
99 public Bitmap mSplashImage; | 99 public String mSplashImage; |
100 | 100 |
101 @Override | 101 @Override |
102 public WebappDataStorage create(final String webappId) { | 102 public WebappDataStorage create(final String webappId) { |
103 return new WebappDataStorageWrapper(webappId); | 103 return new WebappDataStorageWrapper(webappId); |
104 } | 104 } |
105 | 105 |
106 private class WebappDataStorageWrapper extends WebappDataStorage { | 106 private class WebappDataStorageWrapper extends WebappDataStorage { |
107 | 107 |
108 public WebappDataStorageWrapper(String webappId) { | 108 public WebappDataStorageWrapper(String webappId) { |
109 super(webappId); | 109 super(webappId); |
110 } | 110 } |
111 | 111 |
112 @Override | 112 @Override |
113 public void updateSplashScreenImage(Bitmap splashScreenImage) { | 113 public void updateSplashScreenImage(String splashScreenImage) { |
114 assertNull(mSplashImage); | 114 assertNull(mSplashImage); |
115 mSplashImage = splashScreenImage; | 115 mSplashImage = splashScreenImage; |
116 } | 116 } |
117 } | 117 } |
118 } | 118 } |
119 /** | 119 /** |
120 * Test AddToHomescreenManager subclass which mocks showing the add-to-homes
creen dialog and | 120 * Test AddToHomescreenManager subclass which mocks showing the add-to-homes
creen dialog and |
121 * adds the shortcut to the home screen once it is ready. | 121 * adds the shortcut to the home screen once it is ready. |
122 */ | 122 */ |
123 private static class TestAddToHomescreenManager extends AddToHomescreenManag
er { | 123 private static class TestAddToHomescreenManager extends AddToHomescreenManag
er { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 CriteriaHelper.pollUiThread(new Criteria() { | 273 CriteriaHelper.pollUiThread(new Criteria() { |
274 @Override | 274 @Override |
275 public boolean isSatisfied() { | 275 public boolean isSatisfied() { |
276 return dataStorageFactory.mSplashImage != null; | 276 return dataStorageFactory.mSplashImage != null; |
277 } | 277 } |
278 }); | 278 }); |
279 | 279 |
280 // Test that bitmap sizes match expectations. | 280 // Test that bitmap sizes match expectations. |
281 int idealSize = mActivity.getResources().getDimensionPixelSize( | 281 int idealSize = mActivity.getResources().getDimensionPixelSize( |
282 R.dimen.webapp_splash_image_size_ideal); | 282 R.dimen.webapp_splash_image_size_ideal); |
283 assertEquals(idealSize, dataStorageFactory.mSplashImage.getWidth()); | 283 Bitmap splashImage = |
284 assertEquals(idealSize, dataStorageFactory.mSplashImage.getHeight())
; | 284 ShortcutHelper.decodeBitmapFromString(dataStorageFactory.mSp
lashImage); |
| 285 assertEquals(idealSize, splashImage.getWidth()); |
| 286 assertEquals(idealSize, splashImage.getHeight()); |
285 } finally { | 287 } finally { |
286 mTestServer.stopAndDestroyServer(); | 288 mTestServer.stopAndDestroyServer(); |
287 } | 289 } |
288 } | 290 } |
289 | 291 |
290 private void loadUrl(String url, String expectedPageTitle) throws Exception
{ | 292 private void loadUrl(String url, String expectedPageTitle) throws Exception
{ |
291 new TabLoadObserver(mTab, expectedPageTitle, null).fullyLoadUrl(url); | 293 new TabLoadObserver(mTab, expectedPageTitle, null).fullyLoadUrl(url); |
292 } | 294 } |
293 | 295 |
294 private void addShortcutToTab(Tab tab, String title) throws Exception { | 296 private void addShortcutToTab(Tab tab, String title) throws Exception { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 public Integer call() { | 347 public Integer call() { |
346 return getActivity().getTabModelSelector().getModel(false).getCo
unt(); | 348 return getActivity().getTabModelSelector().getModel(false).getCo
unt(); |
347 } | 349 } |
348 })); | 350 })); |
349 | 351 |
350 TabModel tabModel = getActivity().getTabModelSelector().getModel(false); | 352 TabModel tabModel = getActivity().getTabModelSelector().getModel(false); |
351 assertEquals(0, tabModel.indexOf(mTab)); | 353 assertEquals(0, tabModel.indexOf(mTab)); |
352 return getActivity().getTabModelSelector().getModel(false).getTabAt(1); | 354 return getActivity().getTabModelSelector().getModel(false).getTabAt(1); |
353 } | 355 } |
354 } | 356 } |
OLD | NEW |