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