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 "chrome/browser/extensions/api/system_display/system_display_api.h" | |
6 | |
7 #include "base/debug/leak_annotations.h" | 5 #include "base/debug/leak_annotations.h" |
8 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
9 #include "chrome/browser/extensions/api/system_display/display_info_provider.h" | |
10 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
11 #include "chrome/browser/extensions/extension_function_test_utils.h" | 8 #include "chrome/browser/extensions/extension_function_test_utils.h" |
12 #include "chrome/common/extensions/api/system_display.h" | 9 #include "extensions/browser/api/system_display/display_info_provider.h" |
| 10 #include "extensions/browser/api/system_display/system_display_api.h" |
| 11 #include "extensions/common/api/system_display.h" |
13 #include "ui/gfx/display.h" | 12 #include "ui/gfx/display.h" |
14 #include "ui/gfx/display_observer.h" | 13 #include "ui/gfx/display_observer.h" |
15 #include "ui/gfx/screen.h" | 14 #include "ui/gfx/screen.h" |
16 | 15 |
17 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
18 #include "ash/display/screen_ash.h" | 17 #include "ash/display/screen_ash.h" |
19 #include "ash/shell.h" | 18 #include "ash/shell.h" |
20 #endif | 19 #endif |
21 | 20 |
22 namespace utils = extension_function_test_utils; | 21 namespace utils = extension_function_test_utils; |
23 | 22 |
24 namespace extensions { | 23 namespace extensions { |
25 | 24 |
26 using api::system_display::Bounds; | 25 using core_api::system_display::Bounds; |
27 using api::system_display::DisplayUnitInfo; | 26 using core_api::system_display::DisplayUnitInfo; |
28 using gfx::Screen; | 27 using gfx::Screen; |
29 | 28 |
30 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
31 class MockScreen : public ash::ScreenAsh { | 30 class MockScreen : public ash::ScreenAsh { |
32 public: | 31 public: |
33 MockScreen() { | 32 MockScreen() { |
34 for (int i = 0; i < 4; i++) { | 33 for (int i = 0; i < 4; i++) { |
35 gfx::Rect bounds(0, 0, 1280, 720); | 34 gfx::Rect bounds(0, 0, 1280, 720); |
36 gfx::Rect work_area(0, 0, 960, 720); | 35 gfx::Rect work_area(0, 0, 960, 720); |
37 gfx::Display display(i, bounds); | 36 gfx::Display display(i, bounds); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 #endif | 114 #endif |
116 | 115 |
117 class MockDisplayInfoProvider : public DisplayInfoProvider { | 116 class MockDisplayInfoProvider : public DisplayInfoProvider { |
118 public: | 117 public: |
119 MockDisplayInfoProvider() {} | 118 MockDisplayInfoProvider() {} |
120 | 119 |
121 virtual ~MockDisplayInfoProvider() {} | 120 virtual ~MockDisplayInfoProvider() {} |
122 | 121 |
123 virtual bool SetInfo( | 122 virtual bool SetInfo( |
124 const std::string& display_id, | 123 const std::string& display_id, |
125 const api::system_display::DisplayProperties& params, | 124 const core_api::system_display::DisplayProperties& params, |
126 std::string* error) OVERRIDE { | 125 std::string* error) OVERRIDE { |
127 // Should get called only once per test case. | 126 // Should get called only once per test case. |
128 EXPECT_FALSE(set_info_value_); | 127 EXPECT_FALSE(set_info_value_); |
129 set_info_value_ = params.ToValue(); | 128 set_info_value_ = params.ToValue(); |
130 set_info_display_id_ = display_id; | 129 set_info_display_id_ = display_id; |
131 return true; | 130 return true; |
132 } | 131 } |
133 | 132 |
134 virtual gfx::Screen* GetActiveScreen() OVERRIDE { return NULL; } | 133 virtual gfx::Screen* GetActiveScreen() OVERRIDE { return NULL; } |
135 | 134 |
136 scoped_ptr<base::DictionaryValue> GetSetInfoValue() { | 135 scoped_ptr<base::DictionaryValue> GetSetInfoValue() { |
137 return set_info_value_.Pass(); | 136 return set_info_value_.Pass(); |
138 } | 137 } |
139 | 138 |
140 std::string GetSetInfoDisplayId() const { | 139 std::string GetSetInfoDisplayId() const { |
141 return set_info_display_id_; | 140 return set_info_display_id_; |
142 } | 141 } |
143 | 142 |
144 private: | 143 private: |
145 // Update the content of the |unit| obtained for |display| using | 144 // Update the content of the |unit| obtained for |display| using |
146 // platform specific method. | 145 // platform specific method. |
147 virtual void UpdateDisplayUnitInfoForPlatform( | 146 virtual void UpdateDisplayUnitInfoForPlatform( |
148 const gfx::Display& display, | 147 const gfx::Display& display, |
149 extensions::api::system_display::DisplayUnitInfo* unit) OVERRIDE { | 148 extensions::core_api::system_display::DisplayUnitInfo* unit) OVERRIDE { |
150 int64 id = display.id(); | 149 int64 id = display.id(); |
151 unit->name = "DISPLAY NAME FOR " + base::Int64ToString(id); | 150 unit->name = "DISPLAY NAME FOR " + base::Int64ToString(id); |
152 if (id == 1) | 151 if (id == 1) |
153 unit->mirroring_source_id = "0"; | 152 unit->mirroring_source_id = "0"; |
154 unit->is_primary = id == 0 ? true : false; | 153 unit->is_primary = id == 0 ? true : false; |
155 unit->is_internal = id == 0 ? true : false; | 154 unit->is_internal = id == 0 ? true : false; |
156 unit->is_enabled = true; | 155 unit->is_enabled = true; |
157 unit->rotation = (90 * id) % 360; | 156 unit->rotation = (90 * id) % 360; |
158 unit->dpi_x = 96.0; | 157 unit->dpi_x = 96.0; |
159 unit->dpi_y = 96.0; | 158 unit->dpi_y = 96.0; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 EXPECT_EQ(1, utils::GetInteger(overscan, "left")); | 299 EXPECT_EQ(1, utils::GetInteger(overscan, "left")); |
301 EXPECT_EQ(2, utils::GetInteger(overscan, "top")); | 300 EXPECT_EQ(2, utils::GetInteger(overscan, "top")); |
302 EXPECT_EQ(3, utils::GetInteger(overscan, "right")); | 301 EXPECT_EQ(3, utils::GetInteger(overscan, "right")); |
303 EXPECT_EQ(4, utils::GetInteger(overscan, "bottom")); | 302 EXPECT_EQ(4, utils::GetInteger(overscan, "bottom")); |
304 | 303 |
305 EXPECT_EQ("display_id", provider_->GetSetInfoDisplayId()); | 304 EXPECT_EQ("display_id", provider_->GetSetInfoDisplayId()); |
306 } | 305 } |
307 #endif // defined(OS_CHROMEOS) | 306 #endif // defined(OS_CHROMEOS) |
308 | 307 |
309 } // namespace extensions | 308 } // namespace extensions |
OLD | NEW |