| 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 "ui/display/display.h" | 5 #include "ui/display/display.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/display/manager/display_layout.h" | 11 #include "ui/display/manager/display_layout.h" |
| 12 #include "ui/display/manager/display_layout_builder.h" | 12 #include "ui/display/manager/display_layout_builder.h" |
| 13 | 13 |
| 14 namespace display { | 14 namespace display { |
| 15 | 15 |
| 16 TEST(DisplayLayoutTest, Empty) { | 16 TEST(DisplayLayoutTest, Empty) { |
| 17 DisplayList display_list; | 17 Displays display_list; |
| 18 std::vector<int64_t> updated_ids; | 18 std::vector<int64_t> updated_ids; |
| 19 | 19 |
| 20 DisplayLayout display_layout; | 20 DisplayLayout display_layout; |
| 21 display_layout.ApplyToDisplayList(&display_list, &updated_ids, 0); | 21 display_layout.ApplyToDisplayList(&display_list, &updated_ids, 0); |
| 22 | 22 |
| 23 EXPECT_EQ(0u, updated_ids.size()); | 23 EXPECT_EQ(0u, updated_ids.size()); |
| 24 EXPECT_EQ(0u, display_list.size()); | 24 EXPECT_EQ(0u, display_list.size()); |
| 25 } | 25 } |
| 26 | 26 |
| 27 TEST(DisplayLayoutTest, SingleDisplayNoPlacements) { | 27 TEST(DisplayLayoutTest, SingleDisplayNoPlacements) { |
| 28 DisplayList display_list; | 28 Displays display_list; |
| 29 display_list.emplace_back(0, gfx::Rect(0, 0, 800, 600)); | 29 display_list.emplace_back(0, gfx::Rect(0, 0, 800, 600)); |
| 30 std::vector<int64_t> updated_ids; | 30 std::vector<int64_t> updated_ids; |
| 31 | 31 |
| 32 DisplayLayout display_layout; | 32 DisplayLayout display_layout; |
| 33 display_layout.ApplyToDisplayList(&display_list, &updated_ids, 0); | 33 display_layout.ApplyToDisplayList(&display_list, &updated_ids, 0); |
| 34 | 34 |
| 35 EXPECT_EQ(0u, updated_ids.size()); | 35 EXPECT_EQ(0u, updated_ids.size()); |
| 36 ASSERT_EQ(1u, display_list.size()); | 36 ASSERT_EQ(1u, display_list.size()); |
| 37 EXPECT_EQ(gfx::Rect(0, 0, 800, 600), display_list[0].bounds()); | 37 EXPECT_EQ(gfx::Rect(0, 0, 800, 600), display_list[0].bounds()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 TEST(DisplayLayoutTest, SingleDisplayNonRelevantPlacement) { | 40 TEST(DisplayLayoutTest, SingleDisplayNonRelevantPlacement) { |
| 41 DisplayList display_list; | 41 Displays display_list; |
| 42 display_list.emplace_back(0, gfx::Rect(0, 0, 800, 600)); | 42 display_list.emplace_back(0, gfx::Rect(0, 0, 800, 600)); |
| 43 std::vector<int64_t> updated_ids; | 43 std::vector<int64_t> updated_ids; |
| 44 | 44 |
| 45 DisplayLayoutBuilder builder(20); | 45 DisplayLayoutBuilder builder(20); |
| 46 builder.AddDisplayPlacement(20, 40, DisplayPlacement::Position::LEFT, 150); | 46 builder.AddDisplayPlacement(20, 40, DisplayPlacement::Position::LEFT, 150); |
| 47 std::unique_ptr<DisplayLayout> display_layout(builder.Build()); | 47 std::unique_ptr<DisplayLayout> display_layout(builder.Build()); |
| 48 display_layout->ApplyToDisplayList(&display_list, &updated_ids, 0); | 48 display_layout->ApplyToDisplayList(&display_list, &updated_ids, 0); |
| 49 | 49 |
| 50 EXPECT_EQ(0u, updated_ids.size()); | 50 EXPECT_EQ(0u, updated_ids.size()); |
| 51 ASSERT_EQ(1u, display_list.size()); | 51 ASSERT_EQ(1u, display_list.size()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 81 | 81 |
| 82 TEST_P(TwoDisplays, Placement) { | 82 TEST_P(TwoDisplays, Placement) { |
| 83 gfx::Rect primary_display_bounds = std::get<0>(GetParam()); | 83 gfx::Rect primary_display_bounds = std::get<0>(GetParam()); |
| 84 gfx::Rect secondary_display_bounds = std::get<1>(GetParam()); | 84 gfx::Rect secondary_display_bounds = std::get<1>(GetParam()); |
| 85 DisplayPlacement::Position position = std::get<2>(GetParam()); | 85 DisplayPlacement::Position position = std::get<2>(GetParam()); |
| 86 int offset = std::get<3>(GetParam()); | 86 int offset = std::get<3>(GetParam()); |
| 87 int minimum_offset_overlap = std::get<4>(GetParam()); | 87 int minimum_offset_overlap = std::get<4>(GetParam()); |
| 88 gfx::Rect expected_primary_display_bounds = std::get<5>(GetParam()); | 88 gfx::Rect expected_primary_display_bounds = std::get<5>(GetParam()); |
| 89 gfx::Rect expected_secondary_display_bounds = std::get<6>(GetParam()); | 89 gfx::Rect expected_secondary_display_bounds = std::get<6>(GetParam()); |
| 90 | 90 |
| 91 DisplayList display_list; | 91 Displays display_list; |
| 92 display_list.emplace_back(0, primary_display_bounds); | 92 display_list.emplace_back(0, primary_display_bounds); |
| 93 display_list.emplace_back(1, secondary_display_bounds); | 93 display_list.emplace_back(1, secondary_display_bounds); |
| 94 std::vector<int64_t> updated_ids; | 94 std::vector<int64_t> updated_ids; |
| 95 | 95 |
| 96 DisplayLayoutBuilder builder(0); | 96 DisplayLayoutBuilder builder(0); |
| 97 builder.AddDisplayPlacement(1, 0, position, offset); | 97 builder.AddDisplayPlacement(1, 0, position, offset); |
| 98 std::unique_ptr<DisplayLayout> display_layout(builder.Build()); | 98 std::unique_ptr<DisplayLayout> display_layout(builder.Build()); |
| 99 display_layout->ApplyToDisplayList( | 99 display_layout->ApplyToDisplayList( |
| 100 &display_list, &updated_ids, minimum_offset_overlap); | 100 &display_list, &updated_ids, minimum_offset_overlap); |
| 101 | 101 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 std::make_tuple( | 255 std::make_tuple( |
| 256 gfx::Rect(0, 0, 20, 40), gfx::Rect(0, 0, 30, 60), | 256 gfx::Rect(0, 0, 20, 40), gfx::Rect(0, 0, 30, 60), |
| 257 DisplayPlacement::Position::BOTTOM, -30, 14, | 257 DisplayPlacement::Position::BOTTOM, -30, 14, |
| 258 gfx::Rect(0, 0, 20, 40), gfx::Rect(-16, 40, 30, 60)))); | 258 gfx::Rect(0, 0, 20, 40), gfx::Rect(-16, 40, 30, 60)))); |
| 259 | 259 |
| 260 // Display Layout | 260 // Display Layout |
| 261 // [1] [4] | 261 // [1] [4] |
| 262 // [0][3] [6] | 262 // [0][3] [6] |
| 263 // [2] [5] | 263 // [2] [5] |
| 264 TEST(DisplayLayoutTest, MultipleDisplays) { | 264 TEST(DisplayLayoutTest, MultipleDisplays) { |
| 265 DisplayList display_list; | 265 Displays display_list; |
| 266 display_list.emplace_back(0, gfx::Rect(0, 0, 100, 100)); | 266 display_list.emplace_back(0, gfx::Rect(0, 0, 100, 100)); |
| 267 display_list.emplace_back(1, gfx::Rect(0, 0, 100, 100)); | 267 display_list.emplace_back(1, gfx::Rect(0, 0, 100, 100)); |
| 268 display_list.emplace_back(2, gfx::Rect(0, 0, 100, 100)); | 268 display_list.emplace_back(2, gfx::Rect(0, 0, 100, 100)); |
| 269 display_list.emplace_back(3, gfx::Rect(0, 0, 100, 100)); | 269 display_list.emplace_back(3, gfx::Rect(0, 0, 100, 100)); |
| 270 display_list.emplace_back(4, gfx::Rect(0, 0, 100, 100)); | 270 display_list.emplace_back(4, gfx::Rect(0, 0, 100, 100)); |
| 271 display_list.emplace_back(5, gfx::Rect(0, 0, 100, 100)); | 271 display_list.emplace_back(5, gfx::Rect(0, 0, 100, 100)); |
| 272 display_list.emplace_back(6, gfx::Rect(0, 0, 100, 100)); | 272 display_list.emplace_back(6, gfx::Rect(0, 0, 100, 100)); |
| 273 std::vector<int64_t> updated_ids; | 273 std::vector<int64_t> updated_ids; |
| 274 | 274 |
| 275 DisplayLayoutBuilder builder(0); | 275 DisplayLayoutBuilder builder(0); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 328 |
| 329 TEST_P(TwoDisplaysBottomRightReference, Placement) { | 329 TEST_P(TwoDisplaysBottomRightReference, Placement) { |
| 330 gfx::Rect primary_display_bounds = std::get<0>(GetParam()); | 330 gfx::Rect primary_display_bounds = std::get<0>(GetParam()); |
| 331 gfx::Rect secondary_display_bounds = std::get<1>(GetParam()); | 331 gfx::Rect secondary_display_bounds = std::get<1>(GetParam()); |
| 332 DisplayPlacement::Position position = std::get<2>(GetParam()); | 332 DisplayPlacement::Position position = std::get<2>(GetParam()); |
| 333 int offset = std::get<3>(GetParam()); | 333 int offset = std::get<3>(GetParam()); |
| 334 int minimum_offset_overlap = std::get<4>(GetParam()); | 334 int minimum_offset_overlap = std::get<4>(GetParam()); |
| 335 gfx::Rect expected_primary_display_bounds = std::get<5>(GetParam()); | 335 gfx::Rect expected_primary_display_bounds = std::get<5>(GetParam()); |
| 336 gfx::Rect expected_secondary_display_bounds = std::get<6>(GetParam()); | 336 gfx::Rect expected_secondary_display_bounds = std::get<6>(GetParam()); |
| 337 | 337 |
| 338 DisplayList display_list; | 338 Displays display_list; |
| 339 display_list.emplace_back(0, primary_display_bounds); | 339 display_list.emplace_back(0, primary_display_bounds); |
| 340 display_list.emplace_back(1, secondary_display_bounds); | 340 display_list.emplace_back(1, secondary_display_bounds); |
| 341 std::vector<int64_t> updated_ids; | 341 std::vector<int64_t> updated_ids; |
| 342 | 342 |
| 343 DisplayLayoutBuilder builder(0); | 343 DisplayLayoutBuilder builder(0); |
| 344 DisplayPlacement placement; | 344 DisplayPlacement placement; |
| 345 placement.display_id = 1; | 345 placement.display_id = 1; |
| 346 placement.parent_display_id = 0; | 346 placement.parent_display_id = 0; |
| 347 placement.position = position; | 347 placement.position = position; |
| 348 placement.offset = offset; | 348 placement.offset = offset; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 std::make_tuple( | 391 std::make_tuple( |
| 392 gfx::Rect(0, 0, 800, 600), gfx::Rect(0, 0, 1024, 768), | 392 gfx::Rect(0, 0, 800, 600), gfx::Rect(0, 0, 1024, 768), |
| 393 DisplayPlacement::Position::RIGHT, 7, 0, | 393 DisplayPlacement::Position::RIGHT, 7, 0, |
| 394 gfx::Rect(0, 0, 800, 600), gfx::Rect(800, -175, 1024, 768)), | 394 gfx::Rect(0, 0, 800, 600), gfx::Rect(800, -175, 1024, 768)), |
| 395 std::make_tuple( | 395 std::make_tuple( |
| 396 gfx::Rect(0, 0, 800, 600), gfx::Rect(0, 0, 1024, 768), | 396 gfx::Rect(0, 0, 800, 600), gfx::Rect(0, 0, 1024, 768), |
| 397 DisplayPlacement::Position::BOTTOM, 7, 0, | 397 DisplayPlacement::Position::BOTTOM, 7, 0, |
| 398 gfx::Rect(0, 0, 800, 600), gfx::Rect(-231, 600, 1024, 768)))); | 398 gfx::Rect(0, 0, 800, 600), gfx::Rect(-231, 600, 1024, 768)))); |
| 399 | 399 |
| 400 } // namespace display | 400 } // namespace display |
| OLD | NEW |