| 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/display_info_provider.h" | 5 #include "chrome/browser/extensions/api/system_display/display_info_provider.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/display_manager_test_api.h" | 12 #include "ash/test/display_manager_test_api.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "ui/gfx/display.h" | 15 #include "ui/gfx/display.h" |
| 16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 void BindRequestDisplayInfoResult(DisplayInfo* target, bool success) { | |
| 22 ASSERT_TRUE(success); | |
| 23 *target = DisplayInfoProvider::Get()->display_info(); | |
| 24 } | |
| 25 | |
| 26 void BindSetDisplayUnitInfoResult(bool* success, | |
| 27 std::string* error, | |
| 28 bool success_in, | |
| 29 const std::string& error_in) { | |
| 30 *success = success_in; | |
| 31 *error = error_in; | |
| 32 } | |
| 33 | |
| 34 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { | 21 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { |
| 35 public: | 22 public: |
| 36 DisplayInfoProviderChromeosTest() {} | 23 DisplayInfoProviderChromeosTest() {} |
| 37 | 24 |
| 38 virtual ~DisplayInfoProviderChromeosTest() {} | 25 virtual ~DisplayInfoProviderChromeosTest() {} |
| 39 | 26 |
| 40 protected: | 27 protected: |
| 41 void CallRequestDisplayInfo(DisplayInfo* result) { | |
| 42 DisplayInfoProvider::Get()->RequestInfo( | |
| 43 base::Bind(&BindRequestDisplayInfoResult, result)); | |
| 44 RunAllPendingInMessageLoop(); | |
| 45 } | |
| 46 | |
| 47 void CallSetDisplayUnitInfo( | 28 void CallSetDisplayUnitInfo( |
| 48 const std::string& display_id, | 29 const std::string& display_id, |
| 49 const api::system_display::DisplayProperties& info, | 30 const api::system_display::DisplayProperties& info, |
| 50 bool* success, | 31 bool* success, |
| 51 std::string* error) { | 32 std::string* error) { |
| 52 DisplayInfoProvider::Get()->SetInfo(display_id, info, | 33 // Reset error messsage. |
| 53 base::Bind(&BindSetDisplayUnitInfoResult, success, error)); | 34 (*error).clear(); |
| 54 RunAllPendingInMessageLoop(); | 35 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); |
| 55 } | 36 } |
| 56 | 37 |
| 57 bool DisplayExists(int64 display_id) const { | 38 bool DisplayExists(int64 display_id) const { |
| 58 const gfx::Display& display = | 39 const gfx::Display& display = |
| 59 GetDisplayManager()->GetDisplayForId(display_id); | 40 GetDisplayManager()->GetDisplayForId(display_id); |
| 60 return display.id() != gfx::Display::kInvalidDisplayID; | 41 return display.id() != gfx::Display::kInvalidDisplayID; |
| 61 } | 42 } |
| 62 | 43 |
| 63 ash::internal::DisplayManager* GetDisplayManager() const { | 44 ash::internal::DisplayManager* GetDisplayManager() const { |
| 64 return ash::Shell::GetInstance()->display_manager(); | 45 return ash::Shell::GetInstance()->display_manager(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 80 // Order to match gfx::Rect::ToString(). | 61 // Order to match gfx::Rect::ToString(). |
| 81 return base::StringPrintf("%d,%d %dx%d", | 62 return base::StringPrintf("%d,%d %dx%d", |
| 82 bounds.left, bounds.top, bounds.width, bounds.height); | 63 bounds.left, bounds.top, bounds.width, bounds.height); |
| 83 } | 64 } |
| 84 | 65 |
| 85 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); | 66 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); |
| 86 }; | 67 }; |
| 87 | 68 |
| 88 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { | 69 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { |
| 89 UpdateDisplay("500x600,400x520"); | 70 UpdateDisplay("500x600,400x520"); |
| 90 DisplayInfo result; | 71 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 91 CallRequestDisplayInfo(&result); | |
| 92 | 72 |
| 93 ASSERT_EQ(2u, result.size()); | 73 ASSERT_EQ(2u, result.size()); |
| 94 | 74 |
| 95 int64 display_id; | 75 int64 display_id; |
| 96 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) | 76 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) |
| 97 << "Display id must be convertable to integer: " << result[0]->id; | 77 << "Display id must be convertable to integer: " << result[0]->id; |
| 98 | 78 |
| 99 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 79 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 100 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 80 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 101 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0]->overscan)); | 81 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0]->overscan)); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 120 EXPECT_EQ(0, result[1]->rotation); | 100 EXPECT_EQ(0, result[1]->rotation); |
| 121 EXPECT_FALSE(result[1]->is_primary); | 101 EXPECT_FALSE(result[1]->is_primary); |
| 122 EXPECT_EQ(96, result[1]->dpi_x); | 102 EXPECT_EQ(96, result[1]->dpi_x); |
| 123 EXPECT_EQ(96, result[1]->dpi_y); | 103 EXPECT_EQ(96, result[1]->dpi_y); |
| 124 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); | 104 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); |
| 125 EXPECT_TRUE(result[1]->is_enabled); | 105 EXPECT_TRUE(result[1]->is_enabled); |
| 126 } | 106 } |
| 127 | 107 |
| 128 TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { | 108 TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { |
| 129 UpdateDisplay("500x600/r"); | 109 UpdateDisplay("500x600/r"); |
| 130 DisplayInfo result; | 110 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 131 CallRequestDisplayInfo(&result); | |
| 132 | 111 |
| 133 ASSERT_EQ(1u, result.size()); | 112 ASSERT_EQ(1u, result.size()); |
| 134 | 113 |
| 135 int64 display_id; | 114 int64 display_id; |
| 136 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) | 115 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) |
| 137 << "Display id must be convertable to integer: " << result[0]->id; | 116 << "Display id must be convertable to integer: " << result[0]->id; |
| 138 | 117 |
| 139 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 118 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 140 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 119 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 141 EXPECT_EQ(90, result[0]->rotation); | 120 EXPECT_EQ(90, result[0]->rotation); |
| 142 | 121 |
| 143 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_270); | 122 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_270); |
| 144 | 123 |
| 145 CallRequestDisplayInfo(&result); | 124 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 146 | 125 |
| 147 ASSERT_EQ(1u, result.size()); | 126 ASSERT_EQ(1u, result.size()); |
| 148 | 127 |
| 149 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); | 128 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); |
| 150 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 129 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 151 EXPECT_EQ(270, result[0]->rotation); | 130 EXPECT_EQ(270, result[0]->rotation); |
| 152 | 131 |
| 153 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_180); | 132 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_180); |
| 154 | 133 |
| 155 CallRequestDisplayInfo(&result); | 134 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 156 | 135 |
| 157 ASSERT_EQ(1u, result.size()); | 136 ASSERT_EQ(1u, result.size()); |
| 158 | 137 |
| 159 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); | 138 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); |
| 160 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 139 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 161 EXPECT_EQ(180, result[0]->rotation); | 140 EXPECT_EQ(180, result[0]->rotation); |
| 162 | 141 |
| 163 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_0); | 142 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_0); |
| 164 | 143 |
| 165 CallRequestDisplayInfo(&result); | 144 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 166 | 145 |
| 167 ASSERT_EQ(1u, result.size()); | 146 ASSERT_EQ(1u, result.size()); |
| 168 | 147 |
| 169 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); | 148 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); |
| 170 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 149 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 171 EXPECT_EQ(0, result[0]->rotation); | 150 EXPECT_EQ(0, result[0]->rotation); |
| 172 } | 151 } |
| 173 | 152 |
| 174 TEST_F(DisplayInfoProviderChromeosTest, GetHiDPI) { | 153 TEST_F(DisplayInfoProviderChromeosTest, GetHiDPI) { |
| 175 UpdateDisplay("500x600,400x520*2"); | 154 UpdateDisplay("500x600,400x520*2"); |
| 176 DisplayInfo result; | 155 DisplayInfo result; |
| 177 CallRequestDisplayInfo(&result); | 156 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 178 | 157 |
| 179 ASSERT_EQ(2u, result.size()); | 158 ASSERT_EQ(2u, result.size()); |
| 180 | 159 |
| 181 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 160 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 182 EXPECT_EQ(96, result[0]->dpi_x); | 161 EXPECT_EQ(96, result[0]->dpi_x); |
| 183 EXPECT_EQ(96, result[0]->dpi_y); | 162 EXPECT_EQ(96, result[0]->dpi_y); |
| 184 | 163 |
| 185 EXPECT_EQ("500,0 200x260", | 164 EXPECT_EQ("500,0 200x260", |
| 186 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 165 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 187 EXPECT_EQ(2 * 96, result[1]->dpi_x); | 166 EXPECT_EQ(2 * 96, result[1]->dpi_x); |
| 188 EXPECT_EQ(2 * 96, result[1]->dpi_y); | 167 EXPECT_EQ(2 * 96, result[1]->dpi_y); |
| 189 | 168 |
| 190 GetDisplayController()->SwapPrimaryDisplay(); | 169 GetDisplayController()->SwapPrimaryDisplay(); |
| 191 | 170 |
| 192 CallRequestDisplayInfo(&result); | 171 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 193 | 172 |
| 194 ASSERT_EQ(2u, result.size()); | 173 ASSERT_EQ(2u, result.size()); |
| 195 | 174 |
| 196 EXPECT_EQ("-500,0 500x600", | 175 EXPECT_EQ("-500,0 500x600", |
| 197 SystemInfoDisplayBoundsToString(result[0]->bounds)); | 176 SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 198 EXPECT_EQ(96, result[0]->dpi_x); | 177 EXPECT_EQ(96, result[0]->dpi_x); |
| 199 EXPECT_EQ(96, result[0]->dpi_y); | 178 EXPECT_EQ(96, result[0]->dpi_y); |
| 200 | 179 |
| 201 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1]->bounds)); | 180 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 202 EXPECT_EQ(2 * 96, result[1]->dpi_x); | 181 EXPECT_EQ(2 * 96, result[1]->dpi_x); |
| 203 EXPECT_EQ(2 * 96, result[1]->dpi_y); | 182 EXPECT_EQ(2 * 96, result[1]->dpi_y); |
| 204 } | 183 } |
| 205 | 184 |
| 206 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) { | 185 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) { |
| 207 UpdateDisplay("640x720*2/o, 400x520/o"); | 186 UpdateDisplay("640x720*2/o, 400x520/o"); |
| 208 DisplayInfo result; | 187 DisplayInfo result; |
| 209 CallRequestDisplayInfo(&result); | 188 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 210 | 189 |
| 211 ASSERT_EQ(2u, result.size()); | 190 ASSERT_EQ(2u, result.size()); |
| 212 | 191 |
| 213 int64 display_id; | 192 int64 display_id; |
| 214 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id)) | 193 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id)) |
| 215 << "Display id must be convertable to integer: " << result[1]->id; | 194 << "Display id must be convertable to integer: " << result[1]->id; |
| 216 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 195 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 217 | 196 |
| 218 // Default overscan is 5%. | 197 // Default overscan is 5%. |
| 219 EXPECT_EQ("304,0 380x494", | 198 EXPECT_EQ("304,0 380x494", |
| 220 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 199 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 221 EXPECT_EQ("13,10,13,10", | 200 EXPECT_EQ("13,10,13,10", |
| 222 SystemInfoDisplayInsetsToString(result[1]->overscan)); | 201 SystemInfoDisplayInsetsToString(result[1]->overscan)); |
| 223 | 202 |
| 224 GetDisplayManager()->SetOverscanInsets(display_id, | 203 GetDisplayManager()->SetOverscanInsets(display_id, |
| 225 gfx::Insets(20, 30, 50, 60)); | 204 gfx::Insets(20, 30, 50, 60)); |
| 226 CallRequestDisplayInfo(&result); | 205 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 227 | 206 |
| 228 ASSERT_EQ(2u, result.size()); | 207 ASSERT_EQ(2u, result.size()); |
| 229 | 208 |
| 230 EXPECT_EQ(base::Int64ToString(display_id), result[1]->id); | 209 EXPECT_EQ(base::Int64ToString(display_id), result[1]->id); |
| 231 EXPECT_EQ("304,0 310x450", | 210 EXPECT_EQ("304,0 310x450", |
| 232 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 211 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 233 EXPECT_EQ("20,30,50,60", | 212 EXPECT_EQ("20,30,50,60", |
| 234 SystemInfoDisplayInsetsToString(result[1]->overscan)); | 213 SystemInfoDisplayInsetsToString(result[1]->overscan)); |
| 235 | 214 |
| 236 // Set insets for the primary screen. Note that it has 2x scale. | 215 // Set insets for the primary screen. Note that it has 2x scale. |
| 237 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) | 216 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id)) |
| 238 << "Display id must be convertable to integer: " << result[0]->id; | 217 << "Display id must be convertable to integer: " << result[0]->id; |
| 239 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 218 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 240 | 219 |
| 241 EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 220 EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 242 EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0]->overscan)); | 221 EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0]->overscan)); |
| 243 | 222 |
| 244 GetDisplayManager()->SetOverscanInsets(display_id, | 223 GetDisplayManager()->SetOverscanInsets(display_id, |
| 245 gfx::Insets(10, 20, 30, 40)); | 224 gfx::Insets(10, 20, 30, 40)); |
| 246 CallRequestDisplayInfo(&result); | 225 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 247 | 226 |
| 248 ASSERT_EQ(2u, result.size()); | 227 ASSERT_EQ(2u, result.size()); |
| 249 | 228 |
| 250 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); | 229 EXPECT_EQ(base::Int64ToString(display_id), result[0]->id); |
| 251 EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 230 EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 252 EXPECT_EQ("10,20,30,40", | 231 EXPECT_EQ("10,20,30,40", |
| 253 SystemInfoDisplayInsetsToString(result[0]->overscan)); | 232 SystemInfoDisplayInsetsToString(result[0]->overscan)); |
| 254 } | 233 } |
| 255 | 234 |
| 256 TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) { | 235 TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) { |
| 257 UpdateDisplay("600x600, 400x520/o"); | 236 UpdateDisplay("600x600, 400x520/o"); |
| 258 DisplayInfo result; | 237 DisplayInfo result; |
| 259 CallRequestDisplayInfo(&result); | 238 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 260 | 239 |
| 261 ASSERT_EQ(2u, result.size()); | 240 ASSERT_EQ(2u, result.size()); |
| 262 | 241 |
| 263 int64 display_id_primary; | 242 int64 display_id_primary; |
| 264 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id_primary)) | 243 ASSERT_TRUE(base::StringToInt64(result[0]->id, &display_id_primary)) |
| 265 << "Display id must be convertable to integer: " << result[0]->id; | 244 << "Display id must be convertable to integer: " << result[0]->id; |
| 266 ASSERT_TRUE(DisplayExists(display_id_primary)) | 245 ASSERT_TRUE(DisplayExists(display_id_primary)) |
| 267 << display_id_primary << " not found"; | 246 << display_id_primary << " not found"; |
| 268 | 247 |
| 269 int64 display_id_secondary; | 248 int64 display_id_secondary; |
| 270 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id_secondary)) | 249 ASSERT_TRUE(base::StringToInt64(result[1]->id, &display_id_secondary)) |
| 271 << "Display id must be convertable to integer: " << result[1]->id; | 250 << "Display id must be convertable to integer: " << result[1]->id; |
| 272 ASSERT_TRUE(DisplayExists(display_id_secondary)) | 251 ASSERT_TRUE(DisplayExists(display_id_secondary)) |
| 273 << display_id_secondary << " not found"; | 252 << display_id_secondary << " not found"; |
| 274 | 253 |
| 275 ASSERT_FALSE(GetDisplayManager()->IsMirrored()); | 254 ASSERT_FALSE(GetDisplayManager()->IsMirrored()); |
| 276 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); | 255 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); |
| 277 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); | 256 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); |
| 278 | 257 |
| 279 GetDisplayManager()->SetMirrorMode(true); | 258 GetDisplayManager()->SetMirrorMode(true); |
| 280 ASSERT_TRUE(GetDisplayManager()->IsMirrored()); | 259 ASSERT_TRUE(GetDisplayManager()->IsMirrored()); |
| 281 | 260 |
| 282 CallRequestDisplayInfo(&result); | 261 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 283 | 262 |
| 284 ASSERT_EQ(1u, result.size()); | 263 ASSERT_EQ(1u, result.size()); |
| 285 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0]->id); | 264 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0]->id); |
| 286 EXPECT_EQ(base::Int64ToString(display_id_secondary), | 265 EXPECT_EQ(base::Int64ToString(display_id_secondary), |
| 287 result[0]->mirroring_source_id); | 266 result[0]->mirroring_source_id); |
| 288 | 267 |
| 289 GetDisplayManager()->SetMirrorMode(false); | 268 GetDisplayManager()->SetMirrorMode(false); |
| 290 ASSERT_FALSE(GetDisplayManager()->IsMirrored()); | 269 ASSERT_FALSE(GetDisplayManager()->IsMirrored()); |
| 291 | 270 |
| 292 CallRequestDisplayInfo(&result); | 271 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 293 | 272 |
| 294 ASSERT_EQ(2u, result.size()); | 273 ASSERT_EQ(2u, result.size()); |
| 295 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0]->id); | 274 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0]->id); |
| 296 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); | 275 EXPECT_TRUE(result[0]->mirroring_source_id.empty()); |
| 297 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1]->id); | 276 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1]->id); |
| 298 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); | 277 EXPECT_TRUE(result[1]->mirroring_source_id.empty()); |
| 299 } | 278 } |
| 300 | 279 |
| 301 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { | 280 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { |
| 302 UpdateDisplay("600x600, 400x520"); | 281 UpdateDisplay("600x600, 400x520"); |
| 303 GetDisplayController()->SetLayoutForCurrentDisplays( | 282 GetDisplayController()->SetLayoutForCurrentDisplays( |
| 304 ash::DisplayLayout::FromInts(ash::DisplayLayout::LEFT, -40)); | 283 ash::DisplayLayout::FromInts(ash::DisplayLayout::LEFT, -40)); |
| 305 | 284 |
| 306 DisplayInfo result; | 285 DisplayInfo result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 307 CallRequestDisplayInfo(&result); | 286 |
| 308 ASSERT_EQ(2u, result.size()); | 287 ASSERT_EQ(2u, result.size()); |
| 309 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 288 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 310 EXPECT_EQ("-400,-40 400x520", | 289 EXPECT_EQ("-400,-40 400x520", |
| 311 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 290 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 312 | 291 |
| 313 GetDisplayController()->SetLayoutForCurrentDisplays( | 292 GetDisplayController()->SetLayoutForCurrentDisplays( |
| 314 ash::DisplayLayout::FromInts(ash::DisplayLayout::TOP, 40)); | 293 ash::DisplayLayout::FromInts(ash::DisplayLayout::TOP, 40)); |
| 315 | 294 |
| 316 CallRequestDisplayInfo(&result); | 295 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 296 |
| 317 ASSERT_EQ(2u, result.size()); | 297 ASSERT_EQ(2u, result.size()); |
| 318 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 298 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 319 EXPECT_EQ("40,-520 400x520", | 299 EXPECT_EQ("40,-520 400x520", |
| 320 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 300 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 321 | 301 |
| 322 GetDisplayController()->SetLayoutForCurrentDisplays( | 302 GetDisplayController()->SetLayoutForCurrentDisplays( |
| 323 ash::DisplayLayout::FromInts(ash::DisplayLayout::BOTTOM, 80)); | 303 ash::DisplayLayout::FromInts(ash::DisplayLayout::BOTTOM, 80)); |
| 324 | 304 |
| 325 CallRequestDisplayInfo(&result); | 305 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 326 ASSERT_EQ(2u, result.size()); | 306 ASSERT_EQ(2u, result.size()); |
| 327 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 307 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 328 EXPECT_EQ("80,600 400x520", | 308 EXPECT_EQ("80,600 400x520", |
| 329 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 309 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 330 } | 310 } |
| 331 | 311 |
| 332 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { | 312 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { |
| 333 UpdateDisplay("1200x600,520x400"); | 313 UpdateDisplay("1200x600,520x400"); |
| 334 | 314 |
| 335 const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); | 315 const gfx::Display& secondary = ash::ScreenAsh::GetSecondaryDisplay(); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 CallSetDisplayUnitInfo(base::Int64ToString(internal_display_id), info, | 884 CallSetDisplayUnitInfo(base::Int64ToString(internal_display_id), info, |
| 905 &success, &error); | 885 &success, &error); |
| 906 | 886 |
| 907 ASSERT_FALSE(success); | 887 ASSERT_FALSE(success); |
| 908 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", | 888 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", |
| 909 error); | 889 error); |
| 910 } | 890 } |
| 911 | 891 |
| 912 } // namespace | 892 } // namespace |
| 913 } // namespace extensions | 893 } // namespace extensions |
| OLD | NEW |