Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Unified Diff: ui/display/display_layout_unittest.cc

Issue 2814843007: Fix expected PlacementList sort order. (Closed)
Patch Set: Don't register invalid layouts Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/display/display_layout_unittest.cc
diff --git a/ui/display/display_layout_unittest.cc b/ui/display/display_layout_unittest.cc
index d5abf695cda1bd5d51098ea1a7bb2af3cc2df66f..a367c003dbcd0af4edcf9bad3346b5a507ddd249 100644
--- a/ui/display/display_layout_unittest.cc
+++ b/ui/display/display_layout_unittest.cc
@@ -91,14 +91,15 @@ TEST(DisplayLayoutTest, SwapPrimaryDisplayThreeDisplays) {
.AddDisplayPlacement(789, 456, Position::RIGHT, 0)
.Build();
- // Initial layout will be 123 --> 456 <-- 789.
+ // Note: Placement order is determined by least significant 8 bits of IDs.
+ // Initial layout will be 123 (0x7B) --> 456 (0x1C8) <-- 789 (0x315).
EXPECT_EQ(456, layout->primary_id);
- EXPECT_EQ(123, layout->placement_list[0].display_id);
+ EXPECT_EQ(789, layout->placement_list[0].display_id);
EXPECT_EQ(456, layout->placement_list[0].parent_display_id);
- EXPECT_EQ(Position::LEFT, layout->placement_list[0].position);
- EXPECT_EQ(789, layout->placement_list[1].display_id);
+ EXPECT_EQ(Position::RIGHT, layout->placement_list[0].position);
+ EXPECT_EQ(123, layout->placement_list[1].display_id);
EXPECT_EQ(456, layout->placement_list[1].parent_display_id);
- EXPECT_EQ(Position::RIGHT, layout->placement_list[1].position);
+ EXPECT_EQ(Position::LEFT, layout->placement_list[1].position);
// Swap layout to 123 --> 456 --> 789.
layout->SwapPrimaryDisplay(789);
@@ -113,14 +114,40 @@ TEST(DisplayLayoutTest, SwapPrimaryDisplayThreeDisplays) {
// Swap layout to 123 <-- 456 <-- 789.
layout->SwapPrimaryDisplay(123);
EXPECT_EQ(123, layout->primary_id);
- EXPECT_EQ(456, layout->placement_list[0].display_id);
- EXPECT_EQ(123, layout->placement_list[0].parent_display_id);
+ EXPECT_EQ(789, layout->placement_list[0].display_id);
+ EXPECT_EQ(456, layout->placement_list[0].parent_display_id);
EXPECT_EQ(Position::RIGHT, layout->placement_list[0].position);
- EXPECT_EQ(789, layout->placement_list[1].display_id);
- EXPECT_EQ(456, layout->placement_list[1].parent_display_id);
+ EXPECT_EQ(456, layout->placement_list[1].display_id);
+ EXPECT_EQ(123, layout->placement_list[1].parent_display_id);
EXPECT_EQ(Position::RIGHT, layout->placement_list[1].position);
}
+// Makes sure that only the least significant 8 bits of the display IDs in the
+// placement lists are used to validate their sort order.
+TEST(DisplayLayoutTest, PlacementSortOrder) {
+ // Sorted placement lists by full IDs, but not sorted by the least significant
+ // 8 bits of the IDs.
+ std::unique_ptr<DisplayLayout> layout(new DisplayLayout);
+ layout->primary_id = 456;
+ layout->placement_list.emplace_back(0x0405, 456, Position::LEFT, 0,
+ DisplayPlacement::TOP_LEFT);
+ layout->placement_list.emplace_back(0x0506, 0x0405, Position::RIGHT, 0,
+ DisplayPlacement::TOP_LEFT);
+ layout->placement_list.emplace_back(0x0604, 0x0506, Position::RIGHT, 0,
+ DisplayPlacement::TOP_LEFT);
+ EXPECT_FALSE(DisplayLayout::Validate({456, 0x0405, 0x0506, 0x0604}, *layout));
+
+ // Full IDs not sorted, but least significant 8 bits of the IDs are sorted.
+ layout->placement_list.clear();
+ layout->placement_list.emplace_back(0x0504, 456, Position::LEFT, 0,
+ DisplayPlacement::TOP_LEFT);
+ layout->placement_list.emplace_back(0x0605, 0x0504, Position::RIGHT, 0,
+ DisplayPlacement::TOP_LEFT);
+ layout->placement_list.emplace_back(0x0406, 0x0605, Position::RIGHT, 0,
+ DisplayPlacement::TOP_LEFT);
+ EXPECT_TRUE(DisplayLayout::Validate({456, 0x0504, 0x0605, 0x0406}, *layout));
+}
+
namespace {
class TwoDisplays

Powered by Google App Engine
This is Rietveld 408576698