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

Side by Side Diff: chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc

Issue 12212047: Linux/ChromeOS Chromium style checker cleanup, chrome/browser/extensions edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" 6 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_test_message_listener.h" 8 #include "chrome/browser/extensions/extension_test_message_listener.h"
9 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
(...skipping 13 matching lines...) Expand all
24 if (!info) return false; 24 if (!info) return false;
25 25
26 info->num_of_processors = num_of_processors_; 26 info->num_of_processors = num_of_processors_;
27 info->arch_name = "x86"; 27 info->arch_name = "x86";
28 info->model_name = "unknown"; 28 info->model_name = "unknown";
29 29
30 return true; 30 return true;
31 } 31 }
32 32
33 private: 33 private:
34 ~MockCpuInfoProviderImpl() {} 34 virtual ~MockCpuInfoProviderImpl() {}
35 35
36 virtual bool QueryCpuTimePerProcessor(std::vector<CpuTime>* times) OVERRIDE { 36 virtual bool QueryCpuTimePerProcessor(std::vector<CpuTime>* times) OVERRIDE {
37 DCHECK(times); 37 DCHECK(times);
38 38
39 times->clear(); 39 times->clear();
40 static int user_step = 3; 40 static int user_step = 3;
41 static int kernel_step = 2; 41 static int kernel_step = 2;
42 static int idle_step = 1; 42 static int idle_step = 1;
43 static int count = 0; 43 static int count = 0;
44 for (int i = 0; i < num_of_processors_; i++) { 44 for (int i = 0; i < num_of_processors_; i++) {
45 CpuTime time; 45 CpuTime time;
46 time.user += user_step * count; 46 time.user += user_step * count;
47 time.kernel += kernel_step * count; 47 time.kernel += kernel_step * count;
48 time.idle += idle_step * count; 48 time.idle += idle_step * count;
49 times->push_back(time); 49 times->push_back(time);
50 50
51 count++; 51 count++;
52 } 52 }
53 return true; 53 return true;
54 } 54 }
55 55
56 int num_of_processors_; 56 int num_of_processors_;
57 }; 57 };
58 58
59 class SystemInfoCpuApiTest: public ExtensionApiTest { 59 class SystemInfoCpuApiTest: public ExtensionApiTest {
60 public: 60 public:
61 SystemInfoCpuApiTest() {} 61 SystemInfoCpuApiTest() {}
62 ~SystemInfoCpuApiTest() {} 62 virtual ~SystemInfoCpuApiTest() {}
63 63
64 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 64 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
65 ExtensionApiTest::SetUpCommandLine(command_line); 65 ExtensionApiTest::SetUpCommandLine(command_line);
66 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 66 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
67 } 67 }
68 68
69 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 69 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
70 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 70 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
71 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); 71 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI));
72 } 72 }
73 73
74 private: 74 private:
75 scoped_ptr<MessageLoop> message_loop_; 75 scoped_ptr<MessageLoop> message_loop_;
76 }; 76 };
77 77
78 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) { 78 IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) {
79 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); 79 CpuInfoProvider* provider = new MockCpuInfoProviderImpl();
80 // The provider is owned by the single CpuInfoProvider instance. 80 // The provider is owned by the single CpuInfoProvider instance.
81 CpuInfoProvider::InitializeForTesting(provider); 81 CpuInfoProvider::InitializeForTesting(provider);
82 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_; 82 ASSERT_TRUE(RunExtensionTest("systeminfo/cpu")) << message_;
83 } 83 }
84 84
85 } // namespace extensions 85 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698