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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_screen_x11_unittest.cc

Issue 137533006: Call XSetInputFocus after XRaiseWindow when activating. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/views/widget/desktop_aura/desktop_screen_x11.h" 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/display_observer.h" 9 #include "ui/gfx/display_observer.h"
10 #include "ui/views/test/views_test_base.h" 10 #include "ui/views/test/views_test_base.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 gfx::Rect(640, 0, 1024, 768))); 192 gfx::Rect(640, 0, 1024, 768)));
193 displays.push_back(gfx::Display(kSecondDisplay, gfx::Rect(0, 0, 640, 480))); 193 displays.push_back(gfx::Display(kSecondDisplay, gfx::Rect(0, 0, 640, 480)));
194 screen()->ProcessDisplayChange(displays); 194 screen()->ProcessDisplayChange(displays);
195 195
196 // The first display in the list is always the primary, even if other 196 // The first display in the list is always the primary, even if other
197 // displays are to the left in screen layout. 197 // displays are to the left in screen layout.
198 EXPECT_EQ(kFirstDisplay, screen()->GetPrimaryDisplay().id()); 198 EXPECT_EQ(kFirstDisplay, screen()->GetPrimaryDisplay().id());
199 } 199 }
200 200
201 TEST_F(DesktopScreenX11Test, GetWindowAtScreenPoint) { 201 TEST_F(DesktopScreenX11Test, GetWindowAtScreenPoint) {
202 Widget* window_one = BuildTopLevelDesktopWidget(gfx::Rect(10, 10, 10, 10)); 202 Widget* window_one = BuildTopLevelDesktopWidget(gfx::Rect(110, 110, 10, 10));
203 Widget* window_two = BuildTopLevelDesktopWidget(gfx::Rect(50, 50, 10, 10)); 203 Widget* window_two = BuildTopLevelDesktopWidget(gfx::Rect(150, 150, 10, 10));
204 Widget* window_three = BuildTopLevelDesktopWidget(gfx::Rect(15, 15, 20, 20)); 204 Widget* window_three =
205 BuildTopLevelDesktopWidget(gfx::Rect(115, 115, 20, 20));
206
207 window_three->Show();
208 window_two->Show();
209 window_one->Show();
205 210
206 // Make sure the internal state of DesktopWindowTreeHostX11 is set up 211 // Make sure the internal state of DesktopWindowTreeHostX11 is set up
207 // correctly. 212 // correctly.
208 ASSERT_EQ(3u, DesktopWindowTreeHostX11::GetAllOpenWindows().size()); 213 ASSERT_EQ(3u, DesktopWindowTreeHostX11::GetAllOpenWindows().size());
209 214
210 EXPECT_EQ(window_one->GetNativeWindow(), 215 EXPECT_EQ(window_one->GetNativeWindow(),
211 screen()->GetWindowAtScreenPoint(gfx::Point(15, 15))); 216 screen()->GetWindowAtScreenPoint(gfx::Point(115, 115)));
212 EXPECT_EQ(window_two->GetNativeWindow(), 217 EXPECT_EQ(window_two->GetNativeWindow(),
213 screen()->GetWindowAtScreenPoint(gfx::Point(55, 55))); 218 screen()->GetWindowAtScreenPoint(gfx::Point(155, 155)));
214 EXPECT_EQ(NULL, 219 EXPECT_EQ(NULL,
215 screen()->GetWindowAtScreenPoint(gfx::Point(100, 100))); 220 screen()->GetWindowAtScreenPoint(gfx::Point(200, 200)));
216 221
217 // Bring the third window in front. It overlaps with the first window. 222 // Bring the third window in front. It overlaps with the first window.
218 // Hit-testing on the intersecting region should give the third window. 223 // Hit-testing on the intersecting region should give the third window.
219 window_three->Activate(); 224 window_three->Activate();
220 EXPECT_EQ(window_three->GetNativeWindow(), 225 EXPECT_EQ(window_three->GetNativeWindow(),
221 screen()->GetWindowAtScreenPoint(gfx::Point(15, 15))); 226 screen()->GetWindowAtScreenPoint(gfx::Point(115, 115)));
222 227
223 window_one->CloseNow(); 228 window_one->CloseNow();
224 window_two->CloseNow(); 229 window_two->CloseNow();
230 window_three->CloseNow();
225 } 231 }
226 232
227 TEST_F(DesktopScreenX11Test, GetDisplayNearestWindow) { 233 TEST_F(DesktopScreenX11Test, GetDisplayNearestWindow) {
228 // Set up a two monitor situation. 234 // Set up a two monitor situation.
229 std::vector<gfx::Display> displays; 235 std::vector<gfx::Display> displays;
230 displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480))); 236 displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480)));
231 displays.push_back(gfx::Display(kSecondDisplay, 237 displays.push_back(gfx::Display(kSecondDisplay,
232 gfx::Rect(640, 0, 1024, 768))); 238 gfx::Rect(640, 0, 1024, 768)));
233 screen()->ProcessDisplayChange(displays); 239 screen()->ProcessDisplayChange(displays);
234 240
235 Widget* window_one = BuildTopLevelDesktopWidget(gfx::Rect(10, 10, 10, 10)); 241 Widget* window_one = BuildTopLevelDesktopWidget(gfx::Rect(10, 10, 10, 10));
236 Widget* window_two = BuildTopLevelDesktopWidget(gfx::Rect(650, 50, 10, 10)); 242 Widget* window_two = BuildTopLevelDesktopWidget(gfx::Rect(650, 50, 10, 10));
237 243
238 EXPECT_EQ( 244 EXPECT_EQ(
239 kFirstDisplay, 245 kFirstDisplay,
240 screen()->GetDisplayNearestWindow(window_one->GetNativeWindow()).id()); 246 screen()->GetDisplayNearestWindow(window_one->GetNativeWindow()).id());
241 EXPECT_EQ( 247 EXPECT_EQ(
242 kSecondDisplay, 248 kSecondDisplay,
243 screen()->GetDisplayNearestWindow(window_two->GetNativeWindow()).id()); 249 screen()->GetDisplayNearestWindow(window_two->GetNativeWindow()).id());
244 250
245 window_one->CloseNow(); 251 window_one->CloseNow();
246 window_two->CloseNow(); 252 window_two->CloseNow();
247 } 253 }
248 254
249 } // namespace views 255 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_root_window_host_x11.cc ('k') | ui/views/widget/desktop_aura/x11_desktop_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698