Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: chrome/browser/installable/installable_manager_browsertest.cc

Issue 2160513002: Extract AppBannerDataFetcher into an InstallableManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing nits Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/installable/installable_manager.h"
6
7 #include "base/command_line.h"
8 #include "base/run_loop.h"
9 #include "base/threading/thread_task_runner_handle.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h"
15 #include "net/test/embedded_test_server/embedded_test_server.h"
16
17 namespace {
18
19 InstallableParams GetManifestParams() {
20 InstallableParams params;
21 params.check_installable = false;
22 params.fetch_valid_icon = false;
23 return params;
24 }
25
26 InstallableParams GetWebAppParams() {
27 InstallableParams params = GetManifestParams();
28 params.ideal_icon_size_in_dp = 48;
29 params.minimum_icon_size_in_dp = 48;
30 params.check_installable = true;
31 params.fetch_valid_icon = true;
32 return params;
33 }
34
35 InstallableParams GetIconParams() {
36 InstallableParams params = GetManifestParams();
37 params.ideal_icon_size_in_dp = 48;
38 params.minimum_icon_size_in_dp = 48;
39 params.fetch_valid_icon = true;
40 return params;
41 }
42
43 } // anonymous namespace
44
45 class CallbackTester {
46 public:
47 explicit CallbackTester(base::Closure quit_closure)
48 : quit_closure_(quit_closure) { }
49
50 void OnDidFinishInstallableCheck(const InstallableData& data) {
51 error_code_ = data.error_code;
52 manifest_url_ = data.manifest_url;
53 manifest_ = data.manifest;
54 icon_url_ = data.icon_url;
55 if (data.icon)
56 icon_.reset(new SkBitmap(*data.icon));
57 is_installable_ = data.is_installable;
58 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_);
59 }
60
61 InstallableErrorCode error_code() const { return error_code_; }
62 const GURL& manifest_url() const { return manifest_url_; }
63 const content::Manifest& manifest() const { return manifest_; }
64 const GURL& icon_url() const { return icon_url_; }
65 const SkBitmap* icon() const { return icon_.get(); }
66 bool is_installable() const { return is_installable_; }
67
68 private:
69 base::Closure quit_closure_;
70 InstallableErrorCode error_code_;
71 GURL manifest_url_;
72 content::Manifest manifest_;
73 GURL icon_url_;
74 std::unique_ptr<SkBitmap> icon_;
75 bool is_installable_;
76 };
77
78 class NestedCallbackTester {
79 public:
80 NestedCallbackTester(InstallableManager* manager,
81 const InstallableParams& params,
82 base::Closure quit_closure)
83 : manager_(manager), params_(params), quit_closure_(quit_closure) {}
84
85 void Run() {
86 manager_->GetData(params_,
87 base::Bind(&NestedCallbackTester::OnDidFinishFirstCheck,
88 base::Unretained(this)));
89 }
90
91 void OnDidFinishFirstCheck(const InstallableData& data) {
92 error_code_ = data.error_code;
93 manifest_url_ = data.manifest_url;
94 manifest_ = data.manifest;
95 icon_url_ = data.icon_url;
96 if (data.icon)
97 icon_.reset(new SkBitmap(*data.icon));
98 is_installable_ = data.is_installable;
99
100 manager_->GetData(params_,
101 base::Bind(&NestedCallbackTester::OnDidFinishSecondCheck,
102 base::Unretained(this)));
103 }
104
105 void OnDidFinishSecondCheck(const InstallableData& data) {
106 EXPECT_EQ(error_code_, data.error_code);
107 EXPECT_EQ(manifest_url_, data.manifest_url);
108 EXPECT_EQ(icon_url_, data.icon_url);
109 EXPECT_EQ(icon_.get(), data.icon);
110 EXPECT_EQ(is_installable_, data.is_installable);
111 EXPECT_EQ(manifest_.IsEmpty(), data.manifest.IsEmpty());
112 EXPECT_EQ(manifest_.start_url, data.manifest.start_url);
113 EXPECT_EQ(manifest_.display, data.manifest.display);
114 EXPECT_EQ(manifest_.name, data.manifest.name);
115 EXPECT_EQ(manifest_.short_name, data.manifest.short_name);
116
117 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_);
118 }
119
120 private:
121 InstallableManager* manager_;
122 InstallableParams params_;
123 base::Closure quit_closure_;
124 InstallableErrorCode error_code_;
125 GURL manifest_url_;
126 content::Manifest manifest_;
127 GURL icon_url_;
128 std::unique_ptr<SkBitmap> icon_;
129 bool is_installable_;
130 };
131
132 class InstallableManagerBrowserTest : public InProcessBrowserTest {
133 public:
134 void SetUpOnMainThread() override {
135 InProcessBrowserTest::SetUpOnMainThread();
136 ASSERT_TRUE(embedded_test_server()->Start());
137 }
138
139 void NavigateAndRunInstallableManager(CallbackTester* tester,
140 const InstallableParams& params,
141 const std::string& url) {
142 GURL test_url = embedded_test_server()->GetURL(url);
143 ui_test_utils::NavigateToURL(browser(), test_url);
144 RunInstallableManager(tester, params);
145 }
146
147 void RunInstallableManager(CallbackTester* tester,
148 const InstallableParams& params) {
149 InstallableManager* manager = GetManager();
150 manager->GetData(params,
151 base::Bind(&CallbackTester::OnDidFinishInstallableCheck,
152 base::Unretained(tester)));
153 }
154
155 void SetUpCommandLine(base::CommandLine* command_line) override {
156 // Make sure app banners are disabled in the browser so they do not
157 // interfere with the test.
158 command_line->AppendSwitch(switches::kDisableAddToShelf);
159 }
160
161 InstallableManager* GetManager() {
162 content::WebContents* web_contents =
163 browser()->tab_strip_model()->GetActiveWebContents();
164 InstallableManager::CreateForWebContents(web_contents);
165 InstallableManager* manager =
166 InstallableManager::FromWebContents(web_contents);
167 CHECK(manager);
168
169 return manager;
170 }
171
172 };
173
174 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
175 ManagerBeginsInEmptyState) {
176 // Ensure that the InstallableManager starts off with everything null.
177 InstallableManager* manager = GetManager();
178
179 EXPECT_TRUE(manager->manifest().IsEmpty());
180 EXPECT_TRUE(manager->manifest_url().is_empty());
181 EXPECT_TRUE(manager->icons_.empty());
182 EXPECT_FALSE(manager->is_installable());
183
184 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error());
185 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error());
186 EXPECT_TRUE(manager->tasks_.empty());
187 }
188
189 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckNoManifest) {
190 // Ensure that a page with no manifest returns the appropriate error and with
191 // null fields for everything.
192 base::RunLoop run_loop;
193 std::unique_ptr<CallbackTester> tester(
194 new CallbackTester(run_loop.QuitClosure()));
195
196 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
197 "/banners/no_manifest_test_page.html");
198 run_loop.Run();
199
200 // If there is no manifest, everything should be empty.
201 EXPECT_TRUE(tester->manifest().IsEmpty());
202 EXPECT_TRUE(tester->manifest_url().is_empty());
203 EXPECT_TRUE(tester->icon_url().is_empty());
204 EXPECT_EQ(nullptr, tester->icon());
205 EXPECT_FALSE(tester->is_installable());
206 EXPECT_EQ(NO_MANIFEST, tester->error_code());
207 }
208
209 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifest404) {
210 base::RunLoop run_loop;
211 std::unique_ptr<CallbackTester> tester(
212 new CallbackTester(run_loop.QuitClosure()));
213
214 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
215 "/banners/manifest_bad_link.html");
216 run_loop.Run();
217
218 // The installable manager should return a manifest URL even if it 404s.
219 // However, the check should fail with a ManifestEmpty error.
220 EXPECT_TRUE(tester->manifest().IsEmpty());
221
222 EXPECT_FALSE(tester->manifest_url().is_empty());
223 EXPECT_TRUE(tester->icon_url().is_empty());
224 EXPECT_EQ(nullptr, tester->icon());
225 EXPECT_FALSE(tester->is_installable());
226 EXPECT_EQ(MANIFEST_EMPTY, tester->error_code());
227 }
228
229 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestOnly) {
230 // Verify that asking for just the manifest works as expected.
231 base::RunLoop run_loop;
232 std::unique_ptr<CallbackTester> tester(
233 new CallbackTester(run_loop.QuitClosure()));
234
235 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
236 "/banners/manifest_test_page.html");
237 run_loop.Run();
238
239 EXPECT_FALSE(tester->manifest().IsEmpty());
240 EXPECT_FALSE(tester->manifest_url().is_empty());
241
242 EXPECT_TRUE(tester->icon_url().is_empty());
243 EXPECT_EQ(nullptr, tester->icon());
244 EXPECT_FALSE(tester->is_installable());
245 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
246 }
247
248 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
249 CheckInstallableParamsDefaultConstructor) {
250 // Verify that using InstallableParams' default constructor is equivalent to
251 // just asking for the manifest alone.
252 base::RunLoop run_loop;
253 std::unique_ptr<CallbackTester> tester(
254 new CallbackTester(run_loop.QuitClosure()));
255
256 InstallableParams params;
257 NavigateAndRunInstallableManager(tester.get(), params,
258 "/banners/manifest_test_page.html");
259 run_loop.Run();
260
261 EXPECT_FALSE(tester->manifest().IsEmpty());
262 EXPECT_FALSE(tester->manifest_url().is_empty());
263
264 EXPECT_TRUE(tester->icon_url().is_empty());
265 EXPECT_EQ(nullptr, tester->icon());
266 EXPECT_FALSE(tester->is_installable());
267 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
268 }
269
270 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
271 CheckManifestWithOnlyRelatedApplications) {
272 // This page has a manifest with only related applications specified. Asking
273 // for just the manifest should succeed.
274 {
275 base::RunLoop run_loop;
276 std::unique_ptr<CallbackTester> tester(
277 new CallbackTester(run_loop.QuitClosure()));
278
279 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
280 "/banners/play_app_test_page.html");
281 run_loop.Run();
282
283 EXPECT_FALSE(tester->manifest().IsEmpty());
284 EXPECT_FALSE(tester->manifest_url().is_empty());
285 EXPECT_TRUE(tester->manifest().prefer_related_applications);
286
287 EXPECT_TRUE(tester->icon_url().is_empty());
288 EXPECT_EQ(nullptr, tester->icon());
289 EXPECT_FALSE(tester->is_installable());
290 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
291 }
292
293 // Ask for an icon (but don't navigate). This should fail with
294 // NO_ACCEPTABLE_ICON.
295 {
296 base::RunLoop run_loop;
297 std::unique_ptr<CallbackTester> tester(
298 new CallbackTester(run_loop.QuitClosure()));
299
300 RunInstallableManager(tester.get(), GetIconParams());
301 run_loop.Run();
302
303 EXPECT_FALSE(tester->manifest().IsEmpty());
304 EXPECT_FALSE(tester->manifest_url().is_empty());
305 EXPECT_TRUE(tester->manifest().prefer_related_applications);
306
307 EXPECT_TRUE(tester->icon_url().is_empty());
308 EXPECT_EQ(nullptr, tester->icon());
309 EXPECT_FALSE(tester->is_installable());
310 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
311 }
312
313 // Ask for everything. This should fail with NO_ACCEPTABLE_ICON - the icon
314 // fetch has already failed, so that cached error stops the installable check
315 // from being performed.
316 {
317 base::RunLoop run_loop;
318 std::unique_ptr<CallbackTester> tester(
319 new CallbackTester(run_loop.QuitClosure()));
320
321 RunInstallableManager(tester.get(), GetWebAppParams());
322 run_loop.Run();
323
324 EXPECT_FALSE(tester->manifest().IsEmpty());
325 EXPECT_FALSE(tester->manifest_url().is_empty());
326 EXPECT_TRUE(tester->manifest().prefer_related_applications);
327
328 EXPECT_TRUE(tester->icon_url().is_empty());
329 EXPECT_EQ(nullptr, tester->icon());
330 EXPECT_FALSE(tester->is_installable());
331 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
332 }
333
334 // Ask for a different size icon. This should fail with START_URL_NOT_VALID
335 // since we won't have a cached icon error.
336 {
337 base::RunLoop run_loop;
338 std::unique_ptr<CallbackTester> tester(
339 new CallbackTester(run_loop.QuitClosure()));
340
341 InstallableParams params = GetWebAppParams();
342 params.ideal_icon_size_in_dp = 32;
343 params.minimum_icon_size_in_dp = 32;
344 RunInstallableManager(tester.get(), params);
345 run_loop.Run();
346
347 EXPECT_FALSE(tester->manifest().IsEmpty());
348 EXPECT_FALSE(tester->manifest_url().is_empty());
349 EXPECT_TRUE(tester->manifest().prefer_related_applications);
350
351 EXPECT_TRUE(tester->icon_url().is_empty());
352 EXPECT_EQ(nullptr, tester->icon());
353 EXPECT_FALSE(tester->is_installable());
354 EXPECT_EQ(START_URL_NOT_VALID, tester->error_code());
355 }
356 }
357
358 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestAndIcon) {
359 // Add to homescreen checks for manifest + icon.
360 base::RunLoop run_loop;
361 std::unique_ptr<CallbackTester> tester(
362 new CallbackTester(run_loop.QuitClosure()));
363
364 NavigateAndRunInstallableManager(tester.get(), GetIconParams(),
365 "/banners/manifest_test_page.html");
366 run_loop.Run();
367
368 EXPECT_FALSE(tester->manifest().IsEmpty());
369 EXPECT_FALSE(tester->manifest_url().is_empty());
370
371 EXPECT_FALSE(tester->icon_url().is_empty());
372 EXPECT_NE(nullptr, tester->icon());
373
374 EXPECT_FALSE(tester->is_installable());
375 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
376 }
377
378 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) {
379 // Request everything.
380 {
381 base::RunLoop run_loop;
382 std::unique_ptr<CallbackTester> tester(
383 new CallbackTester(run_loop.QuitClosure()));
384
385 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
386 "/banners/manifest_test_page.html");
387 run_loop.Run();
388
389 EXPECT_FALSE(tester->manifest().IsEmpty());
390 EXPECT_FALSE(tester->manifest_url().is_empty());
391 EXPECT_TRUE(tester->is_installable());
392 EXPECT_FALSE(tester->icon_url().is_empty());
393 EXPECT_NE(nullptr, tester->icon());
394 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
395
396 // Verify that the returned state matches manager internal state.
397 InstallableManager* manager = GetManager();
398
399 EXPECT_FALSE(manager->manifest().IsEmpty());
400 EXPECT_FALSE(manager->manifest_url().is_empty());
401 EXPECT_TRUE(manager->is_installable());
402 EXPECT_EQ(1u, manager->icons_.size());
403 EXPECT_FALSE((manager->icon_url({48,48}).is_empty()));
404 EXPECT_NE(nullptr, (manager->icon({48,48})));
405 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error());
406 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error());
407 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error({48,48})));
408 EXPECT_TRUE(manager->tasks_.empty());
409 }
410
411 // Request everything again without navigating away. This should work fine.
412 {
413 base::RunLoop run_loop;
414 std::unique_ptr<CallbackTester> tester(
415 new CallbackTester(run_loop.QuitClosure()));
416
417 RunInstallableManager(tester.get(), GetWebAppParams());
418 run_loop.Run();
419
420 EXPECT_FALSE(tester->manifest().IsEmpty());
421 EXPECT_FALSE(tester->manifest_url().is_empty());
422 EXPECT_TRUE(tester->is_installable());
423 EXPECT_FALSE(tester->icon_url().is_empty());
424 EXPECT_NE(nullptr, tester->icon());
425 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
426
427 // Verify that the returned state matches manager internal state.
428 InstallableManager* manager = GetManager();
429
430 EXPECT_FALSE(manager->manifest().IsEmpty());
431 EXPECT_FALSE(manager->manifest_url().is_empty());
432 EXPECT_TRUE(manager->is_installable());
433 EXPECT_EQ(1u, manager->icons_.size());
434 EXPECT_FALSE((manager->icon_url({48,48}).is_empty()));
435 EXPECT_NE(nullptr, (manager->icon({48,48})));
436 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error());
437 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error());
438 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error({48,48})));
439 EXPECT_TRUE(manager->tasks_.empty());
440 }
441
442 {
443 // Check that a subsequent navigation resets state.
444 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
445 InstallableManager* manager = GetManager();
446
447 EXPECT_TRUE(manager->manifest().IsEmpty());
448 EXPECT_TRUE(manager->manifest_url().is_empty());
449 EXPECT_FALSE(manager->is_installable());
450 EXPECT_TRUE(manager->icons_.empty());
451 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error());
452 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error());
453 EXPECT_TRUE(manager->tasks_.empty());
454 }
455 }
456
457 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebappInIframe) {
458 base::RunLoop run_loop;
459 std::unique_ptr<CallbackTester> tester(
460 new CallbackTester(run_loop.QuitClosure()));
461
462 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
463 "/banners/iframe_test_page.html");
464 run_loop.Run();
465
466 // The installable manager should only retrieve items in the main frame;
467 // everything should be empty here.
468 EXPECT_TRUE(tester->manifest().IsEmpty());
469 EXPECT_TRUE(tester->manifest_url().is_empty());
470 EXPECT_TRUE(tester->icon_url().is_empty());
471 EXPECT_EQ(nullptr, tester->icon());
472 EXPECT_FALSE(tester->is_installable());
473 EXPECT_EQ(NO_MANIFEST, tester->error_code());
474 }
475
476 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
477 CheckPageWithManifestAndNoServiceWorker) {
478 // Just fetch the manifest. This should have no error.
479 {
480 base::RunLoop run_loop;
481 std::unique_ptr<CallbackTester> tester(
482 new CallbackTester(run_loop.QuitClosure()));
483
484 NavigateAndRunInstallableManager(
485 tester.get(), GetManifestParams(),
486 "/banners/manifest_no_service_worker.html");
487 run_loop.Run();
488
489 EXPECT_FALSE(tester->manifest().IsEmpty());
490 EXPECT_FALSE(tester->manifest_url().is_empty());
491
492 EXPECT_TRUE(tester->icon_url().is_empty());
493 EXPECT_EQ(nullptr, tester->icon());
494 EXPECT_FALSE(tester->is_installable());
495 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
496 }
497
498 // Fetch the full criteria should fail.
499 {
500 base::RunLoop run_loop;
501 std::unique_ptr<CallbackTester> tester(
502 new CallbackTester(run_loop.QuitClosure()));
503
504 RunInstallableManager(tester.get(), GetWebAppParams());
505 run_loop.Run();
506
507 EXPECT_FALSE(tester->manifest().IsEmpty());
508 EXPECT_FALSE(tester->manifest_url().is_empty());
509
510 EXPECT_TRUE(tester->icon_url().is_empty());
511 EXPECT_EQ(nullptr, tester->icon());
512 EXPECT_FALSE(tester->is_installable());
513 EXPECT_EQ(NO_MATCHING_SERVICE_WORKER, tester->error_code());
514 }
515 }
516
517 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
518 CheckChangeInIconDimensions) {
519 // Verify that a follow-up request for an icon with a different size works.
520 {
521 base::RunLoop run_loop;
522 std::unique_ptr<CallbackTester> tester(
523 new CallbackTester(run_loop.QuitClosure()));
524
525 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
526 "/banners/manifest_test_page.html");
527 run_loop.Run();
528
529 EXPECT_FALSE(tester->manifest_url().is_empty());
530 EXPECT_FALSE(tester->manifest().IsEmpty());
531 EXPECT_TRUE(tester->is_installable());
532 EXPECT_FALSE(tester->icon_url().is_empty());
533 EXPECT_NE(nullptr, tester->icon());
534 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
535 }
536
537 {
538 base::RunLoop run_loop;
539 std::unique_ptr<CallbackTester> tester(
540 new CallbackTester(run_loop.QuitClosure()));
541
542 // Dial up the icon size requirements to something that isn't available.
543 // This should now fail with NoIconMatchingRequirements.
544 InstallableParams params = GetWebAppParams();
545 params.ideal_icon_size_in_dp = 2000;
546 params.minimum_icon_size_in_dp = 2000;
547 RunInstallableManager(tester.get(), params);
548 run_loop.Run();
549
550 EXPECT_FALSE(tester->manifest_url().is_empty());
551 EXPECT_FALSE(tester->manifest().IsEmpty());
552 EXPECT_TRUE(tester->is_installable());
553 EXPECT_TRUE(tester->icon_url().is_empty());
554 EXPECT_EQ(nullptr, tester->icon());
555 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
556 }
557
558 // Navigate and verify the reverse: an overly large icon requested first
559 // fails, but a smaller icon requested second passes.
560 {
561 base::RunLoop run_loop;
562 std::unique_ptr<CallbackTester> tester(
563 new CallbackTester(run_loop.QuitClosure()));
564
565 // This should fail with NoIconMatchingRequirements.
566 InstallableParams params = GetWebAppParams();
567 params.ideal_icon_size_in_dp = 2000;
568 params.minimum_icon_size_in_dp = 2000;
569 NavigateAndRunInstallableManager(tester.get(), params,
570 "/banners/manifest_test_page.html");
571 run_loop.Run();
572
573 EXPECT_FALSE(tester->manifest_url().is_empty());
574 EXPECT_FALSE(tester->manifest().IsEmpty());
575 EXPECT_TRUE(tester->is_installable());
576 EXPECT_TRUE(tester->icon_url().is_empty());
577 EXPECT_EQ(nullptr, tester->icon());
578 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
579 }
580
581 {
582 base::RunLoop run_loop;
583 std::unique_ptr<CallbackTester> tester(
584 new CallbackTester(run_loop.QuitClosure()));
585 RunInstallableManager(tester.get(), GetWebAppParams());
586
587 run_loop.Run();
588
589 // The smaller icon requirements should allow this to pass.
590 EXPECT_FALSE(tester->manifest_url().is_empty());
591 EXPECT_FALSE(tester->manifest().IsEmpty());
592 EXPECT_TRUE(tester->is_installable());
593 EXPECT_FALSE(tester->icon_url().is_empty());
594 EXPECT_NE(nullptr, tester->icon());
595 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
596 }
597 }
598
599 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
600 CheckNestedCallsToGetData) {
601 // Verify that we can call GetData while in a callback from GetData.
602 base::RunLoop run_loop;
603 InstallableParams params = GetWebAppParams();
604 std::unique_ptr<NestedCallbackTester> tester(
605 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure()));
606
607 tester->Run();
608 run_loop.Run();
609 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698