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

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

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase at r285842 Created 6 years, 4 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 | Annotate | Revision Log
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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/test/event_generator.h"
11 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
12 #include "ui/aura/window_event_dispatcher.h" 11 #include "ui/aura/window_event_dispatcher.h"
13 #include "ui/base/hit_test.h" 12 #include "ui/base/hit_test.h"
14 #include "ui/base/x/x11_util.h" 13 #include "ui/base/x/x11_util.h"
14 #include "ui/events/test/event_generator.h"
15 #include "ui/gfx/display_observer.h" 15 #include "ui/gfx/display_observer.h"
16 #include "ui/gfx/x/x11_types.h" 16 #include "ui/gfx/x/x11_types.h"
17 #include "ui/views/test/views_test_base.h" 17 #include "ui/views/test/views_test_base.h"
18 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 18 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
19 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" 19 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
20 20
21 namespace { 21 namespace {
22 22
23 // Class which allows for the designation of non-client component targets of 23 // Class which allows for the designation of non-client component targets of
24 // hit tests. 24 // hit tests.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 native_widget->set_window_component(HTCAPTION); 283 native_widget->set_window_component(HTCAPTION);
284 284
285 aura::Window* window = widget->GetNativeWindow(); 285 aura::Window* window = widget->GetNativeWindow();
286 window->SetProperty(aura::client::kCanMaximizeKey, true); 286 window->SetProperty(aura::client::kCanMaximizeKey, true);
287 287
288 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized 288 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized
289 DesktopWindowTreeHost* rwh = 289 DesktopWindowTreeHost* rwh =
290 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> 290 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()->
291 GetAcceleratedWidget()); 291 GetAcceleratedWidget());
292 292
293 aura::test::EventGenerator generator(window); 293 ui::test::EventGenerator generator(window);
294 generator.ClickLeftButton(); 294 generator.ClickLeftButton();
295 generator.DoubleClickLeftButton(); 295 generator.DoubleClickLeftButton();
296 RunPendingMessages(); 296 RunPendingMessages();
297 EXPECT_TRUE(rwh->IsMaximized()); 297 EXPECT_TRUE(rwh->IsMaximized());
298 298
299 widget->CloseNow(); 299 widget->CloseNow();
300 } 300 }
301 301
302 // Tests that the window does not maximize in response to a double click event, 302 // Tests that the window does not maximize in response to a double click event,
303 // if the first click was to a different target component than that of the 303 // if the first click was to a different target component than that of the
304 // second click. 304 // second click.
305 TEST_F(DesktopScreenX11Test, DoubleClickTwoDifferentTargetsDoesntMaximizes) { 305 TEST_F(DesktopScreenX11Test, DoubleClickTwoDifferentTargetsDoesntMaximizes) {
306 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); 306 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true);
307 widget->Show(); 307 widget->Show();
308 TestDesktopNativeWidgetAura* native_widget = 308 TestDesktopNativeWidgetAura* native_widget =
309 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget()); 309 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget());
310 310
311 aura::Window* window = widget->GetNativeWindow(); 311 aura::Window* window = widget->GetNativeWindow();
312 window->SetProperty(aura::client::kCanMaximizeKey, true); 312 window->SetProperty(aura::client::kCanMaximizeKey, true);
313 313
314 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized 314 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized
315 DesktopWindowTreeHost* rwh = 315 DesktopWindowTreeHost* rwh =
316 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> 316 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()->
317 GetAcceleratedWidget()); 317 GetAcceleratedWidget());
318 318
319 aura::test::EventGenerator generator(window); 319 ui::test::EventGenerator generator(window);
320 native_widget->set_window_component(HTCLIENT); 320 native_widget->set_window_component(HTCLIENT);
321 generator.ClickLeftButton(); 321 generator.ClickLeftButton();
322 native_widget->set_window_component(HTCAPTION); 322 native_widget->set_window_component(HTCAPTION);
323 generator.DoubleClickLeftButton(); 323 generator.DoubleClickLeftButton();
324 RunPendingMessages(); 324 RunPendingMessages();
325 EXPECT_FALSE(rwh->IsMaximized()); 325 EXPECT_FALSE(rwh->IsMaximized());
326 326
327 widget->CloseNow(); 327 widget->CloseNow();
328 } 328 }
329 329
330 // Tests that the window does not maximize in response to a double click event, 330 // Tests that the window does not maximize in response to a double click event,
331 // if the double click was interrupted by a right click. 331 // if the double click was interrupted by a right click.
332 TEST_F(DesktopScreenX11Test, RightClickDuringDoubleClickDoesntMaximize) { 332 TEST_F(DesktopScreenX11Test, RightClickDuringDoubleClickDoesntMaximize) {
333 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true); 333 Widget* widget = BuildTopLevelDesktopWidget(gfx::Rect(0, 0, 100, 100), true);
334 widget->Show(); 334 widget->Show();
335 TestDesktopNativeWidgetAura* native_widget = 335 TestDesktopNativeWidgetAura* native_widget =
336 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget()); 336 static_cast<TestDesktopNativeWidgetAura*>(widget->native_widget());
337 337
338 aura::Window* window = widget->GetNativeWindow(); 338 aura::Window* window = widget->GetNativeWindow();
339 window->SetProperty(aura::client::kCanMaximizeKey, true); 339 window->SetProperty(aura::client::kCanMaximizeKey, true);
340 340
341 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized 341 // Cast to superclass as DesktopWindowTreeHostX11 hide IsMaximized
342 DesktopWindowTreeHost* rwh = static_cast<DesktopWindowTreeHost*>( 342 DesktopWindowTreeHost* rwh = static_cast<DesktopWindowTreeHost*>(
343 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()-> 343 DesktopWindowTreeHostX11::GetHostForXID(window->GetHost()->
344 GetAcceleratedWidget())); 344 GetAcceleratedWidget()));
345 345
346 aura::test::EventGenerator generator(window); 346 ui::test::EventGenerator generator(window);
347 native_widget->set_window_component(HTCLIENT); 347 native_widget->set_window_component(HTCLIENT);
348 generator.ClickLeftButton(); 348 generator.ClickLeftButton();
349 native_widget->set_window_component(HTCAPTION); 349 native_widget->set_window_component(HTCAPTION);
350 generator.PressRightButton(); 350 generator.PressRightButton();
351 generator.ReleaseRightButton(); 351 generator.ReleaseRightButton();
352 EXPECT_FALSE(rwh->IsMaximized()); 352 EXPECT_FALSE(rwh->IsMaximized());
353 generator.DoubleClickLeftButton(); 353 generator.DoubleClickLeftButton();
354 RunPendingMessages(); 354 RunPendingMessages();
355 EXPECT_FALSE(rwh->IsMaximized()); 355 EXPECT_FALSE(rwh->IsMaximized());
356 356
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 NotifyDisplaysChanged(displays); 444 NotifyDisplaysChanged(displays);
445 EXPECT_EQ(2u, changed_display_.size()); 445 EXPECT_EQ(2u, changed_display_.size());
446 446
447 displays[0].set_device_scale_factor(1.f); 447 displays[0].set_device_scale_factor(1.f);
448 displays[1].set_device_scale_factor(1.f); 448 displays[1].set_device_scale_factor(1.f);
449 NotifyDisplaysChanged(displays); 449 NotifyDisplaysChanged(displays);
450 EXPECT_EQ(4u, changed_display_.size()); 450 EXPECT_EQ(4u, changed_display_.size());
451 } 451 }
452 452
453 } // namespace views 453 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698