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

Side by Side Diff: chrome/browser/extensions/extension_crash_recovery_browsertest.cc

Issue 15025002: Remove ENABLE_MESSAGE_CENTER (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: try bots love work 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) 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 "base/command_line.h"
6 #include "base/logging.h"
5 #include "base/process_util.h" 7 #include "base/process_util.h"
6 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/extensions/extension_browsertest.h" 9 #include "chrome/browser/extensions/extension_browsertest.h"
8 #include "chrome/browser/extensions/extension_host.h" 10 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_process_manager.h" 11 #include "chrome/browser/extensions/extension_process_manager.h"
10 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h" 13 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/notifications/balloon.h" 14 #include "chrome/browser/notifications/balloon.h"
13 #include "chrome/browser/notifications/balloon_collection.h" 15 #include "chrome/browser/notifications/balloon_collection.h"
14 #include "chrome/browser/notifications/balloon_host.h" 16 #include "chrome/browser/notifications/balloon_host.h"
15 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" 17 #include "chrome/browser/notifications/balloon_notification_ui_manager.h"
16 #include "chrome/browser/notifications/notification.h" 18 #include "chrome/browser/notifications/notification.h"
17 #include "chrome/browser/notifications/notification_delegate.h" 19 #include "chrome/browser/notifications/notification_delegate.h"
18 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_commands.h" 22 #include "chrome/browser/ui/browser_commands.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 23 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
23 #include "content/public/browser/navigation_controller.h" 25 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
25 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "content/public/common/result_codes.h" 29 #include "content/public/common/result_codes.h"
28
29 #if defined(ENABLE_MESSAGE_CENTER)
30 #include "base/command_line.h"
31 #include "ui/message_center/message_center.h" 30 #include "ui/message_center/message_center.h"
32 #include "ui/message_center/message_center_switches.h" 31 #include "ui/message_center/message_center_switches.h"
32 #include "ui/message_center/message_center_util.h"
33 #include "ui/message_center/notification_list.h" 33 #include "ui/message_center/notification_list.h"
34 #endif
35 34
36 using content::NavigationController; 35 using content::NavigationController;
37 using content::WebContents; 36 using content::WebContents;
38 using extensions::Extension; 37 using extensions::Extension;
39 38
40 // Tests are timing out waiting for extension to crash. 39 // Tests are timing out waiting for extension to crash.
41 // http://crbug.com/174705 40 // http://crbug.com/174705
42 #if defined(OS_MACOSX) || defined(USE_AURA) 41 #if defined(OS_MACOSX) || defined(USE_AURA)
43 #define MAYBE_ExtensionCrashRecoveryTest DISABLED_ExtensionCrashRecoveryTest 42 #define MAYBE_ExtensionCrashRecoveryTest DISABLED_ExtensionCrashRecoveryTest
44 #else 43 #else
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 ASSERT_TRUE(extension); 109 ASSERT_TRUE(extension);
111 second_extension_id_ = extension->id(); 110 second_extension_id_ = extension->id();
112 CheckExtensionConsistency(second_extension_id_); 111 CheckExtensionConsistency(second_extension_id_);
113 } 112 }
114 113
115 std::string first_extension_id_; 114 std::string first_extension_id_;
116 std::string second_extension_id_; 115 std::string second_extension_id_;
117 116
118 }; 117 };
119 118
120 // TODO(rsesek): Implement and enable these tests. http://crbug.com/179904 119 class MAYBE_ExtensionCrashRecoveryTest
121 #if defined(ENABLE_MESSAGE_CENTER) && !defined(OS_MACOSX)
122
123 class MessageCenterExtensionCrashRecoveryTest
124 : public ExtensionCrashRecoveryTestBase { 120 : public ExtensionCrashRecoveryTestBase {
125 protected: 121 protected:
126 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
127 ExtensionCrashRecoveryTestBase::SetUpCommandLine(command_line);
128 command_line->AppendSwitch(
129 message_center::switches::kEnableRichNotifications);
130 }
131
132 virtual void AcceptNotification(size_t index) OVERRIDE { 122 virtual void AcceptNotification(size_t index) OVERRIDE {
133 message_center::MessageCenter* message_center = 123 if (message_center::IsRichNotificationEnabled()) {
134 message_center::MessageCenter::Get(); 124 message_center::MessageCenter* message_center =
135 ASSERT_GT(message_center->NotificationCount(), index); 125 message_center::MessageCenter::Get();
136 message_center::NotificationList::Notifications::reverse_iterator it = 126 ASSERT_GT(message_center->NotificationCount(), index);
137 message_center->GetNotifications().rbegin(); 127 message_center::NotificationList::Notifications::reverse_iterator it =
138 for (size_t i=0; i < index; ++i) 128 message_center->GetNotifications().rbegin();
139 it++; 129 for (size_t i=0; i < index; ++i)
140 std::string id = (*it)->id(); 130 it++;
141 message_center->ClickOnNotification(id); 131 std::string id = (*it)->id();
132 message_center->ClickOnNotification(id);
133 } else {
134 LOG(ERROR) << "AcceptNotification 1, index: " << index;
135 Balloon* balloon = GetNotificationDelegate(index);
136 LOG(ERROR) << "AcceptNotification 2";
137 ASSERT_TRUE(balloon);
138 LOG(ERROR) << "AcceptNotification 3";
139 balloon->OnClick();
140 LOG(ERROR) << "AcceptNotification 4";
141 }
142 LOG(ERROR) << "AcceptNotification 5";
142 WaitForExtensionLoad(); 143 WaitForExtensionLoad();
144 LOG(ERROR) << "AcceptNotification 6";
143 } 145 }
144 146
145 virtual void CancelNotification(size_t index) OVERRIDE { 147 virtual void CancelNotification(size_t index) OVERRIDE {
146 message_center::MessageCenter* message_center = 148 if (message_center::IsRichNotificationEnabled()) {
147 message_center::MessageCenter::Get(); 149 message_center::MessageCenter* message_center =
148 ASSERT_GT(message_center->NotificationCount(), index); 150 message_center::MessageCenter::Get();
149 message_center::NotificationList::Notifications::reverse_iterator it = 151 ASSERT_GT(message_center->NotificationCount(), index);
150 message_center->GetNotifications().rbegin(); 152 message_center::NotificationList::Notifications::reverse_iterator it =
151 for (size_t i=0; i < index; i++) { it++; } 153 message_center->GetNotifications().rbegin();
152 ASSERT_TRUE( 154 for (size_t i=0; i < index; i++) { it++; }
153 g_browser_process->notification_ui_manager()->CancelById((*it)->id())); 155 ASSERT_TRUE(g_browser_process->notification_ui_manager()->
156 CancelById((*it)->id()));
157 } else {
158 Balloon* balloon = GetNotificationDelegate(index);
159 ASSERT_TRUE(balloon);
160 std::string id = balloon->notification().notification_id();
161 ASSERT_TRUE(g_browser_process->notification_ui_manager()->CancelById(id));
162 }
154 } 163 }
155 164
156 virtual size_t CountBalloons() OVERRIDE { 165 virtual size_t CountBalloons() OVERRIDE {
157 message_center::MessageCenter* message_center = 166 if (message_center::IsRichNotificationEnabled()) {
158 message_center::MessageCenter::Get(); 167 message_center::MessageCenter* message_center =
159 return message_center->NotificationCount(); 168 message_center::MessageCenter::Get();
160 } 169 return message_center->NotificationCount();
161 }; 170 } else {
162 171 BalloonNotificationUIManager* manager =
163 typedef MessageCenterExtensionCrashRecoveryTest 172 BalloonNotificationUIManager::GetInstanceForTesting();
164 MAYBE_ExtensionCrashRecoveryTest; 173 BalloonCollection::Balloons balloons =
165 174 manager->balloon_collection()->GetActiveBalloons();
166 #else // defined(ENABLED_MESSAGE_CENTER) 175 return balloons.size();
167 176 }
168 class BalloonExtensionCrashRecoveryTest
169 : public ExtensionCrashRecoveryTestBase {
170 protected:
171 virtual void AcceptNotification(size_t index) OVERRIDE {
172 Balloon* balloon = GetNotificationDelegate(index);
173 ASSERT_TRUE(balloon);
174 balloon->OnClick();
175 WaitForExtensionLoad();
176 } 177 }
177 178
178 virtual void CancelNotification(size_t index) OVERRIDE { 179 private:
179 Balloon* balloon = GetNotificationDelegate(index); 180 Balloon* GetNotificationDelegate(size_t index) {
180 ASSERT_TRUE(balloon); 181 BalloonNotificationUIManager* manager =
181 std::string id = balloon->notification().notification_id(); 182 BalloonNotificationUIManager::GetInstanceForTesting();
182 ASSERT_TRUE(g_browser_process->notification_ui_manager()->CancelById(id)); 183 BalloonCollection::Balloons balloons =
183 } 184 manager->balloon_collection()->GetActiveBalloons();
184 185 return index < balloons.size() ? balloons.at(index) : NULL;
185 virtual size_t CountBalloons() OVERRIDE { 186 }
186 BalloonNotificationUIManager* manager =
187 BalloonNotificationUIManager::GetInstanceForTesting();
188 BalloonCollection::Balloons balloons =
189 manager->balloon_collection()->GetActiveBalloons();
190 return balloons.size();
191 }
192 private:
193 Balloon* GetNotificationDelegate(size_t index) {
194 BalloonNotificationUIManager* manager =
195 BalloonNotificationUIManager::GetInstanceForTesting();
196 BalloonCollection::Balloons balloons =
197 manager->balloon_collection()->GetActiveBalloons();
198 return index < balloons.size() ? balloons.at(index) : NULL;
199 }
200 }; 187 };
201 188
202 typedef BalloonExtensionCrashRecoveryTest MAYBE_ExtensionCrashRecoveryTest;
203 #endif // defined(ENABLE_MESSAGE_CENTER)
204
205 IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, Basic) { 189 IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, Basic) {
206 const size_t size_before = GetExtensionService()->extensions()->size(); 190 const size_t size_before = GetExtensionService()->extensions()->size();
207 const size_t crash_size_before = 191 const size_t crash_size_before =
208 GetExtensionService()->terminated_extensions()->size(); 192 GetExtensionService()->terminated_extensions()->size();
193 LOG(ERROR) << "Basic 1";
dewittj 2013/05/08 18:53:01 These log statements should probably be removed.
Dmitry Titov 2013/05/08 23:03:26 Done.
209 LoadTestExtension(); 194 LoadTestExtension();
195 LOG(ERROR) << "Basic 2";
210 CrashExtension(first_extension_id_); 196 CrashExtension(first_extension_id_);
197 LOG(ERROR) << "Basic 3";
211 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); 198 ASSERT_EQ(size_before, GetExtensionService()->extensions()->size());
212 ASSERT_EQ(crash_size_before + 1, 199 ASSERT_EQ(crash_size_before + 1,
213 GetExtensionService()->terminated_extensions()->size()); 200 GetExtensionService()->terminated_extensions()->size());
201 LOG(ERROR) << "Basic 4";
214 ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); 202 ASSERT_NO_FATAL_FAILURE(AcceptNotification(0));
215 203
216 SCOPED_TRACE("after clicking the balloon"); 204 SCOPED_TRACE("after clicking the balloon");
205 LOG(ERROR) << "Basic 5";
217 CheckExtensionConsistency(first_extension_id_); 206 CheckExtensionConsistency(first_extension_id_);
207 LOG(ERROR) << "Basic 6";
218 ASSERT_EQ(crash_size_before, 208 ASSERT_EQ(crash_size_before,
219 GetExtensionService()->terminated_extensions()->size()); 209 GetExtensionService()->terminated_extensions()->size());
220 } 210 }
221 211
222 IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, CloseAndReload) { 212 IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, CloseAndReload) {
223 const size_t size_before = GetExtensionService()->extensions()->size(); 213 const size_t size_before = GetExtensionService()->extensions()->size();
224 const size_t crash_size_before = 214 const size_t crash_size_before =
225 GetExtensionService()->terminated_extensions()->size(); 215 GetExtensionService()->terminated_extensions()->size();
226 LoadTestExtension(); 216 LoadTestExtension();
227 CrashExtension(first_extension_id_); 217 CrashExtension(first_extension_id_);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 GetController())); 572 GetController()));
583 chrome::Reload(browser(), CURRENT_TAB); 573 chrome::Reload(browser(), CURRENT_TAB);
584 observer.Wait(); 574 observer.Wait();
585 } 575 }
586 // Extension should now be loaded. 576 // Extension should now be loaded.
587 SCOPED_TRACE("after reloading the tab"); 577 SCOPED_TRACE("after reloading the tab");
588 CheckExtensionConsistency(first_extension_id_); 578 CheckExtensionConsistency(first_extension_id_);
589 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size()); 579 ASSERT_EQ(size_before + 1, GetExtensionService()->extensions()->size());
590 ASSERT_EQ(0U, CountBalloons()); 580 ASSERT_EQ(0U, CountBalloons());
591 } 581 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698