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 #include "base/command_line.h" | 4 #include "base/command_line.h" |
5 #include "base/message_loop.h" | |
6 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" | |
5 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
7 | 9 |
8 namespace extensions { | 10 namespace extensions { |
11 | |
12 using api::experimental_system_info_cpu::CpuInfo; | |
13 using api::experimental_system_info_cpu::CpuCoreInfo; | |
14 | |
15 class MockCpuInfoProviderImpl : public CpuInfoProvider { | |
16 public: | |
17 MockCpuInfoProviderImpl() {} | |
18 ~MockCpuInfoProviderImpl() {} | |
19 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.
| |
20 info_.cores.clear(); | |
21 | |
22 static const unsigned int kNumberOfCores = 4; | |
23 for (unsigned int i = 0; i < kNumberOfCores; ++i) { | |
24 linked_ptr<CpuCoreInfo> core(new CpuCoreInfo()); | |
25 core->load = i*10; | |
26 info_.cores.push_back(core); | |
27 } | |
28 return true; | |
29 } | |
30 }; | |
31 | |
9 class SystemInfoCpuApiTest: public ExtensionApiTest { | 32 class SystemInfoCpuApiTest: public ExtensionApiTest { |
10 public: | 33 public: |
11 SystemInfoCpuApiTest() {} | 34 SystemInfoCpuApiTest() {} |
12 ~SystemInfoCpuApiTest() {} | 35 ~SystemInfoCpuApiTest() {} |
36 | |
13 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
14 ExtensionApiTest::SetUpCommandLine(command_line); | 38 ExtensionApiTest::SetUpCommandLine(command_line); |
15 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 39 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
16 } | 40 } |
41 | |
42 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | |
43 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | |
44 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); | |
45 provider_ = new MockCpuInfoProviderImpl(); | |
46 CpuInfoProvider::InitializeForTesting(provider_); | |
47 } | |
48 | |
49 private: | |
50 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.
| |
51 scoped_ptr<MessageLoop> message_loop_; | |
17 }; | 52 }; |
18 | 53 |
19 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { | 54 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { |
20 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; | 55 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; |
21 } | 56 } |
22 | 57 |
23 } // namespace extensions | 58 } // namespace extensions |
OLD | NEW |