OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 4 |
5 #include "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "extensions/browser/api/system_cpu/cpu_info_provider.h" | 6 #include "extensions/browser/api/system_cpu/cpu_info_provider.h" |
7 | 7 |
8 namespace extensions { | 8 namespace extensions { |
9 | 9 |
10 using core_api::system_cpu::CpuInfo; | 10 using core_api::system_cpu::CpuInfo; |
11 | 11 |
12 class MockCpuInfoProviderImpl : public CpuInfoProvider { | 12 class MockCpuInfoProviderImpl : public CpuInfoProvider { |
13 public: | 13 public: |
14 MockCpuInfoProviderImpl() {} | 14 MockCpuInfoProviderImpl() {} |
15 | 15 |
16 virtual bool QueryInfo() OVERRIDE { | 16 virtual bool QueryInfo() override { |
17 info_.num_of_processors = 4; | 17 info_.num_of_processors = 4; |
18 info_.arch_name = "x86"; | 18 info_.arch_name = "x86"; |
19 info_.model_name = "unknown"; | 19 info_.model_name = "unknown"; |
20 | 20 |
21 info_.features.clear(); | 21 info_.features.clear(); |
22 info_.features.push_back("mmx"); | 22 info_.features.push_back("mmx"); |
23 info_.features.push_back("avx"); | 23 info_.features.push_back("avx"); |
24 | 24 |
25 info_.processors.clear(); | 25 info_.processors.clear(); |
26 info_.processors.push_back(linked_ptr<core_api::system_cpu::ProcessorInfo>( | 26 info_.processors.push_back(linked_ptr<core_api::system_cpu::ProcessorInfo>( |
27 new core_api::system_cpu::ProcessorInfo())); | 27 new core_api::system_cpu::ProcessorInfo())); |
28 info_.processors[0]->usage.kernel = 1; | 28 info_.processors[0]->usage.kernel = 1; |
29 info_.processors[0]->usage.user = 2; | 29 info_.processors[0]->usage.user = 2; |
30 info_.processors[0]->usage.idle = 3; | 30 info_.processors[0]->usage.idle = 3; |
31 info_.processors[0]->usage.total = 6; | 31 info_.processors[0]->usage.total = 6; |
32 return true; | 32 return true; |
33 } | 33 } |
34 | 34 |
35 private: | 35 private: |
36 virtual ~MockCpuInfoProviderImpl() {} | 36 virtual ~MockCpuInfoProviderImpl() {} |
37 }; | 37 }; |
38 | 38 |
39 class SystemCpuApiTest: public ExtensionApiTest { | 39 class SystemCpuApiTest: public ExtensionApiTest { |
40 public: | 40 public: |
41 SystemCpuApiTest() {} | 41 SystemCpuApiTest() {} |
42 virtual ~SystemCpuApiTest() {} | 42 virtual ~SystemCpuApiTest() {} |
43 | 43 |
44 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 44 virtual void SetUpInProcessBrowserTestFixture() override { |
45 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 45 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
46 } | 46 } |
47 }; | 47 }; |
48 | 48 |
49 IN_PROC_BROWSER_TEST_F(SystemCpuApiTest, Cpu) { | 49 IN_PROC_BROWSER_TEST_F(SystemCpuApiTest, Cpu) { |
50 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); | 50 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); |
51 // The provider is owned by the single CpuInfoProvider instance. | 51 // The provider is owned by the single CpuInfoProvider instance. |
52 CpuInfoProvider::InitializeForTesting(provider); | 52 CpuInfoProvider::InitializeForTesting(provider); |
53 ASSERT_TRUE(RunExtensionTest("system/cpu")) << message_; | 53 ASSERT_TRUE(RunExtensionTest("system/cpu")) << message_; |
54 } | 54 } |
55 | 55 |
56 } // namespace extensions | 56 } // namespace extensions |
OLD | NEW |