diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 08:46:28 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-27 08:46:28 +0000 |
commit | 9c5e417def0fef57d5dc79b0348dab9b0d354d42 (patch) | |
tree | 9ea11b8b75b443724becad0ce34916f2de34eacc | |
parent | 5c22958a27f510c5c8f88f77a5769fef971070e3 (diff) | |
download | chromium_src-9c5e417def0fef57d5dc79b0348dab9b0d354d42.zip chromium_src-9c5e417def0fef57d5dc79b0348dab9b0d354d42.tar.gz chromium_src-9c5e417def0fef57d5dc79b0348dab9b0d354d42.tar.bz2 |
Create OpenClose browser test for TaskManager with necessary refactoring.
http://crbug.com/12320
Review URL: http://codereview.chromium.org/113636
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16978 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/task_manager.cc | 10 | ||||
-rw-r--r-- | chrome/browser/task_manager.h | 7 | ||||
-rw-r--r-- | chrome/browser/task_manager_browsertest.cc | 8 | ||||
-rw-r--r-- | chrome/browser/task_manager_linux.cc | 5 | ||||
-rw-r--r-- | chrome/browser/task_manager_win.cc | 9 |
5 files changed, 31 insertions, 8 deletions
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index 717ffd6..de6f47f 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -706,9 +706,10 @@ void TaskManager::Open() { task_manager->view_->OpenWindow(); } +// static void TaskManager::Close() { - model_->StopUpdating(); - model_->Clear(); + TaskManager* task_manager = GetInstance(); + task_manager->view_->CloseWindow(); } bool TaskManager::BrowserProcessIsSelected() { @@ -785,6 +786,11 @@ void TaskManager::RemoveResource(Resource* resource) { model_->RemoveResource(resource); } +void TaskManager::OnWindowClosed() { + model_->StopUpdating(); + model_->Clear(); +} + // static TaskManager* TaskManager::GetInstance() { return Singleton<TaskManager>::get(); diff --git a/chrome/browser/task_manager.h b/chrome/browser/task_manager.h index d58a21e..c0eaa8b 100644 --- a/chrome/browser/task_manager.h +++ b/chrome/browser/task_manager.h @@ -95,8 +95,8 @@ class TaskManager { // moved to the front. static void Open(); - // Close the task manager. - void Close(); + // Close the task manager if it's currently opened. + static void Close(); // Returns true if the current selection includes the browser process. bool BrowserProcessIsSelected(); @@ -118,6 +118,8 @@ class TaskManager { void AddResource(Resource* resource); void RemoveResource(Resource* resource); + void OnWindowClosed(); + private: FRIEND_TEST(TaskManagerTest, Basic); FRIEND_TEST(TaskManagerTest, Resources); @@ -354,6 +356,7 @@ class TaskManagerView { virtual void GetFocused(std::vector<int>* focused) = 0; virtual void OpenWindow() = 0; + virtual void CloseWindow() = 0; }; #endif // CHROME_BROWSER_TASK_MANAGER_H_ diff --git a/chrome/browser/task_manager_browsertest.cc b/chrome/browser/task_manager_browsertest.cc index 6eccc6b..c66ab2d 100644 --- a/chrome/browser/task_manager_browsertest.cc +++ b/chrome/browser/task_manager_browsertest.cc @@ -11,9 +11,11 @@ class TaskManagerBrowserTest : public InProcessBrowserTest { }; // Regression test for http://crbug.com/11180 -IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, ShutdownWhileOpen) { +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, OpenClose) { TaskManager::Open(); + TaskManager::Close(); } -// TODO(phajdan.jr): Write another test which explicitly closes TaskManager. -// This requires a small refactoring. +IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, ShutdownWhileOpen) { + TaskManager::Open(); +}
\ No newline at end of file diff --git a/chrome/browser/task_manager_linux.cc b/chrome/browser/task_manager_linux.cc index f4568de..4171406 100644 --- a/chrome/browser/task_manager_linux.cc +++ b/chrome/browser/task_manager_linux.cc @@ -21,6 +21,7 @@ class TaskManagerViewImpl : public TaskManagerView, virtual void GetSelection(std::vector<int>* selection); virtual void GetFocused(std::vector<int>* focused); virtual void OpenWindow(); + virtual void CloseWindow(); // TaskManagerModelObserver virtual void OnModelChanged(); @@ -41,6 +42,10 @@ void TaskManagerViewImpl::OpenWindow() { NOTIMPLEMENTED(); } +void TaskManagerViewImpl::CloseWindow() { + NOTIMPLEMENTED(); +} + void TaskManagerViewImpl::OnModelChanged() { NOTIMPLEMENTED(); } diff --git a/chrome/browser/task_manager_win.cc b/chrome/browser/task_manager_win.cc index 197cde6..7fc7492 100644 --- a/chrome/browser/task_manager_win.cc +++ b/chrome/browser/task_manager_win.cc @@ -184,6 +184,7 @@ class TaskManagerViewImpl : public TaskManagerView, virtual void GetSelection(std::vector<int>* selection); virtual void GetFocused(std::vector<int>* focused); virtual void OpenWindow(); + virtual void CloseWindow(); // ButtonListener implementation. virtual void ButtonPressed(views::Button* sender); @@ -434,6 +435,12 @@ void TaskManagerViewImpl::OpenWindow() { } } +void TaskManagerViewImpl::CloseWindow() { + if (!window()) + return; + window()->HideWindow(); +} + // ButtonListener implementation. void TaskManagerViewImpl::ButtonPressed(views::Button* sender) { if (sender == kill_button_.get()) @@ -498,7 +505,7 @@ void TaskManagerViewImpl::WindowClosing() { // ViewHierarchyChanged notification to unhook the extra buttons from the // non-client view. GetParent()->RemoveChildView(this); - task_manager_->Close(); + task_manager_->OnWindowClosed(); } void TaskManagerViewImpl::DeleteDelegate() { |