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

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

Issue 231723006: Remove balloon notification code. The last user was the Linux GTK port but that's deleted now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync after elliot's r263101 Created 6 years, 8 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 "chrome/browser/browser_process.h" 5 #include "chrome/browser/browser_process.h"
6 #include "chrome/browser/extensions/extension_browsertest.h" 6 #include "chrome/browser/extensions/extension_browsertest.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/notifications/balloon.h"
9 #include "chrome/browser/notifications/balloon_collection.h"
10 #include "chrome/browser/notifications/balloon_host.h"
11 #include "chrome/browser/notifications/notification.h" 8 #include "chrome/browser/notifications/notification.h"
12 #include "chrome/browser/notifications/notification_delegate.h" 9 #include "chrome/browser/notifications/notification_delegate.h"
10 #include "chrome/browser/notifications/notification_ui_manager.h"
13 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
18 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/render_process_host.h" 17 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/render_view_host.h" 18 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/result_codes.h" 20 #include "content/public/common/result_codes.h"
23 #include "extensions/browser/extension_host.h" 21 #include "extensions/browser/extension_host.h"
24 #include "extensions/browser/extension_registry.h" 22 #include "extensions/browser/extension_registry.h"
25 #include "extensions/browser/extension_system.h" 23 #include "extensions/browser/extension_system.h"
26 #include "extensions/browser/process_manager.h" 24 #include "extensions/browser/process_manager.h"
27 #include "extensions/browser/process_map.h" 25 #include "extensions/browser/process_map.h"
28 #include "ui/message_center/message_center.h" 26 #include "ui/message_center/message_center.h"
29 #include "ui/message_center/message_center_switches.h" 27 #include "ui/message_center/message_center_switches.h"
30 #include "ui/message_center/message_center_util.h" 28 #include "ui/message_center/message_center_util.h"
31 #include "ui/message_center/notification_list.h" 29 #include "ui/message_center/notification_list.h"
32 30
33 #if defined(OS_CHROMEOS)
34 #include "chrome/browser/notifications/notification_ui_manager.h"
35 #else
36 #include "chrome/browser/notifications/balloon_notification_ui_manager.h"
37 #endif
38
39 using content::NavigationController; 31 using content::NavigationController;
40 using content::WebContents; 32 using content::WebContents;
41 using extensions::Extension; 33 using extensions::Extension;
42 using extensions::ExtensionRegistry; 34 using extensions::ExtensionRegistry;
43 35
44 // Tests are timing out waiting for extension to crash. 36 // Tests are timing out waiting for extension to crash.
45 // http://crbug.com/174705 37 // http://crbug.com/174705
46 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_LINUX) 38 #if defined(OS_MACOSX) || defined(USE_AURA) || defined(OS_LINUX)
47 #define MAYBE_ExtensionCrashRecoveryTest DISABLED_ExtensionCrashRecoveryTest 39 #define MAYBE_ExtensionCrashRecoveryTest DISABLED_ExtensionCrashRecoveryTest
48 #else 40 #else
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 122 }
131 123
132 std::string first_extension_id_; 124 std::string first_extension_id_;
133 std::string second_extension_id_; 125 std::string second_extension_id_;
134 }; 126 };
135 127
136 class MAYBE_ExtensionCrashRecoveryTest 128 class MAYBE_ExtensionCrashRecoveryTest
137 : public ExtensionCrashRecoveryTestBase { 129 : public ExtensionCrashRecoveryTestBase {
138 protected: 130 protected:
139 virtual void AcceptNotification(size_t index) OVERRIDE { 131 virtual void AcceptNotification(size_t index) OVERRIDE {
140 if (message_center::IsRichNotificationEnabled()) { 132 message_center::MessageCenter* message_center =
141 message_center::MessageCenter* message_center = 133 message_center::MessageCenter::Get();
142 message_center::MessageCenter::Get(); 134 ASSERT_GT(message_center->NotificationCount(), index);
143 ASSERT_GT(message_center->NotificationCount(), index); 135 message_center::NotificationList::Notifications::reverse_iterator it =
144 message_center::NotificationList::Notifications::reverse_iterator it = 136 message_center->GetVisibleNotifications().rbegin();
145 message_center->GetVisibleNotifications().rbegin(); 137 for (size_t i=0; i < index; ++i)
146 for (size_t i=0; i < index; ++i) 138 it++;
147 it++; 139 std::string id = (*it)->id();
148 std::string id = (*it)->id(); 140 message_center->ClickOnNotification(id);
149 message_center->ClickOnNotification(id);
150 #if defined(TOOLKIT_GTK)
151 } else {
152 Balloon* balloon = GetNotificationDelegate(index);
153 ASSERT_TRUE(balloon);
154 balloon->OnClick();
155 #endif
156 }
157 WaitForExtensionLoad(); 141 WaitForExtensionLoad();
158 } 142 }
159 143
160 virtual void CancelNotification(size_t index) OVERRIDE { 144 virtual void CancelNotification(size_t index) OVERRIDE {
161 if (message_center::IsRichNotificationEnabled()) { 145 message_center::MessageCenter* message_center =
162 message_center::MessageCenter* message_center = 146 message_center::MessageCenter::Get();
163 message_center::MessageCenter::Get(); 147 ASSERT_GT(message_center->NotificationCount(), index);
164 ASSERT_GT(message_center->NotificationCount(), index); 148 message_center::NotificationList::Notifications::reverse_iterator it =
165 message_center::NotificationList::Notifications::reverse_iterator it = 149 message_center->GetVisibleNotifications().rbegin();
166 message_center->GetVisibleNotifications().rbegin(); 150 for (size_t i=0; i < index; i++) { it++; }
167 for (size_t i=0; i < index; i++) { it++; } 151 ASSERT_TRUE(g_browser_process->notification_ui_manager()->
168 ASSERT_TRUE(g_browser_process->notification_ui_manager()-> 152 CancelById((*it)->id()));
169 CancelById((*it)->id()));
170 #if defined(TOOLKIT_GTK)
171 } else {
172 Balloon* balloon = GetNotificationDelegate(index);
173 ASSERT_TRUE(balloon);
174 std::string id = balloon->notification().notification_id();
175 ASSERT_TRUE(g_browser_process->notification_ui_manager()->CancelById(id));
176 #endif
177 }
178 } 153 }
179 154
180 virtual size_t CountBalloons() OVERRIDE { 155 virtual size_t CountBalloons() OVERRIDE {
181 if (message_center::IsRichNotificationEnabled()) 156 return message_center::MessageCenter::Get()->NotificationCount();
182 return message_center::MessageCenter::Get()->NotificationCount();
183
184 #if defined(TOOLKIT_GTK)
185 return BalloonNotificationUIManager::GetInstanceForTesting()->
186 balloon_collection()->GetActiveBalloons().size();
187 #else
188 CHECK(false);
189 return 0;
190 #endif
191 } 157 }
192
193 private:
194 #if defined(TOOLKIT_GTK)
195 Balloon* GetNotificationDelegate(size_t index) {
196 BalloonNotificationUIManager* manager =
197 BalloonNotificationUIManager::GetInstanceForTesting();
198 BalloonCollection::Balloons balloons =
199 manager->balloon_collection()->GetActiveBalloons();
200 return index < balloons.size() ? balloons.at(index) : NULL;
201 }
202 #endif
203 }; 158 };
204 159
205 // Flaky: http://crbug.com/242167. 160 // Flaky: http://crbug.com/242167.
206 IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, DISABLED_Basic) { 161 IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, DISABLED_Basic) {
207 const size_t count_before = GetEnabledExtensionCount(); 162 const size_t count_before = GetEnabledExtensionCount();
208 const size_t crash_count_before = GetTerminatedExtensionCount(); 163 const size_t crash_count_before = GetTerminatedExtensionCount();
209 LoadTestExtension(); 164 LoadTestExtension();
210 CrashExtension(first_extension_id_); 165 CrashExtension(first_extension_id_);
211 ASSERT_EQ(count_before, GetEnabledExtensionCount()); 166 ASSERT_EQ(count_before, GetEnabledExtensionCount());
212 ASSERT_EQ(crash_count_before + 1, GetTerminatedExtensionCount()); 167 ASSERT_EQ(crash_count_before + 1, GetTerminatedExtensionCount());
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 GetController())); 548 GetController()));
594 chrome::Reload(browser(), CURRENT_TAB); 549 chrome::Reload(browser(), CURRENT_TAB);
595 observer.Wait(); 550 observer.Wait();
596 } 551 }
597 // Extension should now be loaded. 552 // Extension should now be loaded.
598 SCOPED_TRACE("after reloading the tab"); 553 SCOPED_TRACE("after reloading the tab");
599 CheckExtensionConsistency(first_extension_id_); 554 CheckExtensionConsistency(first_extension_id_);
600 ASSERT_EQ(count_before + 1, GetEnabledExtensionCount()); 555 ASSERT_EQ(count_before + 1, GetEnabledExtensionCount());
601 ASSERT_EQ(0U, CountBalloons()); 556 ASSERT_EQ(0U, CountBalloons());
602 } 557 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698