diff options
author | johnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-04 21:12:00 +0000 |
---|---|---|
committer | johnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-04 21:12:00 +0000 |
commit | 38baba4defaf68ba8f666a07e139df2a0a8e4ff2 (patch) | |
tree | 8029135137e4e68e58f4198d5d3bf3393274ba4f | |
parent | efbb4b4ba453f91562a437cff0d1bda8f3d1606e (diff) | |
download | chromium_src-38baba4defaf68ba8f666a07e139df2a0a8e4ff2.zip chromium_src-38baba4defaf68ba8f666a07e139df2a0a8e4ff2.tar.gz chromium_src-38baba4defaf68ba8f666a07e139df2a0a8e4ff2.tar.bz2 |
When notifications are closed by the user, send the notification to remove it rom the task manager. Add a browser test for the same.
BUG=46809
TEST=included (or for manual, open the task manager and create and dismiss notifications).
Review URL: http://codereview.chromium.org/4493002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65111 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/notifications/balloon_host.cc | 1 | ||||
-rw-r--r-- | chrome/browser/notifications/notification_test_util.h | 24 | ||||
-rw-r--r-- | chrome/browser/task_manager/task_manager_browsertest.cc | 38 |
3 files changed, 62 insertions, 1 deletions
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc index f47d395..ecb52cd 100644 --- a/chrome/browser/notifications/balloon_host.cc +++ b/chrome/browser/notifications/balloon_host.cc @@ -40,6 +40,7 @@ BalloonHost::BalloonHost(Balloon* balloon) } void BalloonHost::Shutdown() { + NotifyDisconnect(); if (render_view_host_) { render_view_host_->Shutdown(); render_view_host_ = NULL; diff --git a/chrome/browser/notifications/notification_test_util.h b/chrome/browser/notifications/notification_test_util.h index b2f0c34..4cbf600 100644 --- a/chrome/browser/notifications/notification_test_util.h +++ b/chrome/browser/notifications/notification_test_util.h @@ -10,8 +10,30 @@ #include "chrome/browser/notifications/balloon.h" #include "gfx/size.h" +// NotificationDelegate which does nothing, useful for testing when +// the notification events are not important. +class MockNotificationDelegate : public NotificationDelegate { + public: + explicit MockNotificationDelegate(std::string id) : id_(id) {} + virtual ~MockNotificationDelegate() {} + + // NotificationDelegate interface. + virtual void Display() {} + virtual void Error() {} + virtual void Close(bool by_user) {} + virtual void Click() {} + virtual std::string id() const { return id_; } + + private: + std::string id_; +}; + // Mock implementation of Javascript object proxy which logs events that -// would have been fired on it. |Logger| class must static "log()" method. +// would have been fired on it. Useful for tests where the sequence of +// notification events needs to be verified. +// +// |Logger| class provided in template must implement method +// static void log(string); template<class Logger> class LoggingNotificationProxyBase : public NotificationObjectProxy { public: diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc index 5828c22..9e3c181 100644 --- a/chrome/browser/task_manager/task_manager_browsertest.cc +++ b/chrome/browser/task_manager/task_manager_browsertest.cc @@ -6,11 +6,16 @@ #include "app/l10n_util.h" #include "base/file_path.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_navigator.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/extensions/crashed_extension_infobar.h" #include "chrome/browser/extensions/extension_browsertest.h" +#include "chrome/browser/notifications/desktop_notification_service.h" +#include "chrome/browser/notifications/notification_test_util.h" +#include "chrome/browser/notifications/notification_ui_manager.h" #include "chrome/browser/tab_contents/infobar_delegate.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tabs/tab_strip_model.h" @@ -138,6 +143,39 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, MAYBE_NoticeExtensionChanges) { WaitForResourceChange(3); } +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, NoticeNotificationChanges) { + EXPECT_EQ(0, model()->ResourceCount()); + + // Show the task manager. + browser()->window()->ShowTaskManager(); + // Expect to see the browser and the New Tab Page renderer. + EXPECT_EQ(2, model()->ResourceCount()); + + // Show a notification. + NotificationUIManager* notifications = + g_browser_process->notification_ui_manager(); + + string16 content = DesktopNotificationService::CreateDataUrl( + GURL(), ASCIIToUTF16("Hello World!"), string16(), + WebKit::WebTextDirectionDefault); + + scoped_refptr<NotificationDelegate> del1(new MockNotificationDelegate("n1")); + Notification n1( + GURL(), GURL(content), ASCIIToUTF16("Test 1"), string16(), del1.get()); + scoped_refptr<NotificationDelegate> del2(new MockNotificationDelegate("n2")); + Notification n2( + GURL(), GURL(content), ASCIIToUTF16("Test 2"), string16(), del2.get()); + + notifications->Add(n1, browser()->profile()); + WaitForResourceChange(3); + notifications->Add(n2, browser()->profile()); + WaitForResourceChange(4); + notifications->Cancel(n1); + WaitForResourceChange(3); + notifications->Cancel(n2); + WaitForResourceChange(2); +} + // Times out on Vista; disabled to keep tests fast. http://crbug.com/44991 #if defined(OS_WIN) #define KillExtension DISABLED_KillExtension |