Index: chrome/browser/extensions/extension_crash_recovery_browsertest.cc |
diff --git a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc |
index 287aea96f8b422e9b9d3123b5db54636e8248fd8..17f036b36f3d79ff637118dae02805a1410fb41d 100644 |
--- a/chrome/browser/extensions/extension_crash_recovery_browsertest.cc |
+++ b/chrome/browser/extensions/extension_crash_recovery_browsertest.cc |
@@ -2,6 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/command_line.h" |
+#include "base/logging.h" |
#include "base/process_util.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/extensions/extension_browsertest.h" |
@@ -25,13 +27,10 @@ |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/common/result_codes.h" |
- |
-#if defined(ENABLE_MESSAGE_CENTER) |
-#include "base/command_line.h" |
#include "ui/message_center/message_center.h" |
#include "ui/message_center/message_center_switches.h" |
+#include "ui/message_center/message_center_util.h" |
#include "ui/message_center/notification_list.h" |
-#endif |
using content::NavigationController; |
using content::WebContents; |
@@ -117,104 +116,95 @@ class ExtensionCrashRecoveryTestBase : public ExtensionBrowserTest { |
}; |
-// TODO(rsesek): Implement and enable these tests. http://crbug.com/179904 |
-#if defined(ENABLE_MESSAGE_CENTER) && !defined(OS_MACOSX) |
- |
-class MessageCenterExtensionCrashRecoveryTest |
+class MAYBE_ExtensionCrashRecoveryTest |
: public ExtensionCrashRecoveryTestBase { |
protected: |
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
- ExtensionCrashRecoveryTestBase::SetUpCommandLine(command_line); |
- command_line->AppendSwitch( |
- message_center::switches::kEnableRichNotifications); |
- } |
- |
virtual void AcceptNotification(size_t index) OVERRIDE { |
- message_center::MessageCenter* message_center = |
- message_center::MessageCenter::Get(); |
- ASSERT_GT(message_center->NotificationCount(), index); |
- message_center::NotificationList::Notifications::reverse_iterator it = |
- message_center->GetNotifications().rbegin(); |
- for (size_t i=0; i < index; ++i) |
- it++; |
- std::string id = (*it)->id(); |
- message_center->ClickOnNotification(id); |
+ if (message_center::IsRichNotificationEnabled()) { |
+ message_center::MessageCenter* message_center = |
+ message_center::MessageCenter::Get(); |
+ ASSERT_GT(message_center->NotificationCount(), index); |
+ message_center::NotificationList::Notifications::reverse_iterator it = |
+ message_center->GetNotifications().rbegin(); |
+ for (size_t i=0; i < index; ++i) |
+ it++; |
+ std::string id = (*it)->id(); |
+ message_center->ClickOnNotification(id); |
+ } else { |
+LOG(ERROR) << "AcceptNotification 1, index: " << index; |
+ Balloon* balloon = GetNotificationDelegate(index); |
+ LOG(ERROR) << "AcceptNotification 2"; |
+ ASSERT_TRUE(balloon); |
+ LOG(ERROR) << "AcceptNotification 3"; |
+ balloon->OnClick(); |
+ LOG(ERROR) << "AcceptNotification 4"; |
+ } |
+ LOG(ERROR) << "AcceptNotification 5"; |
WaitForExtensionLoad(); |
+ LOG(ERROR) << "AcceptNotification 6"; |
} |
virtual void CancelNotification(size_t index) OVERRIDE { |
- message_center::MessageCenter* message_center = |
- message_center::MessageCenter::Get(); |
- ASSERT_GT(message_center->NotificationCount(), index); |
- message_center::NotificationList::Notifications::reverse_iterator it = |
- message_center->GetNotifications().rbegin(); |
- for (size_t i=0; i < index; i++) { it++; } |
- ASSERT_TRUE( |
- g_browser_process->notification_ui_manager()->CancelById((*it)->id())); |
+ if (message_center::IsRichNotificationEnabled()) { |
+ message_center::MessageCenter* message_center = |
+ message_center::MessageCenter::Get(); |
+ ASSERT_GT(message_center->NotificationCount(), index); |
+ message_center::NotificationList::Notifications::reverse_iterator it = |
+ message_center->GetNotifications().rbegin(); |
+ for (size_t i=0; i < index; i++) { it++; } |
+ ASSERT_TRUE(g_browser_process->notification_ui_manager()-> |
+ CancelById((*it)->id())); |
+ } else { |
+ Balloon* balloon = GetNotificationDelegate(index); |
+ ASSERT_TRUE(balloon); |
+ std::string id = balloon->notification().notification_id(); |
+ ASSERT_TRUE(g_browser_process->notification_ui_manager()->CancelById(id)); |
+ } |
} |
virtual size_t CountBalloons() OVERRIDE { |
- message_center::MessageCenter* message_center = |
- message_center::MessageCenter::Get(); |
- return message_center->NotificationCount(); |
+ if (message_center::IsRichNotificationEnabled()) { |
+ message_center::MessageCenter* message_center = |
+ message_center::MessageCenter::Get(); |
+ return message_center->NotificationCount(); |
+ } else { |
+ BalloonNotificationUIManager* manager = |
+ BalloonNotificationUIManager::GetInstanceForTesting(); |
+ BalloonCollection::Balloons balloons = |
+ manager->balloon_collection()->GetActiveBalloons(); |
+ return balloons.size(); |
+ } |
} |
-}; |
- |
-typedef MessageCenterExtensionCrashRecoveryTest |
- MAYBE_ExtensionCrashRecoveryTest; |
-#else // defined(ENABLED_MESSAGE_CENTER) |
- |
-class BalloonExtensionCrashRecoveryTest |
- : public ExtensionCrashRecoveryTestBase { |
- protected: |
- virtual void AcceptNotification(size_t index) OVERRIDE { |
- Balloon* balloon = GetNotificationDelegate(index); |
- ASSERT_TRUE(balloon); |
- balloon->OnClick(); |
- WaitForExtensionLoad(); |
- } |
- |
- virtual void CancelNotification(size_t index) OVERRIDE { |
- Balloon* balloon = GetNotificationDelegate(index); |
- ASSERT_TRUE(balloon); |
- std::string id = balloon->notification().notification_id(); |
- ASSERT_TRUE(g_browser_process->notification_ui_manager()->CancelById(id)); |
- } |
- |
- virtual size_t CountBalloons() OVERRIDE { |
- BalloonNotificationUIManager* manager = |
- BalloonNotificationUIManager::GetInstanceForTesting(); |
- BalloonCollection::Balloons balloons = |
- manager->balloon_collection()->GetActiveBalloons(); |
- return balloons.size(); |
- } |
- private: |
- Balloon* GetNotificationDelegate(size_t index) { |
- BalloonNotificationUIManager* manager = |
- BalloonNotificationUIManager::GetInstanceForTesting(); |
- BalloonCollection::Balloons balloons = |
- manager->balloon_collection()->GetActiveBalloons(); |
- return index < balloons.size() ? balloons.at(index) : NULL; |
- } |
+private: |
+ Balloon* GetNotificationDelegate(size_t index) { |
+ BalloonNotificationUIManager* manager = |
+ BalloonNotificationUIManager::GetInstanceForTesting(); |
+ BalloonCollection::Balloons balloons = |
+ manager->balloon_collection()->GetActiveBalloons(); |
+ return index < balloons.size() ? balloons.at(index) : NULL; |
+ } |
}; |
-typedef BalloonExtensionCrashRecoveryTest MAYBE_ExtensionCrashRecoveryTest; |
-#endif // defined(ENABLE_MESSAGE_CENTER) |
- |
IN_PROC_BROWSER_TEST_F(MAYBE_ExtensionCrashRecoveryTest, Basic) { |
const size_t size_before = GetExtensionService()->extensions()->size(); |
const size_t crash_size_before = |
GetExtensionService()->terminated_extensions()->size(); |
+ 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.
|
LoadTestExtension(); |
+ LOG(ERROR) << "Basic 2"; |
CrashExtension(first_extension_id_); |
+ LOG(ERROR) << "Basic 3"; |
ASSERT_EQ(size_before, GetExtensionService()->extensions()->size()); |
ASSERT_EQ(crash_size_before + 1, |
GetExtensionService()->terminated_extensions()->size()); |
+ LOG(ERROR) << "Basic 4"; |
ASSERT_NO_FATAL_FAILURE(AcceptNotification(0)); |
SCOPED_TRACE("after clicking the balloon"); |
+ LOG(ERROR) << "Basic 5"; |
CheckExtensionConsistency(first_extension_id_); |
+ LOG(ERROR) << "Basic 6"; |
ASSERT_EQ(crash_size_before, |
GetExtensionService()->terminated_extensions()->size()); |
} |