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

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

Issue 2641413002: Allow InstallableManager to fetch optional badge icon (Closed)
Patch Set: Addressing comments Created 3 years, 10 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
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"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "net/test/embedded_test_server/embedded_test_server.h" 15 #include "net/test/embedded_test_server/embedded_test_server.h"
16 16
17 using IconPurpose = content::Manifest::Icon::IconPurpose;
18
17 namespace { 19 namespace {
18 20
21 const std::tuple<int, int, IconPurpose> kPrimaryIconParams{144, 144,
22 IconPurpose::ANY};
23
19 InstallableParams GetManifestParams() { 24 InstallableParams GetManifestParams() {
20 InstallableParams params; 25 InstallableParams params;
21 params.check_installable = false; 26 params.check_installable = false;
22 params.fetch_valid_primary_icon = false; 27 params.fetch_valid_primary_icon = false;
23 return params; 28 return params;
24 } 29 }
25 30
26 InstallableParams GetWebAppParams() { 31 InstallableParams GetWebAppParams() {
27 InstallableParams params = GetManifestParams(); 32 InstallableParams params = GetManifestParams();
28 params.ideal_primary_icon_size_in_px = 144; 33 params.ideal_primary_icon_size_in_px = 144;
29 params.minimum_primary_icon_size_in_px = 144; 34 params.minimum_primary_icon_size_in_px = 144;
30 params.check_installable = true; 35 params.check_installable = true;
31 params.fetch_valid_primary_icon = true; 36 params.fetch_valid_primary_icon = true;
32 return params; 37 return params;
33 } 38 }
34 39
35 InstallableParams GetIconParams() { 40 InstallableParams GetPrimaryIconParams() {
36 InstallableParams params = GetManifestParams(); 41 InstallableParams params = GetManifestParams();
37 params.ideal_primary_icon_size_in_px = 144; 42 params.ideal_primary_icon_size_in_px = 144;
38 params.minimum_primary_icon_size_in_px = 144; 43 params.minimum_primary_icon_size_in_px = 144;
39 params.fetch_valid_primary_icon = true; 44 params.fetch_valid_primary_icon = true;
40 return params; 45 return params;
41 } 46 }
42 47
48 InstallableParams GetPrimaryIconAndBadgeIconParams() {
49 InstallableParams params = GetManifestParams();
50 params.ideal_primary_icon_size_in_px = 144;
51 params.minimum_primary_icon_size_in_px = 144;
52 params.fetch_valid_primary_icon = true;
53 params.ideal_badge_icon_size_in_px = 72;
54 params.minimum_badge_icon_size_in_px = 72;
55 params.fetch_valid_badge_icon = true;
56 return params;
57 }
58
43 } // anonymous namespace 59 } // anonymous namespace
44 60
45 class CallbackTester { 61 class CallbackTester {
46 public: 62 public:
47 explicit CallbackTester(base::Closure quit_closure) 63 explicit CallbackTester(base::Closure quit_closure)
48 : quit_closure_(quit_closure) { } 64 : quit_closure_(quit_closure) { }
49 65
50 void OnDidFinishInstallableCheck(const InstallableData& data) { 66 void OnDidFinishInstallableCheck(const InstallableData& data) {
51 error_code_ = data.error_code; 67 error_code_ = data.error_code;
52 manifest_url_ = data.manifest_url; 68 manifest_url_ = data.manifest_url;
53 manifest_ = data.manifest; 69 manifest_ = data.manifest;
54 icon_url_ = data.primary_icon_url; 70 primary_icon_url_ = data.primary_icon_url;
55 if (data.primary_icon) 71 if (data.primary_icon)
56 icon_.reset(new SkBitmap(*data.primary_icon)); 72 primary_icon_.reset(new SkBitmap(*data.primary_icon));
73 badge_icon_url_ = data.badge_icon_url;
74 if (data.badge_icon)
75 badge_icon_.reset(new SkBitmap(*data.badge_icon));
57 is_installable_ = data.is_installable; 76 is_installable_ = data.is_installable;
58 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); 77 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_);
59 } 78 }
60 79
61 InstallableStatusCode error_code() const { return error_code_; } 80 InstallableStatusCode error_code() const { return error_code_; }
62 const GURL& manifest_url() const { return manifest_url_; } 81 const GURL& manifest_url() const { return manifest_url_; }
63 const content::Manifest& manifest() const { return manifest_; } 82 const content::Manifest& manifest() const { return manifest_; }
64 const GURL& icon_url() const { return icon_url_; } 83 const GURL& primary_icon_url() const { return primary_icon_url_; }
65 const SkBitmap* icon() const { return icon_.get(); } 84 const SkBitmap* primary_icon() const { return primary_icon_.get(); }
85 const GURL& badge_icon_url() const { return badge_icon_url_; }
86 const SkBitmap* badge_icon() const { return badge_icon_.get(); }
66 bool is_installable() const { return is_installable_; } 87 bool is_installable() const { return is_installable_; }
67 88
68 private: 89 private:
69 base::Closure quit_closure_; 90 base::Closure quit_closure_;
70 InstallableStatusCode error_code_; 91 InstallableStatusCode error_code_;
71 GURL manifest_url_; 92 GURL manifest_url_;
72 content::Manifest manifest_; 93 content::Manifest manifest_;
73 GURL icon_url_; 94 GURL primary_icon_url_;
74 std::unique_ptr<SkBitmap> icon_; 95 std::unique_ptr<SkBitmap> primary_icon_;
96 GURL badge_icon_url_;
97 std::unique_ptr<SkBitmap> badge_icon_;
75 bool is_installable_; 98 bool is_installable_;
76 }; 99 };
77 100
78 class NestedCallbackTester { 101 class NestedCallbackTester {
79 public: 102 public:
80 NestedCallbackTester(InstallableManager* manager, 103 NestedCallbackTester(InstallableManager* manager,
81 const InstallableParams& params, 104 const InstallableParams& params,
82 base::Closure quit_closure) 105 base::Closure quit_closure)
83 : manager_(manager), params_(params), quit_closure_(quit_closure) {} 106 : manager_(manager), params_(params), quit_closure_(quit_closure) {}
84 107
85 void Run() { 108 void Run() {
86 manager_->GetData(params_, 109 manager_->GetData(params_,
87 base::Bind(&NestedCallbackTester::OnDidFinishFirstCheck, 110 base::Bind(&NestedCallbackTester::OnDidFinishFirstCheck,
88 base::Unretained(this))); 111 base::Unretained(this)));
89 } 112 }
90 113
91 void OnDidFinishFirstCheck(const InstallableData& data) { 114 void OnDidFinishFirstCheck(const InstallableData& data) {
92 error_code_ = data.error_code; 115 error_code_ = data.error_code;
93 manifest_url_ = data.manifest_url; 116 manifest_url_ = data.manifest_url;
94 manifest_ = data.manifest; 117 manifest_ = data.manifest;
95 icon_url_ = data.primary_icon_url; 118 primary_icon_url_ = data.primary_icon_url;
96 if (data.primary_icon) 119 if (data.primary_icon)
97 icon_.reset(new SkBitmap(*data.primary_icon)); 120 primary_icon_.reset(new SkBitmap(*data.primary_icon));
98 is_installable_ = data.is_installable; 121 is_installable_ = data.is_installable;
99 122
100 manager_->GetData(params_, 123 manager_->GetData(params_,
101 base::Bind(&NestedCallbackTester::OnDidFinishSecondCheck, 124 base::Bind(&NestedCallbackTester::OnDidFinishSecondCheck,
102 base::Unretained(this))); 125 base::Unretained(this)));
103 } 126 }
104 127
105 void OnDidFinishSecondCheck(const InstallableData& data) { 128 void OnDidFinishSecondCheck(const InstallableData& data) {
106 EXPECT_EQ(error_code_, data.error_code); 129 EXPECT_EQ(error_code_, data.error_code);
107 EXPECT_EQ(manifest_url_, data.manifest_url); 130 EXPECT_EQ(manifest_url_, data.manifest_url);
108 EXPECT_EQ(icon_url_, data.primary_icon_url); 131 EXPECT_EQ(primary_icon_url_, data.primary_icon_url);
109 EXPECT_EQ(icon_.get(), data.primary_icon); 132 EXPECT_EQ(primary_icon_.get(), data.primary_icon);
110 EXPECT_EQ(is_installable_, data.is_installable); 133 EXPECT_EQ(is_installable_, data.is_installable);
111 EXPECT_EQ(manifest_.IsEmpty(), data.manifest.IsEmpty()); 134 EXPECT_EQ(manifest_.IsEmpty(), data.manifest.IsEmpty());
112 EXPECT_EQ(manifest_.start_url, data.manifest.start_url); 135 EXPECT_EQ(manifest_.start_url, data.manifest.start_url);
113 EXPECT_EQ(manifest_.display, data.manifest.display); 136 EXPECT_EQ(manifest_.display, data.manifest.display);
114 EXPECT_EQ(manifest_.name, data.manifest.name); 137 EXPECT_EQ(manifest_.name, data.manifest.name);
115 EXPECT_EQ(manifest_.short_name, data.manifest.short_name); 138 EXPECT_EQ(manifest_.short_name, data.manifest.short_name);
116 139
117 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_); 140 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, quit_closure_);
118 } 141 }
119 142
120 private: 143 private:
121 InstallableManager* manager_; 144 InstallableManager* manager_;
122 InstallableParams params_; 145 InstallableParams params_;
123 base::Closure quit_closure_; 146 base::Closure quit_closure_;
124 InstallableStatusCode error_code_; 147 InstallableStatusCode error_code_;
125 GURL manifest_url_; 148 GURL manifest_url_;
126 content::Manifest manifest_; 149 content::Manifest manifest_;
127 GURL icon_url_; 150 GURL primary_icon_url_;
128 std::unique_ptr<SkBitmap> icon_; 151 std::unique_ptr<SkBitmap> primary_icon_;
129 bool is_installable_; 152 bool is_installable_;
130 }; 153 };
131 154
132 class InstallableManagerBrowserTest : public InProcessBrowserTest { 155 class InstallableManagerBrowserTest : public InProcessBrowserTest {
133 public: 156 public:
134 void SetUpOnMainThread() override { 157 void SetUpOnMainThread() override {
135 InProcessBrowserTest::SetUpOnMainThread(); 158 InProcessBrowserTest::SetUpOnMainThread();
136 ASSERT_TRUE(embedded_test_server()->Start()); 159 ASSERT_TRUE(embedded_test_server()->Start());
137 } 160 }
138 161
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 std::unique_ptr<CallbackTester> tester( 224 std::unique_ptr<CallbackTester> tester(
202 new CallbackTester(run_loop.QuitClosure())); 225 new CallbackTester(run_loop.QuitClosure()));
203 226
204 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), 227 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
205 "/banners/no_manifest_test_page.html"); 228 "/banners/no_manifest_test_page.html");
206 run_loop.Run(); 229 run_loop.Run();
207 230
208 // If there is no manifest, everything should be empty. 231 // If there is no manifest, everything should be empty.
209 EXPECT_TRUE(tester->manifest().IsEmpty()); 232 EXPECT_TRUE(tester->manifest().IsEmpty());
210 EXPECT_TRUE(tester->manifest_url().is_empty()); 233 EXPECT_TRUE(tester->manifest_url().is_empty());
211 EXPECT_TRUE(tester->icon_url().is_empty()); 234 EXPECT_TRUE(tester->primary_icon_url().is_empty());
212 EXPECT_EQ(nullptr, tester->icon()); 235 EXPECT_EQ(nullptr, tester->primary_icon());
236 EXPECT_TRUE(tester->badge_icon_url().is_empty());
237 EXPECT_EQ(nullptr, tester->badge_icon());
213 EXPECT_FALSE(tester->is_installable()); 238 EXPECT_FALSE(tester->is_installable());
214 EXPECT_EQ(NO_MANIFEST, tester->error_code()); 239 EXPECT_EQ(NO_MANIFEST, tester->error_code());
215 } 240 }
216 241
217 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifest404) { 242 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifest404) {
218 base::RunLoop run_loop; 243 base::RunLoop run_loop;
219 std::unique_ptr<CallbackTester> tester( 244 std::unique_ptr<CallbackTester> tester(
220 new CallbackTester(run_loop.QuitClosure())); 245 new CallbackTester(run_loop.QuitClosure()));
221 246
222 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), 247 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
223 GetURLOfPageWithServiceWorkerAndManifest( 248 GetURLOfPageWithServiceWorkerAndManifest(
224 "/banners/manifest_missing.json")); 249 "/banners/manifest_missing.json"));
225 run_loop.Run(); 250 run_loop.Run();
226 251
227 // 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.
228 // However, the check should fail with a ManifestEmpty error. 253 // However, the check should fail with a ManifestEmpty error.
229 EXPECT_TRUE(tester->manifest().IsEmpty()); 254 EXPECT_TRUE(tester->manifest().IsEmpty());
230 255
231 EXPECT_FALSE(tester->manifest_url().is_empty()); 256 EXPECT_FALSE(tester->manifest_url().is_empty());
232 EXPECT_TRUE(tester->icon_url().is_empty()); 257 EXPECT_TRUE(tester->primary_icon_url().is_empty());
233 EXPECT_EQ(nullptr, tester->icon()); 258 EXPECT_EQ(nullptr, tester->primary_icon());
259 EXPECT_TRUE(tester->badge_icon_url().is_empty());
260 EXPECT_EQ(nullptr, tester->badge_icon());
234 EXPECT_FALSE(tester->is_installable()); 261 EXPECT_FALSE(tester->is_installable());
235 EXPECT_EQ(MANIFEST_EMPTY, tester->error_code()); 262 EXPECT_EQ(MANIFEST_EMPTY, tester->error_code());
236 } 263 }
237 264
238 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestOnly) { 265 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestOnly) {
239 // Verify that asking for just the manifest works as expected. 266 // Verify that asking for just the manifest works as expected.
240 base::RunLoop run_loop; 267 base::RunLoop run_loop;
241 std::unique_ptr<CallbackTester> tester( 268 std::unique_ptr<CallbackTester> tester(
242 new CallbackTester(run_loop.QuitClosure())); 269 new CallbackTester(run_loop.QuitClosure()));
243 270
244 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), 271 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
245 "/banners/manifest_test_page.html"); 272 "/banners/manifest_test_page.html");
246 run_loop.Run(); 273 run_loop.Run();
247 274
248 EXPECT_FALSE(tester->manifest().IsEmpty()); 275 EXPECT_FALSE(tester->manifest().IsEmpty());
249 EXPECT_FALSE(tester->manifest_url().is_empty()); 276 EXPECT_FALSE(tester->manifest_url().is_empty());
250 277
251 EXPECT_TRUE(tester->icon_url().is_empty()); 278 EXPECT_TRUE(tester->primary_icon_url().is_empty());
252 EXPECT_EQ(nullptr, tester->icon()); 279 EXPECT_EQ(nullptr, tester->primary_icon());
280 EXPECT_TRUE(tester->badge_icon_url().is_empty());
281 EXPECT_EQ(nullptr, tester->badge_icon());
253 EXPECT_FALSE(tester->is_installable()); 282 EXPECT_FALSE(tester->is_installable());
254 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 283 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
255 } 284 }
256 285
257 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 286 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
258 CheckInstallableParamsDefaultConstructor) { 287 CheckInstallableParamsDefaultConstructor) {
259 // Verify that using InstallableParams' default constructor is equivalent to 288 // Verify that using InstallableParams' default constructor is equivalent to
260 // just asking for the manifest alone. 289 // just asking for the manifest alone.
261 base::RunLoop run_loop; 290 base::RunLoop run_loop;
262 std::unique_ptr<CallbackTester> tester( 291 std::unique_ptr<CallbackTester> tester(
263 new CallbackTester(run_loop.QuitClosure())); 292 new CallbackTester(run_loop.QuitClosure()));
264 293
265 InstallableParams params; 294 InstallableParams params;
266 NavigateAndRunInstallableManager(tester.get(), params, 295 NavigateAndRunInstallableManager(tester.get(), params,
267 "/banners/manifest_test_page.html"); 296 "/banners/manifest_test_page.html");
268 run_loop.Run(); 297 run_loop.Run();
269 298
270 EXPECT_FALSE(tester->manifest().IsEmpty()); 299 EXPECT_FALSE(tester->manifest().IsEmpty());
271 EXPECT_FALSE(tester->manifest_url().is_empty()); 300 EXPECT_FALSE(tester->manifest_url().is_empty());
272 301
273 EXPECT_TRUE(tester->icon_url().is_empty()); 302 EXPECT_TRUE(tester->primary_icon_url().is_empty());
274 EXPECT_EQ(nullptr, tester->icon()); 303 EXPECT_EQ(nullptr, tester->primary_icon());
304 EXPECT_TRUE(tester->badge_icon_url().is_empty());
305 EXPECT_EQ(nullptr, tester->badge_icon());
275 EXPECT_FALSE(tester->is_installable()); 306 EXPECT_FALSE(tester->is_installable());
276 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 307 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
277 } 308 }
278 309
279 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 310 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
280 CheckManifestWithOnlyRelatedApplications) { 311 CheckManifestWithOnlyRelatedApplications) {
281 // This page has a manifest with only related applications specified. Asking 312 // This page has a manifest with only related applications specified. Asking
282 // for just the manifest should succeed. 313 // for just the manifest should succeed.
283 { 314 {
284 base::RunLoop run_loop; 315 base::RunLoop run_loop;
285 std::unique_ptr<CallbackTester> tester( 316 std::unique_ptr<CallbackTester> tester(
286 new CallbackTester(run_loop.QuitClosure())); 317 new CallbackTester(run_loop.QuitClosure()));
287 318
288 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), 319 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
289 "/banners/play_app_test_page.html"); 320 "/banners/play_app_test_page.html");
290 run_loop.Run(); 321 run_loop.Run();
291 322
292 EXPECT_FALSE(tester->manifest().IsEmpty()); 323 EXPECT_FALSE(tester->manifest().IsEmpty());
293 EXPECT_FALSE(tester->manifest_url().is_empty()); 324 EXPECT_FALSE(tester->manifest_url().is_empty());
294 EXPECT_TRUE(tester->manifest().prefer_related_applications); 325 EXPECT_TRUE(tester->manifest().prefer_related_applications);
295 326
296 EXPECT_TRUE(tester->icon_url().is_empty()); 327 EXPECT_TRUE(tester->primary_icon_url().is_empty());
297 EXPECT_EQ(nullptr, tester->icon()); 328 EXPECT_EQ(nullptr, tester->primary_icon());
329 EXPECT_TRUE(tester->badge_icon_url().is_empty());
330 EXPECT_EQ(nullptr, tester->badge_icon());
298 EXPECT_FALSE(tester->is_installable()); 331 EXPECT_FALSE(tester->is_installable());
299 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 332 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
300 } 333 }
301 334
302 // Ask for an icon (but don't navigate). This should fail with 335 // Ask for a primary icon (but don't navigate). This should fail with
303 // NO_ACCEPTABLE_ICON. 336 // NO_ACCEPTABLE_ICON.
304 { 337 {
305 base::RunLoop run_loop; 338 base::RunLoop run_loop;
306 std::unique_ptr<CallbackTester> tester( 339 std::unique_ptr<CallbackTester> tester(
307 new CallbackTester(run_loop.QuitClosure())); 340 new CallbackTester(run_loop.QuitClosure()));
308 341
309 RunInstallableManager(tester.get(), GetIconParams()); 342 RunInstallableManager(tester.get(), GetPrimaryIconParams());
310 run_loop.Run(); 343 run_loop.Run();
311 344
312 EXPECT_FALSE(tester->manifest().IsEmpty()); 345 EXPECT_FALSE(tester->manifest().IsEmpty());
313 EXPECT_FALSE(tester->manifest_url().is_empty()); 346 EXPECT_FALSE(tester->manifest_url().is_empty());
314 EXPECT_TRUE(tester->manifest().prefer_related_applications); 347 EXPECT_TRUE(tester->manifest().prefer_related_applications);
315 348
316 EXPECT_TRUE(tester->icon_url().is_empty()); 349 EXPECT_TRUE(tester->primary_icon_url().is_empty());
317 EXPECT_EQ(nullptr, tester->icon()); 350 EXPECT_EQ(nullptr, tester->primary_icon());
351 EXPECT_TRUE(tester->badge_icon_url().is_empty());
352 EXPECT_EQ(nullptr, tester->badge_icon());
318 EXPECT_FALSE(tester->is_installable()); 353 EXPECT_FALSE(tester->is_installable());
319 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 354 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
320 } 355 }
321 356
322 // Ask for everything. This should fail with NO_ACCEPTABLE_ICON - the icon 357 // Ask for everything except badge icon. This should fail with
323 // fetch has already failed, so that cached error stops the installable check 358 // NO_ACCEPTABLE_ICON - the primary icon fetch has already failed, so that
324 // from being performed. 359 // cached error stops the installable check from being performed.
325 { 360 {
326 base::RunLoop run_loop; 361 base::RunLoop run_loop;
327 std::unique_ptr<CallbackTester> tester( 362 std::unique_ptr<CallbackTester> tester(
328 new CallbackTester(run_loop.QuitClosure())); 363 new CallbackTester(run_loop.QuitClosure()));
329 364
330 RunInstallableManager(tester.get(), GetWebAppParams()); 365 RunInstallableManager(tester.get(), GetWebAppParams());
331 run_loop.Run(); 366 run_loop.Run();
332 367
333 EXPECT_FALSE(tester->manifest().IsEmpty()); 368 EXPECT_FALSE(tester->manifest().IsEmpty());
334 EXPECT_FALSE(tester->manifest_url().is_empty()); 369 EXPECT_FALSE(tester->manifest_url().is_empty());
335 EXPECT_TRUE(tester->manifest().prefer_related_applications); 370 EXPECT_TRUE(tester->manifest().prefer_related_applications);
336 371
337 EXPECT_TRUE(tester->icon_url().is_empty()); 372 EXPECT_TRUE(tester->primary_icon_url().is_empty());
338 EXPECT_EQ(nullptr, tester->icon()); 373 EXPECT_EQ(nullptr, tester->primary_icon());
374 EXPECT_TRUE(tester->badge_icon_url().is_empty());
375 EXPECT_EQ(nullptr, tester->badge_icon());
339 EXPECT_FALSE(tester->is_installable()); 376 EXPECT_FALSE(tester->is_installable());
340 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 377 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
341 } 378 }
342 379
343 // Ask for a different size icon. This should fail with START_URL_NOT_VALID 380 // Ask for a different size primary icon. This should fail with
344 // since we won't have a cached icon error. 381 // START_URL_NOT_VALID since we won't have a cached icon error.
345 { 382 {
346 base::RunLoop run_loop; 383 base::RunLoop run_loop;
347 std::unique_ptr<CallbackTester> tester( 384 std::unique_ptr<CallbackTester> tester(
348 new CallbackTester(run_loop.QuitClosure())); 385 new CallbackTester(run_loop.QuitClosure()));
349 386
350 InstallableParams params = GetWebAppParams(); 387 InstallableParams params = GetWebAppParams();
351 params.ideal_primary_icon_size_in_px = 96; 388 params.ideal_primary_icon_size_in_px = 96;
352 params.minimum_primary_icon_size_in_px = 96; 389 params.minimum_primary_icon_size_in_px = 96;
353 RunInstallableManager(tester.get(), params); 390 RunInstallableManager(tester.get(), params);
354 run_loop.Run(); 391 run_loop.Run();
355 392
356 EXPECT_FALSE(tester->manifest().IsEmpty()); 393 EXPECT_FALSE(tester->manifest().IsEmpty());
357 EXPECT_FALSE(tester->manifest_url().is_empty()); 394 EXPECT_FALSE(tester->manifest_url().is_empty());
358 EXPECT_TRUE(tester->manifest().prefer_related_applications); 395 EXPECT_TRUE(tester->manifest().prefer_related_applications);
359 396
360 EXPECT_TRUE(tester->icon_url().is_empty()); 397 EXPECT_TRUE(tester->primary_icon_url().is_empty());
361 EXPECT_EQ(nullptr, tester->icon()); 398 EXPECT_EQ(nullptr, tester->primary_icon());
399 EXPECT_TRUE(tester->badge_icon_url().is_empty());
400 EXPECT_EQ(nullptr, tester->badge_icon());
362 EXPECT_FALSE(tester->is_installable()); 401 EXPECT_FALSE(tester->is_installable());
363 EXPECT_EQ(START_URL_NOT_VALID, tester->error_code()); 402 EXPECT_EQ(START_URL_NOT_VALID, tester->error_code());
364 } 403 }
365 } 404 }
366 405
367 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestAndIcon) { 406 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestAndIcon) {
368 // Add to homescreen checks for manifest + icon. 407 // Add to homescreen checks for manifest + primary icon.
369 base::RunLoop run_loop; 408 {
370 std::unique_ptr<CallbackTester> tester( 409 base::RunLoop run_loop;
371 new CallbackTester(run_loop.QuitClosure())); 410 std::unique_ptr<CallbackTester> tester(
411 new CallbackTester(run_loop.QuitClosure()));
372 412
373 NavigateAndRunInstallableManager(tester.get(), GetIconParams(), 413 NavigateAndRunInstallableManager(tester.get(), GetPrimaryIconParams(),
374 "/banners/manifest_test_page.html"); 414 "/banners/manifest_test_page.html");
375 run_loop.Run(); 415 run_loop.Run();
376 416
377 EXPECT_FALSE(tester->manifest().IsEmpty()); 417 EXPECT_FALSE(tester->manifest().IsEmpty());
378 EXPECT_FALSE(tester->manifest_url().is_empty()); 418 EXPECT_FALSE(tester->manifest_url().is_empty());
379 419
380 EXPECT_FALSE(tester->icon_url().is_empty()); 420 EXPECT_FALSE(tester->primary_icon_url().is_empty());
381 EXPECT_NE(nullptr, tester->icon()); 421 EXPECT_NE(nullptr, tester->primary_icon());
422 EXPECT_TRUE(tester->badge_icon_url().is_empty());
423 EXPECT_EQ(nullptr, tester->badge_icon());
382 424
383 EXPECT_FALSE(tester->is_installable()); 425 EXPECT_FALSE(tester->is_installable());
384 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 426 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
427 }
428
429 // Add to homescreen checks for manifest + primary icon + badge icon.
430 {
431 base::RunLoop run_loop;
432 std::unique_ptr<CallbackTester> tester(
433 new CallbackTester(run_loop.QuitClosure()));
434
435 RunInstallableManager(tester.get(), GetPrimaryIconAndBadgeIconParams());
436 run_loop.Run();
437
438 EXPECT_FALSE(tester->manifest().IsEmpty());
439 EXPECT_FALSE(tester->manifest_url().is_empty());
440
441 EXPECT_FALSE(tester->primary_icon_url().is_empty());
442 EXPECT_NE(nullptr, tester->primary_icon());
443
dominickn 2017/01/30 00:51:27 Minor nit: remove the line breaks in between icon
F 2017/01/30 16:50:06 Done.
444 EXPECT_FALSE(tester->badge_icon_url().is_empty());
445 EXPECT_NE(nullptr, tester->badge_icon());
446
447 EXPECT_FALSE(tester->is_installable());
448 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
449 }
450
451 // Request an oversized badge icon. This should fetch only the manifest and
452 // the primary icon, and return no errors.
453 {
454 base::RunLoop run_loop;
455 std::unique_ptr<CallbackTester> tester(
456 new CallbackTester(run_loop.QuitClosure()));
457
458 InstallableParams params = GetPrimaryIconAndBadgeIconParams();
459 params.ideal_badge_icon_size_in_px = 2000;
460 params.minimum_badge_icon_size_in_px = 2000;
461 RunInstallableManager(tester.get(), params);
462 run_loop.Run();
463
464 EXPECT_FALSE(tester->manifest().IsEmpty());
465 EXPECT_FALSE(tester->manifest_url().is_empty());
466
467 EXPECT_FALSE(tester->primary_icon_url().is_empty());
468 EXPECT_NE(nullptr, tester->primary_icon());
469
dominickn 2017/01/30 00:51:27 Ditto re line breaks
F 2017/01/30 16:50:06 Done.
470 EXPECT_TRUE(tester->badge_icon_url().is_empty());
471 EXPECT_EQ(nullptr, tester->badge_icon());
472
473 EXPECT_FALSE(tester->is_installable());
474 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
475 }
385 } 476 }
386 477
387 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) { 478 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) {
388 // Request everything. 479 // Request everything except badge icon.
389 { 480 {
390 base::RunLoop run_loop; 481 base::RunLoop run_loop;
391 std::unique_ptr<CallbackTester> tester( 482 std::unique_ptr<CallbackTester> tester(
392 new CallbackTester(run_loop.QuitClosure())); 483 new CallbackTester(run_loop.QuitClosure()));
393 484
394 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), 485 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
395 "/banners/manifest_test_page.html"); 486 "/banners/manifest_test_page.html");
396 run_loop.Run(); 487 run_loop.Run();
397 488
398 EXPECT_FALSE(tester->manifest().IsEmpty()); 489 EXPECT_FALSE(tester->manifest().IsEmpty());
399 EXPECT_FALSE(tester->manifest_url().is_empty()); 490 EXPECT_FALSE(tester->manifest_url().is_empty());
400 EXPECT_TRUE(tester->is_installable()); 491 EXPECT_TRUE(tester->is_installable());
401 EXPECT_FALSE(tester->icon_url().is_empty()); 492 EXPECT_FALSE(tester->primary_icon_url().is_empty());
402 EXPECT_NE(nullptr, tester->icon()); 493 EXPECT_NE(nullptr, tester->primary_icon());
494 EXPECT_TRUE(tester->badge_icon_url().is_empty());
495 EXPECT_EQ(nullptr, tester->badge_icon());
403 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 496 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
404 497
405 // Verify that the returned state matches manager internal state. 498 // Verify that the returned state matches manager internal state.
406 InstallableManager* manager = GetManager(); 499 InstallableManager* manager = GetManager();
407 500
408 EXPECT_FALSE(manager->manifest().IsEmpty()); 501 EXPECT_FALSE(manager->manifest().IsEmpty());
409 EXPECT_FALSE(manager->manifest_url().is_empty()); 502 EXPECT_FALSE(manager->manifest_url().is_empty());
410 EXPECT_TRUE(manager->is_installable()); 503 EXPECT_TRUE(manager->is_installable());
411 EXPECT_EQ(1u, manager->icons_.size()); 504 EXPECT_EQ(1u, manager->icons_.size());
412 EXPECT_FALSE((manager->icon_url({144,144}).is_empty())); 505 EXPECT_FALSE((manager->icon_url(kPrimaryIconParams).is_empty()));
413 EXPECT_NE(nullptr, (manager->icon({144,144}))); 506 EXPECT_NE(nullptr, (manager->icon(kPrimaryIconParams)));
414 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error()); 507 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error());
415 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error()); 508 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error());
416 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error({144,144}))); 509 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error(kPrimaryIconParams)));
417 EXPECT_TRUE(manager->tasks_.empty()); 510 EXPECT_TRUE(manager->tasks_.empty());
418 } 511 }
419 512
420 // Request everything again without navigating away. This should work fine. 513 // Request everything except badge icon again without navigating away. This
514 // should work fine.
421 { 515 {
422 base::RunLoop run_loop; 516 base::RunLoop run_loop;
423 std::unique_ptr<CallbackTester> tester( 517 std::unique_ptr<CallbackTester> tester(
424 new CallbackTester(run_loop.QuitClosure())); 518 new CallbackTester(run_loop.QuitClosure()));
425 519
426 RunInstallableManager(tester.get(), GetWebAppParams()); 520 RunInstallableManager(tester.get(), GetWebAppParams());
427 run_loop.Run(); 521 run_loop.Run();
428 522
429 EXPECT_FALSE(tester->manifest().IsEmpty()); 523 EXPECT_FALSE(tester->manifest().IsEmpty());
430 EXPECT_FALSE(tester->manifest_url().is_empty()); 524 EXPECT_FALSE(tester->manifest_url().is_empty());
431 EXPECT_TRUE(tester->is_installable()); 525 EXPECT_TRUE(tester->is_installable());
432 EXPECT_FALSE(tester->icon_url().is_empty()); 526 EXPECT_FALSE(tester->primary_icon_url().is_empty());
433 EXPECT_NE(nullptr, tester->icon()); 527 EXPECT_NE(nullptr, tester->primary_icon());
528 EXPECT_TRUE(tester->badge_icon_url().is_empty());
529 EXPECT_EQ(nullptr, tester->badge_icon());
434 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 530 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
435 531
436 // Verify that the returned state matches manager internal state. 532 // Verify that the returned state matches manager internal state.
437 InstallableManager* manager = GetManager(); 533 InstallableManager* manager = GetManager();
438 534
439 EXPECT_FALSE(manager->manifest().IsEmpty()); 535 EXPECT_FALSE(manager->manifest().IsEmpty());
440 EXPECT_FALSE(manager->manifest_url().is_empty()); 536 EXPECT_FALSE(manager->manifest_url().is_empty());
441 EXPECT_TRUE(manager->is_installable()); 537 EXPECT_TRUE(manager->is_installable());
442 EXPECT_EQ(1u, manager->icons_.size()); 538 EXPECT_EQ(1u, manager->icons_.size());
443 EXPECT_FALSE((manager->icon_url({144,144}).is_empty())); 539 EXPECT_FALSE((manager->icon_url(kPrimaryIconParams).is_empty()));
444 EXPECT_NE(nullptr, (manager->icon({144,144}))); 540 EXPECT_NE(nullptr, (manager->icon(kPrimaryIconParams)));
445 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error()); 541 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error());
446 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error()); 542 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error());
447 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error({144,144}))); 543 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error(kPrimaryIconParams)));
448 EXPECT_TRUE(manager->tasks_.empty()); 544 EXPECT_TRUE(manager->tasks_.empty());
449 } 545 }
450 546
451 { 547 {
452 // Check that a subsequent navigation resets state. 548 // Check that a subsequent navigation resets state.
453 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 549 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
454 InstallableManager* manager = GetManager(); 550 InstallableManager* manager = GetManager();
455 551
456 EXPECT_TRUE(manager->manifest().IsEmpty()); 552 EXPECT_TRUE(manager->manifest().IsEmpty());
457 EXPECT_TRUE(manager->manifest_url().is_empty()); 553 EXPECT_TRUE(manager->manifest_url().is_empty());
(...skipping 11 matching lines...) Expand all
469 new CallbackTester(run_loop.QuitClosure())); 565 new CallbackTester(run_loop.QuitClosure()));
470 566
471 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), 567 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
472 "/banners/iframe_test_page.html"); 568 "/banners/iframe_test_page.html");
473 run_loop.Run(); 569 run_loop.Run();
474 570
475 // The installable manager should only retrieve items in the main frame; 571 // The installable manager should only retrieve items in the main frame;
476 // everything should be empty here. 572 // everything should be empty here.
477 EXPECT_TRUE(tester->manifest().IsEmpty()); 573 EXPECT_TRUE(tester->manifest().IsEmpty());
478 EXPECT_TRUE(tester->manifest_url().is_empty()); 574 EXPECT_TRUE(tester->manifest_url().is_empty());
479 EXPECT_TRUE(tester->icon_url().is_empty()); 575 EXPECT_TRUE(tester->primary_icon_url().is_empty());
480 EXPECT_EQ(nullptr, tester->icon()); 576 EXPECT_EQ(nullptr, tester->primary_icon());
577 EXPECT_TRUE(tester->badge_icon_url().is_empty());
578 EXPECT_EQ(nullptr, tester->badge_icon());
481 EXPECT_FALSE(tester->is_installable()); 579 EXPECT_FALSE(tester->is_installable());
482 EXPECT_EQ(NO_MANIFEST, tester->error_code()); 580 EXPECT_EQ(NO_MANIFEST, tester->error_code());
483 } 581 }
484 582
485 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 583 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
486 CheckPageWithManifestAndNoServiceWorker) { 584 CheckPageWithManifestAndNoServiceWorker) {
487 // Just fetch the manifest. This should have no error. 585 // Just fetch the manifest. This should have no error.
488 { 586 {
489 base::RunLoop run_loop; 587 base::RunLoop run_loop;
490 std::unique_ptr<CallbackTester> tester( 588 std::unique_ptr<CallbackTester> tester(
491 new CallbackTester(run_loop.QuitClosure())); 589 new CallbackTester(run_loop.QuitClosure()));
492 590
493 NavigateAndRunInstallableManager( 591 NavigateAndRunInstallableManager(
494 tester.get(), GetManifestParams(), 592 tester.get(), GetManifestParams(),
495 "/banners/manifest_no_service_worker.html"); 593 "/banners/manifest_no_service_worker.html");
496 run_loop.Run(); 594 run_loop.Run();
497 595
498 EXPECT_FALSE(tester->manifest().IsEmpty()); 596 EXPECT_FALSE(tester->manifest().IsEmpty());
499 EXPECT_FALSE(tester->manifest_url().is_empty()); 597 EXPECT_FALSE(tester->manifest_url().is_empty());
500 598
501 EXPECT_TRUE(tester->icon_url().is_empty()); 599 EXPECT_TRUE(tester->primary_icon_url().is_empty());
502 EXPECT_EQ(nullptr, tester->icon()); 600 EXPECT_EQ(nullptr, tester->primary_icon());
601 EXPECT_TRUE(tester->badge_icon_url().is_empty());
602 EXPECT_EQ(nullptr, tester->badge_icon());
503 EXPECT_FALSE(tester->is_installable()); 603 EXPECT_FALSE(tester->is_installable());
504 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 604 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
505 } 605 }
506 606
507 // Fetch the full criteria should fail. 607 // Fetch the full criteria should fail.
508 { 608 {
509 base::RunLoop run_loop; 609 base::RunLoop run_loop;
510 std::unique_ptr<CallbackTester> tester( 610 std::unique_ptr<CallbackTester> tester(
511 new CallbackTester(run_loop.QuitClosure())); 611 new CallbackTester(run_loop.QuitClosure()));
512 612
513 RunInstallableManager(tester.get(), GetWebAppParams()); 613 RunInstallableManager(tester.get(), GetWebAppParams());
514 run_loop.Run(); 614 run_loop.Run();
515 615
516 EXPECT_FALSE(tester->manifest().IsEmpty()); 616 EXPECT_FALSE(tester->manifest().IsEmpty());
517 EXPECT_FALSE(tester->manifest_url().is_empty()); 617 EXPECT_FALSE(tester->manifest_url().is_empty());
518 618
519 EXPECT_TRUE(tester->icon_url().is_empty()); 619 EXPECT_TRUE(tester->primary_icon_url().is_empty());
520 EXPECT_EQ(nullptr, tester->icon()); 620 EXPECT_EQ(nullptr, tester->primary_icon());
621 EXPECT_TRUE(tester->badge_icon_url().is_empty());
622 EXPECT_EQ(nullptr, tester->badge_icon());
521 EXPECT_FALSE(tester->is_installable()); 623 EXPECT_FALSE(tester->is_installable());
522 EXPECT_EQ(NO_MATCHING_SERVICE_WORKER, tester->error_code()); 624 EXPECT_EQ(NO_MATCHING_SERVICE_WORKER, tester->error_code());
523 } 625 }
524 } 626 }
525 627
526 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 628 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
527 CheckManifestCorruptedIcon) { 629 CheckManifestCorruptedIcon) {
528 // Verify that the returned InstallableData::icon is null if the web manifest 630 // Verify that the returned InstallableData::primary_icon is null if the web
529 // points to a corrupt icon. 631 // manifest points to a corrupt primary icon.
530 base::RunLoop run_loop; 632 base::RunLoop run_loop;
531 std::unique_ptr<CallbackTester> tester( 633 std::unique_ptr<CallbackTester> tester(
532 new CallbackTester(run_loop.QuitClosure())); 634 new CallbackTester(run_loop.QuitClosure()));
533 635
534 NavigateAndRunInstallableManager(tester.get(), GetIconParams(), 636 NavigateAndRunInstallableManager(tester.get(), GetPrimaryIconParams(),
535 GetURLOfPageWithServiceWorkerAndManifest( 637 GetURLOfPageWithServiceWorkerAndManifest(
536 "/banners/manifest_bad_icon.json")); 638 "/banners/manifest_bad_icon.json"));
537 run_loop.Run(); 639 run_loop.Run();
538 640
539 EXPECT_FALSE(tester->manifest().IsEmpty()); 641 EXPECT_FALSE(tester->manifest().IsEmpty());
540 EXPECT_FALSE(tester->manifest_url().is_empty()); 642 EXPECT_FALSE(tester->manifest_url().is_empty());
541 EXPECT_TRUE(tester->icon_url().is_empty()); 643 EXPECT_TRUE(tester->primary_icon_url().is_empty());
542 EXPECT_EQ(nullptr, tester->icon()); 644 EXPECT_EQ(nullptr, tester->primary_icon());
645 EXPECT_TRUE(tester->badge_icon_url().is_empty());
646 EXPECT_EQ(nullptr, tester->badge_icon());
543 EXPECT_FALSE(tester->is_installable()); 647 EXPECT_FALSE(tester->is_installable());
544 EXPECT_EQ(NO_ICON_AVAILABLE, tester->error_code()); 648 EXPECT_EQ(NO_ICON_AVAILABLE, tester->error_code());
545 } 649 }
546 650
547 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 651 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
548 CheckChangeInIconDimensions) { 652 CheckChangeInIconDimensions) {
549 // Verify that a follow-up request for an icon with a different size works. 653 // Verify that a follow-up request for a primary icon with a different size
654 // works.
550 { 655 {
551 base::RunLoop run_loop; 656 base::RunLoop run_loop;
552 std::unique_ptr<CallbackTester> tester( 657 std::unique_ptr<CallbackTester> tester(
553 new CallbackTester(run_loop.QuitClosure())); 658 new CallbackTester(run_loop.QuitClosure()));
554 659
555 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), 660 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
556 "/banners/manifest_test_page.html"); 661 "/banners/manifest_test_page.html");
557 run_loop.Run(); 662 run_loop.Run();
558 663
559 EXPECT_FALSE(tester->manifest_url().is_empty()); 664 EXPECT_FALSE(tester->manifest_url().is_empty());
560 EXPECT_FALSE(tester->manifest().IsEmpty()); 665 EXPECT_FALSE(tester->manifest().IsEmpty());
561 EXPECT_TRUE(tester->is_installable()); 666 EXPECT_TRUE(tester->is_installable());
562 EXPECT_FALSE(tester->icon_url().is_empty()); 667 EXPECT_FALSE(tester->primary_icon_url().is_empty());
563 EXPECT_NE(nullptr, tester->icon()); 668 EXPECT_NE(nullptr, tester->primary_icon());
669 EXPECT_TRUE(tester->badge_icon_url().is_empty());
670 EXPECT_EQ(nullptr, tester->badge_icon());
564 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 671 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
565 } 672 }
566 673
567 { 674 {
568 base::RunLoop run_loop; 675 base::RunLoop run_loop;
569 std::unique_ptr<CallbackTester> tester( 676 std::unique_ptr<CallbackTester> tester(
570 new CallbackTester(run_loop.QuitClosure())); 677 new CallbackTester(run_loop.QuitClosure()));
571 678
572 // Dial up the icon size requirements to something that isn't available. 679 // Dial up the primary icon size requirements to something that isn't
573 // This should now fail with NoIconMatchingRequirements. 680 // available. This should now fail with NoIconMatchingRequirements.
574 InstallableParams params = GetWebAppParams(); 681 InstallableParams params = GetWebAppParams();
575 params.ideal_primary_icon_size_in_px = 2000; 682 params.ideal_primary_icon_size_in_px = 2000;
576 params.minimum_primary_icon_size_in_px = 2000; 683 params.minimum_primary_icon_size_in_px = 2000;
577 RunInstallableManager(tester.get(), params); 684 RunInstallableManager(tester.get(), params);
578 run_loop.Run(); 685 run_loop.Run();
579 686
580 EXPECT_FALSE(tester->manifest_url().is_empty()); 687 EXPECT_FALSE(tester->manifest_url().is_empty());
581 EXPECT_FALSE(tester->manifest().IsEmpty()); 688 EXPECT_FALSE(tester->manifest().IsEmpty());
582 EXPECT_TRUE(tester->is_installable()); 689 EXPECT_TRUE(tester->is_installable());
583 EXPECT_TRUE(tester->icon_url().is_empty()); 690 EXPECT_TRUE(tester->primary_icon_url().is_empty());
584 EXPECT_EQ(nullptr, tester->icon()); 691 EXPECT_EQ(nullptr, tester->primary_icon());
692 EXPECT_TRUE(tester->badge_icon_url().is_empty());
693 EXPECT_EQ(nullptr, tester->badge_icon());
585 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 694 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
586 } 695 }
587 696
588 // Navigate and verify the reverse: an overly large icon requested first 697 // Navigate and verify the reverse: an overly large primary icon requested
589 // fails, but a smaller icon requested second passes. 698 // first fails, but a smaller primary icon requested second passes.
590 { 699 {
591 base::RunLoop run_loop; 700 base::RunLoop run_loop;
592 std::unique_ptr<CallbackTester> tester( 701 std::unique_ptr<CallbackTester> tester(
593 new CallbackTester(run_loop.QuitClosure())); 702 new CallbackTester(run_loop.QuitClosure()));
594 703
595 // This should fail with NoIconMatchingRequirements. 704 // This should fail with NoIconMatchingRequirements.
596 InstallableParams params = GetWebAppParams(); 705 InstallableParams params = GetWebAppParams();
597 params.ideal_primary_icon_size_in_px = 2000; 706 params.ideal_primary_icon_size_in_px = 2000;
598 params.minimum_primary_icon_size_in_px = 2000; 707 params.minimum_primary_icon_size_in_px = 2000;
599 NavigateAndRunInstallableManager(tester.get(), params, 708 NavigateAndRunInstallableManager(tester.get(), params,
600 "/banners/manifest_test_page.html"); 709 "/banners/manifest_test_page.html");
601 run_loop.Run(); 710 run_loop.Run();
602 711
603 EXPECT_FALSE(tester->manifest_url().is_empty()); 712 EXPECT_FALSE(tester->manifest_url().is_empty());
604 EXPECT_FALSE(tester->manifest().IsEmpty()); 713 EXPECT_FALSE(tester->manifest().IsEmpty());
605 EXPECT_TRUE(tester->is_installable()); 714 EXPECT_TRUE(tester->is_installable());
606 EXPECT_TRUE(tester->icon_url().is_empty()); 715 EXPECT_TRUE(tester->primary_icon_url().is_empty());
607 EXPECT_EQ(nullptr, tester->icon()); 716 EXPECT_EQ(nullptr, tester->primary_icon());
717 EXPECT_TRUE(tester->badge_icon_url().is_empty());
718 EXPECT_EQ(nullptr, tester->badge_icon());
608 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 719 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
609 } 720 }
610 721
611 { 722 {
612 base::RunLoop run_loop; 723 base::RunLoop run_loop;
613 std::unique_ptr<CallbackTester> tester( 724 std::unique_ptr<CallbackTester> tester(
614 new CallbackTester(run_loop.QuitClosure())); 725 new CallbackTester(run_loop.QuitClosure()));
615 RunInstallableManager(tester.get(), GetWebAppParams()); 726 RunInstallableManager(tester.get(), GetWebAppParams());
616 727
617 run_loop.Run(); 728 run_loop.Run();
618 729
619 // The smaller icon requirements should allow this to pass. 730 // The smaller primary icon requirements should allow this to pass.
620 EXPECT_FALSE(tester->manifest_url().is_empty()); 731 EXPECT_FALSE(tester->manifest_url().is_empty());
621 EXPECT_FALSE(tester->manifest().IsEmpty()); 732 EXPECT_FALSE(tester->manifest().IsEmpty());
622 EXPECT_TRUE(tester->is_installable()); 733 EXPECT_TRUE(tester->is_installable());
623 EXPECT_FALSE(tester->icon_url().is_empty()); 734 EXPECT_FALSE(tester->primary_icon_url().is_empty());
624 EXPECT_NE(nullptr, tester->icon()); 735 EXPECT_NE(nullptr, tester->primary_icon());
736 EXPECT_TRUE(tester->badge_icon_url().is_empty());
737 EXPECT_EQ(nullptr, tester->badge_icon());
625 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 738 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
626 } 739 }
627 } 740 }
628 741
629 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 742 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
630 CheckNestedCallsToGetData) { 743 CheckNestedCallsToGetData) {
631 // Verify that we can call GetData while in a callback from GetData. 744 // Verify that we can call GetData while in a callback from GetData.
632 base::RunLoop run_loop; 745 base::RunLoop run_loop;
633 InstallableParams params = GetWebAppParams(); 746 InstallableParams params = GetWebAppParams();
634 std::unique_ptr<NestedCallbackTester> tester( 747 std::unique_ptr<NestedCallbackTester> tester(
635 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); 748 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure()));
636 749
637 tester->Run(); 750 tester->Run();
638 run_loop.Run(); 751 run_loop.Run();
639 } 752 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698