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 #include "chrome/browser/browser_process.h" | 5 #include "chrome/browser/browser_process.h" |
6 #include "chrome/browser/extensions/api/notifications/notifications_api.h" | 6 #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_function_test_utils.h" | 8 #include "chrome/browser/extensions/extension_function_test_utils.h" |
9 #include "chrome/common/chrome_notification_types.h" | 9 #include "chrome/common/chrome_notification_types.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/extensions/features/feature.h" | 11 #include "chrome/common/extensions/features/feature.h" |
12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
13 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
14 #include "ui/message_center/message_center.h" | 14 #include "ui/message_center/message_center.h" |
15 #include "ui/message_center/message_center_util.h" | 15 #include "ui/message_center/message_center_util.h" |
16 | 16 |
| 17 // TODO(kbr): remove: http://crbug.com/222296 |
| 18 #if defined(OS_MACOSX) |
| 19 #import "base/mac/mac_util.h" |
| 20 #endif |
| 21 |
17 using extensions::Extension; | 22 using extensions::Extension; |
18 | 23 |
19 namespace utils = extension_function_test_utils; | 24 namespace utils = extension_function_test_utils; |
20 | 25 |
21 namespace { | 26 namespace { |
22 | 27 |
23 class NotificationsApiTest : public ExtensionApiTest { | 28 class NotificationsApiTest : public ExtensionApiTest { |
24 public: | 29 public: |
25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
26 ExtensionApiTest::SetUpCommandLine(command_line); | 31 ExtensionApiTest::SetUpCommandLine(command_line); |
(...skipping 10 matching lines...) Expand all Loading... |
37 if (extension) { | 42 if (extension) { |
38 page_created.Wait(); | 43 page_created.Wait(); |
39 } | 44 } |
40 return extension; | 45 return extension; |
41 } | 46 } |
42 }; | 47 }; |
43 | 48 |
44 } // namespace | 49 } // namespace |
45 | 50 |
46 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { | 51 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestIdUsage) { |
| 52 #if defined(OS_MACOSX) |
| 53 // TODO(kbr): re-enable: http://crbug.com/222296 |
| 54 if (base::mac::IsOSMountainLionOrLater()) |
| 55 return; |
| 56 #endif |
| 57 |
47 // Create a new notification. A lingering output of this block is the | 58 // Create a new notification. A lingering output of this block is the |
48 // notifications ID, which we'll use in later parts of this test. | 59 // notifications ID, which we'll use in later parts of this test. |
49 std::string notification_id; | 60 std::string notification_id; |
50 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); | 61 scoped_refptr<Extension> empty_extension(utils::CreateEmptyExtension()); |
51 { | 62 { |
52 scoped_refptr<extensions::NotificationsCreateFunction> | 63 scoped_refptr<extensions::NotificationsCreateFunction> |
53 notification_function( | 64 notification_function( |
54 new extensions::NotificationsCreateFunction()); | 65 new extensions::NotificationsCreateFunction()); |
55 | 66 |
56 notification_function->set_extension(empty_extension.get()); | 67 notification_function->set_extension(empty_extension.get()); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 browser(), utils::NONE)); | 254 browser(), utils::NONE)); |
244 // TODO(dharcourt): [...], items = [{title: foo, message: bar}, ...], [...] | 255 // TODO(dharcourt): [...], items = [{title: foo, message: bar}, ...], [...] |
245 | 256 |
246 std::string notification_id; | 257 std::string notification_id; |
247 ASSERT_EQ(base::Value::TYPE_STRING, result->GetType()); | 258 ASSERT_EQ(base::Value::TYPE_STRING, result->GetType()); |
248 ASSERT_TRUE(result->GetAsString(¬ification_id)); | 259 ASSERT_TRUE(result->GetAsString(¬ification_id)); |
249 ASSERT_TRUE(notification_id.length() > 0); | 260 ASSERT_TRUE(notification_id.length() > 0); |
250 } | 261 } |
251 | 262 |
252 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestEvents) { | 263 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestEvents) { |
| 264 #if defined(OS_MACOSX) |
| 265 // TODO(kbr): re-enable: http://crbug.com/222296 |
| 266 if (base::mac::IsOSMountainLionOrLater()) |
| 267 return; |
| 268 #endif |
| 269 |
253 ASSERT_TRUE(RunExtensionTest("notifications/api/events")) << message_; | 270 ASSERT_TRUE(RunExtensionTest("notifications/api/events")) << message_; |
254 } | 271 } |
255 | 272 |
256 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestCSP) { | 273 IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestCSP) { |
257 ASSERT_TRUE(RunExtensionTest("notifications/api/csp")) << message_; | 274 ASSERT_TRUE(RunExtensionTest("notifications/api/csp")) << message_; |
258 } | 275 } |
259 | 276 |
260 #ifdef ENABLE_MESSAGE_CENTER | 277 #ifdef ENABLE_MESSAGE_CENTER |
261 #if !defined(OS_WIN) || !defined(USE_ASH) | 278 #if !defined(OS_WIN) || !defined(USE_ASH) |
262 | 279 |
(...skipping 17 matching lines...) Expand all Loading... |
280 ResultCatcher catcher; | 297 ResultCatcher catcher; |
281 g_browser_process->message_center()->SendRemoveNotification( | 298 g_browser_process->message_center()->SendRemoveNotification( |
282 extension->id() + "-BAR", | 299 extension->id() + "-BAR", |
283 true); | 300 true); |
284 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 301 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
285 } | 302 } |
286 } | 303 } |
287 | 304 |
288 #endif | 305 #endif |
289 #endif | 306 #endif |
OLD | NEW |