| 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 "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" | 5 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
| 8 #include "chrome/test/base/ui_test_utils.h" | 8 #include "chrome/test/base/ui_test_utils.h" |
| 9 | 9 |
| 10 namespace extensions { | 10 namespace extensions { |
| 11 | 11 |
| 12 using api::system_info_cpu::CpuInfo; | 12 using api::system_info_cpu::CpuInfo; |
| 13 | 13 |
| 14 const char kExtensionId[] = "lfakdgdkbaleijdcpbfbngfphpmgfdfn"; | 14 const char kExtensionId[] = "lfakdgdkbaleijdcpbfbngfphpmgfdfn"; |
| 15 | 15 |
| 16 class MockCpuInfoProviderImpl : public CpuInfoProvider { | 16 class MockCpuInfoProviderImpl : public CpuInfoProvider { |
| 17 public: | 17 public: |
| 18 MockCpuInfoProviderImpl() {} | 18 MockCpuInfoProviderImpl() {} |
| 19 | 19 |
| 20 virtual bool QueryInfo(CpuInfo* info) OVERRIDE { | 20 virtual bool QueryInfo() OVERRIDE { |
| 21 if (!info) return false; | 21 info_.num_of_processors = 4; |
| 22 | 22 info_.arch_name = "x86"; |
| 23 info->num_of_processors = 4; | 23 info_.model_name = "unknown"; |
| 24 info->arch_name = "x86"; | |
| 25 info->model_name = "unknown"; | |
| 26 | |
| 27 return true; | 24 return true; |
| 28 } | 25 } |
| 29 | 26 |
| 30 private: | 27 private: |
| 31 virtual ~MockCpuInfoProviderImpl() {} | 28 virtual ~MockCpuInfoProviderImpl() {} |
| 32 }; | 29 }; |
| 33 | 30 |
| 34 class SystemInfoCpuApiTest: public ExtensionApiTest { | 31 class SystemInfoCpuApiTest: public ExtensionApiTest { |
| 35 public: | 32 public: |
| 36 SystemInfoCpuApiTest() {} | 33 SystemInfoCpuApiTest() {} |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 }; | 45 }; |
| 49 | 46 |
| 50 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { | 47 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { |
| 51 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); | 48 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); |
| 52 // The provider is owned by the single CpuInfoProvider instance. | 49 // The provider is owned by the single CpuInfoProvider instance. |
| 53 CpuInfoProvider::InitializeForTesting(provider); | 50 CpuInfoProvider::InitializeForTesting(provider); |
| 54 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; | 51 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; |
| 55 } | 52 } |
| 56 | 53 |
| 57 } // namespace extensions | 54 } // namespace extensions |
| OLD | NEW |