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

Side by Side Diff: ash/display/display_util_unittest.cc

Issue 1823913002: Allow moving cursors between connected displays. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 } 92 }
93 93
94 TEST_F(DisplayUtilTest, GenerateDisplayIdList) { 94 TEST_F(DisplayUtilTest, GenerateDisplayIdList) {
95 DisplayIdList list; 95 DisplayIdList list;
96 { 96 {
97 int64_t ids[] = {10, 1}; 97 int64_t ids[] = {10, 1};
98 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); 98 list = GenerateDisplayIdList(std::begin(ids), std::end(ids));
99 EXPECT_EQ(1, list[0]); 99 EXPECT_EQ(1, list[0]);
100 EXPECT_EQ(10, list[1]); 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]);
101 } 108 }
102 { 109 {
103 int64_t ids[] = {10, 100}; 110 int64_t ids[] = {10, 100};
104 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); 111 list = GenerateDisplayIdList(std::begin(ids), std::end(ids));
105 EXPECT_EQ(10, list[0]); 112 EXPECT_EQ(10, list[0]);
106 EXPECT_EQ(100, list[1]); 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]);
107 } 121 }
108 { 122 {
109 test::ScopedSetInternalDisplayId set_internal(100); 123 test::ScopedSetInternalDisplayId set_internal(100);
110 int64_t ids[] = {10, 100}; 124 int64_t ids[] = {10, 100};
111 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); 125 list = GenerateDisplayIdList(std::begin(ids), std::end(ids));
112 EXPECT_EQ(100, list[0]); 126 EXPECT_EQ(100, list[0]);
113 EXPECT_EQ(10, list[1]); 127 EXPECT_EQ(10, list[1]);
114 128
115 std::swap(ids[0], ids[1]); 129 std::swap(ids[0], ids[1]);
116 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); 130 list = GenerateDisplayIdList(std::begin(ids), std::end(ids));
117 EXPECT_EQ(100, list[0]); 131 EXPECT_EQ(100, list[0]);
118 EXPECT_EQ(10, list[1]); 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]);
119 } 140 }
120 { 141 {
121 test::ScopedSetInternalDisplayId set_internal(10); 142 test::ScopedSetInternalDisplayId set_internal(10);
122 int64_t ids[] = {10, 100}; 143 int64_t ids[] = {10, 100};
123 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); 144 list = GenerateDisplayIdList(std::begin(ids), std::end(ids));
124 EXPECT_EQ(10, list[0]); 145 EXPECT_EQ(10, list[0]);
125 EXPECT_EQ(100, list[1]); 146 EXPECT_EQ(100, list[1]);
126 147
127 std::swap(ids[0], ids[1]); 148 std::swap(ids[0], ids[1]);
128 list = GenerateDisplayIdList(std::begin(ids), std::end(ids)); 149 list = GenerateDisplayIdList(std::begin(ids), std::end(ids));
129 EXPECT_EQ(10, list[0]); 150 EXPECT_EQ(10, list[0]);
130 EXPECT_EQ(100, list[1]); 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]);
131 } 159 }
132 } 160 }
133 161
162 TEST_F(DisplayUtilTest, DisplayIdListToString) {
163 {
164 int64_t ids[] = {10, 1, 16};
165 DisplayIdList list = GenerateDisplayIdList(std::begin(ids), std::end(ids));
166 EXPECT_EQ("1,10,16", DisplayIdListToString(list));
167 }
168 {
169 test::ScopedSetInternalDisplayId set_internal(16);
170 int64_t ids[] = {10, 1, 16};
171 DisplayIdList list = GenerateDisplayIdList(std::begin(ids), std::end(ids));
172 EXPECT_EQ("16,1,10", DisplayIdListToString(list));
173 }
174 }
175
134 } // namespace 176 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698