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

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

Issue 18290002: [SystemInfo API] Finish TODOs in SystemInfoProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dev_rewrite_storage_info_api
Patch Set: Pass chromeos unit_tests Created 7 years, 5 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
OLDNEW
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 // CpuInfoProvider unit tests 5 // CpuInfoProvider unit tests
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h" 9 #include "chrome/browser/extensions/api/system_info_cpu/cpu_info_provider.h"
10 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread.h"
(...skipping 10 matching lines...) Expand all
21 int num_of_processors; 21 int num_of_processors;
22 }; 22 };
23 23
24 const struct TestCpuInfo kTestingCpuInfoData = { 24 const struct TestCpuInfo kTestingCpuInfoData = {
25 "x86", "Intel Core", 2 25 "x86", "Intel Core", 2
26 }; 26 };
27 27
28 class TestCpuInfoProvider : public CpuInfoProvider { 28 class TestCpuInfoProvider : public CpuInfoProvider {
29 public: 29 public:
30 TestCpuInfoProvider(); 30 TestCpuInfoProvider();
31 virtual bool QueryInfo(CpuInfo* info) OVERRIDE; 31 virtual bool QueryInfo() OVERRIDE;
32 32
33 private: 33 private:
34 virtual ~TestCpuInfoProvider(); 34 virtual ~TestCpuInfoProvider();
35 }; 35 };
36 36
37 TestCpuInfoProvider::TestCpuInfoProvider() {} 37 TestCpuInfoProvider::TestCpuInfoProvider() {}
38 38
39 TestCpuInfoProvider::~TestCpuInfoProvider() {} 39 TestCpuInfoProvider::~TestCpuInfoProvider() {}
40 40
41 bool TestCpuInfoProvider::QueryInfo(CpuInfo* info) { 41 bool TestCpuInfoProvider::QueryInfo() {
42 if (info == NULL) 42 info_.arch_name = kTestingCpuInfoData.arch_name;
43 return false; 43 info_.model_name = kTestingCpuInfoData.model_name;
44 info->arch_name = kTestingCpuInfoData.arch_name; 44 info_.num_of_processors = kTestingCpuInfoData.num_of_processors;
45 info->model_name = kTestingCpuInfoData.model_name;
46 info->num_of_processors = kTestingCpuInfoData.num_of_processors;
47 return true; 45 return true;
48 } 46 }
49 47
50 class CpuInfoProviderTest : public testing::Test { 48 class CpuInfoProviderTest : public testing::Test {
51 public: 49 public:
52 CpuInfoProviderTest(); 50 CpuInfoProviderTest();
53 51
54 protected: 52 protected:
55 scoped_refptr<TestCpuInfoProvider> cpu_info_provider_; 53 scoped_refptr<TestCpuInfoProvider> cpu_info_provider_;
56 }; 54 };
57 55
58 CpuInfoProviderTest::CpuInfoProviderTest() {} 56 CpuInfoProviderTest::CpuInfoProviderTest() {}
59 57
60 TEST_F(CpuInfoProviderTest, QueryCpuInfo) { 58 TEST_F(CpuInfoProviderTest, QueryCpuInfo) {
61 cpu_info_provider_ = new TestCpuInfoProvider(); 59 cpu_info_provider_ = new TestCpuInfoProvider();
62 scoped_ptr<CpuInfo> cpu_info(new CpuInfo()); 60 EXPECT_TRUE(cpu_info_provider_->QueryInfo());
63 EXPECT_TRUE(cpu_info_provider_->QueryInfo(cpu_info.get())); 61 EXPECT_EQ(kTestingCpuInfoData.arch_name,
64 EXPECT_EQ(kTestingCpuInfoData.arch_name, cpu_info->arch_name); 62 cpu_info_provider_->cpu_info().arch_name);
65 EXPECT_EQ(kTestingCpuInfoData.model_name, cpu_info->model_name); 63 EXPECT_EQ(kTestingCpuInfoData.model_name,
66 EXPECT_EQ(kTestingCpuInfoData.num_of_processors, cpu_info->num_of_processors); 64 cpu_info_provider_->cpu_info().model_name);
65 EXPECT_EQ(kTestingCpuInfoData.num_of_processors,
66 cpu_info_provider_->cpu_info().num_of_processors);
67 } 67 }
68 68
69 } 69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698