Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: trunk/src/chrome/browser/notifications/message_center_notifications_browsertest.cc

Issue 14631021: Revert 199625 "Remove ENABLE_MESSAGE_CENTER" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/notifications/message_center_notification_manager.h" 12 #include "chrome/browser/notifications/message_center_notification_manager.h"
13 #include "chrome/browser/notifications/notification.h" 13 #include "chrome/browser/notifications/notification.h"
14 #include "chrome/browser/notifications/notification_ui_manager.h" 14 #include "chrome/browser/notifications/notification_ui_manager.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "ui/message_center/message_center.h" 18 #include "ui/message_center/message_center.h"
19
20 #if defined(ENABLE_MESSAGE_CENTER)
19 #include "ui/message_center/message_center_switches.h" 21 #include "ui/message_center/message_center_switches.h"
20 #include "ui/message_center/message_center_util.h" 22 #endif
21 23
22 class MessageCenterNotificationsTest : public InProcessBrowserTest { 24 class MessageCenterNotificationsTest : public InProcessBrowserTest {
23 public: 25 public:
24 MessageCenterNotificationsTest() {} 26 MessageCenterNotificationsTest() {}
25 27
26 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 28 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
27 // This switch enables the new piping of Notifications through Message 29 // This switch enables the new piping of Notifications through Message
28 // Center. 30 // Center.
29 command_line->AppendSwitch( 31 command_line->AppendSwitch(
30 message_center::switches::kEnableRichNotifications); 32 message_center::switches::kEnableRichNotifications);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 new_delegate); 91 new_delegate);
90 } 92 }
91 }; 93 };
92 94
93 // TODO(rsesek): Implement Message Center on Mac and get these tests passing 95 // TODO(rsesek): Implement Message Center on Mac and get these tests passing
94 // for real. http://crbug.com/179904 96 // for real. http://crbug.com/179904
95 #if !defined(OS_MACOSX) 97 #if !defined(OS_MACOSX)
96 98
97 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) { 99 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) {
98 // Make sure comamnd-line switch has an effect. 100 // Make sure comamnd-line switch has an effect.
99 EXPECT_EQ(NotificationUIManager::DelegatesToMessageCenter(), 101 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
100 message_center::IsRichNotificationEnabled());
101 EXPECT_TRUE(manager()); 102 EXPECT_TRUE(manager());
102 EXPECT_TRUE(message_center()); 103 EXPECT_TRUE(message_center());
103 } 104 }
104 105
105 // MessaceCenter-specific test. 106 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicAddCancel) {
106 #if defined(RUN_MESSAGE_CENTER_TESTS)
107 #define MAYBE_BasicAddCancel BasicAddCancel
108 #else
109 #define MAYBE_BasicAddCancel DISABLED_BasicAddCancel
110 #endif
111
112 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, MAYBE_BasicAddCancel) {
113 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
114 manager()->Add(CreateTestNotification("hey"), profile()); 107 manager()->Add(CreateTestNotification("hey"), profile());
115 EXPECT_EQ(1u, message_center()->NotificationCount()); 108 EXPECT_EQ(1u, message_center()->NotificationCount());
116 manager()->CancelById("hey"); 109 manager()->CancelById("hey");
117 EXPECT_EQ(0u, message_center()->NotificationCount()); 110 EXPECT_EQ(0u, message_center()->NotificationCount());
118 } 111 }
119 112
120 // MessaceCenter-specific test. 113 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicDelegate) {
121 #if defined(RUN_MESSAGE_CENTER_TESTS)
122 #define MAYBE_BasicDelegate BasicDelegate
123 #else
124 #define MAYBE_BasicDelegate DISABLED_BasicDelegate
125 #endif
126
127 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, MAYBE_BasicDelegate) {
128 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
129 TestDelegate* delegate; 114 TestDelegate* delegate;
130 manager()->Add(CreateTestNotification("hey", &delegate), profile()); 115 manager()->Add(CreateTestNotification("hey", &delegate), profile());
131 // Verify that delegate accumulated correct log of events. 116 // Verify that delegate accumulated correct log of events.
132 EXPECT_EQ("Display_", delegate->log()); 117 EXPECT_EQ("Display_", delegate->log());
133 manager()->CancelById("hey"); 118 manager()->CancelById("hey");
134 // Verify that delegate accumulated correct log of events. 119 // Verify that delegate accumulated correct log of events.
135 EXPECT_EQ("Display_Close_programmatically_", delegate->log()); 120 EXPECT_EQ("Display_Close_programmatically_", delegate->log());
136 delegate->Release(); 121 delegate->Release();
137 } 122 }
138 123
139 // MessaceCenter-specific test. 124 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, ButtonClickedDelegate) {
140 #if defined(RUN_MESSAGE_CENTER_TESTS)
141 #define MAYBE_ButtonClickedDelegate ButtonClickedDelegate
142 #else
143 #define MAYBE_ButtonClickedDelegate DISABLED_ButtonClickedDelegate
144 #endif
145
146 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
147 MAYBE_ButtonClickedDelegate) {
148 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
149 TestDelegate* delegate; 125 TestDelegate* delegate;
150 manager()->Add(CreateTestNotification("n", &delegate), profile()); 126 manager()->Add(CreateTestNotification("n", &delegate), profile());
151 message_center()->ClickOnNotificationButton("n", 1); 127 message_center()->ClickOnNotificationButton("n", 1);
152 // Verify that delegate accumulated correct log of events. 128 // Verify that delegate accumulated correct log of events.
153 EXPECT_EQ("Display_ButtonClick_1_", delegate->log()); 129 EXPECT_EQ("Display_ButtonClick_1_", delegate->log());
154 delegate->Release(); 130 delegate->Release();
155 } 131 }
156 132
157 #endif // !defined(OS_MACOSX) 133 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698