Index: chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc |
diff --git a/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc b/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc |
index 0faab79b513062d34769e33afdb34ed5a1eb85d9..0227fb2a36569b217e49dd9ec604658d0cfc702b 100644 |
--- a/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc |
+++ b/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc |
@@ -2,18 +2,53 @@ |
// 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/message_loop.h" |
+#include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" |
#include "chrome/browser/extensions/extension_apitest.h" |
#include "chrome/common/chrome_switches.h" |
namespace extensions { |
+ |
+using api::experimental_system_info_cpu::CpuInfo; |
+using api::experimental_system_info_cpu::CpuCoreInfo; |
+ |
+class MockCpuInfoProviderImpl : public CpuInfoProvider { |
+ public: |
+ MockCpuInfoProviderImpl() {} |
+ ~MockCpuInfoProviderImpl() {} |
+ virtual bool QueryInfo() { |
Mihai Parparita -not on Chrome
2012/08/21 01:14:52
Add OVERRIDE annotation.
Hongbo Min
2012/08/21 03:07:11
Done.
|
+ info_.cores.clear(); |
+ |
+ static const unsigned int kNumberOfCores = 4; |
+ for (unsigned int i = 0; i < kNumberOfCores; ++i) { |
+ linked_ptr<CpuCoreInfo> core(new CpuCoreInfo()); |
+ core->load = i*10; |
+ info_.cores.push_back(core); |
+ } |
+ return true; |
+ } |
+}; |
+ |
class SystemInfoCpuApiTest: public ExtensionApiTest { |
public: |
SystemInfoCpuApiTest() {} |
~SystemInfoCpuApiTest() {} |
+ |
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
ExtensionApiTest::SetUpCommandLine(command_line); |
command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
} |
+ |
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
+ ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
+ message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); |
+ provider_ = new MockCpuInfoProviderImpl(); |
+ CpuInfoProvider::InitializeForTesting(provider_); |
+ } |
+ |
+ private: |
+ CpuInfoProvider* provider_; |
Mihai Parparita -not on Chrome
2012/08/21 01:14:52
Does this need to be a member? You don't actually
Hongbo Min
2012/08/21 03:07:11
Done.
|
+ scoped_ptr<MessageLoop> message_loop_; |
}; |
IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { |