| 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 CpuInfo* info = &info_; |
| 22 | |
| 23 info->num_of_processors = 4; | 22 info->num_of_processors = 4; |
| 24 info->arch_name = "x86"; | 23 info->arch_name = "x86"; |
| 25 info->model_name = "unknown"; | 24 info->model_name = "unknown"; |
| 26 | |
| 27 return true; | 25 return true; |
| 28 } | 26 } |
| 29 | 27 |
| 30 private: | 28 private: |
| 31 virtual ~MockCpuInfoProviderImpl() {} | 29 virtual ~MockCpuInfoProviderImpl() {} |
| 32 }; | 30 }; |
| 33 | 31 |
| 34 class SystemInfoCpuApiTest: public ExtensionApiTest { | 32 class SystemInfoCpuApiTest: public ExtensionApiTest { |
| 35 public: | 33 public: |
| 36 SystemInfoCpuApiTest() {} | 34 SystemInfoCpuApiTest() {} |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 }; | 46 }; |
| 49 | 47 |
| 50 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { | 48 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { |
| 51 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); | 49 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); |
| 52 // The provider is owned by the single CpuInfoProvider instance. | 50 // The provider is owned by the single CpuInfoProvider instance. |
| 53 CpuInfoProvider::InitializeForTesting(provider); | 51 CpuInfoProvider::InitializeForTesting(provider); |
| 54 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; | 52 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; |
| 55 } | 53 } |
| 56 | 54 |
| 57 } // namespace extensions | 55 } // namespace extensions |
| OLD | NEW |