| OLD | NEW |
| 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/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "grit/chromium_strings.h" | 12 #include "grit/chromium_strings.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | |
| 16 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/gfx/image/image_skia.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
| 21 // From task_manager.cc: | 21 // From task_manager.cc: |
| 22 // Activity Monitor shows %cpu with one decimal digit -- be | 22 // Activity Monitor shows %cpu with one decimal digit -- be |
| 23 // consistent with that. | 23 // consistent with that. |
| 24 const char* kZeroCPUUsage = "0.0"; | 24 const char* kZeroCPUUsage = "0.0"; |
| 25 #else | 25 #else |
| 26 const char* kZeroCPUUsage = "0"; | 26 const char* kZeroCPUUsage = "0"; |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 class TestResource : public TaskManager::Resource { | 29 class TestResource : public TaskManager::Resource { |
| 30 public: | 30 public: |
| 31 TestResource() : refresh_called_(false) {} | 31 TestResource() : refresh_called_(false) {} |
| 32 | 32 |
| 33 virtual string16 GetTitle() const OVERRIDE { | 33 virtual string16 GetTitle() const OVERRIDE { |
| 34 return ASCIIToUTF16("test title"); | 34 return ASCIIToUTF16("test title"); |
| 35 } | 35 } |
| 36 virtual string16 GetProfileName() const OVERRIDE { | 36 virtual string16 GetProfileName() const OVERRIDE { |
| 37 return ASCIIToUTF16("test profile"); | 37 return ASCIIToUTF16("test profile"); |
| 38 } | 38 } |
| 39 virtual SkBitmap GetIcon() const { return SkBitmap(); } | 39 virtual gfx::ImageSkia GetIcon() const { return gfx::ImageSkia(); } |
| 40 virtual base::ProcessHandle GetProcess() const { | 40 virtual base::ProcessHandle GetProcess() const { |
| 41 return base::GetCurrentProcessHandle(); | 41 return base::GetCurrentProcessHandle(); |
| 42 } | 42 } |
| 43 virtual int GetUniqueChildProcessId() const OVERRIDE { | 43 virtual int GetUniqueChildProcessId() const OVERRIDE { |
| 44 // In reality the unique child process ID is not the actual process ID, | 44 // In reality the unique child process ID is not the actual process ID, |
| 45 // but for testing purposes it shouldn't make difference. | 45 // but for testing purposes it shouldn't make difference. |
| 46 return static_cast<int>(base::GetCurrentProcId()); | 46 return static_cast<int>(base::GetCurrentProcId()); |
| 47 } | 47 } |
| 48 virtual Type GetType() const { return RENDERER; } | 48 virtual Type GetType() const { return RENDERER; } |
| 49 virtual bool SupportNetworkUsage() const { return false; } | 49 virtual bool SupportNetworkUsage() const { return false; } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 TaskManagerModel* model = task_manager.model_; | 115 TaskManagerModel* model = task_manager.model_; |
| 116 TestResource resource; | 116 TestResource resource; |
| 117 | 117 |
| 118 task_manager.AddResource(&resource); | 118 task_manager.AddResource(&resource); |
| 119 ASSERT_FALSE(resource.refresh_called()); | 119 ASSERT_FALSE(resource.refresh_called()); |
| 120 model->update_state_ = TaskManagerModel::TASK_PENDING; | 120 model->update_state_ = TaskManagerModel::TASK_PENDING; |
| 121 model->Refresh(); | 121 model->Refresh(); |
| 122 ASSERT_TRUE(resource.refresh_called()); | 122 ASSERT_TRUE(resource.refresh_called()); |
| 123 task_manager.RemoveResource(&resource); | 123 task_manager.RemoveResource(&resource); |
| 124 } | 124 } |
| OLD | NEW |