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
3 // found in the LICENSE file.
5 #include "extensions/browser/api/system_cpu/cpu_info_provider.h"
6 #include "extensions/shell/test/shell_apitest.h"
10 using api::system_cpu::CpuInfo
;
12 class MockCpuInfoProviderImpl
: public CpuInfoProvider
{
14 MockCpuInfoProviderImpl() {}
16 bool QueryInfo() override
{
17 info_
.num_of_processors
= 4;
18 info_
.arch_name
= "x86";
19 info_
.model_name
= "unknown";
21 info_
.features
.clear();
22 info_
.features
.push_back("mmx");
23 info_
.features
.push_back("avx");
25 info_
.processors
.clear();
26 info_
.processors
.push_back(linked_ptr
<api::system_cpu::ProcessorInfo
>(
27 new api::system_cpu::ProcessorInfo()));
28 info_
.processors
[0]->usage
.kernel
= 1;
29 info_
.processors
[0]->usage
.user
= 2;
30 info_
.processors
[0]->usage
.idle
= 3;
31 info_
.processors
[0]->usage
.total
= 6;
36 ~MockCpuInfoProviderImpl() override
{}
39 class SystemCpuApiTest
: public ShellApiTest
{
42 ~SystemCpuApiTest() override
{}
44 void SetUpInProcessBrowserTestFixture() override
{
45 ShellApiTest::SetUpInProcessBrowserTestFixture();
49 IN_PROC_BROWSER_TEST_F(SystemCpuApiTest
, Cpu
) {
50 CpuInfoProvider
* provider
= new MockCpuInfoProviderImpl();
51 // The provider is owned by the single CpuInfoProvider instance.
52 CpuInfoProvider::InitializeForTesting(provider
);
53 ASSERT_TRUE(RunAppTest("system/cpu")) << message_
;
56 } // namespace extensions