OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 const notifications = chrome.notifications; | 5 const notifications = chrome.notifications; |
6 | 6 |
7 const red_dot = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA" + | 7 const red_dot = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA" + |
8 "AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO" + | 8 "AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO" + |
9 "9TXL0Y4OHwAAAABJRU5ErkJggg=="; | 9 "9TXL0Y4OHwAAAABJRU5ErkJggg=="; |
10 | 10 |
| 11 function createBigImageUrl() { |
| 12 var canvas = document.createElement('canvas'); |
| 13 canvas.width = 5000; |
| 14 canvas.height = 5000; |
| 15 var ctx = canvas.getContext('2d'); |
| 16 ctx.fillStyle = "rgb(200, 0, 0)"; |
| 17 ctx.fillRect(10, 20, 30, 40); |
| 18 |
| 19 return canvas.toDataURL(); |
| 20 }; |
| 21 |
11 var basicNotificationOptions = { | 22 var basicNotificationOptions = { |
12 type: "basic", | 23 type: "basic", |
13 title: "Basic title", | 24 title: "Basic title", |
14 message: "Basic message", | 25 message: "Basic message", |
15 iconUrl: red_dot | 26 iconUrl: red_dot |
16 }; | 27 }; |
17 | 28 |
18 function create(id, options) { | 29 function create(id, options) { |
19 return new Promise(function (resolve, reject) { | 30 return new Promise(function (resolve, reject) { |
20 notifications.create(id, options, function (id) { | 31 notifications.create(id, options, function (id) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 .then(fail, function () { return update("progress", { progress: 101 }); }) | 304 .then(fail, function () { return update("progress", { progress: 101 }); }) |
294 .then(function () { return clear("progress"); }) | 305 .then(function () { return clear("progress"); }) |
295 // Finally try to create a notification that has a progress value but not | 306 // Finally try to create a notification that has a progress value but not |
296 // progress type. | 307 // progress type. |
297 .then(fail, function () { | 308 .then(fail, function () { |
298 progressOptions.type = "basic"; | 309 progressOptions.type = "basic"; |
299 return create("progress", progressOptions); | 310 return create("progress", progressOptions); |
300 }).then(fail, succeed); | 311 }).then(fail, succeed); |
301 } | 312 } |
302 | 313 |
| 314 function testLargeImage() { |
| 315 var testName = "testLargeImage"; |
| 316 console.log("Starting " + testName); |
| 317 var succeed = succeedTest(testName); |
| 318 var fail = failTest(testName); |
| 319 var options = { |
| 320 type: "basic", |
| 321 title: "Basic title", |
| 322 message: "Basic message", |
| 323 iconUrl: createBigImageUrl(), |
| 324 }; |
| 325 create("largeImage", options).then(succeed, fail); |
| 326 } |
| 327 |
303 chrome.test.runTests([ | 328 chrome.test.runTests([ |
304 testIdUsage, testBaseFormat, testListItem, testGetAll, testProgress | 329 testIdUsage, testBaseFormat, testListItem, testGetAll, testProgress, |
| 330 testLargeImage |
305 ]); | 331 ]); |
OLD | NEW |