| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "services/ui/display/screen_manager.h" | 12 #include "services/ui/common/task_runner_test_base.h" |
| 13 #include "services/ui/display/screen_manager_ozone.h" | 13 #include "services/ui/display/screen_manager_ozone.h" |
| 14 #include "services/ui/display/viewport_metrics.h" | 14 #include "services/ui/display/viewport_metrics.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "ui/display/display.h" |
| 17 #include "ui/display/display_switches.h" | 18 #include "ui/display/display_switches.h" |
| 19 #include "ui/display/fake_display_delegate.h" |
| 18 #include "ui/display/fake_display_snapshot.h" | 20 #include "ui/display/fake_display_snapshot.h" |
| 21 #include "ui/display/screen.h" |
| 19 #include "ui/display/types/display_constants.h" | 22 #include "ui/display/types/display_constants.h" |
| 20 #include "ui/display/types/display_mode.h" | 23 #include "ui/display/types/display_mode.h" |
| 21 #include "ui/display/types/display_snapshot.h" | 24 #include "ui/display/types/display_snapshot.h" |
| 25 #include "ui/display/types/fake_display_controller.h" |
| 26 #include "ui/events/devices/device_data_manager.h" |
| 22 #include "ui/ozone/public/ozone_platform.h" | 27 #include "ui/ozone/public/ozone_platform.h" |
| 23 | 28 |
| 24 namespace display { | 29 namespace display { |
| 25 | 30 |
| 26 using ui::DisplayMode; | 31 using ui::DisplayMode; |
| 27 using ui::DisplaySnapshot; | 32 using ui::DisplaySnapshot; |
| 28 using testing::IsEmpty; | 33 using testing::IsEmpty; |
| 29 using testing::SizeIs; | 34 using testing::SizeIs; |
| 30 | 35 |
| 31 namespace { | 36 namespace { |
| 32 | 37 |
| 33 // Holds info about the display state we want to test. | 38 // Holds info about the display state we want to test. |
| 34 struct DisplayState { | 39 struct DisplayState { |
| 35 int64_t id; | 40 int64_t id; |
| 36 ViewportMetrics metrics; | 41 ViewportMetrics metrics; |
| 37 }; | 42 }; |
| 38 | 43 |
| 39 // Matchers that operate on DisplayState. | 44 // Matchers that operate on DisplayState. |
| 40 MATCHER_P(DisplayId, display_id, "") { | 45 MATCHER_P(DisplayIdIs, display_id, "") { |
| 41 *result_listener << "has id " << arg.id; | 46 *result_listener << "has id " << arg.id; |
| 42 return arg.id == display_id; | 47 return arg.id == display_id; |
| 43 } | 48 } |
| 44 | 49 |
| 45 MATCHER_P(DisplaySize, size_string, "") { | 50 MATCHER_P(DisplayPixelSizeIs, size_string, "") { |
| 46 *result_listener << "has size " << arg.metrics.bounds.size().ToString(); | 51 *result_listener << "has size " << arg.metrics.pixel_size.ToString(); |
| 47 return arg.metrics.bounds.size().ToString() == size_string; | 52 return arg.metrics.pixel_size.ToString() == size_string; |
| 48 } | 53 } |
| 49 | 54 |
| 50 MATCHER_P(DisplayOrigin, origin_string, "") { | 55 MATCHER_P(DisplayBoundsIs, bounds_string, "") { |
| 51 *result_listener << "has origin " << arg.metrics.bounds.origin().ToString(); | 56 *result_listener << "has size " << arg.metrics.bounds.ToString(); |
| 52 return arg.metrics.bounds.origin().ToString() == origin_string; | 57 return arg.metrics.bounds.ToString() == bounds_string; |
| 53 } | |
| 54 | |
| 55 // Make a DisplaySnapshot with specified id and size. | |
| 56 std::unique_ptr<DisplaySnapshot> MakeSnapshot(int64_t id, | |
| 57 const gfx::Size& size) { | |
| 58 return FakeDisplaySnapshot::Builder() | |
| 59 .SetId(id) | |
| 60 .SetNativeMode(size) | |
| 61 .SetCurrentMode(size) | |
| 62 .Build(); | |
| 63 } | 58 } |
| 64 | 59 |
| 65 // Test delegate to track what functions calls the delegate receives. | 60 // Test delegate to track what functions calls the delegate receives. |
| 66 class TestScreenManagerDelegate : public ScreenManagerDelegate { | 61 class TestScreenManagerDelegate : public ScreenManagerDelegate { |
| 67 public: | 62 public: |
| 68 TestScreenManagerDelegate() {} | 63 TestScreenManagerDelegate() {} |
| 69 ~TestScreenManagerDelegate() override {} | 64 ~TestScreenManagerDelegate() override {} |
| 70 | 65 |
| 71 const std::vector<DisplayState>& added() const { return added_; } | 66 const std::vector<DisplayState>& added() const { return added_; } |
| 72 const std::vector<DisplayState>& modified() const { return modified_; } | 67 const std::vector<DisplayState>& modified() const { return modified_; } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 std::vector<DisplayState> modified_; | 108 std::vector<DisplayState> modified_; |
| 114 std::string changes_; | 109 std::string changes_; |
| 115 | 110 |
| 116 DISALLOW_COPY_AND_ASSIGN(TestScreenManagerDelegate); | 111 DISALLOW_COPY_AND_ASSIGN(TestScreenManagerDelegate); |
| 117 }; | 112 }; |
| 118 | 113 |
| 119 } // namespace | 114 } // namespace |
| 120 | 115 |
| 121 // Test fixture with helpers to act like ui::DisplayConfigurator and send | 116 // Test fixture with helpers to act like ui::DisplayConfigurator and send |
| 122 // OnDisplayModeChanged() to ScreenManagerOzone. | 117 // OnDisplayModeChanged() to ScreenManagerOzone. |
| 123 class ScreenManagerOzoneTest : public testing::Test { | 118 class ScreenManagerOzoneTest : public ui::TaskRunnerTestBase { |
| 124 public: | 119 public: |
| 125 ScreenManagerOzoneTest() {} | 120 ScreenManagerOzoneTest() {} |
| 126 ~ScreenManagerOzoneTest() override {} | 121 ~ScreenManagerOzoneTest() override {} |
| 127 | 122 |
| 128 ScreenManagerOzone* screen_manager() { return screen_manager_.get(); } | 123 ScreenManagerOzone* screen_manager() { return screen_manager_.get(); } |
| 129 TestScreenManagerDelegate* delegate() { return &delegate_; } | 124 TestScreenManagerDelegate* delegate() { return &delegate_; } |
| 130 | 125 |
| 131 // Adds a display snapshot with specified ID and default size. | 126 // Adds a display snapshot with specified ID and default size. |
| 132 void AddDisplay(int64_t id) { return AddDisplay(id, gfx::Size(1024, 768)); } | 127 void AddDisplay(int64_t id) { |
| 128 return AddDisplay(FakeDisplaySnapshot::Builder() |
| 129 .SetId(id) |
| 130 .SetNativeMode(gfx::Size(1024, 768)) |
| 131 .Build()); |
| 132 } |
| 133 | 133 |
| 134 // Adds a display snapshot with specified ID and size to list of snapshots. | 134 void AddDisplay(std::unique_ptr<ui::DisplaySnapshot> snapshot) { |
| 135 void AddDisplay(int64_t id, const gfx::Size& size) { | 135 EXPECT_TRUE(fake_display_controller_->AddDisplay(std::move(snapshot))); |
| 136 snapshots_.push_back(MakeSnapshot(id, size)); | 136 RunAllTasks(); |
| 137 TriggerOnDisplayModeChanged(); | |
| 138 } | 137 } |
| 139 | 138 |
| 140 // Removes display snapshot with specified ID. | 139 // Removes display snapshot with specified ID. |
| 141 void RemoveDisplay(int64_t id) { | 140 void RemoveDisplay(int64_t id) { |
| 142 snapshots_.erase( | 141 EXPECT_TRUE(fake_display_controller_->RemoveDisplay(id)); |
| 143 std::remove_if(snapshots_.begin(), snapshots_.end(), | 142 RunAllTasks(); |
| 144 [id](std::unique_ptr<DisplaySnapshot>& snapshot) { | |
| 145 return snapshot->display_id() == id; | |
| 146 })); | |
| 147 TriggerOnDisplayModeChanged(); | |
| 148 } | 143 } |
| 149 | 144 |
| 150 // Modify the size of the display snapshot with specified ID. | 145 static void SetUpTestCase() { ui::DeviceDataManager::CreateInstance(); } |
| 151 void ModifyDisplay(int64_t id, const gfx::Size& size) { | |
| 152 DisplaySnapshot* snapshot = GetSnapshotById(id); | |
| 153 | 146 |
| 154 const DisplayMode* new_mode = nullptr; | 147 static void TearDownTestCase() { ui::DeviceDataManager::DeleteInstance(); } |
| 155 for (auto& mode : snapshot->modes()) { | |
| 156 if (mode->size() == size) { | |
| 157 new_mode = mode.get(); | |
| 158 break; | |
| 159 } | |
| 160 } | |
| 161 | |
| 162 if (!new_mode) { | |
| 163 snapshot->add_mode(new DisplayMode(size, false, 30.0f)); | |
| 164 new_mode = snapshot->modes().back().get(); | |
| 165 } | |
| 166 | |
| 167 snapshot->set_current_mode(new_mode); | |
| 168 TriggerOnDisplayModeChanged(); | |
| 169 } | |
| 170 | |
| 171 // Calls OnDisplayModeChanged with our list of display snapshots. | |
| 172 void TriggerOnDisplayModeChanged() { | |
| 173 std::vector<DisplaySnapshot*> snapshots_ptrs; | |
| 174 for (auto& snapshot : snapshots_) { | |
| 175 snapshots_ptrs.push_back(snapshot.get()); | |
| 176 } | |
| 177 screen_manager_->OnDisplayModeChanged(snapshots_ptrs); | |
| 178 } | |
| 179 | 148 |
| 180 private: | 149 private: |
| 181 DisplaySnapshot* GetSnapshotById(int64_t id) { | |
| 182 for (auto& snapshot : snapshots_) { | |
| 183 if (snapshot->display_id() == id) | |
| 184 return snapshot.get(); | |
| 185 } | |
| 186 return nullptr; | |
| 187 } | |
| 188 | |
| 189 // testing::Test: | 150 // testing::Test: |
| 190 void SetUp() override { | 151 void SetUp() override { |
| 152 TaskRunnerTestBase::SetUp(); |
| 153 |
| 191 base::CommandLine::ForCurrentProcess()->AppendSwitchNative( | 154 base::CommandLine::ForCurrentProcess()->AppendSwitchNative( |
| 192 switches::kScreenConfig, "none"); | 155 switches::kScreenConfig, "none"); |
| 193 | 156 |
| 194 testing::Test::SetUp(); | |
| 195 ui::OzonePlatform::InitializeForUI(); | |
| 196 screen_manager_ = base::MakeUnique<ScreenManagerOzone>(); | 157 screen_manager_ = base::MakeUnique<ScreenManagerOzone>(); |
| 158 |
| 159 // Create NDD for FakeDisplayController. |
| 160 std::unique_ptr<ui::NativeDisplayDelegate> ndd = |
| 161 base::MakeUnique<FakeDisplayDelegate>(); |
| 162 fake_display_controller_ = ndd->GetFakeDisplayController(); |
| 163 |
| 164 // Add NDD to ScreenManager so one isn't loaded from Ozone. |
| 165 screen_manager_->native_display_delegate_ = std::move(ndd); |
| 166 |
| 167 AddDisplay(FakeDisplaySnapshot::Builder() |
| 168 .SetId(1) |
| 169 .SetNativeMode(gfx::Size(1024, 768)) |
| 170 .SetType(ui::DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 171 .Build()); |
| 172 |
| 197 screen_manager_->Init(&delegate_); | 173 screen_manager_->Init(&delegate_); |
| 198 | 174 RunAllTasks(); |
| 199 // Have all tests start with a 1024x768 display by default. | |
| 200 AddDisplay(1, gfx::Size(1024, 768)); | |
| 201 TriggerOnDisplayModeChanged(); | |
| 202 | 175 |
| 203 // Double check the expected display exists and clear counters. | 176 // Double check the expected display exists and clear counters. |
| 204 ASSERT_THAT(delegate()->added(), SizeIs(1)); | 177 ASSERT_THAT(delegate()->added(), SizeIs(1)); |
| 205 ASSERT_THAT(delegate_.added()[0], DisplayId(1)); | 178 ASSERT_THAT(delegate_.added()[0], DisplayIdIs(1)); |
| 206 ASSERT_THAT(delegate_.added()[0], DisplayOrigin("0,0")); | 179 ASSERT_THAT(delegate_.added()[0], DisplayBoundsIs("0,0 1024x768")); |
| 207 ASSERT_THAT(delegate_.added()[0], DisplaySize("1024x768")); | 180 ASSERT_THAT(delegate_.added()[0], DisplayPixelSizeIs("1024x768")); |
| 208 ASSERT_EQ("Added(1);Primary(1)", delegate()->changes()); | 181 ASSERT_EQ("Added(1);Primary(1)", delegate()->changes()); |
| 209 delegate_.Reset(); | 182 delegate_.Reset(); |
| 210 } | 183 } |
| 211 | 184 |
| 212 void TearDown() override { | 185 void TearDown() override { |
| 213 snapshots_.clear(); | |
| 214 delegate_.Reset(); | 186 delegate_.Reset(); |
| 215 screen_manager_.reset(); | 187 screen_manager_.reset(); |
| 216 } | 188 } |
| 217 | 189 |
| 190 FakeDisplayController* fake_display_controller_ = nullptr; |
| 218 TestScreenManagerDelegate delegate_; | 191 TestScreenManagerDelegate delegate_; |
| 219 std::unique_ptr<ScreenManagerOzone> screen_manager_; | 192 std::unique_ptr<ScreenManagerOzone> screen_manager_; |
| 220 std::vector<std::unique_ptr<DisplaySnapshot>> snapshots_; | |
| 221 }; | 193 }; |
| 222 | 194 |
| 223 TEST_F(ScreenManagerOzoneTest, AddDisplay) { | 195 TEST_F(ScreenManagerOzoneTest, AddDisplay) { |
| 224 AddDisplay(2); | 196 AddDisplay(FakeDisplaySnapshot::Builder() |
| 197 .SetId(2) |
| 198 .SetNativeMode(gfx::Size(1600, 900)) |
| 199 .Build()); |
| 225 | 200 |
| 226 // Check that display 2 was added. | 201 // Check that display 2 was added with expected bounds and pixel_size. |
| 227 EXPECT_EQ("Added(2)", delegate()->changes()); | 202 EXPECT_EQ("Added(2)", delegate()->changes()); |
| 203 EXPECT_THAT(delegate()->added()[0], DisplayPixelSizeIs("1600x900")); |
| 204 EXPECT_THAT(delegate()->added()[0], DisplayBoundsIs("1024,0 1600x900")); |
| 228 } | 205 } |
| 229 | 206 |
| 230 TEST_F(ScreenManagerOzoneTest, RemoveDisplay) { | 207 TEST_F(ScreenManagerOzoneTest, RemoveDisplay) { |
| 231 AddDisplay(2); | 208 AddDisplay(2); |
| 232 delegate()->Reset(); | 209 delegate()->Reset(); |
| 233 | 210 |
| 234 RemoveDisplay(2); | 211 RemoveDisplay(2); |
| 235 | 212 |
| 236 // Check that display 2 was removed. | 213 // Check that display 2 was removed. |
| 237 EXPECT_EQ("Removed(2)", delegate()->changes()); | 214 EXPECT_EQ("Removed(2)", delegate()->changes()); |
| 238 } | 215 } |
| 239 | 216 |
| 240 TEST_F(ScreenManagerOzoneTest, RemoveFirstDisplay) { | 217 TEST_F(ScreenManagerOzoneTest, DISABLED_RemovePrimaryDisplay) { |
| 241 AddDisplay(2); | 218 AddDisplay(2); |
| 242 delegate()->Reset(); | 219 delegate()->Reset(); |
| 243 | 220 |
| 244 RemoveDisplay(1); | 221 RemoveDisplay(1); |
| 245 | 222 |
| 246 // Check that display 1 was removed and display 2 was modified due to the | 223 // Check that display 1 was removed and display 2 becomes the primary display |
| 247 // origin changing. | 224 // and has it's origin change. |
| 248 EXPECT_EQ("Primary(2);Removed(1);Modified(2)", delegate()->changes()); | 225 EXPECT_EQ("Removed(1);Modified(2);Primary(2)", delegate()->changes()); |
| 249 ASSERT_THAT(delegate()->modified(), SizeIs(1)); | 226 ASSERT_THAT(delegate()->modified(), SizeIs(1)); |
| 250 EXPECT_THAT(delegate()->modified()[0], DisplayId(2)); | 227 EXPECT_THAT(delegate()->modified()[0], DisplayIdIs(2)); |
| 251 EXPECT_THAT(delegate()->modified()[0], DisplayOrigin("0,0")); | 228 EXPECT_THAT(delegate()->modified()[0], DisplayBoundsIs("0,0 1024x768")); |
| 252 } | 229 } |
| 253 | 230 |
| 254 TEST_F(ScreenManagerOzoneTest, RemoveMultipleDisplay) { | 231 TEST_F(ScreenManagerOzoneTest, AddRemoveMultipleDisplay) { |
| 255 AddDisplay(2); | 232 AddDisplay(2); |
| 256 AddDisplay(3); | 233 AddDisplay(3); |
| 234 EXPECT_EQ("Added(2);Added(3)", delegate()->changes()); |
| 235 EXPECT_THAT(delegate()->added()[0], DisplayBoundsIs("1024,0 1024x768")); |
| 236 EXPECT_THAT(delegate()->added()[1], DisplayBoundsIs("2048,0 1024x768")); |
| 257 delegate()->Reset(); | 237 delegate()->Reset(); |
| 258 | 238 |
| 239 // Check that display 2 was removed and display 3 origin changed. |
| 259 RemoveDisplay(2); | 240 RemoveDisplay(2); |
| 241 EXPECT_EQ("Removed(2);Modified(3)", delegate()->changes()); |
| 242 EXPECT_THAT(delegate()->modified()[0], DisplayBoundsIs("1024,0 1024x768")); |
| 243 delegate()->Reset(); |
| 244 |
| 245 // Check that display 3 was removed. |
| 260 RemoveDisplay(3); | 246 RemoveDisplay(3); |
| 261 | 247 EXPECT_EQ("Removed(3)", delegate()->changes()); |
| 262 // Check that display 2 was removed and display 3 is modifed (origin change), | |
| 263 // then display 3 was removed. | |
| 264 EXPECT_EQ("Removed(2);Modified(3);Removed(3)", delegate()->changes()); | |
| 265 } | 248 } |
| 266 | 249 |
| 267 TEST_F(ScreenManagerOzoneTest, ModifyDisplaySize) { | 250 TEST_F(ScreenManagerOzoneTest, AddDisplay4k) { |
| 268 const gfx::Size size1(1920, 1200); | 251 AddDisplay(FakeDisplaySnapshot::Builder() |
| 269 const gfx::Size size2(1680, 1050); | 252 .SetId(2) |
| 253 .SetNativeMode(gfx::Size(4096, 2160)) |
| 254 .SetType(ui::DISPLAY_CONNECTION_TYPE_DVI) |
| 255 .Build()); |
| 270 | 256 |
| 271 AddDisplay(2, size1); | 257 // Check that display 2 has a device scale factor of 2 since it's a 4k |
| 272 | 258 // display. |
| 273 // Check that display 2 was added with expected size. | |
| 274 ASSERT_THAT(delegate()->added(), SizeIs(1)); | |
| 275 EXPECT_THAT(delegate()->added()[0], DisplayId(2)); | |
| 276 EXPECT_THAT(delegate()->added()[0], DisplaySize(size1.ToString())); | |
| 277 EXPECT_EQ("Added(2)", delegate()->changes()); | 259 EXPECT_EQ("Added(2)", delegate()->changes()); |
| 278 delegate()->Reset(); | 260 EXPECT_THAT(delegate()->added()[0], DisplayBoundsIs("1024,0 2048x1080")); |
| 279 | 261 EXPECT_THAT(delegate()->added()[0], DisplayPixelSizeIs("4096x2160")); |
| 280 ModifyDisplay(2, size2); | |
| 281 | |
| 282 // Check that display 2 was modified to have the new expected size. | |
| 283 ASSERT_THAT(delegate()->modified(), SizeIs(1)); | |
| 284 EXPECT_THAT(delegate()->modified()[0], DisplayId(2)); | |
| 285 EXPECT_THAT(delegate()->modified()[0], DisplaySize(size2.ToString())); | |
| 286 EXPECT_EQ("Modified(2)", delegate()->changes()); | |
| 287 } | |
| 288 | |
| 289 TEST_F(ScreenManagerOzoneTest, ModifyFirstDisplaySize) { | |
| 290 const gfx::Size size(1920, 1200); | |
| 291 | |
| 292 AddDisplay(2, size); | |
| 293 | |
| 294 // Check that display 2 has the expected initial origin. | |
| 295 EXPECT_EQ("Added(2)", delegate()->changes()); | |
| 296 ASSERT_THAT(delegate()->added(), SizeIs(1)); | |
| 297 EXPECT_THAT(delegate()->added()[0], DisplayOrigin("1024,0")); | |
| 298 delegate()->Reset(); | |
| 299 | |
| 300 ModifyDisplay(1, size); | |
| 301 | |
| 302 // Check that display 1 was modified with a new size and display 2 origin was | |
| 303 // modified after. | |
| 304 EXPECT_EQ("Modified(1);Modified(2)", delegate()->changes()); | |
| 305 ASSERT_THAT(delegate()->modified(), SizeIs(2)); | |
| 306 EXPECT_THAT(delegate()->modified()[0], DisplayId(1)); | |
| 307 EXPECT_THAT(delegate()->modified()[0], DisplaySize(size.ToString())); | |
| 308 EXPECT_THAT(delegate()->modified()[1], DisplayId(2)); | |
| 309 EXPECT_THAT(delegate()->modified()[1], DisplayOrigin("1920,0")); | |
| 310 } | |
| 311 | |
| 312 TEST_F(ScreenManagerOzoneTest, RemovePrimaryDisplay) { | |
| 313 AddDisplay(2); | |
| 314 delegate()->Reset(); | |
| 315 | |
| 316 RemoveDisplay(1); | |
| 317 | |
| 318 // Check the primary display changed because the old primary was removed. | |
| 319 EXPECT_EQ("Primary(2);Removed(1);Modified(2)", delegate()->changes()); | |
| 320 } | |
| 321 | |
| 322 TEST_F(ScreenManagerOzoneTest, RemoveLastDisplay) { | |
| 323 RemoveDisplay(1); | |
| 324 | |
| 325 // Check that display 1 is removed and no updates for the primary display are | |
| 326 // received. | |
| 327 EXPECT_EQ("Removed(1)", delegate()->changes()); | |
| 328 } | 262 } |
| 329 | 263 |
| 330 TEST_F(ScreenManagerOzoneTest, SwapPrimaryDisplay) { | 264 TEST_F(ScreenManagerOzoneTest, SwapPrimaryDisplay) { |
| 331 AddDisplay(2); | 265 AddDisplay(2); |
| 332 delegate()->Reset(); | 266 delegate()->Reset(); |
| 333 | 267 |
| 268 EXPECT_EQ(1, Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 269 |
| 270 // Swapping displays will modify the bounds of both displays and change the |
| 271 // primary. |
| 334 screen_manager()->SwapPrimaryDisplay(); | 272 screen_manager()->SwapPrimaryDisplay(); |
| 335 EXPECT_EQ("Primary(2)", delegate()->changes()); | 273 EXPECT_EQ("Modified(1);Modified(2);Primary(2)", delegate()->changes()); |
| 336 } | 274 EXPECT_THAT(delegate()->modified()[0], DisplayBoundsIs("-1024,0 1024x768")); |
| 337 | 275 EXPECT_THAT(delegate()->modified()[1], DisplayBoundsIs("0,0 1024x768")); |
| 338 TEST_F(ScreenManagerOzoneTest, SwapPrimaryThreeDisplays) { | 276 EXPECT_EQ(2, Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 339 AddDisplay(2); | |
| 340 AddDisplay(3); | |
| 341 EXPECT_EQ("Added(2);Added(3)", delegate()->changes()); | |
| 342 delegate()->Reset(); | 277 delegate()->Reset(); |
| 343 | 278 |
| 279 // Swapping again should be similar and end up back with display 1 as primary. |
| 344 screen_manager()->SwapPrimaryDisplay(); | 280 screen_manager()->SwapPrimaryDisplay(); |
| 345 screen_manager()->SwapPrimaryDisplay(); | 281 EXPECT_EQ("Modified(1);Modified(2);Primary(1)", delegate()->changes()); |
| 346 screen_manager()->SwapPrimaryDisplay(); | 282 EXPECT_THAT(delegate()->modified()[0], DisplayBoundsIs("0,0 1024x768")); |
| 347 EXPECT_EQ("Primary(2);Primary(3);Primary(1)", delegate()->changes()); | 283 EXPECT_THAT(delegate()->modified()[1], DisplayBoundsIs("1024,0 1024x768")); |
| 284 EXPECT_EQ(1, Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 348 } | 285 } |
| 349 | 286 |
| 350 } // namespace display | 287 } // namespace display |
| OLD | NEW |