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

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

Issue 2641413002: Allow InstallableManager to fetch optional badge icon (Closed)
Patch Set: format Created 3 years, 11 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());
dominickn 2017/01/27 06:40:43 Tests which don't fetch the badge should check tha
F 2017/01/27 20:11:17 Done.
212 EXPECT_EQ(nullptr, tester->icon()); 235 EXPECT_EQ(nullptr, tester->primary_icon());
213 EXPECT_FALSE(tester->is_installable()); 236 EXPECT_FALSE(tester->is_installable());
214 EXPECT_EQ(NO_MANIFEST, tester->error_code()); 237 EXPECT_EQ(NO_MANIFEST, tester->error_code());
215 } 238 }
216 239
217 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifest404) { 240 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifest404) {
218 base::RunLoop run_loop; 241 base::RunLoop run_loop;
219 std::unique_ptr<CallbackTester> tester( 242 std::unique_ptr<CallbackTester> tester(
220 new CallbackTester(run_loop.QuitClosure())); 243 new CallbackTester(run_loop.QuitClosure()));
221 244
222 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), 245 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
223 GetURLOfPageWithServiceWorkerAndManifest( 246 GetURLOfPageWithServiceWorkerAndManifest(
224 "/banners/manifest_missing.json")); 247 "/banners/manifest_missing.json"));
225 run_loop.Run(); 248 run_loop.Run();
226 249
227 // The installable manager should return a manifest URL even if it 404s. 250 // The installable manager should return a manifest URL even if it 404s.
228 // However, the check should fail with a ManifestEmpty error. 251 // However, the check should fail with a ManifestEmpty error.
229 EXPECT_TRUE(tester->manifest().IsEmpty()); 252 EXPECT_TRUE(tester->manifest().IsEmpty());
230 253
231 EXPECT_FALSE(tester->manifest_url().is_empty()); 254 EXPECT_FALSE(tester->manifest_url().is_empty());
232 EXPECT_TRUE(tester->icon_url().is_empty()); 255 EXPECT_TRUE(tester->primary_icon_url().is_empty());
233 EXPECT_EQ(nullptr, tester->icon()); 256 EXPECT_EQ(nullptr, tester->primary_icon());
234 EXPECT_FALSE(tester->is_installable()); 257 EXPECT_FALSE(tester->is_installable());
235 EXPECT_EQ(MANIFEST_EMPTY, tester->error_code()); 258 EXPECT_EQ(MANIFEST_EMPTY, tester->error_code());
236 } 259 }
237 260
238 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestOnly) { 261 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestOnly) {
239 // Verify that asking for just the manifest works as expected. 262 // Verify that asking for just the manifest works as expected.
240 base::RunLoop run_loop; 263 base::RunLoop run_loop;
241 std::unique_ptr<CallbackTester> tester( 264 std::unique_ptr<CallbackTester> tester(
242 new CallbackTester(run_loop.QuitClosure())); 265 new CallbackTester(run_loop.QuitClosure()));
243 266
244 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), 267 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
245 "/banners/manifest_test_page.html"); 268 "/banners/manifest_test_page.html");
246 run_loop.Run(); 269 run_loop.Run();
247 270
248 EXPECT_FALSE(tester->manifest().IsEmpty()); 271 EXPECT_FALSE(tester->manifest().IsEmpty());
249 EXPECT_FALSE(tester->manifest_url().is_empty()); 272 EXPECT_FALSE(tester->manifest_url().is_empty());
250 273
251 EXPECT_TRUE(tester->icon_url().is_empty()); 274 EXPECT_TRUE(tester->primary_icon_url().is_empty());
252 EXPECT_EQ(nullptr, tester->icon()); 275 EXPECT_EQ(nullptr, tester->primary_icon());
253 EXPECT_FALSE(tester->is_installable()); 276 EXPECT_FALSE(tester->is_installable());
254 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 277 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
255 } 278 }
256 279
257 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 280 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
258 CheckInstallableParamsDefaultConstructor) { 281 CheckInstallableParamsDefaultConstructor) {
259 // Verify that using InstallableParams' default constructor is equivalent to 282 // Verify that using InstallableParams' default constructor is equivalent to
260 // just asking for the manifest alone. 283 // just asking for the manifest alone.
261 base::RunLoop run_loop; 284 base::RunLoop run_loop;
262 std::unique_ptr<CallbackTester> tester( 285 std::unique_ptr<CallbackTester> tester(
263 new CallbackTester(run_loop.QuitClosure())); 286 new CallbackTester(run_loop.QuitClosure()));
264 287
265 InstallableParams params; 288 InstallableParams params;
266 NavigateAndRunInstallableManager(tester.get(), params, 289 NavigateAndRunInstallableManager(tester.get(), params,
267 "/banners/manifest_test_page.html"); 290 "/banners/manifest_test_page.html");
268 run_loop.Run(); 291 run_loop.Run();
269 292
270 EXPECT_FALSE(tester->manifest().IsEmpty()); 293 EXPECT_FALSE(tester->manifest().IsEmpty());
271 EXPECT_FALSE(tester->manifest_url().is_empty()); 294 EXPECT_FALSE(tester->manifest_url().is_empty());
272 295
273 EXPECT_TRUE(tester->icon_url().is_empty()); 296 EXPECT_TRUE(tester->primary_icon_url().is_empty());
274 EXPECT_EQ(nullptr, tester->icon()); 297 EXPECT_EQ(nullptr, tester->primary_icon());
275 EXPECT_FALSE(tester->is_installable()); 298 EXPECT_FALSE(tester->is_installable());
276 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 299 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
277 } 300 }
278 301
279 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 302 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
280 CheckManifestWithOnlyRelatedApplications) { 303 CheckManifestWithOnlyRelatedApplications) {
281 // This page has a manifest with only related applications specified. Asking 304 // This page has a manifest with only related applications specified. Asking
282 // for just the manifest should succeed. 305 // for just the manifest should succeed.
283 { 306 {
284 base::RunLoop run_loop; 307 base::RunLoop run_loop;
285 std::unique_ptr<CallbackTester> tester( 308 std::unique_ptr<CallbackTester> tester(
286 new CallbackTester(run_loop.QuitClosure())); 309 new CallbackTester(run_loop.QuitClosure()));
287 310
288 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(), 311 NavigateAndRunInstallableManager(tester.get(), GetManifestParams(),
289 "/banners/play_app_test_page.html"); 312 "/banners/play_app_test_page.html");
290 run_loop.Run(); 313 run_loop.Run();
291 314
292 EXPECT_FALSE(tester->manifest().IsEmpty()); 315 EXPECT_FALSE(tester->manifest().IsEmpty());
293 EXPECT_FALSE(tester->manifest_url().is_empty()); 316 EXPECT_FALSE(tester->manifest_url().is_empty());
294 EXPECT_TRUE(tester->manifest().prefer_related_applications); 317 EXPECT_TRUE(tester->manifest().prefer_related_applications);
295 318
296 EXPECT_TRUE(tester->icon_url().is_empty()); 319 EXPECT_TRUE(tester->primary_icon_url().is_empty());
297 EXPECT_EQ(nullptr, tester->icon()); 320 EXPECT_EQ(nullptr, tester->primary_icon());
298 EXPECT_FALSE(tester->is_installable()); 321 EXPECT_FALSE(tester->is_installable());
299 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 322 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
300 } 323 }
301 324
302 // Ask for an icon (but don't navigate). This should fail with 325 // Ask for a primary icon (but don't navigate). This should fail with
303 // NO_ACCEPTABLE_ICON. 326 // NO_ACCEPTABLE_ICON.
304 { 327 {
305 base::RunLoop run_loop; 328 base::RunLoop run_loop;
306 std::unique_ptr<CallbackTester> tester( 329 std::unique_ptr<CallbackTester> tester(
307 new CallbackTester(run_loop.QuitClosure())); 330 new CallbackTester(run_loop.QuitClosure()));
308 331
309 RunInstallableManager(tester.get(), GetIconParams()); 332 RunInstallableManager(tester.get(), GetPrimaryIconParams());
310 run_loop.Run(); 333 run_loop.Run();
311 334
312 EXPECT_FALSE(tester->manifest().IsEmpty()); 335 EXPECT_FALSE(tester->manifest().IsEmpty());
313 EXPECT_FALSE(tester->manifest_url().is_empty()); 336 EXPECT_FALSE(tester->manifest_url().is_empty());
314 EXPECT_TRUE(tester->manifest().prefer_related_applications); 337 EXPECT_TRUE(tester->manifest().prefer_related_applications);
315 338
316 EXPECT_TRUE(tester->icon_url().is_empty()); 339 EXPECT_TRUE(tester->primary_icon_url().is_empty());
317 EXPECT_EQ(nullptr, tester->icon()); 340 EXPECT_EQ(nullptr, tester->primary_icon());
318 EXPECT_FALSE(tester->is_installable()); 341 EXPECT_FALSE(tester->is_installable());
319 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 342 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
320 } 343 }
321 344
322 // Ask for everything. This should fail with NO_ACCEPTABLE_ICON - the icon 345 // Ask for everything except badge icon. This should fail with
323 // fetch has already failed, so that cached error stops the installable check 346 // NO_ACCEPTABLE_ICON - the primary icon fetch has already failed, so that
324 // from being performed. 347 // cached error stops the installable check from being performed.
325 { 348 {
326 base::RunLoop run_loop; 349 base::RunLoop run_loop;
327 std::unique_ptr<CallbackTester> tester( 350 std::unique_ptr<CallbackTester> tester(
328 new CallbackTester(run_loop.QuitClosure())); 351 new CallbackTester(run_loop.QuitClosure()));
329 352
330 RunInstallableManager(tester.get(), GetWebAppParams()); 353 RunInstallableManager(tester.get(), GetWebAppParams());
331 run_loop.Run(); 354 run_loop.Run();
332 355
333 EXPECT_FALSE(tester->manifest().IsEmpty()); 356 EXPECT_FALSE(tester->manifest().IsEmpty());
334 EXPECT_FALSE(tester->manifest_url().is_empty()); 357 EXPECT_FALSE(tester->manifest_url().is_empty());
335 EXPECT_TRUE(tester->manifest().prefer_related_applications); 358 EXPECT_TRUE(tester->manifest().prefer_related_applications);
336 359
337 EXPECT_TRUE(tester->icon_url().is_empty()); 360 EXPECT_TRUE(tester->primary_icon_url().is_empty());
338 EXPECT_EQ(nullptr, tester->icon()); 361 EXPECT_EQ(nullptr, tester->primary_icon());
339 EXPECT_FALSE(tester->is_installable()); 362 EXPECT_FALSE(tester->is_installable());
340 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 363 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
341 } 364 }
342 365
343 // Ask for a different size icon. This should fail with START_URL_NOT_VALID 366 // Ask for a different size primary icon. This should fail with
344 // since we won't have a cached icon error. 367 // START_URL_NOT_VALID since we won't have a cached icon error.
345 { 368 {
346 base::RunLoop run_loop; 369 base::RunLoop run_loop;
347 std::unique_ptr<CallbackTester> tester( 370 std::unique_ptr<CallbackTester> tester(
348 new CallbackTester(run_loop.QuitClosure())); 371 new CallbackTester(run_loop.QuitClosure()));
349 372
350 InstallableParams params = GetWebAppParams(); 373 InstallableParams params = GetWebAppParams();
351 params.ideal_primary_icon_size_in_px = 96; 374 params.ideal_primary_icon_size_in_px = 96;
352 params.minimum_primary_icon_size_in_px = 96; 375 params.minimum_primary_icon_size_in_px = 96;
353 RunInstallableManager(tester.get(), params); 376 RunInstallableManager(tester.get(), params);
354 run_loop.Run(); 377 run_loop.Run();
355 378
356 EXPECT_FALSE(tester->manifest().IsEmpty()); 379 EXPECT_FALSE(tester->manifest().IsEmpty());
357 EXPECT_FALSE(tester->manifest_url().is_empty()); 380 EXPECT_FALSE(tester->manifest_url().is_empty());
358 EXPECT_TRUE(tester->manifest().prefer_related_applications); 381 EXPECT_TRUE(tester->manifest().prefer_related_applications);
359 382
360 EXPECT_TRUE(tester->icon_url().is_empty()); 383 EXPECT_TRUE(tester->primary_icon_url().is_empty());
361 EXPECT_EQ(nullptr, tester->icon()); 384 EXPECT_EQ(nullptr, tester->primary_icon());
362 EXPECT_FALSE(tester->is_installable()); 385 EXPECT_FALSE(tester->is_installable());
363 EXPECT_EQ(START_URL_NOT_VALID, tester->error_code()); 386 EXPECT_EQ(START_URL_NOT_VALID, tester->error_code());
364 } 387 }
365 } 388 }
366 389
367 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestAndIcon) { 390 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckManifestAndIcon) {
368 // Add to homescreen checks for manifest + icon. 391 // Add to homescreen checks for manifest + primary icon.
369 base::RunLoop run_loop; 392 {
370 std::unique_ptr<CallbackTester> tester( 393 base::RunLoop run_loop;
371 new CallbackTester(run_loop.QuitClosure())); 394 std::unique_ptr<CallbackTester> tester(
395 new CallbackTester(run_loop.QuitClosure()));
372 396
373 NavigateAndRunInstallableManager(tester.get(), GetIconParams(), 397 NavigateAndRunInstallableManager(tester.get(), GetPrimaryIconParams(),
374 "/banners/manifest_test_page.html"); 398 "/banners/manifest_test_page.html");
375 run_loop.Run(); 399 run_loop.Run();
376 400
377 EXPECT_FALSE(tester->manifest().IsEmpty()); 401 EXPECT_FALSE(tester->manifest().IsEmpty());
378 EXPECT_FALSE(tester->manifest_url().is_empty()); 402 EXPECT_FALSE(tester->manifest_url().is_empty());
379 403
380 EXPECT_FALSE(tester->icon_url().is_empty()); 404 EXPECT_FALSE(tester->primary_icon_url().is_empty());
381 EXPECT_NE(nullptr, tester->icon()); 405 EXPECT_NE(nullptr, tester->primary_icon());
382 406
383 EXPECT_FALSE(tester->is_installable()); 407 EXPECT_FALSE(tester->is_installable());
384 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 408 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
409 }
410
411 // Add to homescreen checks for manifest + primary icon + badge icon.
412 {
413 base::RunLoop run_loop;
414 std::unique_ptr<CallbackTester> tester(
415 new CallbackTester(run_loop.QuitClosure()));
416
417 RunInstallableManager(tester.get(), GetPrimaryIconAndBadgeIconParams());
418 run_loop.Run();
419
420 EXPECT_FALSE(tester->manifest().IsEmpty());
421 EXPECT_FALSE(tester->manifest_url().is_empty());
422
423 EXPECT_FALSE(tester->primary_icon_url().is_empty());
424 EXPECT_NE(nullptr, tester->primary_icon());
425
426 EXPECT_FALSE(tester->badge_icon_url().is_empty());
427 EXPECT_NE(nullptr, tester->badge_icon());
428
429 EXPECT_FALSE(tester->is_installable());
430 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
431 }
432
433 // Request an oversized badge icon. This should should only primary icon, but
dominickn 2017/01/27 06:40:43 This comment is a bit weird
F 2017/01/27 20:11:17 Done. Thanks!
434 // without errors.
435 {
436 base::RunLoop run_loop;
437 std::unique_ptr<CallbackTester> tester(
438 new CallbackTester(run_loop.QuitClosure()));
439
440 InstallableParams params = GetPrimaryIconAndBadgeIconParams();
441 params.ideal_badge_icon_size_in_px = 2000;
442 params.minimum_badge_icon_size_in_px = 2000;
443 RunInstallableManager(tester.get(), params);
444 run_loop.Run();
445
446 EXPECT_FALSE(tester->manifest().IsEmpty());
447 EXPECT_FALSE(tester->manifest_url().is_empty());
448
449 EXPECT_FALSE(tester->primary_icon_url().is_empty());
450 EXPECT_NE(nullptr, tester->primary_icon());
451
452 EXPECT_TRUE(tester->badge_icon_url().is_empty());
453 EXPECT_EQ(nullptr, tester->badge_icon());
454
455 EXPECT_FALSE(tester->is_installable());
456 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
457 }
385 } 458 }
386 459
387 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) { 460 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, CheckWebapp) {
388 // Request everything. 461 // Request everything except badge icon.
389 { 462 {
390 base::RunLoop run_loop; 463 base::RunLoop run_loop;
391 std::unique_ptr<CallbackTester> tester( 464 std::unique_ptr<CallbackTester> tester(
392 new CallbackTester(run_loop.QuitClosure())); 465 new CallbackTester(run_loop.QuitClosure()));
393 466
394 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), 467 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
395 "/banners/manifest_test_page.html"); 468 "/banners/manifest_test_page.html");
396 run_loop.Run(); 469 run_loop.Run();
397 470
398 EXPECT_FALSE(tester->manifest().IsEmpty()); 471 EXPECT_FALSE(tester->manifest().IsEmpty());
399 EXPECT_FALSE(tester->manifest_url().is_empty()); 472 EXPECT_FALSE(tester->manifest_url().is_empty());
400 EXPECT_TRUE(tester->is_installable()); 473 EXPECT_TRUE(tester->is_installable());
401 EXPECT_FALSE(tester->icon_url().is_empty()); 474 EXPECT_FALSE(tester->primary_icon_url().is_empty());
402 EXPECT_NE(nullptr, tester->icon()); 475 EXPECT_NE(nullptr, tester->primary_icon());
403 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 476 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
404 477
405 // Verify that the returned state matches manager internal state. 478 // Verify that the returned state matches manager internal state.
406 InstallableManager* manager = GetManager(); 479 InstallableManager* manager = GetManager();
407 480
408 EXPECT_FALSE(manager->manifest().IsEmpty()); 481 EXPECT_FALSE(manager->manifest().IsEmpty());
409 EXPECT_FALSE(manager->manifest_url().is_empty()); 482 EXPECT_FALSE(manager->manifest_url().is_empty());
410 EXPECT_TRUE(manager->is_installable()); 483 EXPECT_TRUE(manager->is_installable());
411 EXPECT_EQ(1u, manager->icons_.size()); 484 EXPECT_EQ(1u, manager->icons_.size());
412 EXPECT_FALSE((manager->icon_url({144,144}).is_empty())); 485 EXPECT_FALSE((manager->icon_url(kPrimaryIconParams).is_empty()));
413 EXPECT_NE(nullptr, (manager->icon({144,144}))); 486 EXPECT_NE(nullptr, (manager->icon(kPrimaryIconParams)));
414 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error()); 487 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error());
415 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error()); 488 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error());
416 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error({144,144}))); 489 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error(kPrimaryIconParams)));
417 EXPECT_TRUE(manager->tasks_.empty()); 490 EXPECT_TRUE(manager->tasks_.empty());
418 } 491 }
419 492
420 // Request everything again without navigating away. This should work fine. 493 // Request everything except badge icon again without navigating away. This
494 // should work fine.
421 { 495 {
422 base::RunLoop run_loop; 496 base::RunLoop run_loop;
423 std::unique_ptr<CallbackTester> tester( 497 std::unique_ptr<CallbackTester> tester(
424 new CallbackTester(run_loop.QuitClosure())); 498 new CallbackTester(run_loop.QuitClosure()));
425 499
426 RunInstallableManager(tester.get(), GetWebAppParams()); 500 RunInstallableManager(tester.get(), GetWebAppParams());
427 run_loop.Run(); 501 run_loop.Run();
428 502
429 EXPECT_FALSE(tester->manifest().IsEmpty()); 503 EXPECT_FALSE(tester->manifest().IsEmpty());
430 EXPECT_FALSE(tester->manifest_url().is_empty()); 504 EXPECT_FALSE(tester->manifest_url().is_empty());
431 EXPECT_TRUE(tester->is_installable()); 505 EXPECT_TRUE(tester->is_installable());
432 EXPECT_FALSE(tester->icon_url().is_empty()); 506 EXPECT_FALSE(tester->primary_icon_url().is_empty());
433 EXPECT_NE(nullptr, tester->icon()); 507 EXPECT_NE(nullptr, tester->primary_icon());
434 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 508 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
435 509
436 // Verify that the returned state matches manager internal state. 510 // Verify that the returned state matches manager internal state.
437 InstallableManager* manager = GetManager(); 511 InstallableManager* manager = GetManager();
438 512
439 EXPECT_FALSE(manager->manifest().IsEmpty()); 513 EXPECT_FALSE(manager->manifest().IsEmpty());
440 EXPECT_FALSE(manager->manifest_url().is_empty()); 514 EXPECT_FALSE(manager->manifest_url().is_empty());
441 EXPECT_TRUE(manager->is_installable()); 515 EXPECT_TRUE(manager->is_installable());
442 EXPECT_EQ(1u, manager->icons_.size()); 516 EXPECT_EQ(1u, manager->icons_.size());
443 EXPECT_FALSE((manager->icon_url({144,144}).is_empty())); 517 EXPECT_FALSE((manager->icon_url(kPrimaryIconParams).is_empty()));
444 EXPECT_NE(nullptr, (manager->icon({144,144}))); 518 EXPECT_NE(nullptr, (manager->icon(kPrimaryIconParams)));
445 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error()); 519 EXPECT_EQ(NO_ERROR_DETECTED, manager->manifest_error());
446 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error()); 520 EXPECT_EQ(NO_ERROR_DETECTED, manager->installable_error());
447 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error({144,144}))); 521 EXPECT_EQ(NO_ERROR_DETECTED, (manager->icon_error(kPrimaryIconParams)));
448 EXPECT_TRUE(manager->tasks_.empty()); 522 EXPECT_TRUE(manager->tasks_.empty());
449 } 523 }
450 524
451 { 525 {
452 // Check that a subsequent navigation resets state. 526 // Check that a subsequent navigation resets state.
453 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 527 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
454 InstallableManager* manager = GetManager(); 528 InstallableManager* manager = GetManager();
455 529
456 EXPECT_TRUE(manager->manifest().IsEmpty()); 530 EXPECT_TRUE(manager->manifest().IsEmpty());
457 EXPECT_TRUE(manager->manifest_url().is_empty()); 531 EXPECT_TRUE(manager->manifest_url().is_empty());
(...skipping 11 matching lines...) Expand all
469 new CallbackTester(run_loop.QuitClosure())); 543 new CallbackTester(run_loop.QuitClosure()));
470 544
471 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), 545 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
472 "/banners/iframe_test_page.html"); 546 "/banners/iframe_test_page.html");
473 run_loop.Run(); 547 run_loop.Run();
474 548
475 // The installable manager should only retrieve items in the main frame; 549 // The installable manager should only retrieve items in the main frame;
476 // everything should be empty here. 550 // everything should be empty here.
477 EXPECT_TRUE(tester->manifest().IsEmpty()); 551 EXPECT_TRUE(tester->manifest().IsEmpty());
478 EXPECT_TRUE(tester->manifest_url().is_empty()); 552 EXPECT_TRUE(tester->manifest_url().is_empty());
479 EXPECT_TRUE(tester->icon_url().is_empty()); 553 EXPECT_TRUE(tester->primary_icon_url().is_empty());
480 EXPECT_EQ(nullptr, tester->icon()); 554 EXPECT_EQ(nullptr, tester->primary_icon());
481 EXPECT_FALSE(tester->is_installable()); 555 EXPECT_FALSE(tester->is_installable());
482 EXPECT_EQ(NO_MANIFEST, tester->error_code()); 556 EXPECT_EQ(NO_MANIFEST, tester->error_code());
483 } 557 }
484 558
485 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 559 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
486 CheckPageWithManifestAndNoServiceWorker) { 560 CheckPageWithManifestAndNoServiceWorker) {
487 // Just fetch the manifest. This should have no error. 561 // Just fetch the manifest. This should have no error.
488 { 562 {
489 base::RunLoop run_loop; 563 base::RunLoop run_loop;
490 std::unique_ptr<CallbackTester> tester( 564 std::unique_ptr<CallbackTester> tester(
491 new CallbackTester(run_loop.QuitClosure())); 565 new CallbackTester(run_loop.QuitClosure()));
492 566
493 NavigateAndRunInstallableManager( 567 NavigateAndRunInstallableManager(
494 tester.get(), GetManifestParams(), 568 tester.get(), GetManifestParams(),
495 "/banners/manifest_no_service_worker.html"); 569 "/banners/manifest_no_service_worker.html");
496 run_loop.Run(); 570 run_loop.Run();
497 571
498 EXPECT_FALSE(tester->manifest().IsEmpty()); 572 EXPECT_FALSE(tester->manifest().IsEmpty());
499 EXPECT_FALSE(tester->manifest_url().is_empty()); 573 EXPECT_FALSE(tester->manifest_url().is_empty());
500 574
501 EXPECT_TRUE(tester->icon_url().is_empty()); 575 EXPECT_TRUE(tester->primary_icon_url().is_empty());
502 EXPECT_EQ(nullptr, tester->icon()); 576 EXPECT_EQ(nullptr, tester->primary_icon());
503 EXPECT_FALSE(tester->is_installable()); 577 EXPECT_FALSE(tester->is_installable());
504 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 578 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
505 } 579 }
506 580
507 // Fetch the full criteria should fail. 581 // Fetch the full criteria should fail.
508 { 582 {
509 base::RunLoop run_loop; 583 base::RunLoop run_loop;
510 std::unique_ptr<CallbackTester> tester( 584 std::unique_ptr<CallbackTester> tester(
511 new CallbackTester(run_loop.QuitClosure())); 585 new CallbackTester(run_loop.QuitClosure()));
512 586
513 RunInstallableManager(tester.get(), GetWebAppParams()); 587 RunInstallableManager(tester.get(), GetWebAppParams());
514 run_loop.Run(); 588 run_loop.Run();
515 589
516 EXPECT_FALSE(tester->manifest().IsEmpty()); 590 EXPECT_FALSE(tester->manifest().IsEmpty());
517 EXPECT_FALSE(tester->manifest_url().is_empty()); 591 EXPECT_FALSE(tester->manifest_url().is_empty());
518 592
519 EXPECT_TRUE(tester->icon_url().is_empty()); 593 EXPECT_TRUE(tester->primary_icon_url().is_empty());
520 EXPECT_EQ(nullptr, tester->icon()); 594 EXPECT_EQ(nullptr, tester->primary_icon());
521 EXPECT_FALSE(tester->is_installable()); 595 EXPECT_FALSE(tester->is_installable());
522 EXPECT_EQ(NO_MATCHING_SERVICE_WORKER, tester->error_code()); 596 EXPECT_EQ(NO_MATCHING_SERVICE_WORKER, tester->error_code());
523 } 597 }
524 } 598 }
525 599
526 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 600 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
527 CheckManifestCorruptedIcon) { 601 CheckManifestCorruptedIcon) {
528 // Verify that the returned InstallableData::icon is null if the web manifest 602 // Verify that the returned InstallableData::primary_icon is null if the web
529 // points to a corrupt icon. 603 // manifest points to a corrupt primary icon.
530 base::RunLoop run_loop; 604 base::RunLoop run_loop;
531 std::unique_ptr<CallbackTester> tester( 605 std::unique_ptr<CallbackTester> tester(
532 new CallbackTester(run_loop.QuitClosure())); 606 new CallbackTester(run_loop.QuitClosure()));
533 607
534 NavigateAndRunInstallableManager(tester.get(), GetIconParams(), 608 NavigateAndRunInstallableManager(tester.get(), GetPrimaryIconParams(),
535 GetURLOfPageWithServiceWorkerAndManifest( 609 GetURLOfPageWithServiceWorkerAndManifest(
536 "/banners/manifest_bad_icon.json")); 610 "/banners/manifest_bad_icon.json"));
537 run_loop.Run(); 611 run_loop.Run();
538 612
539 EXPECT_FALSE(tester->manifest().IsEmpty()); 613 EXPECT_FALSE(tester->manifest().IsEmpty());
540 EXPECT_FALSE(tester->manifest_url().is_empty()); 614 EXPECT_FALSE(tester->manifest_url().is_empty());
541 EXPECT_TRUE(tester->icon_url().is_empty()); 615 EXPECT_TRUE(tester->primary_icon_url().is_empty());
542 EXPECT_EQ(nullptr, tester->icon()); 616 EXPECT_EQ(nullptr, tester->primary_icon());
543 EXPECT_FALSE(tester->is_installable()); 617 EXPECT_FALSE(tester->is_installable());
544 EXPECT_EQ(NO_ICON_AVAILABLE, tester->error_code()); 618 EXPECT_EQ(NO_ICON_AVAILABLE, tester->error_code());
545 } 619 }
546 620
547 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 621 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
548 CheckChangeInIconDimensions) { 622 CheckChangeInIconDimensions) {
549 // Verify that a follow-up request for an icon with a different size works. 623 // Verify that a follow-up request for a primary icon with a different size
624 // works.
550 { 625 {
551 base::RunLoop run_loop; 626 base::RunLoop run_loop;
552 std::unique_ptr<CallbackTester> tester( 627 std::unique_ptr<CallbackTester> tester(
553 new CallbackTester(run_loop.QuitClosure())); 628 new CallbackTester(run_loop.QuitClosure()));
554 629
555 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(), 630 NavigateAndRunInstallableManager(tester.get(), GetWebAppParams(),
556 "/banners/manifest_test_page.html"); 631 "/banners/manifest_test_page.html");
557 run_loop.Run(); 632 run_loop.Run();
558 633
559 EXPECT_FALSE(tester->manifest_url().is_empty()); 634 EXPECT_FALSE(tester->manifest_url().is_empty());
560 EXPECT_FALSE(tester->manifest().IsEmpty()); 635 EXPECT_FALSE(tester->manifest().IsEmpty());
561 EXPECT_TRUE(tester->is_installable()); 636 EXPECT_TRUE(tester->is_installable());
562 EXPECT_FALSE(tester->icon_url().is_empty()); 637 EXPECT_FALSE(tester->primary_icon_url().is_empty());
563 EXPECT_NE(nullptr, tester->icon()); 638 EXPECT_NE(nullptr, tester->primary_icon());
564 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 639 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
565 } 640 }
566 641
567 { 642 {
568 base::RunLoop run_loop; 643 base::RunLoop run_loop;
569 std::unique_ptr<CallbackTester> tester( 644 std::unique_ptr<CallbackTester> tester(
570 new CallbackTester(run_loop.QuitClosure())); 645 new CallbackTester(run_loop.QuitClosure()));
571 646
572 // Dial up the icon size requirements to something that isn't available. 647 // Dial up the primary icon size requirements to something that isn't
573 // This should now fail with NoIconMatchingRequirements. 648 // available. This should now fail with NoIconMatchingRequirements.
574 InstallableParams params = GetWebAppParams(); 649 InstallableParams params = GetWebAppParams();
575 params.ideal_primary_icon_size_in_px = 2000; 650 params.ideal_primary_icon_size_in_px = 2000;
576 params.minimum_primary_icon_size_in_px = 2000; 651 params.minimum_primary_icon_size_in_px = 2000;
577 RunInstallableManager(tester.get(), params); 652 RunInstallableManager(tester.get(), params);
578 run_loop.Run(); 653 run_loop.Run();
579 654
580 EXPECT_FALSE(tester->manifest_url().is_empty()); 655 EXPECT_FALSE(tester->manifest_url().is_empty());
581 EXPECT_FALSE(tester->manifest().IsEmpty()); 656 EXPECT_FALSE(tester->manifest().IsEmpty());
582 EXPECT_TRUE(tester->is_installable()); 657 EXPECT_TRUE(tester->is_installable());
583 EXPECT_TRUE(tester->icon_url().is_empty()); 658 EXPECT_TRUE(tester->primary_icon_url().is_empty());
584 EXPECT_EQ(nullptr, tester->icon()); 659 EXPECT_EQ(nullptr, tester->primary_icon());
585 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 660 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
586 } 661 }
587 662
588 // Navigate and verify the reverse: an overly large icon requested first 663 // Navigate and verify the reverse: an overly large primary icon requested
589 // fails, but a smaller icon requested second passes. 664 // first fails, but a smaller primary icon requested second passes.
590 { 665 {
591 base::RunLoop run_loop; 666 base::RunLoop run_loop;
592 std::unique_ptr<CallbackTester> tester( 667 std::unique_ptr<CallbackTester> tester(
593 new CallbackTester(run_loop.QuitClosure())); 668 new CallbackTester(run_loop.QuitClosure()));
594 669
595 // This should fail with NoIconMatchingRequirements. 670 // This should fail with NoIconMatchingRequirements.
596 InstallableParams params = GetWebAppParams(); 671 InstallableParams params = GetWebAppParams();
597 params.ideal_primary_icon_size_in_px = 2000; 672 params.ideal_primary_icon_size_in_px = 2000;
598 params.minimum_primary_icon_size_in_px = 2000; 673 params.minimum_primary_icon_size_in_px = 2000;
599 NavigateAndRunInstallableManager(tester.get(), params, 674 NavigateAndRunInstallableManager(tester.get(), params,
600 "/banners/manifest_test_page.html"); 675 "/banners/manifest_test_page.html");
601 run_loop.Run(); 676 run_loop.Run();
602 677
603 EXPECT_FALSE(tester->manifest_url().is_empty()); 678 EXPECT_FALSE(tester->manifest_url().is_empty());
604 EXPECT_FALSE(tester->manifest().IsEmpty()); 679 EXPECT_FALSE(tester->manifest().IsEmpty());
605 EXPECT_TRUE(tester->is_installable()); 680 EXPECT_TRUE(tester->is_installable());
606 EXPECT_TRUE(tester->icon_url().is_empty()); 681 EXPECT_TRUE(tester->primary_icon_url().is_empty());
607 EXPECT_EQ(nullptr, tester->icon()); 682 EXPECT_EQ(nullptr, tester->primary_icon());
608 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code()); 683 EXPECT_EQ(NO_ACCEPTABLE_ICON, tester->error_code());
609 } 684 }
610 685
611 { 686 {
612 base::RunLoop run_loop; 687 base::RunLoop run_loop;
613 std::unique_ptr<CallbackTester> tester( 688 std::unique_ptr<CallbackTester> tester(
614 new CallbackTester(run_loop.QuitClosure())); 689 new CallbackTester(run_loop.QuitClosure()));
615 RunInstallableManager(tester.get(), GetWebAppParams()); 690 RunInstallableManager(tester.get(), GetWebAppParams());
616 691
617 run_loop.Run(); 692 run_loop.Run();
618 693
619 // The smaller icon requirements should allow this to pass. 694 // The smaller primary icon requirements should allow this to pass.
620 EXPECT_FALSE(tester->manifest_url().is_empty()); 695 EXPECT_FALSE(tester->manifest_url().is_empty());
621 EXPECT_FALSE(tester->manifest().IsEmpty()); 696 EXPECT_FALSE(tester->manifest().IsEmpty());
622 EXPECT_TRUE(tester->is_installable()); 697 EXPECT_TRUE(tester->is_installable());
623 EXPECT_FALSE(tester->icon_url().is_empty()); 698 EXPECT_FALSE(tester->primary_icon_url().is_empty());
624 EXPECT_NE(nullptr, tester->icon()); 699 EXPECT_NE(nullptr, tester->primary_icon());
625 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code()); 700 EXPECT_EQ(NO_ERROR_DETECTED, tester->error_code());
626 } 701 }
627 } 702 }
628 703
629 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest, 704 IN_PROC_BROWSER_TEST_F(InstallableManagerBrowserTest,
630 CheckNestedCallsToGetData) { 705 CheckNestedCallsToGetData) {
631 // Verify that we can call GetData while in a callback from GetData. 706 // Verify that we can call GetData while in a callback from GetData.
632 base::RunLoop run_loop; 707 base::RunLoop run_loop;
633 InstallableParams params = GetWebAppParams(); 708 InstallableParams params = GetWebAppParams();
634 std::unique_ptr<NestedCallbackTester> tester( 709 std::unique_ptr<NestedCallbackTester> tester(
635 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure())); 710 new NestedCallbackTester(GetManager(), params, run_loop.QuitClosure()));
636 711
637 tester->Run(); 712 tester->Run();
638 run_loop.Run(); 713 run_loop.Run();
639 } 714 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698