Chromium Code Reviews| 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 #include "chrome/browser/installable/installable_manager.h" | 5 #include "chrome/browser/installable/installable_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 | 226 |
| 227 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), | 227 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), |
| 228 "/banners/no_manifest_test_page.html"); | 228 "/banners/no_manifest_test_page.html"); |
| 229 run_loop.Run(); | 229 run_loop.Run(); |
| 230 | 230 |
| 231 // If there is no manifest, everything should be empty. | 231 // If there is no manifest, everything should be empty. |
| 232 EXPECT_TRUE(tester->manifest().IsEmpty()); | 232 EXPECT_TRUE(tester->manifest().IsEmpty()); |
| 233 EXPECT_TRUE(tester->manifest_url().is_empty()); | 233 EXPECT_TRUE(tester->manifest_url().is_empty()); |
| 234 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 234 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 235 EXPECT_EQ(nullptr, tester->primary_icon()); | 235 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 236 EXPECT_FALSE(tester->is_installable()); | |
| 236 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 237 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 237 EXPECT_EQ(nullptr, tester->badge_icon()); | 238 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 238 EXPECT_FALSE(tester->is_installable()); | |
| 239 EXPECT_EQ(NO_MANIFEST, tester->error_code()); | 239 EXPECT_EQ(NO_MANIFEST, tester->error_code()); |
| 240 } | 240 } |
| 241 | 241 |
| 242 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifest404) { | 242 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifest404) { |
| 243 base::RunLoop run_loop; | 243 base::RunLoop run_loop; |
| 244 std::unique_ptr<CallbackTester> tester( | 244 std::unique_ptr<CallbackTester> tester( |
| 245 new CallbackTester(run_loop.QuitClosure())); | 245 new CallbackTester(run_loop.QuitClosure())); |
| 246 | 246 |
| 247 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), | 247 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), |
| 248 GetURLOfPageWithServiceWorkerAndManifest( | 248 GetURLOfPageWithServiceWorkerAndManifest( |
| 249 "/banners/manifest_missing.json")); | 249 "/banners/manifest_missing.json")); |
| 250 run_loop.Run(); | 250 run_loop.Run(); |
| 251 | 251 |
| 252 // The installable manager should return a manifest URL even if it 404s. | 252 // The installable manager should return a manifest URL even if it 404s. |
| 253 // However, the check should fail with a ManifestEmpty error. | 253 // However, the check should fail with a ManifestEmpty error. |
| 254 EXPECT_TRUE(tester->manifest().IsEmpty()); | 254 EXPECT_TRUE(tester->manifest().IsEmpty()); |
| 255 | 255 |
| 256 EXPECT_FALSE(tester->manifest_url().is_empty()); | 256 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 257 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 257 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 258 EXPECT_EQ(nullptr, tester->primary_icon()); | 258 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 259 EXPECT_FALSE(tester->is_installable()); | |
| 259 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 260 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 260 EXPECT_EQ(nullptr, tester->badge_icon()); | 261 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 261 EXPECT_FALSE(tester->is_installable()); | |
| 262 EXPECT_EQ(MANIFEST_EMPTY, tester->error_code()); | 262 EXPECT_EQ(MANIFEST_EMPTY, tester->error_code()); |
| 263 } | 263 } |
| 264 | 264 |
| 265 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestOnly) { | 265 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestOnly) { |
| 266 // Verify that asking for just the manifest works as expected. | 266 // Verify that asking for just the manifest works as expected. |
| 267 base::RunLoop run_loop; | 267 base::RunLoop run_loop; |
| 268 std::unique_ptr<CallbackTester> tester( | 268 std::unique_ptr<CallbackTester> tester( |
| 269 new CallbackTester(run_loop.QuitClosure())); | 269 new CallbackTester(run_loop.QuitClosure())); |
| 270 | 270 |
| 271 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), | 271 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), |
| 272 "/banners/manifest_test_page.html"); | 272 "/banners/manifest_test_page.html"); |
| 273 run_loop.Run(); | 273 run_loop.Run(); |
| 274 | 274 |
| 275 EXPECT_FALSE(tester->manifest().IsEmpty()); | 275 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 276 EXPECT_FALSE(tester->manifest_url().is_empty()); | 276 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 277 | 277 |
| 278 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 278 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 279 EXPECT_EQ(nullptr, tester->primary_icon()); | 279 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 280 EXPECT_FALSE(tester->is_installable()); | |
| 280 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 281 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 281 EXPECT_EQ(nullptr, tester->badge_icon()); | 282 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 282 EXPECT_FALSE(tester->is_installable()); | |
| 283 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 283 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 284 } | 284 } |
| 285 | 285 |
| 286 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, | 286 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, |
| 287 CheckInstallableParamsDefaultConstructor) { | 287 CheckInstallableParamsDefaultConstructor) { |
| 288 // Verify that using InstallableParams' default constructor is equivalent to | 288 // Verify that using InstallableParams' default constructor is equivalent to |
| 289 // just asking for the manifest alone. | 289 // just asking for the manifest alone. |
| 290 base::RunLoop run_loop; | 290 base::RunLoop run_loop; |
| 291 std::unique_ptr<CallbackTester> tester( | 291 std::unique_ptr<CallbackTester> tester( |
| 292 new CallbackTester(run_loop.QuitClosure())); | 292 new CallbackTester(run_loop.QuitClosure())); |
| 293 | 293 |
| 294 InstallableParams params; | 294 InstallableParams params; |
| 295 NavigateAndRunInstallableManager(tester.get(), params, | 295 NavigateAndRunInstallableManager(tester.get(), params, |
| 296 "/banners/manifest_test_page.html"); | 296 "/banners/manifest_test_page.html"); |
| 297 run_loop.Run(); | 297 run_loop.Run(); |
| 298 | 298 |
| 299 EXPECT_FALSE(tester->manifest().IsEmpty()); | 299 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 300 EXPECT_FALSE(tester->manifest_url().is_empty()); | 300 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 301 | 301 |
| 302 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 302 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 303 EXPECT_EQ(nullptr, tester->primary_icon()); | 303 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 304 EXPECT_FALSE(tester->is_installable()); | |
| 304 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 305 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 305 EXPECT_EQ(nullptr, tester->badge_icon()); | 306 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 306 EXPECT_FALSE(tester->is_installable()); | |
| 307 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 307 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, | 310 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, |
| 311 CheckManifestWithOnlyRelatedApplications) { | 311 CheckManifestWithOnlyRelatedApplications) { |
| 312 // This page has a manifest with only related applications specified. Asking | 312 // This page has a manifest with only related applications specified. Asking |
| 313 // for just the manifest should succeed. | 313 // for just the manifest should succeed. |
| 314 { | 314 { |
| 315 base::RunLoop run_loop; | 315 base::RunLoop run_loop; |
| 316 std::unique_ptr<CallbackTester> tester( | 316 std::unique_ptr<CallbackTester> tester( |
| 317 new CallbackTester(run_loop.QuitClosure())); | 317 new CallbackTester(run_loop.QuitClosure())); |
| 318 | 318 |
| 319 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), | 319 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), |
| 320 "/banners/play_app_test_page.html"); | 320 "/banners/play_app_test_page.html"); |
| 321 run_loop.Run(); | 321 run_loop.Run(); |
| 322 | 322 |
| 323 EXPECT_FALSE(tester->manifest().IsEmpty()); | 323 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 324 EXPECT_FALSE(tester->manifest_url().is_empty()); | 324 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 325 EXPECT_TRUE(tester->manifest().prefer_related_applications); | 325 EXPECT_TRUE(tester->manifest().prefer_related_applications); |
| 326 | 326 |
| 327 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 327 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 328 EXPECT_EQ(nullptr, tester->primary_icon()); | 328 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 329 EXPECT_FALSE(tester->is_installable()); | |
| 329 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 330 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 330 EXPECT_EQ(nullptr, tester->badge_icon()); | 331 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 331 EXPECT_FALSE(tester->is_installable()); | |
| 332 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 332 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 333 } | 333 } |
| 334 | 334 |
| 335 // Ask for a primary icon (but don't navigate). This should fail with | 335 // Ask for a primary icon (but don't navigate). This should fail with |
| 336 // NO_ACCEPTABLE_ICON. | 336 // NO_ACCEPTABLE_ICON. |
| 337 { | 337 { |
| 338 base::RunLoop run_loop; | 338 base::RunLoop run_loop; |
| 339 std::unique_ptr<CallbackTester> tester( | 339 std::unique_ptr<CallbackTester> tester( |
| 340 new CallbackTester(run_loop.QuitClosure())); | 340 new CallbackTester(run_loop.QuitClosure())); |
| 341 | 341 |
| 342 RunInstallableManager(tester.get(), GetPrimaryIconParams()); | 342 RunInstallableManager(tester.get(), GetPrimaryIconParams()); |
| 343 run_loop.Run(); | 343 run_loop.Run(); |
| 344 | 344 |
| 345 EXPECT_FALSE(tester->manifest().IsEmpty()); | 345 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 346 EXPECT_FALSE(tester->manifest_url().is_empty()); | 346 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 347 EXPECT_TRUE(tester->manifest().prefer_related_applications); | 347 EXPECT_TRUE(tester->manifest().prefer_related_applications); |
| 348 | 348 |
| 349 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 349 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 350 EXPECT_EQ(nullptr, tester->primary_icon()); | 350 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 351 EXPECT_FALSE(tester->is_installable()); | |
| 351 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 352 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 352 EXPECT_EQ(nullptr, tester->badge_icon()); | 353 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 353 EXPECT_FALSE(tester->is_installable()); | |
| 354 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); | 354 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 // Ask for everything except badge icon. This should fail with | 357 // Ask for everything except badge icon. This should fail with |
| 358 // NO_ACCEPTABLE_ICON - the primary icon fetch has already failed, so that | 358 // NO_ACCEPTABLE_ICON - the primary icon fetch has already failed, so that |
| 359 // cached error stops the installable check from being performed. | 359 // cached error stops the installable check from being performed. |
| 360 { | 360 { |
| 361 base::RunLoop run_loop; | 361 base::RunLoop run_loop; |
| 362 std::unique_ptr<CallbackTester> tester( | 362 std::unique_ptr<CallbackTester> tester( |
| 363 new CallbackTester(run_loop.QuitClosure())); | 363 new CallbackTester(run_loop.QuitClosure())); |
| 364 | 364 |
| 365 RunInstallableManager(tester.get(), GetWebAppParams()); | 365 RunInstallableManager(tester.get(), GetWebAppParams()); |
| 366 run_loop.Run(); | 366 run_loop.Run(); |
| 367 | 367 |
| 368 EXPECT_FALSE(tester->manifest().IsEmpty()); | 368 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 369 EXPECT_FALSE(tester->manifest_url().is_empty()); | 369 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 370 EXPECT_TRUE(tester->manifest().prefer_related_applications); | 370 EXPECT_TRUE(tester->manifest().prefer_related_applications); |
| 371 | 371 |
| 372 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 372 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 373 EXPECT_EQ(nullptr, tester->primary_icon()); | 373 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 374 EXPECT_FALSE(tester->is_installable()); | |
| 374 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 375 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 375 EXPECT_EQ(nullptr, tester->badge_icon()); | 376 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 376 EXPECT_FALSE(tester->is_installable()); | |
| 377 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); | 377 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); |
| 378 } | 378 } |
| 379 | |
| 380 // Ask for a different size primary icon. This should fail with | |
| 381 // START_URL_NOT_VALID since we won't have a cached icon error. | |
|
dominickn
2017/04/07 04:42:54
Not sure why you removed this test?
F
2017/04/07 15:43:38
I removed this because now that primary icon is fe
| |
| 382 { | |
| 383 base::RunLoop run_loop; | |
| 384 std::unique_ptr<CallbackTester> tester( | |
| 385 new CallbackTester(run_loop.QuitClosure())); | |
| 386 | |
| 387 InstallableParams params = GetWebAppParams(); | |
| 388 params.ideal_primary_icon_size_in_px = 96; | |
| 389 params.minimum_primary_icon_size_in_px = 96; | |
| 390 RunInstallableManager(tester.get(), params); | |
| 391 run_loop.Run(); | |
| 392 | |
| 393 EXPECT_FALSE(tester->manifest().IsEmpty()); | |
| 394 EXPECT_FALSE(tester->manifest_url().is_empty()); | |
| 395 EXPECT_TRUE(tester->manifest().prefer_related_applications); | |
| 396 | |
| 397 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | |
| 398 EXPECT_EQ(nullptr, tester->primary_icon()); | |
| 399 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | |
| 400 EXPECT_EQ(nullptr, tester->badge_icon()); | |
| 401 EXPECT_FALSE(tester->is_installable()); | |
| 402 EXPECT_EQ(START_URL_NOT_VALID, tester->error_code()); | |
| 403 } | |
| 404 } | 379 } |
| 405 | 380 |
| 406 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestAndIcon) { | 381 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestAndIcon) { |
| 407 // Add to homescreen checks for manifest + primary icon. | 382 // Add to homescreen checks for manifest + primary icon. |
| 408 { | 383 { |
| 409 base::RunLoop run_loop; | 384 base::RunLoop run_loop; |
| 410 std::unique_ptr<CallbackTester> tester( | 385 std::unique_ptr<CallbackTester> tester( |
| 411 new CallbackTester(run_loop.QuitClosure())); | 386 new CallbackTester(run_loop.QuitClosure())); |
| 412 | 387 |
| 413 NavigateAndRunInstallableManager(tester.get(), GetPrimaryIconParams(), | 388 NavigateAndRunInstallableManager(tester.get(), GetPrimaryIconParams(), |
| 414 "/banners/manifest_test_page.html"); | 389 "/banners/manifest_test_page.html"); |
| 415 run_loop.Run(); | 390 run_loop.Run(); |
| 416 | 391 |
| 417 EXPECT_FALSE(tester->manifest().IsEmpty()); | 392 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 418 EXPECT_FALSE(tester->manifest_url().is_empty()); | 393 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 419 | 394 |
| 420 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 395 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 421 EXPECT_NE(nullptr, tester->primary_icon()); | 396 EXPECT_NE(nullptr, tester->primary_icon()); |
| 397 EXPECT_FALSE(tester->is_installable()); | |
| 422 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 398 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 423 EXPECT_EQ(nullptr, tester->badge_icon()); | 399 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 424 EXPECT_FALSE(tester->is_installable()); | |
| 425 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 400 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 426 } | 401 } |
| 427 | 402 |
| 428 // Add to homescreen checks for manifest + primary icon + badge icon. | 403 // Add to homescreen checks for manifest + primary icon + badge icon. |
| 429 { | 404 { |
| 430 base::RunLoop run_loop; | 405 base::RunLoop run_loop; |
| 431 std::unique_ptr<CallbackTester> tester( | 406 std::unique_ptr<CallbackTester> tester( |
| 432 new CallbackTester(run_loop.QuitClosure())); | 407 new CallbackTester(run_loop.QuitClosure())); |
| 433 | 408 |
| 434 RunInstallableManager(tester.get(), GetPrimaryIconAndBadgeIconParams()); | 409 RunInstallableManager(tester.get(), GetPrimaryIconAndBadgeIconParams()); |
| 435 run_loop.Run(); | 410 run_loop.Run(); |
| 436 | 411 |
| 437 EXPECT_FALSE(tester->manifest().IsEmpty()); | 412 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 438 EXPECT_FALSE(tester->manifest_url().is_empty()); | 413 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 439 | 414 |
| 440 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 415 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 441 EXPECT_NE(nullptr, tester->primary_icon()); | 416 EXPECT_NE(nullptr, tester->primary_icon()); |
| 417 EXPECT_FALSE(tester->is_installable()); | |
| 442 EXPECT_FALSE(tester->badge_icon_url().is_empty()); | 418 EXPECT_FALSE(tester->badge_icon_url().is_empty()); |
| 443 EXPECT_NE(nullptr, tester->badge_icon()); | 419 EXPECT_NE(nullptr, tester->badge_icon()); |
| 444 EXPECT_FALSE(tester->is_installable()); | |
| 445 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 420 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 446 } | 421 } |
| 447 | 422 |
| 448 // Request an oversized badge icon. This should fetch only the manifest and | 423 // Request an oversized badge icon. This should fetch only the manifest and |
| 449 // the primary icon, and return no errors. | 424 // the primary icon, and return no errors. |
| 450 { | 425 { |
| 451 base::RunLoop run_loop; | 426 base::RunLoop run_loop; |
| 452 std::unique_ptr<CallbackTester> tester( | 427 std::unique_ptr<CallbackTester> tester( |
| 453 new CallbackTester(run_loop.QuitClosure())); | 428 new CallbackTester(run_loop.QuitClosure())); |
| 454 | 429 |
| 455 InstallableParams params = GetPrimaryIconAndBadgeIconParams(); | 430 InstallableParams params = GetPrimaryIconAndBadgeIconParams(); |
| 456 params.ideal_badge_icon_size_in_px = 2000; | 431 params.ideal_badge_icon_size_in_px = 2000; |
| 457 params.minimum_badge_icon_size_in_px = 2000; | 432 params.minimum_badge_icon_size_in_px = 2000; |
| 458 RunInstallableManager(tester.get(), params); | 433 RunInstallableManager(tester.get(), params); |
| 459 run_loop.Run(); | 434 run_loop.Run(); |
| 460 | 435 |
| 461 EXPECT_FALSE(tester->manifest().IsEmpty()); | 436 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 462 EXPECT_FALSE(tester->manifest_url().is_empty()); | 437 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 463 | 438 |
| 464 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 439 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 465 EXPECT_NE(nullptr, tester->primary_icon()); | 440 EXPECT_NE(nullptr, tester->primary_icon()); |
| 441 EXPECT_FALSE(tester->is_installable()); | |
| 466 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 442 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 467 EXPECT_EQ(nullptr, tester->badge_icon()); | 443 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 468 EXPECT_FALSE(tester->is_installable()); | |
| 469 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 444 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 470 } | 445 } |
| 471 } | 446 } |
| 472 | 447 |
| 473 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) { | 448 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) { |
| 474 // Request everything except badge icon. | 449 // Request everything except badge icon. |
| 475 { | 450 { |
| 476 base::RunLoop run_loop; | 451 base::RunLoop run_loop; |
| 477 std::unique_ptr<CallbackTester> tester( | 452 std::unique_ptr<CallbackTester> tester( |
| 478 new CallbackTester(run_loop.QuitClosure())); | 453 new CallbackTester(run_loop.QuitClosure())); |
| 479 | 454 |
| 480 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), | 455 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), |
| 481 "/banners/manifest_test_page.html"); | 456 "/banners/manifest_test_page.html"); |
| 482 run_loop.Run(); | 457 run_loop.Run(); |
| 483 | 458 |
| 484 EXPECT_FALSE(tester->manifest().IsEmpty()); | 459 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 485 EXPECT_FALSE(tester->manifest_url().is_empty()); | 460 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 486 EXPECT_TRUE(tester->is_installable()); | |
| 487 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 461 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 488 EXPECT_NE(nullptr, tester->primary_icon()); | 462 EXPECT_NE(nullptr, tester->primary_icon()); |
| 463 EXPECT_TRUE(tester->is_installable()); | |
| 489 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 464 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 490 EXPECT_EQ(nullptr, tester->badge_icon()); | 465 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 491 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 466 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 492 | 467 |
| 493 // Verify that the returned state matches manager internal state. | 468 // Verify that the returned state matches manager internal state. |
| 494 InstallableManager* manager = GetManager(); | 469 InstallableManager* manager = GetManager(); |
| 495 | 470 |
| 496 EXPECT_FALSE(manager->manifest().IsEmpty()); | 471 EXPECT_FALSE(manager->manifest().IsEmpty()); |
| 497 EXPECT_FALSE(manager->manifest_url().is_empty()); | 472 EXPECT_FALSE(manager->manifest_url().is_empty()); |
| 498 EXPECT_TRUE(manager->is_installable()); | 473 EXPECT_TRUE(manager->is_installable()); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 510 { | 485 { |
| 511 base::RunLoop run_loop; | 486 base::RunLoop run_loop; |
| 512 std::unique_ptr<CallbackTester> tester( | 487 std::unique_ptr<CallbackTester> tester( |
| 513 new CallbackTester(run_loop.QuitClosure())); | 488 new CallbackTester(run_loop.QuitClosure())); |
| 514 | 489 |
| 515 RunInstallableManager(tester.get(), GetWebAppParams()); | 490 RunInstallableManager(tester.get(), GetWebAppParams()); |
| 516 run_loop.Run(); | 491 run_loop.Run(); |
| 517 | 492 |
| 518 EXPECT_FALSE(tester->manifest().IsEmpty()); | 493 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 519 EXPECT_FALSE(tester->manifest_url().is_empty()); | 494 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 520 EXPECT_TRUE(tester->is_installable()); | |
| 521 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 495 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 522 EXPECT_NE(nullptr, tester->primary_icon()); | 496 EXPECT_NE(nullptr, tester->primary_icon()); |
| 497 EXPECT_TRUE(tester->is_installable()); | |
| 523 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 498 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 524 EXPECT_EQ(nullptr, tester->badge_icon()); | 499 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 525 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 500 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 526 | 501 |
| 527 // Verify that the returned state matches manager internal state. | 502 // Verify that the returned state matches manager internal state. |
| 528 InstallableManager* manager = GetManager(); | 503 InstallableManager* manager = GetManager(); |
| 529 | 504 |
| 530 EXPECT_FALSE(manager->manifest().IsEmpty()); | 505 EXPECT_FALSE(manager->manifest().IsEmpty()); |
| 531 EXPECT_FALSE(manager->manifest_url().is_empty()); | 506 EXPECT_FALSE(manager->manifest_url().is_empty()); |
| 532 EXPECT_TRUE(manager->is_installable()); | 507 EXPECT_TRUE(manager->is_installable()); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 562 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), | 537 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), |
| 563 "/banners/iframe_test_page.html"); | 538 "/banners/iframe_test_page.html"); |
| 564 run_loop.Run(); | 539 run_loop.Run(); |
| 565 | 540 |
| 566 // The installable manager should only retrieve items in the main frame; | 541 // The installable manager should only retrieve items in the main frame; |
| 567 // everything should be empty here. | 542 // everything should be empty here. |
| 568 EXPECT_TRUE(tester->manifest().IsEmpty()); | 543 EXPECT_TRUE(tester->manifest().IsEmpty()); |
| 569 EXPECT_TRUE(tester->manifest_url().is_empty()); | 544 EXPECT_TRUE(tester->manifest_url().is_empty()); |
| 570 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 545 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 571 EXPECT_EQ(nullptr, tester->primary_icon()); | 546 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 547 EXPECT_FALSE(tester->is_installable()); | |
| 572 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 548 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 573 EXPECT_EQ(nullptr, tester->badge_icon()); | 549 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 574 EXPECT_FALSE(tester->is_installable()); | |
| 575 EXPECT_EQ(NO_MANIFEST, tester->error_code()); | 550 EXPECT_EQ(NO_MANIFEST, tester->error_code()); |
| 576 } | 551 } |
| 577 | 552 |
| 578 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, | 553 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, |
| 579 CheckPageWithManifestAndNoServiceWorker) { | 554 CheckPageWithManifestAndNoServiceWorker) { |
| 580 // Just fetch the manifest. This should have no error. | 555 // Just fetch the manifest. This should have no error. |
| 581 { | 556 { |
| 582 base::RunLoop run_loop; | 557 base::RunLoop run_loop; |
| 583 std::unique_ptr<CallbackTester> tester( | 558 std::unique_ptr<CallbackTester> tester( |
| 584 new CallbackTester(run_loop.QuitClosure())); | 559 new CallbackTester(run_loop.QuitClosure())); |
| 585 | 560 |
| 586 NavigateAndRunInstallableManager( | 561 NavigateAndRunInstallableManager( |
| 587 tester.get(), GetManifestParams(), | 562 tester.get(), GetManifestParams(), |
| 588 "/banners/manifest_no_service_worker.html"); | 563 "/banners/manifest_no_service_worker.html"); |
| 589 run_loop.Run(); | 564 run_loop.Run(); |
| 590 | 565 |
| 591 EXPECT_FALSE(tester->manifest().IsEmpty()); | 566 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 592 EXPECT_FALSE(tester->manifest_url().is_empty()); | 567 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 593 | 568 |
| 594 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 569 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 595 EXPECT_EQ(nullptr, tester->primary_icon()); | 570 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 571 EXPECT_FALSE(tester->is_installable()); | |
| 596 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 572 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 597 EXPECT_EQ(nullptr, tester->badge_icon()); | 573 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 598 EXPECT_FALSE(tester->is_installable()); | |
| 599 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 574 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 600 } | 575 } |
| 601 | 576 |
| 602 // Fetch the full criteria should fail. | 577 // Fetch the full criteria should fail. |
| 603 { | 578 { |
| 604 base::RunLoop run_loop; | 579 base::RunLoop run_loop; |
| 605 std::unique_ptr<CallbackTester> tester( | 580 std::unique_ptr<CallbackTester> tester( |
| 606 new CallbackTester(run_loop.QuitClosure())); | 581 new CallbackTester(run_loop.QuitClosure())); |
| 607 | 582 |
| 608 RunInstallableManager(tester.get(), GetWebAppParams()); | 583 RunInstallableManager(tester.get(), GetWebAppParams()); |
| 609 run_loop.Run(); | 584 run_loop.Run(); |
| 610 | 585 |
| 611 EXPECT_FALSE(tester->manifest().IsEmpty()); | 586 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 612 EXPECT_FALSE(tester->manifest_url().is_empty()); | 587 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 613 | 588 |
| 614 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 589 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 615 EXPECT_EQ(nullptr, tester->primary_icon()); | 590 EXPECT_NE(nullptr, tester->primary_icon()); |
| 591 EXPECT_FALSE(tester->is_installable()); | |
| 616 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 592 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 617 EXPECT_EQ(nullptr, tester->badge_icon()); | 593 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 618 EXPECT_FALSE(tester->is_installable()); | |
| 619 EXPECT_EQ(NO_MATCHING_SERVICE_WORKER, tester->error_code()); | 594 EXPECT_EQ(NO_MATCHING_SERVICE_WORKER, tester->error_code()); |
| 620 } | 595 } |
| 621 } | 596 } |
| 622 | 597 |
| 623 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, | 598 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, |
| 624 CheckPageWithNoServiceWorkerFetchHandler) { | 599 CheckPageWithNoServiceWorkerFetchHandler) { |
| 625 base::RunLoop run_loop; | 600 base::RunLoop run_loop; |
| 626 std::unique_ptr<CallbackTester> tester( | 601 std::unique_ptr<CallbackTester> tester( |
| 627 new CallbackTester(run_loop.QuitClosure())); | 602 new CallbackTester(run_loop.QuitClosure())); |
| 628 | 603 |
| 629 NavigateAndRunInstallableManager( | 604 NavigateAndRunInstallableManager( |
| 630 tester.get(), GetWebAppParams(), | 605 tester.get(), GetWebAppParams(), |
| 631 "/banners/no_sw_fetch_handler_test_page.html"); | 606 "/banners/no_sw_fetch_handler_test_page.html"); |
| 632 | 607 |
| 633 RunInstallableManager(tester.get(), GetWebAppParams()); | 608 RunInstallableManager(tester.get(), GetWebAppParams()); |
| 634 run_loop.Run(); | 609 run_loop.Run(); |
| 635 | 610 |
| 636 EXPECT_FALSE(tester->manifest().IsEmpty()); | 611 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 637 EXPECT_FALSE(tester->manifest_url().is_empty()); | 612 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 638 | 613 |
| 639 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 614 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 640 EXPECT_EQ(nullptr, tester->primary_icon()); | 615 EXPECT_NE(nullptr, tester->primary_icon()); |
| 616 EXPECT_FALSE(tester->is_installable()); | |
| 641 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 617 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 642 EXPECT_EQ(nullptr, tester->badge_icon()); | 618 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 643 EXPECT_FALSE(tester->is_installable()); | |
| 644 EXPECT_EQ(NOT_OFFLINE_CAPABLE, tester->error_code()); | 619 EXPECT_EQ(NOT_OFFLINE_CAPABLE, tester->error_code()); |
| 645 } | 620 } |
| 646 | 621 |
| 647 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckDataUrlIcon) { | 622 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckDataUrlIcon) { |
| 648 // Verify that InstallableManager can handle data URL icons. | 623 // Verify that InstallableManager can handle data URL icons. |
| 649 base::RunLoop run_loop; | 624 base::RunLoop run_loop; |
| 650 std::unique_ptr<CallbackTester> tester( | 625 std::unique_ptr<CallbackTester> tester( |
| 651 new CallbackTester(run_loop.QuitClosure())); | 626 new CallbackTester(run_loop.QuitClosure())); |
| 652 | 627 |
| 653 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), | 628 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), |
| 654 GetURLOfPageWithServiceWorkerAndManifest( | 629 GetURLOfPageWithServiceWorkerAndManifest( |
| 655 "/banners/manifest_data_url_icon.json")); | 630 "/banners/manifest_data_url_icon.json")); |
| 656 run_loop.Run(); | 631 run_loop.Run(); |
| 657 | 632 |
| 658 EXPECT_FALSE(tester->manifest().IsEmpty()); | 633 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 659 EXPECT_FALSE(tester->manifest_url().is_empty()); | 634 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 660 | 635 |
| 661 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 636 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 662 EXPECT_NE(nullptr, tester->primary_icon()); | 637 EXPECT_NE(nullptr, tester->primary_icon()); |
| 663 EXPECT_EQ(144, tester->primary_icon()->width()); | 638 EXPECT_EQ(144, tester->primary_icon()->width()); |
| 639 EXPECT_TRUE(tester->is_installable()); | |
| 664 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 640 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 665 EXPECT_EQ(nullptr, tester->badge_icon()); | 641 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 666 EXPECT_TRUE(tester->is_installable()); | |
| 667 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 642 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 668 } | 643 } |
| 669 | 644 |
| 670 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, | 645 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, |
| 671 CheckManifestCorruptedIcon) { | 646 CheckManifestCorruptedIcon) { |
| 672 // Verify that the returned InstallableData::primary_icon is null if the web | 647 // Verify that the returned InstallableData::primary_icon is null if the web |
| 673 // manifest points to a corrupt primary icon. | 648 // manifest points to a corrupt primary icon. |
| 674 base::RunLoop run_loop; | 649 base::RunLoop run_loop; |
| 675 std::unique_ptr<CallbackTester> tester( | 650 std::unique_ptr<CallbackTester> tester( |
| 676 new CallbackTester(run_loop.QuitClosure())); | 651 new CallbackTester(run_loop.QuitClosure())); |
| 677 | 652 |
| 678 NavigateAndRunInstallableManager(tester.get(), GetPrimaryIconParams(), | 653 NavigateAndRunInstallableManager(tester.get(), GetPrimaryIconParams(), |
| 679 GetURLOfPageWithServiceWorkerAndManifest( | 654 GetURLOfPageWithServiceWorkerAndManifest( |
| 680 "/banners/manifest_bad_icon.json")); | 655 "/banners/manifest_bad_icon.json")); |
| 681 run_loop.Run(); | 656 run_loop.Run(); |
| 682 | 657 |
| 683 EXPECT_FALSE(tester->manifest().IsEmpty()); | 658 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 684 EXPECT_FALSE(tester->manifest_url().is_empty()); | 659 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 685 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 660 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 686 EXPECT_EQ(nullptr, tester->primary_icon()); | 661 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 662 EXPECT_FALSE(tester->is_installable()); | |
| 687 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 663 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 688 EXPECT_EQ(nullptr, tester->badge_icon()); | 664 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 689 EXPECT_FALSE(tester->is_installable()); | |
| 690 EXPECT_EQ(NO_ICON_AVAILABLE, tester->error_code()); | 665 EXPECT_EQ(NO_ICON_AVAILABLE, tester->error_code()); |
| 691 } | 666 } |
| 692 | 667 |
| 693 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, | 668 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, |
| 694 CheckChangeInIconDimensions) { | 669 CheckChangeInIconDimensions) { |
| 695 // Verify that a follow-up request for a primary icon with a different size | 670 // Verify that a follow-up request for a primary icon with a different size |
| 696 // works. | 671 // works. |
| 697 { | 672 { |
| 698 base::RunLoop run_loop; | 673 base::RunLoop run_loop; |
| 699 std::unique_ptr<CallbackTester> tester( | 674 std::unique_ptr<CallbackTester> tester( |
| 700 new CallbackTester(run_loop.QuitClosure())); | 675 new CallbackTester(run_loop.QuitClosure())); |
| 701 | 676 |
| 702 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), | 677 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), |
| 703 "/banners/manifest_test_page.html"); | 678 "/banners/manifest_test_page.html"); |
| 704 run_loop.Run(); | 679 run_loop.Run(); |
| 705 | 680 |
| 706 EXPECT_FALSE(tester->manifest_url().is_empty()); | 681 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 707 EXPECT_FALSE(tester->manifest().IsEmpty()); | 682 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 708 EXPECT_TRUE(tester->is_installable()); | |
| 709 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 683 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 710 EXPECT_NE(nullptr, tester->primary_icon()); | 684 EXPECT_NE(nullptr, tester->primary_icon()); |
| 685 EXPECT_TRUE(tester->is_installable()); | |
| 711 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 686 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 712 EXPECT_EQ(nullptr, tester->badge_icon()); | 687 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 713 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 688 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 714 } | 689 } |
| 715 | 690 |
| 716 { | 691 { |
| 717 base::RunLoop run_loop; | 692 base::RunLoop run_loop; |
| 718 std::unique_ptr<CallbackTester> tester( | 693 std::unique_ptr<CallbackTester> tester( |
| 719 new CallbackTester(run_loop.QuitClosure())); | 694 new CallbackTester(run_loop.QuitClosure())); |
| 720 | 695 |
| 721 // Dial up the primary icon size requirements to something that isn't | 696 // Dial up the primary icon size requirements to something that isn't |
| 722 // available. This should now fail with NoIconMatchingRequirements. | 697 // available. This should now fail with NoIconMatchingRequirements. |
| 723 InstallableParams params = GetWebAppParams(); | 698 InstallableParams params = GetWebAppParams(); |
| 724 params.ideal_primary_icon_size_in_px = 2000; | 699 params.ideal_primary_icon_size_in_px = 2000; |
| 725 params.minimum_primary_icon_size_in_px = 2000; | 700 params.minimum_primary_icon_size_in_px = 2000; |
| 726 RunInstallableManager(tester.get(), params); | 701 RunInstallableManager(tester.get(), params); |
| 727 run_loop.Run(); | 702 run_loop.Run(); |
| 728 | 703 |
| 729 EXPECT_FALSE(tester->manifest_url().is_empty()); | 704 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 730 EXPECT_FALSE(tester->manifest().IsEmpty()); | 705 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 731 EXPECT_TRUE(tester->is_installable()); | |
| 732 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 706 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 733 EXPECT_EQ(nullptr, tester->primary_icon()); | 707 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 708 EXPECT_TRUE(tester->is_installable()); | |
| 734 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 709 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 735 EXPECT_EQ(nullptr, tester->badge_icon()); | 710 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 736 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); | 711 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); |
| 737 } | 712 } |
| 738 | 713 |
| 739 // Navigate and verify the reverse: an overly large primary icon requested | 714 // Navigate and verify the reverse: an overly large primary icon requested |
| 740 // first fails, but a smaller primary icon requested second passes. | 715 // first fails, but a smaller primary icon requested second passes. |
| 741 { | 716 { |
| 742 base::RunLoop run_loop; | 717 base::RunLoop run_loop; |
| 743 std::unique_ptr<CallbackTester> tester( | 718 std::unique_ptr<CallbackTester> tester( |
| 744 new CallbackTester(run_loop.QuitClosure())); | 719 new CallbackTester(run_loop.QuitClosure())); |
| 745 | 720 |
| 746 // This should fail with NoIconMatchingRequirements. | 721 // This should fail with NoIconMatchingRequirements. |
| 747 InstallableParams params = GetWebAppParams(); | 722 InstallableParams params = GetWebAppParams(); |
| 748 params.ideal_primary_icon_size_in_px = 2000; | 723 params.ideal_primary_icon_size_in_px = 2000; |
| 749 params.minimum_primary_icon_size_in_px = 2000; | 724 params.minimum_primary_icon_size_in_px = 2000; |
| 750 NavigateAndRunInstallableManager(tester.get(), params, | 725 NavigateAndRunInstallableManager(tester.get(), params, |
| 751 "/banners/manifest_test_page.html"); | 726 "/banners/manifest_test_page.html"); |
| 752 run_loop.Run(); | 727 run_loop.Run(); |
| 753 | 728 |
| 754 EXPECT_FALSE(tester->manifest_url().is_empty()); | 729 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 755 EXPECT_FALSE(tester->manifest().IsEmpty()); | 730 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 756 EXPECT_TRUE(tester->is_installable()); | |
| 757 EXPECT_TRUE(tester->primary_icon_url().is_empty()); | 731 EXPECT_TRUE(tester->primary_icon_url().is_empty()); |
| 758 EXPECT_EQ(nullptr, tester->primary_icon()); | 732 EXPECT_EQ(nullptr, tester->primary_icon()); |
| 733 EXPECT_FALSE(tester->is_installable()); | |
| 759 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 734 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 760 EXPECT_EQ(nullptr, tester->badge_icon()); | 735 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 761 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); | 736 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); |
| 762 } | 737 } |
| 763 | 738 |
| 764 { | 739 { |
| 765 base::RunLoop run_loop; | 740 base::RunLoop run_loop; |
| 766 std::unique_ptr<CallbackTester> tester( | 741 std::unique_ptr<CallbackTester> tester( |
| 767 new CallbackTester(run_loop.QuitClosure())); | 742 new CallbackTester(run_loop.QuitClosure())); |
| 768 RunInstallableManager(tester.get(), GetWebAppParams()); | 743 RunInstallableManager(tester.get(), GetWebAppParams()); |
| 769 | 744 |
| 770 run_loop.Run(); | 745 run_loop.Run(); |
| 771 | 746 |
| 772 // The smaller primary icon requirements should allow this to pass. | 747 // The smaller primary icon requirements should allow this to pass. |
| 773 EXPECT_FALSE(tester->manifest_url().is_empty()); | 748 EXPECT_FALSE(tester->manifest_url().is_empty()); |
| 774 EXPECT_FALSE(tester->manifest().IsEmpty()); | 749 EXPECT_FALSE(tester->manifest().IsEmpty()); |
| 775 EXPECT_TRUE(tester->is_installable()); | |
| 776 EXPECT_FALSE(tester->primary_icon_url().is_empty()); | 750 EXPECT_FALSE(tester->primary_icon_url().is_empty()); |
| 777 EXPECT_NE(nullptr, tester->primary_icon()); | 751 EXPECT_NE(nullptr, tester->primary_icon()); |
| 752 EXPECT_TRUE(tester->is_installable()); | |
| 778 EXPECT_TRUE(tester->badge_icon_url().is_empty()); | 753 EXPECT_TRUE(tester->badge_icon_url().is_empty()); |
| 779 EXPECT_EQ(nullptr, tester->badge_icon()); | 754 EXPECT_EQ(nullptr, tester->badge_icon()); |
| 780 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); | 755 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); |
| 781 } | 756 } |
| 782 } | 757 } |
| 783 | 758 |
| 784 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, | 759 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, |
| 785 CheckNestedCallsToGetData) { | 760 CheckNestedCallsToGetData) { |
| 786 // Verify that we can call GetData while in a callback from GetData. | 761 // Verify that we can call GetData while in a callback from GetData. |
| 787 base::RunLoop run_loop; | 762 base::RunLoop run_loop; |
| 788 InstallableParams params = GetWebAppParams(); | 763 InstallableParams params = GetWebAppParams(); |
| 789 std::unique_ptr<NestedCallbackTester> tester( | 764 std::unique_ptr<NestedCallbackTester> tester( |
| 790 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); | 765 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); |
| 791 | 766 |
| 792 tester->Run(); | 767 tester->Run(); |
| 793 run_loop.Run(); | 768 run_loop.Run(); |
| 794 } | 769 } |
| OLD | NEW |