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