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 "chrome/browser/extensions/api/notification_provider/notification_provi
der_api.h" | 5 #include "chrome/browser/extensions/api/notification_provider/notification_provi
der_api.h" |
6 | 6 |
7 #include "chrome/browser/extensions/chrome_extension_function.h" | |
8 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "chrome/common/extensions/api/notification_provider.h" | |
11 | 8 |
12 typedef ExtensionApiTest NotificationProviderApiTest; | 9 typedef ExtensionApiTest NotificationProviderApiTest; |
13 | 10 |
14 namespace { | |
15 | |
16 void CreateNotificationOptionsForTest( | |
17 extensions::api::notifications::NotificationOptions* options) { | |
18 options->type = extensions::api::notifications::ParseTemplateType("basic"); | |
19 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->message = | |
22 scoped_ptr<std::string>(new std::string("Here goes the message")); | |
23 return; | |
24 } | |
25 | |
26 } // namespace | |
27 | |
28 IN_PROC_BROWSER_TEST_F(NotificationProviderApiTest, Events) { | 11 IN_PROC_BROWSER_TEST_F(NotificationProviderApiTest, Events) { |
29 std::string sender_id1 = "SenderId1"; | 12 ASSERT_TRUE(RunExtensionTest("notification_provider/events")) << message_; |
30 std::string notification_id1 = "NotificationId1"; | |
31 | |
32 scoped_ptr<extensions::api::notifications::NotificationOptions> options( | |
33 new extensions::api::notifications::NotificationOptions()); | |
34 CreateNotificationOptionsForTest(options.get()); | |
35 | |
36 ResultCatcher catcher; | |
37 catcher.RestrictToProfile(browser()->profile()); | |
38 | |
39 // Test notification provider extension | |
40 const extensions::Extension* extension = | |
41 LoadExtension(test_data_dir_.AppendASCII("notification_provider/events")); | |
42 ASSERT_TRUE(extension); | |
43 | |
44 scoped_ptr<extensions::NotificationProviderEventRouter> event_router( | |
45 new extensions::NotificationProviderEventRouter(browser()->profile())); | |
46 | |
47 event_router->CreateNotification( | |
48 extension->id(), sender_id1, notification_id1, *options); | |
49 event_router->UpdateNotification( | |
50 extension->id(), sender_id1, notification_id1, *options); | |
51 event_router->ClearNotification( | |
52 extension->id(), sender_id1, notification_id1); | |
53 | |
54 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | |
55 } | 13 } |
56 | 14 |
57 IN_PROC_BROWSER_TEST_F(NotificationProviderApiTest, TestBasicUsage) { | 15 IN_PROC_BROWSER_TEST_F(NotificationProviderApiTest, TestBasicUsage) { |
58 ASSERT_TRUE(RunExtensionTest("notification_provider/basic_usage")) | 16 ASSERT_TRUE(RunExtensionTest("notification_provider/basic_usage")) |
59 << message_; | 17 << message_; |
60 } | 18 } |
OLD | NEW |