Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: extensions/browser/api/system_cpu/system_cpu_apitest.cc

Issue 1842953002: [Extensions] Convert APIs to use movable types [13] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "extensions/browser/api/system_cpu/cpu_info_provider.h" 5 #include "extensions/browser/api/system_cpu/cpu_info_provider.h"
6 #include "extensions/shell/test/shell_apitest.h" 6 #include "extensions/shell/test/shell_apitest.h"
7 7
8 namespace extensions { 8 namespace extensions {
9 9
10 using api::system_cpu::CpuInfo; 10 using 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 bool QueryInfo() override { 16 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<api::system_cpu::ProcessorInfo>( 26 info_.processors.push_back(api::system_cpu::ProcessorInfo());
27 new api::system_cpu::ProcessorInfo())); 27 info_.processors[0].usage.kernel = 1;
28 info_.processors[0]->usage.kernel = 1; 28 info_.processors[0].usage.user = 2;
29 info_.processors[0]->usage.user = 2; 29 info_.processors[0].usage.idle = 3;
30 info_.processors[0]->usage.idle = 3; 30 info_.processors[0].usage.total = 6;
31 info_.processors[0]->usage.total = 6;
32 return true; 31 return true;
33 } 32 }
34 33
35 private: 34 private:
36 ~MockCpuInfoProviderImpl() override {} 35 ~MockCpuInfoProviderImpl() override {}
37 }; 36 };
38 37
39 class SystemCpuApiTest : public ShellApiTest { 38 class SystemCpuApiTest : public ShellApiTest {
40 public: 39 public:
41 SystemCpuApiTest() {} 40 SystemCpuApiTest() {}
42 ~SystemCpuApiTest() override {} 41 ~SystemCpuApiTest() override {}
43 42
44 void SetUpInProcessBrowserTestFixture() override { 43 void SetUpInProcessBrowserTestFixture() override {
45 ShellApiTest::SetUpInProcessBrowserTestFixture(); 44 ShellApiTest::SetUpInProcessBrowserTestFixture();
46 } 45 }
47 }; 46 };
48 47
49 IN_PROC_BROWSER_TEST_F(SystemCpuApiTest, Cpu) { 48 IN_PROC_BROWSER_TEST_F(SystemCpuApiTest, Cpu) {
50 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); 49 CpuInfoProvider* provider = new MockCpuInfoProviderImpl();
51 // The provider is owned by the single CpuInfoProvider instance. 50 // The provider is owned by the single CpuInfoProvider instance.
52 CpuInfoProvider::InitializeForTesting(provider); 51 CpuInfoProvider::InitializeForTesting(provider);
53 ASSERT_TRUE(RunAppTest("system/cpu")) << message_; 52 ASSERT_TRUE(RunAppTest("system/cpu")) << message_;
54 } 53 }
55 54
56 } // namespace extensions 55 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698