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

Unified Diff: chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc

Issue 10831353: Add a generic template for system info provider (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Simplify the SystemInfoProvider template code Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc
diff --git a/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc b/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc
index 0faab79b513062d34769e33afdb34ed5a1eb85d9..0227fb2a36569b217e49dd9ec604658d0cfc702b 100644
--- a/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc
+++ b/chrome/browser/extensions/api/system_info_cpu/system_info_cpu_apitest.cc
@@ -2,18 +2,53 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/message_loop.h"
+#include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/common/chrome_switches.h"
namespace extensions {
+
+using api::experimental_system_info_cpu::CpuInfo;
+using api::experimental_system_info_cpu::CpuCoreInfo;
+
+class MockCpuInfoProviderImpl : public CpuInfoProvider {
+ public:
+ MockCpuInfoProviderImpl() {}
+ ~MockCpuInfoProviderImpl() {}
+ virtual bool QueryInfo() {
Mihai Parparita -not on Chrome 2012/08/21 01:14:52 Add OVERRIDE annotation.
Hongbo Min 2012/08/21 03:07:11 Done.
+ info_.cores.clear();
+
+ static const unsigned int kNumberOfCores = 4;
+ for (unsigned int i = 0; i < kNumberOfCores; ++i) {
+ linked_ptr<CpuCoreInfo> core(new CpuCoreInfo());
+ core->load = i*10;
+ info_.cores.push_back(core);
+ }
+ return true;
+ }
+};
+
class SystemInfoCpuApiTest: public ExtensionApiTest {
public:
SystemInfoCpuApiTest() {}
~SystemInfoCpuApiTest() {}
+
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
}
+
+ virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
+ ExtensionApiTest::SetUpInProcessBrowserTestFixture();
+ message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI));
+ provider_ = new MockCpuInfoProviderImpl();
+ CpuInfoProvider::InitializeForTesting(provider_);
+ }
+
+ private:
+ CpuInfoProvider* provider_;
Mihai Parparita -not on Chrome 2012/08/21 01:14:52 Does this need to be a member? You don't actually
Hongbo Min 2012/08/21 03:07:11 Done.
+ scoped_ptr<MessageLoop> message_loop_;
};
IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) {

Powered by Google App Engine
This is Rietveld 408576698