OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 notification = chrome.experimental.notification; | 5 const notifications = chrome.experimental.notifications; |
6 var theOnlyTestDone = null; | 6 var theOnlyTestDone = null; |
7 | 7 |
8 var notificationData = { | 8 var notificationData = { |
9 templateType: "basic", | 9 templateType: "basic", |
10 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + | 10 iconUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAA" + |
11 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + | 11 "CNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHw" + |
12 "AAAABJRU5ErkJggg==", | 12 "AAAABJRU5ErkJggg==", |
13 title: "Attention!", | 13 title: "Attention!", |
14 message: "Check out Cirque du Soleil" | 14 message: "Check out Cirque du Soleil" |
15 }; | 15 }; |
16 | 16 |
17 var results = { | 17 var results = { |
18 FOO: false, | 18 FOO: false, |
19 BAR: true, | 19 BAR: true, |
20 BAT: false, | 20 BAT: false, |
21 BIFF: false, | 21 BIFF: false, |
22 BLAT: true, | 22 BLAT: true, |
23 BLOT: true | 23 BLOT: true |
24 }; | 24 }; |
25 | 25 |
26 function createCallback(id) { } | 26 function createCallback(id) { } |
27 | 27 |
28 var onClosedHooks = { | 28 var onClosedHooks = { |
29 BIFF: function() { | 29 BIFF: function() { |
30 notification.create("BLAT", notificationData, createCallback); | 30 notifications.create("BLAT", notificationData, createCallback); |
31 notification.create("BLOT", notificationData, createCallback); | 31 notifications.create("BLOT", notificationData, createCallback); |
32 }, | 32 }, |
33 }; | 33 }; |
34 | 34 |
35 function onClosedListener(id, by_user) { | 35 function onClosedListener(id, by_user) { |
36 if (results[id] !== by_user) { | 36 if (results[id] !== by_user) { |
37 chrome.test.notifyFail("Notification " + id + | 37 chrome.test.notifyFail("Notification " + id + |
38 " closed with bad by_user param ( "+ by_user +" )"); | 38 " closed with bad by_user param ( "+ by_user +" )"); |
39 return; | 39 return; |
40 } | 40 } |
41 chrome.test.notifyPass(); | 41 chrome.test.notifyPass(); |
42 delete results[id]; | 42 delete results[id]; |
43 | 43 |
44 if (typeof onClosedHooks[id] === "function") | 44 if (typeof onClosedHooks[id] === "function") |
45 onClosedHooks[id](); | 45 onClosedHooks[id](); |
46 | 46 |
47 if (Object.keys(results).length === 0) | 47 if (Object.keys(results).length === 0) |
48 theOnlyTestDone(); | 48 theOnlyTestDone(); |
49 } | 49 } |
50 | 50 |
51 notification.onClosed.addListener(onClosedListener); | 51 notifications.onClosed.addListener(onClosedListener); |
52 | 52 |
53 function theOnlyTest() { | 53 function theOnlyTest() { |
54 theOnlyTestDone = chrome.test.callbackAdded(); | 54 theOnlyTestDone = chrome.test.callbackAdded(); |
55 | 55 |
56 notification.create("FOO", notificationData, createCallback); | 56 notifications.create("FOO", notificationData, createCallback); |
57 notification.create("BAR", notificationData, createCallback); | 57 notifications.create("BAR", notificationData, createCallback); |
58 notification.create("BAT", notificationData, createCallback); | 58 notifications.create("BAT", notificationData, createCallback); |
59 notification.create("BIFF", notificationData, createCallback); | 59 notifications.create("BIFF", notificationData, createCallback); |
60 } | 60 } |
61 | 61 |
62 chrome.test.runTests([ theOnlyTest ]); | 62 chrome.test.runTests([ theOnlyTest ]); |
OLD | NEW |