| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/display/display_util.h" | 5 #include "ash/display/display_util.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/test/display_manager_test_api.h" | 10 #include "ash/test/display_manager_test_api.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 GetRootWindowController(root_windows[0])->ash_host(); | 84 GetRootWindowController(root_windows[0])->ash_host(); |
| 85 AshWindowTreeHost* host1 = | 85 AshWindowTreeHost* host1 = |
| 86 GetRootWindowController(root_windows[1])->ash_host(); | 86 GetRootWindowController(root_windows[1])->ash_host(); |
| 87 gfx::Rect rect0 = GetNativeEdgeBounds(host0, gfx::Rect(499, 10, 1, 300)); | 87 gfx::Rect rect0 = GetNativeEdgeBounds(host0, gfx::Rect(499, 10, 1, 300)); |
| 88 gfx::Rect rect1 = GetNativeEdgeBounds(host1, gfx::Rect(500, 10, 1, 300)); | 88 gfx::Rect rect1 = GetNativeEdgeBounds(host1, gfx::Rect(500, 10, 1, 300)); |
| 89 EXPECT_EQ("10,99 1x300", rect0.ToString()); | 89 EXPECT_EQ("10,99 1x300", rect0.ToString()); |
| 90 EXPECT_EQ("600,20 1x300", rect1.ToString()); | 90 EXPECT_EQ("600,20 1x300", rect1.ToString()); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 TEST_F(DisplayUtilTest, GenerateDisplayIdList) { | 94 } // namespace ash |
| 95 display::DisplayIdList list; | |
| 96 { | |
| 97 int64_t ids[] = {10, 1}; | |
| 98 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 99 EXPECT_EQ(1, list[0]); | |
| 100 EXPECT_EQ(10, list[1]); | |
| 101 | |
| 102 int64_t three_ids[] = {10, 5, 1}; | |
| 103 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); | |
| 104 ASSERT_EQ(3u, list.size()); | |
| 105 EXPECT_EQ(1, list[0]); | |
| 106 EXPECT_EQ(5, list[1]); | |
| 107 EXPECT_EQ(10, list[2]); | |
| 108 } | |
| 109 { | |
| 110 int64_t ids[] = {10, 100}; | |
| 111 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 112 EXPECT_EQ(10, list[0]); | |
| 113 EXPECT_EQ(100, list[1]); | |
| 114 | |
| 115 int64_t three_ids[] = {10, 100, 1000}; | |
| 116 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); | |
| 117 ASSERT_EQ(3u, list.size()); | |
| 118 EXPECT_EQ(10, list[0]); | |
| 119 EXPECT_EQ(100, list[1]); | |
| 120 EXPECT_EQ(1000, list[2]); | |
| 121 } | |
| 122 { | |
| 123 test::ScopedSetInternalDisplayId set_internal(100); | |
| 124 int64_t ids[] = {10, 100}; | |
| 125 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 126 EXPECT_EQ(100, list[0]); | |
| 127 EXPECT_EQ(10, list[1]); | |
| 128 | |
| 129 std::swap(ids[0], ids[1]); | |
| 130 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 131 EXPECT_EQ(100, list[0]); | |
| 132 EXPECT_EQ(10, list[1]); | |
| 133 | |
| 134 int64_t three_ids[] = {10, 100, 1000}; | |
| 135 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); | |
| 136 ASSERT_EQ(3u, list.size()); | |
| 137 EXPECT_EQ(100, list[0]); | |
| 138 EXPECT_EQ(10, list[1]); | |
| 139 EXPECT_EQ(1000, list[2]); | |
| 140 } | |
| 141 { | |
| 142 test::ScopedSetInternalDisplayId set_internal(10); | |
| 143 int64_t ids[] = {10, 100}; | |
| 144 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 145 EXPECT_EQ(10, list[0]); | |
| 146 EXPECT_EQ(100, list[1]); | |
| 147 | |
| 148 std::swap(ids[0], ids[1]); | |
| 149 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 150 EXPECT_EQ(10, list[0]); | |
| 151 EXPECT_EQ(100, list[1]); | |
| 152 | |
| 153 int64_t three_ids[] = {10, 100, 1000}; | |
| 154 list = GenerateDisplayIdList(std::begin(three_ids), std::end(three_ids)); | |
| 155 ASSERT_EQ(3u, list.size()); | |
| 156 EXPECT_EQ(10, list[0]); | |
| 157 EXPECT_EQ(100, list[1]); | |
| 158 EXPECT_EQ(1000, list[2]); | |
| 159 } | |
| 160 } | |
| 161 | |
| 162 TEST_F(DisplayUtilTest, DisplayIdListToString) { | |
| 163 { | |
| 164 int64_t ids[] = {10, 1, 16}; | |
| 165 display::DisplayIdList list = | |
| 166 GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 167 EXPECT_EQ("1,10,16", DisplayIdListToString(list)); | |
| 168 } | |
| 169 { | |
| 170 test::ScopedSetInternalDisplayId set_internal(16); | |
| 171 int64_t ids[] = {10, 1, 16}; | |
| 172 display::DisplayIdList list = | |
| 173 GenerateDisplayIdList(std::begin(ids), std::end(ids)); | |
| 174 EXPECT_EQ("16,1,10", DisplayIdListToString(list)); | |
| 175 } | |
| 176 } | |
| 177 | |
| 178 } // namespace | |
| OLD | NEW |