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 notification = chrome.experimental.notification; |
6 | 6 |
7 var idString = "foo"; | 7 var idString = "foo"; |
8 | 8 |
9 var testBasicEvents = function() { | 9 var testBasicEvents = function() { |
10 var incidents = 0; | 10 var incidents = 0; |
11 | 11 |
12 var onCreateCallback = function(id) { | 12 var onCreateCallback = function(id) { |
13 chrome.test.assertTrue(id.length > 0); | 13 chrome.test.assertTrue(id.length > 0); |
14 chrome.test.assertEq(idString, id); | 14 chrome.test.assertEq(idString, id); |
15 incidents++; | 15 incidents++; |
16 } | 16 } |
17 | 17 |
18 var onDisplayed = function(id) { | 18 var onDisplayed = function(id) { |
19 incidents++; | 19 incidents++; |
20 if (incidents == 2) { | 20 if (incidents == 2) { |
21 chrome.test.assertEq(idString, id); | 21 chrome.test.assertEq(idString, id); |
22 chrome.test.succeed(); | 22 chrome.test.succeed(); |
23 } | 23 } |
24 } | 24 } |
25 notification.onDisplayed.addListener(onDisplayed); | 25 notification.onDisplayed.addListener(onDisplayed); |
26 | 26 |
27 var options = { | 27 var options = { |
28 type: "base", | 28 templateType: "basic", |
29 iconUrl: "http://www.google.com/intl/en/chrome/assets/" + | 29 iconUrl: "http://www.google.com/intl/en/chrome/assets/" + |
30 "common/images/chrome_logo_2x.png", | 30 "common/images/chrome_logo_2x.png", |
31 title: "Attention!", | 31 title: "Attention!", |
32 message: "Check out Cirque du Soleil" | 32 message: "Check out Cirque du Soleil" |
33 }; | 33 }; |
34 notification.create(idString, options, onCreateCallback); | 34 notification.create(idString, options, onCreateCallback); |
35 }; | 35 }; |
36 | 36 |
37 chrome.test.runTests([ testBasicEvents ]); | 37 chrome.test.runTests([ testBasicEvents ]); |
OLD | NEW |