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 #include "base/memory/scoped_ptr.h" |
5 #include "chrome/browser/extensions/api/notification_provider/notification_provi
der_api.h" | 6 #include "chrome/browser/extensions/api/notification_provider/notification_provi
der_api.h" |
6 #include "chrome/browser/extensions/chrome_extension_function.h" | 7 #include "chrome/browser/extensions/chrome_extension_function.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/common/extensions/api/notification_provider.h" | 10 #include "chrome/common/extensions/api/notification_provider.h" |
10 | 11 |
11 typedef ExtensionApiTest NotificationProviderApiTest; | 12 typedef ExtensionApiTest NotificationProviderApiTest; |
12 | 13 |
13 IN_PROC_BROWSER_TEST_F(NotificationProviderApiTest, Events) { | 14 IN_PROC_BROWSER_TEST_F(NotificationProviderApiTest, Events) { |
14 std::string sender_id1 = "SenderId1"; | 15 std::string sender_id1 = "SenderId1"; |
15 std::string notification_id1 = "NotificationId1"; | 16 std::string notification_id1 = "NotificationId1"; |
16 | 17 |
17 extensions::api::notifications::NotificationOptions options; | 18 extensions::api::notifications::NotificationOptions options; |
18 options.type = extensions::api::notifications::ParseTemplateType("basic"); | 19 options.type = extensions::api::notifications::ParseTemplateType("basic"); |
19 options.icon_url = scoped_ptr<std::string>(new std::string("icon.png")); | 20 options.icon_url = scoped_ptr<std::string>(new std::string("icon.png")); |
20 options.title = scoped_ptr<std::string>(new std::string("Title")); | 21 options.title = scoped_ptr<std::string>(new std::string("Title")); |
21 options.message = | 22 options.message = |
22 scoped_ptr<std::string>(new std::string("Here goes the message")); | 23 scoped_ptr<std::string>(new std::string("Here goes the message")); |
23 | 24 |
24 ResultCatcher catcher; | 25 ResultCatcher catcher; |
25 catcher.RestrictToProfile(browser()->profile()); | 26 catcher.RestrictToProfile(browser()->profile()); |
26 | 27 |
27 // Test notification provider extension | 28 // Test notification provider extension |
28 const extensions::Extension* extension = | 29 const extensions::Extension* extension = |
29 LoadExtension(test_data_dir_.AppendASCII("notification_provider/events")); | 30 LoadExtension(test_data_dir_.AppendASCII("notification_provider/events")); |
30 ASSERT_TRUE(extension); | 31 ASSERT_TRUE(extension); |
31 | 32 |
32 extensions::NotificationProviderEventRouter* event_router = | 33 scoped_ptr<extensions::NotificationProviderEventRouter> event_router( |
33 new extensions::NotificationProviderEventRouter(browser()->profile()); | 34 new extensions::NotificationProviderEventRouter(browser()->profile())); |
34 | 35 |
35 event_router->CreateNotification( | 36 event_router->CreateNotification( |
36 extension->id(), sender_id1, notification_id1, options); | 37 extension->id(), sender_id1, notification_id1, options); |
37 event_router->UpdateNotification( | 38 event_router->UpdateNotification( |
38 extension->id(), sender_id1, notification_id1, options); | 39 extension->id(), sender_id1, notification_id1, options); |
39 event_router->ClearNotification( | 40 event_router->ClearNotification( |
40 extension->id(), sender_id1, notification_id1); | 41 extension->id(), sender_id1, notification_id1); |
41 | 42 |
42 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 43 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
43 } | 44 } |
OLD | NEW |