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

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: 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 void QueryInfo() OVERRIDE;
32 const CpuInfo* cpu_info() const;
32 33
33 private: 34 private:
34 virtual ~TestCpuInfoProvider(); 35 virtual ~TestCpuInfoProvider();
35 }; 36 };
36 37
37 TestCpuInfoProvider::TestCpuInfoProvider() {} 38 TestCpuInfoProvider::TestCpuInfoProvider() {}
38 39
39 TestCpuInfoProvider::~TestCpuInfoProvider() {} 40 TestCpuInfoProvider::~TestCpuInfoProvider() {}
40 41
41 bool TestCpuInfoProvider::QueryInfo(CpuInfo* info) { 42 void TestCpuInfoProvider::QueryInfo() {
42 if (info == NULL) 43 CpuInfo* info = &info_;
43 return false; 44
44 info->arch_name = kTestingCpuInfoData.arch_name; 45 info->arch_name = kTestingCpuInfoData.arch_name;
45 info->model_name = kTestingCpuInfoData.model_name; 46 info->model_name = kTestingCpuInfoData.model_name;
46 info->num_of_processors = kTestingCpuInfoData.num_of_processors; 47 info->num_of_processors = kTestingCpuInfoData.num_of_processors;
47 return true; 48 success_ = true;
49 }
50
51 const CpuInfo* TestCpuInfoProvider::cpu_info() const {
52 return &info_;
48 } 53 }
49 54
50 class CpuInfoProviderTest : public testing::Test { 55 class CpuInfoProviderTest : public testing::Test {
51 public: 56 public:
52 CpuInfoProviderTest(); 57 CpuInfoProviderTest();
53 58
54 protected: 59 protected:
55 scoped_refptr<TestCpuInfoProvider> cpu_info_provider_; 60 scoped_refptr<TestCpuInfoProvider> cpu_info_provider_;
56 }; 61 };
57 62
58 CpuInfoProviderTest::CpuInfoProviderTest() {} 63 CpuInfoProviderTest::CpuInfoProviderTest() {}
59 64
60 TEST_F(CpuInfoProviderTest, QueryCpuInfo) { 65 TEST_F(CpuInfoProviderTest, QueryCpuInfo) {
61 cpu_info_provider_ = new TestCpuInfoProvider(); 66 cpu_info_provider_ = new TestCpuInfoProvider();
62 scoped_ptr<CpuInfo> cpu_info(new CpuInfo()); 67 cpu_info_provider_->QueryInfo();
63 EXPECT_TRUE(cpu_info_provider_->QueryInfo(cpu_info.get())); 68 EXPECT_EQ(kTestingCpuInfoData.arch_name,
64 EXPECT_EQ(kTestingCpuInfoData.arch_name, cpu_info->arch_name); 69 cpu_info_provider_->cpu_info()->arch_name);
65 EXPECT_EQ(kTestingCpuInfoData.model_name, cpu_info->model_name); 70 EXPECT_EQ(kTestingCpuInfoData.model_name,
66 EXPECT_EQ(kTestingCpuInfoData.num_of_processors, cpu_info->num_of_processors); 71 cpu_info_provider_->cpu_info()->model_name);
72 EXPECT_EQ(kTestingCpuInfoData.num_of_processors,
73 cpu_info_provider_->cpu_info()->num_of_processors);
67 } 74 }
68 75
69 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698