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

Side by Side Diff: chrome/browser/extensions/api/system_info_display/display_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 // DisplayInfoProvider unit tests. 5 // DisplayInfoProvider unit tests.
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "chrome/browser/extensions/api/system_info_display/display_info_provide r.h" 8 #include "chrome/browser/extensions/api/system_info_display/display_info_provide r.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 22 matching lines...) Expand all
33 33
34 const struct TestDisplayInfo kTestingDisplayInfoData[] = { 34 const struct TestDisplayInfo kTestingDisplayInfoData[] = {
35 {"Display1", "Display Name1", true, true, true, 96.0, 96.0, 35 {"Display1", "Display Name1", true, true, true, 96.0, 96.0,
36 {0, 0, 1280, 720}, {0, 0, 960, 720}}, 36 {0, 0, 1280, 720}, {0, 0, 960, 720}},
37 {"Display2", "Display Name2", true, true, true, 221.0, 221.0, 37 {"Display2", "Display Name2", true, true, true, 221.0, 221.0,
38 {0, 0, 1280, 720}, {0, 0, 960, 720}} 38 {0, 0, 1280, 720}, {0, 0, 960, 720}}
39 }; 39 };
40 40
41 class TestDisplayInfoProvider : public DisplayInfoProvider { 41 class TestDisplayInfoProvider : public DisplayInfoProvider {
42 public: 42 public:
43 virtual bool QueryInfo(DisplayInfo* info) OVERRIDE; 43 virtual void QueryInfo() OVERRIDE;
44 44
45 const DisplayInfo* display_info() const;
45 private: 46 private:
46 virtual ~TestDisplayInfoProvider(); 47 virtual ~TestDisplayInfoProvider();
47 }; 48 };
48 49
49 TestDisplayInfoProvider::~TestDisplayInfoProvider() {} 50 TestDisplayInfoProvider::~TestDisplayInfoProvider() {}
50 51
51 bool TestDisplayInfoProvider::QueryInfo(DisplayInfo* info) { 52 void TestDisplayInfoProvider::QueryInfo() {
52 if (info == NULL) 53 DisplayInfo* info = &info_;
53 return false;
54 info->clear(); 54 info->clear();
55 for (size_t i = 0; i < arraysize(kTestingDisplayInfoData); ++i) { 55 for (size_t i = 0; i < arraysize(kTestingDisplayInfoData); ++i) {
56 linked_ptr<DisplayUnitInfo> unit(new DisplayUnitInfo()); 56 linked_ptr<DisplayUnitInfo> unit(new DisplayUnitInfo());
57 unit->id = kTestingDisplayInfoData[i].id; 57 unit->id = kTestingDisplayInfoData[i].id;
58 unit->name = kTestingDisplayInfoData[i].name; 58 unit->name = kTestingDisplayInfoData[i].name;
59 unit->is_enabled = kTestingDisplayInfoData[i].is_enabled; 59 unit->is_enabled = kTestingDisplayInfoData[i].is_enabled;
60 unit->is_primary = kTestingDisplayInfoData[i].is_primary; 60 unit->is_primary = kTestingDisplayInfoData[i].is_primary;
61 unit->is_internal = kTestingDisplayInfoData[i].is_internal; 61 unit->is_internal = kTestingDisplayInfoData[i].is_internal;
62 unit->dpi_x = kTestingDisplayInfoData[i].dpi_x; 62 unit->dpi_x = kTestingDisplayInfoData[i].dpi_x;
63 unit->dpi_y = kTestingDisplayInfoData[i].dpi_y; 63 unit->dpi_y = kTestingDisplayInfoData[i].dpi_y;
64 unit->bounds.left = kTestingDisplayInfoData[i].bounds.left; 64 unit->bounds.left = kTestingDisplayInfoData[i].bounds.left;
65 unit->bounds.top = kTestingDisplayInfoData[i].bounds.top; 65 unit->bounds.top = kTestingDisplayInfoData[i].bounds.top;
66 unit->bounds.width = kTestingDisplayInfoData[i].bounds.width; 66 unit->bounds.width = kTestingDisplayInfoData[i].bounds.width;
67 unit->bounds.height = kTestingDisplayInfoData[i].bounds.height; 67 unit->bounds.height = kTestingDisplayInfoData[i].bounds.height;
68 unit->work_area.left = kTestingDisplayInfoData[i].work_area.left; 68 unit->work_area.left = kTestingDisplayInfoData[i].work_area.left;
69 unit->work_area.top = kTestingDisplayInfoData[i].work_area.top; 69 unit->work_area.top = kTestingDisplayInfoData[i].work_area.top;
70 unit->work_area.width = kTestingDisplayInfoData[i].work_area.width; 70 unit->work_area.width = kTestingDisplayInfoData[i].work_area.width;
71 unit->work_area.height = kTestingDisplayInfoData[i].work_area.height; 71 unit->work_area.height = kTestingDisplayInfoData[i].work_area.height;
72 info->push_back(unit); 72 info->push_back(unit);
73 } 73 }
74 return true; 74 success_ = true;
75 }
76
77 const DisplayInfo* TestDisplayInfoProvider::display_info() const {
78 return &info_;
75 } 79 }
76 80
77 class DisplayInfoProviderTest : public testing::Test { 81 class DisplayInfoProviderTest : public testing::Test {
78 public: 82 public:
79 DisplayInfoProviderTest(); 83 DisplayInfoProviderTest();
80 84
81 protected: 85 protected:
82 scoped_refptr<TestDisplayInfoProvider> display_info_provider_; 86 scoped_refptr<TestDisplayInfoProvider> display_info_provider_;
83 }; 87 };
84 88
85 DisplayInfoProviderTest::DisplayInfoProviderTest() 89 DisplayInfoProviderTest::DisplayInfoProviderTest()
86 : display_info_provider_(new TestDisplayInfoProvider()) { 90 : display_info_provider_(new TestDisplayInfoProvider()) {
87 } 91 }
88 92
89 TEST_F(DisplayInfoProviderTest, QueryDisplayInfo) { 93 TEST_F(DisplayInfoProviderTest, QueryDisplayInfo) {
90 scoped_ptr<DisplayInfo> display_info(new DisplayInfo()); 94 display_info_provider_->QueryInfo();
91 EXPECT_TRUE(display_info_provider_->QueryInfo(display_info.get())); 95 const DisplayInfo* display_info = display_info_provider_->display_info();
92 EXPECT_EQ(arraysize(kTestingDisplayInfoData), display_info->size()); 96 EXPECT_EQ(arraysize(kTestingDisplayInfoData), display_info->size());
93 for (size_t i = 0; i < arraysize(kTestingDisplayInfoData); ++i) { 97 for (size_t i = 0; i < arraysize(kTestingDisplayInfoData); ++i) {
94 const linked_ptr<api::system_info_display::DisplayUnitInfo> unit = 98 const linked_ptr<api::system_info_display::DisplayUnitInfo> unit =
95 (*display_info.get())[i]; 99 (*display_info)[i];
96 EXPECT_EQ(kTestingDisplayInfoData[i].id, unit->id); 100 EXPECT_EQ(kTestingDisplayInfoData[i].id, unit->id);
97 EXPECT_EQ(kTestingDisplayInfoData[i].name, unit->name); 101 EXPECT_EQ(kTestingDisplayInfoData[i].name, unit->name);
98 EXPECT_DOUBLE_EQ(kTestingDisplayInfoData[i].dpi_x, unit->dpi_x); 102 EXPECT_DOUBLE_EQ(kTestingDisplayInfoData[i].dpi_x, unit->dpi_x);
99 EXPECT_DOUBLE_EQ(kTestingDisplayInfoData[i].dpi_y, unit->dpi_y); 103 EXPECT_DOUBLE_EQ(kTestingDisplayInfoData[i].dpi_y, unit->dpi_y);
100 EXPECT_EQ(kTestingDisplayInfoData[i].is_enabled, unit->is_enabled); 104 EXPECT_EQ(kTestingDisplayInfoData[i].is_enabled, unit->is_enabled);
101 EXPECT_EQ(kTestingDisplayInfoData[i].is_internal, unit->is_internal); 105 EXPECT_EQ(kTestingDisplayInfoData[i].is_internal, unit->is_internal);
102 EXPECT_EQ(kTestingDisplayInfoData[i].is_primary, unit->is_primary); 106 EXPECT_EQ(kTestingDisplayInfoData[i].is_primary, unit->is_primary);
103 EXPECT_EQ(kTestingDisplayInfoData[i].bounds.left, unit->bounds.left); 107 EXPECT_EQ(kTestingDisplayInfoData[i].bounds.left, unit->bounds.left);
104 EXPECT_EQ(kTestingDisplayInfoData[i].bounds.top, unit->bounds.top); 108 EXPECT_EQ(kTestingDisplayInfoData[i].bounds.top, unit->bounds.top);
105 EXPECT_EQ(kTestingDisplayInfoData[i].bounds.width, unit->bounds.width); 109 EXPECT_EQ(kTestingDisplayInfoData[i].bounds.width, unit->bounds.width);
106 EXPECT_EQ(kTestingDisplayInfoData[i].bounds.height, unit->bounds.height); 110 EXPECT_EQ(kTestingDisplayInfoData[i].bounds.height, unit->bounds.height);
107 EXPECT_EQ(kTestingDisplayInfoData[i].work_area.left, unit->work_area.left); 111 EXPECT_EQ(kTestingDisplayInfoData[i].work_area.left, unit->work_area.left);
108 EXPECT_EQ(kTestingDisplayInfoData[i].work_area.top, unit->work_area.top); 112 EXPECT_EQ(kTestingDisplayInfoData[i].work_area.top, unit->work_area.top);
109 EXPECT_EQ(kTestingDisplayInfoData[i].work_area.width, 113 EXPECT_EQ(kTestingDisplayInfoData[i].work_area.width,
110 unit->work_area.width); 114 unit->work_area.width);
111 EXPECT_EQ(kTestingDisplayInfoData[i].work_area.height, 115 EXPECT_EQ(kTestingDisplayInfoData[i].work_area.height,
112 unit->work_area.height); 116 unit->work_area.height);
113 } 117 }
114 } 118 }
115 119
116 } // namespace extensions 120 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698