diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 17:27:01 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 17:27:01 +0000 |
commit | d277d432270803785ad05293674789c5f711b325 (patch) | |
tree | 750ec294bbc2befd8d65ce628a24926800e6e4d9 /chrome/browser/task_manager_unittest.cc | |
parent | 26eb09f69b07041c3fb674205aca65e2faa3996e (diff) | |
download | chromium_src-d277d432270803785ad05293674789c5f711b325.zip chromium_src-d277d432270803785ad05293674789c5f711b325.tar.gz chromium_src-d277d432270803785ad05293674789c5f711b325.tar.bz2 |
Refactors freaky TaskManager::Resource self-updating
Currently, TaskManagerTabContentsResource supports getting WebCore cache information. This information has to be fetched from the renderer process via an IPC round-trip. Currently, the Resource updates itself whenever a query is made from the View via the TaskManagerModel::GetResourceWebCore*() methods, which seems very wrong from a design POV and is tricky to test. This patch cleans up the picture a bit by routing the TaskManagerModel::Refresh() call to interested TaskManager::Resource objects.
TEST=try bots, open task manager + right click to enable cache columns, browse around, observe updated values
BUG=none
Review URL: http://codereview.chromium.org/267062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28829 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager_unittest.cc')
-rw-r--r-- | chrome/browser/task_manager_unittest.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/chrome/browser/task_manager_unittest.cc b/chrome/browser/task_manager_unittest.cc index 1ce3e55..f97879ea 100644 --- a/chrome/browser/task_manager_unittest.cc +++ b/chrome/browser/task_manager_unittest.cc @@ -16,6 +16,8 @@ namespace { class TestResource : public TaskManager::Resource { public: + TestResource() : refresh_called_(false) {} + virtual std::wstring GetTitle() const { return L"test title"; } virtual SkBitmap GetIcon() const { return SkBitmap(); } virtual base::ProcessHandle GetProcess() const { @@ -23,6 +25,14 @@ class TestResource : public TaskManager::Resource { } virtual bool SupportNetworkUsage() const { return false; } virtual void SetSupportNetworkUsage() { NOTREACHED(); } + virtual void Refresh() { refresh_called_ = true; } + bool refresh_called() const { return refresh_called_; } + void set_refresh_called(bool refresh_called) { + refresh_called_ = refresh_called; + } + + private: + bool refresh_called_; }; } // namespace @@ -71,3 +81,17 @@ TEST_F(TaskManagerTest, Resources) { task_manager.RemoveResource(&resource2); EXPECT_EQ(0, model->ResourceCount()); } + +// Tests that the model is calling Refresh() on its resources. +TEST_F(TaskManagerTest, RefreshCalled) { + MessageLoop loop; + TaskManager task_manager; + TaskManagerModel* model = task_manager.model_; + TestResource resource; + + task_manager.AddResource(&resource); + ASSERT_FALSE(resource.refresh_called()); + model->update_state_ = TaskManagerModel::TASK_PENDING; + model->Refresh(); + ASSERT_TRUE(resource.refresh_called()); +} |