| 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" | 5 #include "base/message_loop.h" |
| 6 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" | 6 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" |
| 7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 | 9 |
| 10 namespace extensions { | 10 namespace extensions { |
| 11 | 11 |
| 12 using api::experimental_system_info_cpu::CpuInfo; | 12 using api::experimental_system_info_cpu::CpuInfo; |
| 13 using api::experimental_system_info_cpu::CpuCoreInfo; | |
| 14 | 13 |
| 15 class MockCpuInfoProviderImpl : public CpuInfoProvider { | 14 class MockCpuInfoProviderImpl : public CpuInfoProvider { |
| 16 public: | 15 public: |
| 17 MockCpuInfoProviderImpl() {} | 16 MockCpuInfoProviderImpl() {} |
| 18 ~MockCpuInfoProviderImpl() {} | 17 ~MockCpuInfoProviderImpl() {} |
| 19 | 18 |
| 20 virtual bool QueryInfo(CpuInfo* info) OVERRIDE { | 19 virtual bool QueryInfo(CpuInfo* info) OVERRIDE { |
| 21 DCHECK(info); | 20 if (!info) return false; |
| 22 | 21 |
| 23 info->cores.clear(); | 22 info->num_of_processors = 4; |
| 23 info->arch_name = "x86"; |
| 24 info->model_name = "unknown"; |
| 24 | 25 |
| 25 static const unsigned int kNumberOfCores = 4; | |
| 26 for (unsigned int i = 0; i < kNumberOfCores; ++i) { | |
| 27 linked_ptr<CpuCoreInfo> core(new CpuCoreInfo()); | |
| 28 core->load = i*10; | |
| 29 info->cores.push_back(core); | |
| 30 } | |
| 31 return true; | 26 return true; |
| 32 } | 27 } |
| 33 }; | 28 }; |
| 34 | 29 |
| 35 class SystemInfoCpuApiTest: public ExtensionApiTest { | 30 class SystemInfoCpuApiTest: public ExtensionApiTest { |
| 36 public: | 31 public: |
| 37 SystemInfoCpuApiTest() {} | 32 SystemInfoCpuApiTest() {} |
| 38 ~SystemInfoCpuApiTest() {} | 33 ~SystemInfoCpuApiTest() {} |
| 39 | 34 |
| 40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 35 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 53 | 48 |
| 54 private: | 49 private: |
| 55 scoped_ptr<MessageLoop> message_loop_; | 50 scoped_ptr<MessageLoop> message_loop_; |
| 56 }; | 51 }; |
| 57 | 52 |
| 58 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { | 53 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { |
| 59 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; | 54 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; |
| 60 } | 55 } |
| 61 | 56 |
| 62 } // namespace extensions | 57 } // namespace extensions |
| OLD | NEW |