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