Chromium Code Reviews| 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 static org.junit.Assert.assertEquals; | 7 import static org.junit.Assert.assertEquals; |
| 8 import static org.junit.Assert.assertTrue; | 8 import static org.junit.Assert.assertTrue; |
| 9 | 9 |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 mCallbackCalled = false; | 43 mCallbackCalled = false; |
| 44 } | 44 } |
| 45 | 45 |
| 46 @Test | 46 @Test |
| 47 @Feature({"Webapp"}) | 47 @Feature({"Webapp"}) |
| 48 public void testBackwardCompat() { | 48 public void testBackwardCompat() { |
| 49 assertEquals("webapp_", WebappDataStorage.SHARED_PREFS_FILE_PREFIX); | 49 assertEquals("webapp_", WebappDataStorage.SHARED_PREFS_FILE_PREFIX); |
| 50 assertEquals("splash_icon", WebappDataStorage.KEY_SPLASH_ICON); | 50 assertEquals("splash_icon", WebappDataStorage.KEY_SPLASH_ICON); |
| 51 assertEquals("last_used", WebappDataStorage.KEY_LAST_USED); | 51 assertEquals("last_used", WebappDataStorage.KEY_LAST_USED); |
| 52 assertEquals("origin_url", WebappDataStorage.KEY_ORIGIN_URL); | |
| 52 } | 53 } |
| 53 | 54 |
| 54 @Test | 55 @Test |
| 55 @Feature({"Webapp"}) | 56 @Feature({"Webapp"}) |
| 56 public void testLastUsedRetrieval() throws Exception { | 57 public void testLastUsedRetrieval() throws Exception { |
| 57 mSharedPreferences.edit() | 58 mSharedPreferences.edit() |
| 58 .putLong(WebappDataStorage.KEY_LAST_USED, 100L) | 59 .putLong(WebappDataStorage.KEY_LAST_USED, 100L) |
| 59 .commit(); | 60 .commit(); |
| 60 | 61 |
| 61 WebappDataStorage.getLastUsedTime(Robolectric.application, "test", | 62 WebappDataStorage.getLastUsedTime(Robolectric.application, "test", |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 for (int j = 0; j < actual.getHeight(); j++) { | 137 for (int j = 0; j < actual.getHeight(); j++) { |
| 137 if (actual.getPixel(i, j) != 0) return false; | 138 if (actual.getPixel(i, j) != 0) return false; |
| 138 } | 139 } |
| 139 } | 140 } |
| 140 return true; | 141 return true; |
| 141 } | 142 } |
| 142 | 143 |
| 143 private static Bitmap createBitmap() { | 144 private static Bitmap createBitmap() { |
| 144 return Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444); | 145 return Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444); |
| 145 } | 146 } |
| 146 } | 147 |
| 148 @Test | |
| 149 @Feature({"Webapp"}) | |
| 150 public void testOriginUrlRetrieval() throws Exception { | |
| 151 final String origin = "http://drive.google.com"; | |
| 152 mSharedPreferences.edit() | |
| 153 .putString(WebappDataStorage.KEY_ORIGIN_URL, origin) | |
| 154 .commit(); | |
| 155 | |
| 156 WebappDataStorage.getOriginUrl(Robolectric.application, "test", | |
|
gone
2016/03/08 23:03:52
Maybe it'd make sense to create and declare the Fe
dominickn
2016/03/09 08:18:32
Done.
| |
| 157 new WebappDataStorage.FetchCallback<String>() { | |
| 158 @Override | |
| 159 public void onDataRetrieved(String readObject) { | |
| 160 mCallbackCalled = true; | |
| 161 assertEquals(origin, readObject); | |
| 162 } | |
| 163 }); | |
| 164 BackgroundShadowAsyncTask.runBackgroundTasks(); | |
| 165 Robolectric.runUiThreadTasks(); | |
| 166 | |
| 167 assertTrue(mCallbackCalled); | |
| 168 } | |
| 169 | |
| 170 @Test | |
| 171 @Feature({"Webapp"}) | |
| 172 public void testOriginUrlUpdate() throws Exception { | |
| 173 final String origin = "http://maps.google.com"; | |
| 174 | |
| 175 WebappDataStorage.updateOriginUrl(Robolectric.application, "test", origi n); | |
| 176 BackgroundShadowAsyncTask.runBackgroundTasks(); | |
| 177 Robolectric.runUiThreadTasks(); | |
| 178 | |
| 179 assertEquals(origin, mSharedPreferences.getString(WebappDataStorage.KEY_ ORIGIN_URL, null)); | |
| 180 } | |
| 181 } | |
| OLD | NEW |