| 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.content.Intent; | 7 import android.content.Intent; |
| 8 import android.support.test.filters.SmallTest; | 8 import android.support.test.filters.SmallTest; |
| 9 import android.test.InstrumentationTestCase; | 9 |
| 10 import org.junit.Assert; |
| 11 import org.junit.Test; |
| 12 import org.junit.runner.RunWith; |
| 10 | 13 |
| 11 import org.chromium.base.test.util.Feature; | 14 import org.chromium.base.test.util.Feature; |
| 12 import org.chromium.blink_public.platform.WebDisplayMode; | 15 import org.chromium.blink_public.platform.WebDisplayMode; |
| 13 import org.chromium.chrome.browser.ShortcutHelper; | 16 import org.chromium.chrome.browser.ShortcutHelper; |
| 14 import org.chromium.chrome.browser.ShortcutSource; | 17 import org.chromium.chrome.browser.ShortcutSource; |
| 18 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| 15 import org.chromium.content_public.common.ScreenOrientationValues; | 19 import org.chromium.content_public.common.ScreenOrientationValues; |
| 16 | 20 |
| 17 /** | 21 /** |
| 18 * Tests the WebappInfo class's ability to parse various URLs. | 22 * Tests the WebappInfo class's ability to parse various URLs. |
| 19 */ | 23 */ |
| 20 public class WebappInfoTest extends InstrumentationTestCase { | 24 @RunWith(ChromeJUnit4ClassRunner.class) |
| 25 public class WebappInfoTest { |
| 26 @Test |
| 21 @SmallTest | 27 @SmallTest |
| 22 @Feature({"Webapps"}) | 28 @Feature({"Webapps"}) |
| 23 public void testAbout() { | 29 public void testAbout() { |
| 24 String id = "webapp id"; | 30 String id = "webapp id"; |
| 25 String name = "longName"; | 31 String name = "longName"; |
| 26 String shortName = "name"; | 32 String shortName = "name"; |
| 27 String url = "about:blank"; | 33 String url = "about:blank"; |
| 28 | 34 |
| 29 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, | 35 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, |
| 30 WebDisplayMode.Standalone, ScreenOrientationValues.DEFAULT, Shor
tcutSource.UNKNOWN, | 36 WebDisplayMode.Standalone, ScreenOrientationValues.DEFAULT, Shor
tcutSource.UNKNOWN, |
| 31 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, | 37 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, |
| 32 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false); | 38 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false); |
| 33 assertNotNull(info); | 39 Assert.assertNotNull(info); |
| 34 } | 40 } |
| 35 | 41 |
| 42 @Test |
| 36 @SmallTest | 43 @SmallTest |
| 37 @Feature({"Webapps"}) | 44 @Feature({"Webapps"}) |
| 38 public void testRandomUrl() { | 45 public void testRandomUrl() { |
| 39 String id = "webapp id"; | 46 String id = "webapp id"; |
| 40 String name = "longName"; | 47 String name = "longName"; |
| 41 String shortName = "name"; | 48 String shortName = "name"; |
| 42 String url = "http://google.com"; | 49 String url = "http://google.com"; |
| 43 | 50 |
| 44 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, | 51 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, |
| 45 WebDisplayMode.Standalone, ScreenOrientationValues.DEFAULT, Shor
tcutSource.UNKNOWN, | 52 WebDisplayMode.Standalone, ScreenOrientationValues.DEFAULT, Shor
tcutSource.UNKNOWN, |
| 46 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, | 53 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, |
| 47 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false); | 54 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false); |
| 48 assertNotNull(info); | 55 Assert.assertNotNull(info); |
| 49 } | 56 } |
| 50 | 57 |
| 58 @Test |
| 51 @SmallTest | 59 @SmallTest |
| 52 @Feature({"Webapps"}) | 60 @Feature({"Webapps"}) |
| 53 public void testSpacesInUrl() { | 61 public void testSpacesInUrl() { |
| 54 String id = "webapp id"; | 62 String id = "webapp id"; |
| 55 String name = "longName"; | 63 String name = "longName"; |
| 56 String shortName = "name"; | 64 String shortName = "name"; |
| 57 String bustedUrl = "http://money.cnn.com/?category=Latest News"; | 65 String bustedUrl = "http://money.cnn.com/?category=Latest News"; |
| 58 | 66 |
| 59 Intent intent = new Intent(); | 67 Intent intent = new Intent(); |
| 60 intent.putExtra(ShortcutHelper.EXTRA_ID, id); | 68 intent.putExtra(ShortcutHelper.EXTRA_ID, id); |
| 61 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); | 69 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); |
| 62 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); | 70 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
| 63 intent.putExtra(ShortcutHelper.EXTRA_URL, bustedUrl); | 71 intent.putExtra(ShortcutHelper.EXTRA_URL, bustedUrl); |
| 64 | 72 |
| 65 WebappInfo info = WebappInfo.create(intent); | 73 WebappInfo info = WebappInfo.create(intent); |
| 66 assertNotNull(info); | 74 Assert.assertNotNull(info); |
| 67 } | 75 } |
| 68 | 76 |
| 77 @Test |
| 69 @SmallTest | 78 @SmallTest |
| 70 @Feature({"Webapps"}) | 79 @Feature({"Webapps"}) |
| 71 public void testIntentTitleFallBack() { | 80 public void testIntentTitleFallBack() { |
| 72 String title = "webapp title"; | 81 String title = "webapp title"; |
| 73 | 82 |
| 74 Intent intent = createIntentWithUrlAndId(); | 83 Intent intent = createIntentWithUrlAndId(); |
| 75 intent.putExtra(ShortcutHelper.EXTRA_TITLE, title); | 84 intent.putExtra(ShortcutHelper.EXTRA_TITLE, title); |
| 76 | 85 |
| 77 WebappInfo info = WebappInfo.create(intent); | 86 WebappInfo info = WebappInfo.create(intent); |
| 78 assertEquals(title, info.name()); | 87 Assert.assertEquals(title, info.name()); |
| 79 assertEquals(title, info.shortName()); | 88 Assert.assertEquals(title, info.shortName()); |
| 80 } | 89 } |
| 81 | 90 |
| 91 @Test |
| 82 @SmallTest | 92 @SmallTest |
| 83 @Feature({"Webapps"}) | 93 @Feature({"Webapps"}) |
| 84 public void testIntentNameBlankNoTitle() { | 94 public void testIntentNameBlankNoTitle() { |
| 85 String shortName = "name"; | 95 String shortName = "name"; |
| 86 | 96 |
| 87 Intent intent = createIntentWithUrlAndId(); | 97 Intent intent = createIntentWithUrlAndId(); |
| 88 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); | 98 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
| 89 | 99 |
| 90 WebappInfo info = WebappInfo.create(intent); | 100 WebappInfo info = WebappInfo.create(intent); |
| 91 assertEquals("", info.name()); | 101 Assert.assertEquals("", info.name()); |
| 92 assertEquals(shortName, info.shortName()); | 102 Assert.assertEquals(shortName, info.shortName()); |
| 93 } | 103 } |
| 94 | 104 |
| 105 @Test |
| 95 @SmallTest | 106 @SmallTest |
| 96 @Feature({"Webapps"}) | 107 @Feature({"Webapps"}) |
| 97 public void testIntentShortNameFallBack() { | 108 public void testIntentShortNameFallBack() { |
| 98 String title = "webapp title"; | 109 String title = "webapp title"; |
| 99 String shortName = "name"; | 110 String shortName = "name"; |
| 100 | 111 |
| 101 Intent intent = createIntentWithUrlAndId(); | 112 Intent intent = createIntentWithUrlAndId(); |
| 102 intent.putExtra(ShortcutHelper.EXTRA_TITLE, title); | 113 intent.putExtra(ShortcutHelper.EXTRA_TITLE, title); |
| 103 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); | 114 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
| 104 | 115 |
| 105 WebappInfo info = WebappInfo.create(intent); | 116 WebappInfo info = WebappInfo.create(intent); |
| 106 assertEquals(title, info.name()); | 117 Assert.assertEquals(title, info.name()); |
| 107 assertEquals(shortName, info.shortName()); | 118 Assert.assertEquals(shortName, info.shortName()); |
| 108 } | 119 } |
| 109 | 120 |
| 121 @Test |
| 110 @SmallTest | 122 @SmallTest |
| 111 @Feature({"Webapps"}) | 123 @Feature({"Webapps"}) |
| 112 public void testIntentNameShortname() { | 124 public void testIntentNameShortname() { |
| 113 String name = "longName"; | 125 String name = "longName"; |
| 114 String shortName = "name"; | 126 String shortName = "name"; |
| 115 | 127 |
| 116 Intent intent = createIntentWithUrlAndId(); | 128 Intent intent = createIntentWithUrlAndId(); |
| 117 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); | 129 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); |
| 118 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); | 130 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
| 119 | 131 |
| 120 WebappInfo info = WebappInfo.create(intent); | 132 WebappInfo info = WebappInfo.create(intent); |
| 121 assertEquals(name, info.name()); | 133 Assert.assertEquals(name, info.name()); |
| 122 assertEquals(shortName, info.shortName()); | 134 Assert.assertEquals(shortName, info.shortName()); |
| 123 } | 135 } |
| 124 | 136 |
| 137 @Test |
| 125 @SmallTest | 138 @SmallTest |
| 126 @Feature({"Webapps"}) | 139 @Feature({"Webapps"}) |
| 127 public void testDisplayModeAndOrientationAndSource() { | 140 public void testDisplayModeAndOrientationAndSource() { |
| 128 String id = "webapp id"; | 141 String id = "webapp id"; |
| 129 String name = "longName"; | 142 String name = "longName"; |
| 130 String shortName = "name"; | 143 String shortName = "name"; |
| 131 String url = "http://money.cnn.com"; | 144 String url = "http://money.cnn.com"; |
| 132 | 145 |
| 133 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, | 146 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, |
| 134 WebDisplayMode.Fullscreen, ScreenOrientationValues.DEFAULT, Shor
tcutSource.UNKNOWN, | 147 WebDisplayMode.Fullscreen, ScreenOrientationValues.DEFAULT, Shor
tcutSource.UNKNOWN, |
| 135 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, | 148 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, |
| 136 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false); | 149 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false); |
| 137 assertEquals(WebDisplayMode.Fullscreen, info.displayMode()); | 150 Assert.assertEquals(WebDisplayMode.Fullscreen, info.displayMode()); |
| 138 assertEquals(ScreenOrientationValues.DEFAULT, info.orientation()); | 151 Assert.assertEquals(ScreenOrientationValues.DEFAULT, info.orientation())
; |
| 139 assertEquals(ShortcutSource.UNKNOWN, info.source()); | 152 Assert.assertEquals(ShortcutSource.UNKNOWN, info.source()); |
| 140 } | 153 } |
| 141 | 154 |
| 155 @Test |
| 142 @SmallTest | 156 @SmallTest |
| 143 @Feature({"Webapps"}) | 157 @Feature({"Webapps"}) |
| 144 public void testNormalColors() { | 158 public void testNormalColors() { |
| 145 String id = "webapp id"; | 159 String id = "webapp id"; |
| 146 String name = "longName"; | 160 String name = "longName"; |
| 147 String shortName = "name"; | 161 String shortName = "name"; |
| 148 String url = "http://money.cnn.com"; | 162 String url = "http://money.cnn.com"; |
| 149 long themeColor = 0xFF00FF00L; | 163 long themeColor = 0xFF00FF00L; |
| 150 long backgroundColor = 0xFF0000FFL; | 164 long backgroundColor = 0xFF0000FFL; |
| 151 | 165 |
| 152 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, | 166 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, |
| 153 WebDisplayMode.Standalone, ScreenOrientationValues.DEFAULT, | 167 WebDisplayMode.Standalone, ScreenOrientationValues.DEFAULT, |
| 154 ShortcutSource.UNKNOWN, themeColor, backgroundColor, false); | 168 ShortcutSource.UNKNOWN, themeColor, backgroundColor, false); |
| 155 assertEquals(themeColor, info.themeColor()); | 169 Assert.assertEquals(themeColor, info.themeColor()); |
| 156 assertEquals(backgroundColor, info.backgroundColor()); | 170 Assert.assertEquals(backgroundColor, info.backgroundColor()); |
| 157 } | 171 } |
| 158 | 172 |
| 173 @Test |
| 159 @SmallTest | 174 @SmallTest |
| 160 @Feature({"Webapps"}) | 175 @Feature({"Webapps"}) |
| 161 public void testInvalidOrMissingColors() { | 176 public void testInvalidOrMissingColors() { |
| 162 String id = "webapp id"; | 177 String id = "webapp id"; |
| 163 String name = "longName"; | 178 String name = "longName"; |
| 164 String shortName = "name"; | 179 String shortName = "name"; |
| 165 String url = "http://money.cnn.com"; | 180 String url = "http://money.cnn.com"; |
| 166 | 181 |
| 167 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, | 182 WebappInfo info = WebappInfo.create(id, url, null, null, name, shortName
, |
| 168 WebDisplayMode.Standalone, ScreenOrientationValues.DEFAULT, Shor
tcutSource.UNKNOWN, | 183 WebDisplayMode.Standalone, ScreenOrientationValues.DEFAULT, Shor
tcutSource.UNKNOWN, |
| 169 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, | 184 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, |
| 170 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false); | 185 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, false); |
| 171 assertEquals(ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, info.them
eColor()); | 186 Assert.assertEquals(ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, in
fo.themeColor()); |
| 172 assertEquals(ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, info.back
groundColor()); | 187 Assert.assertEquals( |
| 188 ShortcutHelper.MANIFEST_COLOR_INVALID_OR_MISSING, info.backgroun
dColor()); |
| 173 } | 189 } |
| 174 | 190 |
| 191 @Test |
| 175 @SmallTest | 192 @SmallTest |
| 176 @Feature({"Webapps"}) | 193 @Feature({"Webapps"}) |
| 177 public void testColorsIntentCreation() { | 194 public void testColorsIntentCreation() { |
| 178 long themeColor = 0xFF00FF00L; | 195 long themeColor = 0xFF00FF00L; |
| 179 long backgroundColor = 0xFF0000FFL; | 196 long backgroundColor = 0xFF0000FFL; |
| 180 | 197 |
| 181 Intent intent = createIntentWithUrlAndId(); | 198 Intent intent = createIntentWithUrlAndId(); |
| 182 intent.putExtra(ShortcutHelper.EXTRA_THEME_COLOR, themeColor); | 199 intent.putExtra(ShortcutHelper.EXTRA_THEME_COLOR, themeColor); |
| 183 intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, backgroundColor); | 200 intent.putExtra(ShortcutHelper.EXTRA_BACKGROUND_COLOR, backgroundColor); |
| 184 | 201 |
| 185 WebappInfo info = WebappInfo.create(intent); | 202 WebappInfo info = WebappInfo.create(intent); |
| 186 assertEquals(themeColor, info.themeColor()); | 203 Assert.assertEquals(themeColor, info.themeColor()); |
| 187 assertEquals(backgroundColor, info.backgroundColor()); | 204 Assert.assertEquals(backgroundColor, info.backgroundColor()); |
| 188 } | 205 } |
| 189 | 206 |
| 207 @Test |
| 190 @SmallTest | 208 @SmallTest |
| 191 @Feature({"Webapps"}) | 209 @Feature({"Webapps"}) |
| 192 public void testScopeIntentCreation() { | 210 public void testScopeIntentCreation() { |
| 193 String scope = "https://www.foo.com"; | 211 String scope = "https://www.foo.com"; |
| 194 Intent intent = createIntentWithUrlAndId(); | 212 Intent intent = createIntentWithUrlAndId(); |
| 195 intent.putExtra(ShortcutHelper.EXTRA_SCOPE, scope); | 213 intent.putExtra(ShortcutHelper.EXTRA_SCOPE, scope); |
| 196 WebappInfo info = WebappInfo.create(intent); | 214 WebappInfo info = WebappInfo.create(intent); |
| 197 assertEquals(scope, info.scopeUri().toString()); | 215 Assert.assertEquals(scope, info.scopeUri().toString()); |
| 198 } | 216 } |
| 199 | 217 |
| 218 @Test |
| 200 @SmallTest | 219 @SmallTest |
| 201 @Feature({"Webapps"}) | 220 @Feature({"Webapps"}) |
| 202 public void testIntentScopeFallback() { | 221 public void testIntentScopeFallback() { |
| 203 String url = "https://www.foo.com/homepage.html"; | 222 String url = "https://www.foo.com/homepage.html"; |
| 204 Intent intent = createIntentWithUrlAndId(); | 223 Intent intent = createIntentWithUrlAndId(); |
| 205 intent.putExtra(ShortcutHelper.EXTRA_URL, url); | 224 intent.putExtra(ShortcutHelper.EXTRA_URL, url); |
| 206 WebappInfo info = WebappInfo.create(intent); | 225 WebappInfo info = WebappInfo.create(intent); |
| 207 assertEquals(ShortcutHelper.getScopeFromUrl(url), info.scopeUri().toStri
ng()); | 226 Assert.assertEquals(ShortcutHelper.getScopeFromUrl(url), info.scopeUri()
.toString()); |
| 208 } | 227 } |
| 209 | 228 |
| 229 @Test |
| 210 @SmallTest | 230 @SmallTest |
| 211 @Feature({"Webapps"}) | 231 @Feature({"Webapps"}) |
| 212 public void testIntentDisplayMode() { | 232 public void testIntentDisplayMode() { |
| 213 Intent intent = createIntentWithUrlAndId(); | 233 Intent intent = createIntentWithUrlAndId(); |
| 214 intent.putExtra(ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Minima
lUi); | 234 intent.putExtra(ShortcutHelper.EXTRA_DISPLAY_MODE, WebDisplayMode.Minima
lUi); |
| 215 WebappInfo info = WebappInfo.create(intent); | 235 WebappInfo info = WebappInfo.create(intent); |
| 216 assertEquals(WebDisplayMode.MinimalUi, info.displayMode()); | 236 Assert.assertEquals(WebDisplayMode.MinimalUi, info.displayMode()); |
| 217 } | 237 } |
| 218 | 238 |
| 239 @Test |
| 219 @SmallTest | 240 @SmallTest |
| 220 @Feature({"Webapps"}) | 241 @Feature({"Webapps"}) |
| 221 public void testIntentOrientation() { | 242 public void testIntentOrientation() { |
| 222 Intent intent = createIntentWithUrlAndId(); | 243 Intent intent = createIntentWithUrlAndId(); |
| 223 intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValue
s.LANDSCAPE); | 244 intent.putExtra(ShortcutHelper.EXTRA_ORIENTATION, ScreenOrientationValue
s.LANDSCAPE); |
| 224 WebappInfo info = WebappInfo.create(intent); | 245 WebappInfo info = WebappInfo.create(intent); |
| 225 assertEquals(ScreenOrientationValues.LANDSCAPE, info.orientation()); | 246 Assert.assertEquals(ScreenOrientationValues.LANDSCAPE, info.orientation(
)); |
| 226 } | 247 } |
| 227 | 248 |
| 249 @Test |
| 228 @SmallTest | 250 @SmallTest |
| 229 @Feature({"Webapps"}) | 251 @Feature({"Webapps"}) |
| 230 public void testIntentGeneratedIcon() { | 252 public void testIntentGeneratedIcon() { |
| 231 String id = "webapp id"; | 253 String id = "webapp id"; |
| 232 String name = "longName"; | 254 String name = "longName"; |
| 233 String shortName = "name"; | 255 String shortName = "name"; |
| 234 String url = "about:blank"; | 256 String url = "about:blank"; |
| 235 | 257 |
| 236 // Default value. | 258 // Default value. |
| 237 { | 259 { |
| 238 Intent intent = new Intent(); | 260 Intent intent = new Intent(); |
| 239 intent.putExtra(ShortcutHelper.EXTRA_ID, id); | 261 intent.putExtra(ShortcutHelper.EXTRA_ID, id); |
| 240 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); | 262 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); |
| 241 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); | 263 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
| 242 intent.putExtra(ShortcutHelper.EXTRA_URL, url); | 264 intent.putExtra(ShortcutHelper.EXTRA_URL, url); |
| 243 | 265 |
| 244 assertFalse(name, WebappInfo.create(intent).isIconGenerated()); | 266 Assert.assertFalse(name, WebappInfo.create(intent).isIconGenerated()
); |
| 245 } | 267 } |
| 246 | 268 |
| 247 // Set to true. | 269 // Set to true. |
| 248 { | 270 { |
| 249 Intent intent = new Intent(); | 271 Intent intent = new Intent(); |
| 250 intent.putExtra(ShortcutHelper.EXTRA_ID, id); | 272 intent.putExtra(ShortcutHelper.EXTRA_ID, id); |
| 251 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); | 273 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); |
| 252 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); | 274 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
| 253 intent.putExtra(ShortcutHelper.EXTRA_URL, url); | 275 intent.putExtra(ShortcutHelper.EXTRA_URL, url); |
| 254 intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, true); | 276 intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, true); |
| 255 | 277 |
| 256 assertTrue(name, WebappInfo.create(intent).isIconGenerated()); | 278 Assert.assertTrue(name, WebappInfo.create(intent).isIconGenerated())
; |
| 257 } | 279 } |
| 258 | 280 |
| 259 // Set to false. | 281 // Set to false. |
| 260 { | 282 { |
| 261 Intent intent = new Intent(); | 283 Intent intent = new Intent(); |
| 262 intent.putExtra(ShortcutHelper.EXTRA_ID, id); | 284 intent.putExtra(ShortcutHelper.EXTRA_ID, id); |
| 263 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); | 285 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); |
| 264 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); | 286 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
| 265 intent.putExtra(ShortcutHelper.EXTRA_URL, url); | 287 intent.putExtra(ShortcutHelper.EXTRA_URL, url); |
| 266 intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, false); | 288 intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, false); |
| 267 | 289 |
| 268 assertFalse(name, WebappInfo.create(intent).isIconGenerated()); | 290 Assert.assertFalse(name, WebappInfo.create(intent).isIconGenerated()
); |
| 269 } | 291 } |
| 270 | 292 |
| 271 // Set to something else than a boolean. | 293 // Set to something else than a boolean. |
| 272 { | 294 { |
| 273 Intent intent = new Intent(); | 295 Intent intent = new Intent(); |
| 274 intent.putExtra(ShortcutHelper.EXTRA_ID, id); | 296 intent.putExtra(ShortcutHelper.EXTRA_ID, id); |
| 275 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); | 297 intent.putExtra(ShortcutHelper.EXTRA_NAME, name); |
| 276 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); | 298 intent.putExtra(ShortcutHelper.EXTRA_SHORT_NAME, shortName); |
| 277 intent.putExtra(ShortcutHelper.EXTRA_URL, url); | 299 intent.putExtra(ShortcutHelper.EXTRA_URL, url); |
| 278 intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, "true"); | 300 intent.putExtra(ShortcutHelper.EXTRA_IS_ICON_GENERATED, "true"); |
| 279 | 301 |
| 280 assertFalse(name, WebappInfo.create(intent).isIconGenerated()); | 302 Assert.assertFalse(name, WebappInfo.create(intent).isIconGenerated()
); |
| 281 } | 303 } |
| 282 } | 304 } |
| 283 | 305 |
| 284 /** | 306 /** |
| 285 * Creates intent with url and id. If the url or id are not set WebappInfo#c
reate() returns | 307 * Creates intent with url and id. If the url or id are not set WebappInfo#c
reate() returns |
| 286 * null. | 308 * null. |
| 287 */ | 309 */ |
| 288 private Intent createIntentWithUrlAndId() { | 310 private Intent createIntentWithUrlAndId() { |
| 289 Intent intent = new Intent(); | 311 Intent intent = new Intent(); |
| 290 intent.putExtra(ShortcutHelper.EXTRA_ID, "web app id"); | 312 intent.putExtra(ShortcutHelper.EXTRA_ID, "web app id"); |
| 291 intent.putExtra(ShortcutHelper.EXTRA_URL, "about:blank"); | 313 intent.putExtra(ShortcutHelper.EXTRA_URL, "about:blank"); |
| 292 return intent; | 314 return intent; |
| 293 } | 315 } |
| 294 } | 316 } |
| OLD | NEW |