| OLD | NEW |
| 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; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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(api::system_cpu::ProcessorInfo()); | 26 info_.processors.push_back(api::system_cpu::ProcessorInfo()); |
| 27 info_.processors[0].usage.kernel = 1; | 27 info_.processors[0].usage.kernel = 1; |
| 28 info_.processors[0].usage.user = 2; | 28 info_.processors[0].usage.user = 2; |
| 29 info_.processors[0].usage.idle = 3; | 29 info_.processors[0].usage.idle = 3; |
| 30 info_.processors[0].usage.total = 6; | 30 info_.processors[0].usage.total = 6; |
| 31 |
| 32 info_.temperatures.clear(); |
| 33 // The fractional part of these values should be exactly represented as |
| 34 // floating points to avoid rounding errors. |
| 35 info_.temperatures.push_back(30.125); |
| 36 info_.temperatures.push_back(40.0625); |
| 31 return true; | 37 return true; |
| 32 } | 38 } |
| 33 | 39 |
| 34 private: | 40 private: |
| 35 ~MockCpuInfoProviderImpl() override {} | 41 ~MockCpuInfoProviderImpl() override {} |
| 36 }; | 42 }; |
| 37 | 43 |
| 38 class SystemCpuApiTest : public ShellApiTest { | 44 class SystemCpuApiTest : public ShellApiTest { |
| 39 public: | 45 public: |
| 40 SystemCpuApiTest() {} | 46 SystemCpuApiTest() {} |
| 41 ~SystemCpuApiTest() override {} | 47 ~SystemCpuApiTest() override {} |
| 42 | 48 |
| 43 void SetUpInProcessBrowserTestFixture() override { | 49 void SetUpInProcessBrowserTestFixture() override { |
| 44 ShellApiTest::SetUpInProcessBrowserTestFixture(); | 50 ShellApiTest::SetUpInProcessBrowserTestFixture(); |
| 45 } | 51 } |
| 46 }; | 52 }; |
| 47 | 53 |
| 48 IN_PROC_BROWSER_TEST_F(SystemCpuApiTest, Cpu) { | 54 IN_PROC_BROWSER_TEST_F(SystemCpuApiTest, Cpu) { |
| 49 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); | 55 CpuInfoProvider* provider = new MockCpuInfoProviderImpl(); |
| 50 // The provider is owned by the single CpuInfoProvider instance. | 56 // The provider is owned by the single CpuInfoProvider instance. |
| 51 CpuInfoProvider::InitializeForTesting(provider); | 57 CpuInfoProvider::InitializeForTesting(provider); |
| 52 ASSERT_TRUE(RunAppTest("system/cpu")) << message_; | 58 ASSERT_TRUE(RunAppTest("system/cpu")) << message_; |
| 53 } | 59 } |
| 54 | 60 |
| 55 } // namespace extensions | 61 } // namespace extensions |
| OLD | NEW |