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

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: Code polishment 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..fcd5cb9d808553b1e41eac18b5d4191d3356ba8a 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,57 @@
// 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(CpuInfo* info) OVERRIDE {
+ DCHECK(info);
+
+ 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));
+
+ CpuInfoProvider* provider = new MockCpuInfoProviderImpl();
+ // The provider is owned by the single CpuInfoProvider instance.
+ CpuInfoProvider::InitializeForTesting(provider);
+ }
+
+ private:
+ scoped_ptr<MessageLoop> message_loop_;
};
IN_PROC_BROWSER_TEST_F(SystemInfoCpuApiTest, Cpu) {
« no previous file with comments | « chrome/browser/extensions/api/system_info_cpu/system_info_cpu_api.cc ('k') | chrome/browser/extensions/system_info_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698