1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/wm/workspace/workspace_event_handler.h"
7 #include "ash/screen_util.h"
9 #include "ash/test/ash_test_base.h"
10 #include "ash/wm/window_state.h"
11 #include "ash/wm/window_util.h"
12 #include "ash/wm/wm_event.h"
13 #include "ash/wm/workspace_controller.h"
14 #include "ash/wm/workspace_controller_test_helper.h"
15 #include "ui/aura/client/aura_constants.h"
16 #include "ui/aura/test/test_window_delegate.h"
17 #include "ui/aura/window.h"
18 #include "ui/aura/window_tree_host.h"
19 #include "ui/base/hit_test.h"
20 #include "ui/events/event_processor.h"
21 #include "ui/events/event_utils.h"
22 #include "ui/events/test/event_generator.h"
23 #include "ui/gfx/screen.h"
24 #include "ui/wm/core/window_util.h"
25 #include "ui/wm/public/window_move_client.h"
28 #include "base/win/windows_version.h"
35 // Clicks |button| with |flags|.
36 void ClickButtonWithFlags(ui::test::EventGenerator
* generator
,
39 gfx::Point location
= generator
->current_location();
40 ui::MouseEvent
press(ui::ET_MOUSE_PRESSED
, location
, location
,
41 ui::EventTimeForNow(), button
| flags
, button
);
42 generator
->Dispatch(&press
);
43 ui::MouseEvent
release(ui::ET_MOUSE_RELEASED
, location
, location
,
44 ui::EventTimeForNow(), button
| flags
, button
);
45 generator
->Dispatch(&release
);
50 class WorkspaceEventHandlerTest
: public test::AshTestBase
{
52 WorkspaceEventHandlerTest() {}
53 ~WorkspaceEventHandlerTest() override
{}
56 aura::Window
* CreateTestWindow(aura::WindowDelegate
* delegate
,
57 const gfx::Rect
& bounds
) {
58 aura::Window
* window
= new aura::Window(delegate
);
59 window
->SetType(ui::wm::WINDOW_TYPE_NORMAL
);
60 window
->Init(ui::LAYER_TEXTURED
);
61 ParentWindowInPrimaryRootWindow(window
);
62 window
->SetBounds(bounds
);
68 DISALLOW_COPY_AND_ASSIGN(WorkspaceEventHandlerTest
);
71 // Keeps track of the properties changed of a particular window.
72 class WindowPropertyObserver
: public aura::WindowObserver
{
74 explicit WindowPropertyObserver(aura::Window
* window
)
76 window
->AddObserver(this);
79 ~WindowPropertyObserver() override
{ window_
->RemoveObserver(this); }
81 bool DidPropertyChange(const void* property
) const {
82 return std::find(properties_changed_
.begin(),
83 properties_changed_
.end(),
84 property
) != properties_changed_
.end();
88 void OnWindowPropertyChanged(aura::Window
* window
,
90 intptr_t old
) override
{
91 properties_changed_
.push_back(key
);
94 aura::Window
* window_
;
95 std::vector
<const void*> properties_changed_
;
97 DISALLOW_COPY_AND_ASSIGN(WindowPropertyObserver
);
100 TEST_F(WorkspaceEventHandlerTest
, DoubleClickSingleAxisResizeEdge
) {
101 // Double clicking the vertical resize edge of a window should maximize it
103 gfx::Rect
restored_bounds(10, 10, 50, 50);
104 aura::test::TestWindowDelegate delegate
;
105 scoped_ptr
<aura::Window
> window(CreateTestWindow(&delegate
, restored_bounds
));
107 wm::ActivateWindow(window
.get());
109 gfx::Rect work_area
= Shell::GetScreen()->GetDisplayNearestWindow(
110 window
.get()).work_area();
112 ui::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(),
115 // Double-click the top resize edge.
116 delegate
.set_window_component(HTTOP
);
117 // On X a double click actually generates a drag between each press/release.
118 // Explicitly trigger this path since we had bugs in dealing with it
120 generator
.PressLeftButton();
121 generator
.ReleaseLeftButton();
122 generator
.set_flags(ui::EF_IS_DOUBLE_CLICK
);
123 generator
.PressLeftButton();
124 generator
.MoveMouseTo(generator
.current_location(), 1);
125 generator
.ReleaseLeftButton();
126 gfx::Rect bounds_in_screen
= window
->GetBoundsInScreen();
127 EXPECT_EQ(restored_bounds
.x(), bounds_in_screen
.x());
128 EXPECT_EQ(restored_bounds
.width(), bounds_in_screen
.width());
129 EXPECT_EQ(work_area
.y(), bounds_in_screen
.y());
130 EXPECT_EQ(work_area
.height(), bounds_in_screen
.height());
132 wm::WindowState
* window_state
= wm::GetWindowState(window
.get());
133 // Single-axis maximization is not considered real maximization.
134 EXPECT_FALSE(window_state
->IsMaximized());
137 generator
.DoubleClickLeftButton();
138 bounds_in_screen
= window
->GetBoundsInScreen();
139 EXPECT_EQ(restored_bounds
.ToString(), bounds_in_screen
.ToString());
140 // Note that it should not even be restored at this point, it should have
141 // also cleared the restore rectangle.
142 EXPECT_FALSE(window_state
->HasRestoreBounds());
144 // Double clicking the left resize edge should maximize horizontally.
145 delegate
.set_window_component(HTLEFT
);
146 generator
.DoubleClickLeftButton();
147 bounds_in_screen
= window
->GetBoundsInScreen();
148 EXPECT_EQ(restored_bounds
.y(), bounds_in_screen
.y());
149 EXPECT_EQ(restored_bounds
.height(), bounds_in_screen
.height());
150 EXPECT_EQ(work_area
.x(), bounds_in_screen
.x());
151 EXPECT_EQ(work_area
.width(), bounds_in_screen
.width());
152 // Single-axis maximization is not considered real maximization.
153 EXPECT_FALSE(window_state
->IsMaximized());
156 generator
.DoubleClickLeftButton();
157 EXPECT_EQ(restored_bounds
.ToString(), window
->GetBoundsInScreen().ToString());
160 // Multi display test does not run on Win8 bot. crbug.com/247427.
161 if (!SupportsMultipleDisplays())
165 // Verify the double clicking the resize edge works on 2nd display too.
166 UpdateDisplay("200x200,400x300");
167 gfx::Rect work_area2
= ScreenUtil::GetSecondaryDisplay().work_area();
168 restored_bounds
.SetRect(220, 20, 50, 50);
169 window
->SetBoundsInScreen(restored_bounds
, ScreenUtil::GetSecondaryDisplay());
170 aura::Window
* second_root
= Shell::GetAllRootWindows()[1];
171 EXPECT_EQ(second_root
, window
->GetRootWindow());
172 ui::test::EventGenerator
generator2(second_root
, window
.get());
174 // Y-axis maximization.
175 delegate
.set_window_component(HTTOP
);
176 generator2
.PressLeftButton();
177 generator2
.ReleaseLeftButton();
178 generator2
.set_flags(ui::EF_IS_DOUBLE_CLICK
);
179 generator2
.PressLeftButton();
180 generator2
.MoveMouseTo(generator
.current_location(), 1);
181 generator2
.ReleaseLeftButton();
182 generator
.DoubleClickLeftButton();
183 bounds_in_screen
= window
->GetBoundsInScreen();
184 EXPECT_EQ(restored_bounds
.x(), bounds_in_screen
.x());
185 EXPECT_EQ(restored_bounds
.width(), bounds_in_screen
.width());
186 EXPECT_EQ(work_area2
.y(), bounds_in_screen
.y());
187 EXPECT_EQ(work_area2
.height(), bounds_in_screen
.height());
188 EXPECT_FALSE(window_state
->IsMaximized());
191 generator2
.DoubleClickLeftButton();
192 EXPECT_EQ(restored_bounds
.ToString(), window
->GetBoundsInScreen().ToString());
194 // X-axis maximization.
195 delegate
.set_window_component(HTLEFT
);
196 generator2
.DoubleClickLeftButton();
197 bounds_in_screen
= window
->GetBoundsInScreen();
198 EXPECT_EQ(restored_bounds
.y(), bounds_in_screen
.y());
199 EXPECT_EQ(restored_bounds
.height(), bounds_in_screen
.height());
200 EXPECT_EQ(work_area2
.x(), bounds_in_screen
.x());
201 EXPECT_EQ(work_area2
.width(), bounds_in_screen
.width());
202 EXPECT_FALSE(window_state
->IsMaximized());
205 generator2
.DoubleClickLeftButton();
206 EXPECT_EQ(restored_bounds
.ToString(), window
->GetBoundsInScreen().ToString());
209 // Tests the behavior when double clicking the border of a side snapped window.
210 TEST_F(WorkspaceEventHandlerTest
, DoubleClickSingleAxisWhenSideSnapped
) {
211 gfx::Rect
restored_bounds(10, 10, 50, 50);
212 aura::test::TestWindowDelegate delegate
;
213 scoped_ptr
<aura::Window
> window(CreateTestWindow(&delegate
, restored_bounds
));
215 gfx::Rect work_area_in_screen
= Shell::GetScreen()->GetDisplayNearestWindow(
216 window
.get()).work_area();
218 wm::WindowState
* window_state
= wm::GetWindowState(window
.get());
219 const wm::WMEvent
snap_event(wm::WM_EVENT_SNAP_LEFT
);
220 window_state
->OnWMEvent(&snap_event
);
222 gfx::Rect snapped_bounds_in_screen
= window
->GetBoundsInScreen();
223 EXPECT_EQ(work_area_in_screen
.x(), snapped_bounds_in_screen
.x());
224 EXPECT_EQ(work_area_in_screen
.y(), snapped_bounds_in_screen
.y());
225 EXPECT_GT(work_area_in_screen
.width(), snapped_bounds_in_screen
.width());
226 EXPECT_EQ(work_area_in_screen
.height(), snapped_bounds_in_screen
.height());
228 // Double clicking the top border should not do anything for side snapped
229 // windows. (They already take up the entire workspace height and reverting
230 // to the restored bounds would be weird).
231 ui::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(),
233 delegate
.set_window_component(HTTOP
);
234 generator
.DoubleClickLeftButton();
235 EXPECT_EQ(wm::WINDOW_STATE_TYPE_LEFT_SNAPPED
, window_state
->GetStateType());
236 EXPECT_EQ(snapped_bounds_in_screen
.ToString(),
237 window
->GetBoundsInScreen().ToString());
239 // Double clicking the right border should exit the side snapped state and
240 // make the window take up the entire work area.
241 delegate
.set_window_component(HTRIGHT
);
242 generator
.DoubleClickLeftButton();
243 EXPECT_TRUE(window_state
->IsNormalStateType());
244 EXPECT_EQ(work_area_in_screen
.ToString(),
245 window
->GetBoundsInScreen().ToString());
248 TEST_F(WorkspaceEventHandlerTest
,
249 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained
) {
250 gfx::Rect
restored_bounds(10, 10, 50, 50);
251 aura::test::TestWindowDelegate delegate
;
252 scoped_ptr
<aura::Window
> window(CreateTestWindow(&delegate
, restored_bounds
));
254 wm::ActivateWindow(window
.get());
256 gfx::Rect work_area
= Shell::GetScreen()->GetDisplayNearestWindow(
257 window
.get()).work_area();
259 delegate
.set_maximum_size(gfx::Size(0, 100));
261 ui::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(),
263 // Double-click the top resize edge.
264 delegate
.set_window_component(HTTOP
);
265 generator
.DoubleClickLeftButton();
267 // The size of the window should be unchanged.
268 EXPECT_EQ(restored_bounds
.y(), window
->bounds().y());
269 EXPECT_EQ(restored_bounds
.height(), window
->bounds().height());
272 TEST_F(WorkspaceEventHandlerTest
,
273 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained
) {
274 gfx::Rect
restored_bounds(10, 10, 50, 50);
275 aura::test::TestWindowDelegate delegate
;
276 scoped_ptr
<aura::Window
> window(CreateTestWindow(&delegate
, restored_bounds
));
278 wm::ActivateWindow(window
.get());
280 gfx::Rect work_area
= Shell::GetScreen()->GetDisplayNearestWindow(
281 window
.get()).work_area();
283 delegate
.set_maximum_size(gfx::Size(100, 0));
285 ui::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(),
287 // Double-click the top resize edge.
288 delegate
.set_window_component(HTRIGHT
);
289 generator
.DoubleClickLeftButton();
291 // The size of the window should be unchanged.
292 EXPECT_EQ(restored_bounds
.x(), window
->bounds().x());
293 EXPECT_EQ(restored_bounds
.width(), window
->bounds().width());
296 TEST_F(WorkspaceEventHandlerTest
,
297 DoubleClickOrTapWithModalChildDoesntMaximize
) {
298 aura::test::TestWindowDelegate delegate1
;
299 aura::test::TestWindowDelegate delegate2
;
300 scoped_ptr
<aura::Window
> window(
301 CreateTestWindow(&delegate1
, gfx::Rect(10, 20, 30, 40)));
302 scoped_ptr
<aura::Window
> child(
303 CreateTestWindow(&delegate2
, gfx::Rect(0, 0, 1, 1)));
304 window
->SetProperty(aura::client::kCanMaximizeKey
, true);
305 delegate1
.set_window_component(HTCAPTION
);
307 child
->SetProperty(aura::client::kModalKey
, ui::MODAL_TYPE_WINDOW
);
308 ::wm::AddTransientChild(window
.get(), child
.get());
310 wm::WindowState
* window_state
= wm::GetWindowState(window
.get());
311 EXPECT_FALSE(window_state
->IsMaximized());
312 aura::Window
* root
= Shell::GetPrimaryRootWindow();
313 ui::test::EventGenerator
generator(root
, window
.get());
314 generator
.DoubleClickLeftButton();
315 EXPECT_EQ("10,20 30x40", window
->bounds().ToString());
316 EXPECT_FALSE(window_state
->IsMaximized());
318 generator
.GestureTapAt(gfx::Point(25, 25));
319 generator
.GestureTapAt(gfx::Point(25, 25));
320 RunAllPendingInMessageLoop();
321 EXPECT_EQ("10,20 30x40", window
->bounds().ToString());
322 EXPECT_FALSE(window_state
->IsMaximized());
325 // Test the behavior as a result of double clicking the window header.
326 TEST_F(WorkspaceEventHandlerTest
, DoubleClickCaptionTogglesMaximize
) {
327 aura::test::TestWindowDelegate delegate
;
328 scoped_ptr
<aura::Window
> window(
329 CreateTestWindow(&delegate
, gfx::Rect(1, 2, 30, 40)));
330 window
->SetProperty(aura::client::kCanMaximizeKey
, true);
332 wm::WindowState
* window_state
= wm::GetWindowState(window
.get());
333 gfx::Rect restore_bounds
= window
->bounds();
334 gfx::Rect work_area_in_parent
= ScreenUtil::GetDisplayWorkAreaBoundsInParent(
337 EXPECT_FALSE(window_state
->IsMaximized());
339 // 1) Double clicking a normal window should maximize.
340 delegate
.set_window_component(HTCAPTION
);
341 aura::Window
* root
= Shell::GetPrimaryRootWindow();
342 ui::test::EventGenerator
generator(root
, window
.get());
343 generator
.DoubleClickLeftButton();
344 EXPECT_NE(restore_bounds
.ToString(), window
->bounds().ToString());
345 EXPECT_TRUE(window_state
->IsMaximized());
347 generator
.DoubleClickLeftButton();
348 EXPECT_TRUE(window_state
->IsNormalStateType());
349 EXPECT_EQ(restore_bounds
.ToString(), window
->bounds().ToString());
351 // 2) Double clicking a horizontally maximized window should maximize.
352 delegate
.set_window_component(HTLEFT
);
353 generator
.DoubleClickLeftButton();
354 EXPECT_TRUE(window_state
->IsNormalStateType());
355 EXPECT_EQ(work_area_in_parent
.x(), window
->bounds().x());
356 EXPECT_EQ(restore_bounds
.y(), window
->bounds().y());
357 EXPECT_EQ(work_area_in_parent
.width(), window
->bounds().width());
358 EXPECT_EQ(restore_bounds
.height(), window
->bounds().height());
360 delegate
.set_window_component(HTCAPTION
);
361 generator
.DoubleClickLeftButton();
362 EXPECT_TRUE(window_state
->IsMaximized());
364 generator
.DoubleClickLeftButton();
365 EXPECT_TRUE(window_state
->IsNormalStateType());
366 EXPECT_EQ(restore_bounds
.ToString(), window
->bounds().ToString());
368 // 3) Double clicking a snapped window should maximize.
369 const wm::WMEvent
snap_event(wm::WM_EVENT_SNAP_LEFT
);
370 window_state
->OnWMEvent(&snap_event
);
371 EXPECT_TRUE(window_state
->IsSnapped());
372 generator
.MoveMouseTo(window
->GetBoundsInRootWindow().CenterPoint());
373 generator
.DoubleClickLeftButton();
374 EXPECT_TRUE(window_state
->IsMaximized());
376 generator
.DoubleClickLeftButton();
377 EXPECT_TRUE(window_state
->IsNormalStateType());
378 EXPECT_EQ(restore_bounds
.ToString(), window
->bounds().ToString());
381 // Test that double clicking the middle button on the window header does not
382 // toggle the maximized state.
383 TEST_F(WorkspaceEventHandlerTest
,
384 DoubleClickMiddleButtonDoesNotToggleMaximize
) {
385 aura::test::TestWindowDelegate delegate
;
386 scoped_ptr
<aura::Window
> window(
387 CreateTestWindow(&delegate
, gfx::Rect(1, 2, 30, 40)));
388 window
->SetProperty(aura::client::kCanMaximizeKey
, true);
389 delegate
.set_window_component(HTCAPTION
);
390 aura::Window
* root
= Shell::GetPrimaryRootWindow();
391 ui::test::EventGenerator
generator(root
, window
.get());
393 WindowPropertyObserver
observer(window
.get());
394 ClickButtonWithFlags(&generator
, ui::EF_MIDDLE_MOUSE_BUTTON
, ui::EF_NONE
);
395 ClickButtonWithFlags(&generator
, ui::EF_MIDDLE_MOUSE_BUTTON
,
396 ui::EF_IS_DOUBLE_CLICK
);
398 EXPECT_FALSE(wm::GetWindowState(window
.get())->IsMaximized());
399 EXPECT_EQ("1,2 30x40", window
->bounds().ToString());
400 EXPECT_FALSE(observer
.DidPropertyChange(aura::client::kShowStateKey
));
403 TEST_F(WorkspaceEventHandlerTest
, DoubleTapCaptionTogglesMaximize
) {
404 aura::test::TestWindowDelegate delegate
;
405 gfx::Rect
bounds(10, 20, 30, 40);
406 scoped_ptr
<aura::Window
> window(CreateTestWindow(&delegate
, bounds
));
407 window
->SetProperty(aura::client::kCanMaximizeKey
, true);
408 delegate
.set_window_component(HTCAPTION
);
410 wm::WindowState
* window_state
= wm::GetWindowState(window
.get());
411 EXPECT_FALSE(window_state
->IsMaximized());
412 ui::test::EventGenerator
generator(Shell::GetPrimaryRootWindow(),
414 generator
.GestureTapAt(gfx::Point(25, 25));
415 generator
.GestureTapAt(gfx::Point(25, 25));
416 RunAllPendingInMessageLoop();
417 EXPECT_NE(bounds
.ToString(), window
->bounds().ToString());
418 EXPECT_TRUE(window_state
->IsMaximized());
420 generator
.GestureTapAt(gfx::Point(5, 5));
421 generator
.GestureTapAt(gfx::Point(10, 10));
423 EXPECT_FALSE(window_state
->IsMaximized());
424 EXPECT_EQ(bounds
.ToString(), window
->bounds().ToString());
427 // Verifies deleting the window while dragging doesn't crash.
428 TEST_F(WorkspaceEventHandlerTest
, DeleteWhenDragging
) {
429 // Create a large window in the background. This is necessary so that when we
430 // delete |window| WorkspaceEventHandler is still the active event handler.
431 aura::test::TestWindowDelegate delegate2
;
432 scoped_ptr
<aura::Window
> window2(
433 CreateTestWindow(&delegate2
, gfx::Rect(0, 0, 500, 500)));
435 aura::test::TestWindowDelegate delegate
;
436 const gfx::Rect
bounds(10, 20, 30, 40);
437 scoped_ptr
<aura::Window
> window(CreateTestWindow(&delegate
, bounds
));
438 delegate
.set_window_component(HTCAPTION
);
439 ui::test::EventGenerator
generator(window
->GetRootWindow());
440 generator
.MoveMouseToCenterOf(window
.get());
441 generator
.PressLeftButton();
442 generator
.MoveMouseTo(generator
.current_location() + gfx::Vector2d(50, 50));
443 DCHECK_NE(bounds
.origin().ToString(), window
->bounds().origin().ToString());
445 generator
.MoveMouseTo(generator
.current_location() + gfx::Vector2d(50, 50));
448 // Verifies deleting the window while in a run loop doesn't crash.
449 TEST_F(WorkspaceEventHandlerTest
, DeleteWhileInRunLoop
) {
450 aura::test::TestWindowDelegate delegate
;
451 const gfx::Rect
bounds(10, 20, 30, 40);
452 scoped_ptr
<aura::Window
> window(CreateTestWindow(&delegate
, bounds
));
453 delegate
.set_window_component(HTCAPTION
);
455 ASSERT_TRUE(aura::client::GetWindowMoveClient(window
->GetRootWindow()));
456 base::MessageLoop::current()->DeleteSoon(FROM_HERE
, window
.get());
457 aura::client::GetWindowMoveClient(window
->GetRootWindow())
458 ->RunMoveLoop(window
.release(),
460 aura::client::WINDOW_MOVE_SOURCE_MOUSE
);
463 // Verifies that double clicking in the header does not maximize if the target
464 // component has changed.
465 TEST_F(WorkspaceEventHandlerTest
,
466 DoubleClickTwoDifferentTargetsDoesntMaximize
) {
467 aura::test::TestWindowDelegate delegate
;
468 scoped_ptr
<aura::Window
> window(
469 CreateTestWindow(&delegate
, gfx::Rect(1, 2, 30, 40)));
470 window
->SetProperty(aura::client::kCanMaximizeKey
, true);
472 wm::WindowState
* window_state
= wm::GetWindowState(window
.get());
473 gfx::Rect restore_bounds
= window
->bounds();
474 gfx::Rect work_area_in_parent
= ScreenUtil::GetDisplayWorkAreaBoundsInParent(
477 EXPECT_FALSE(window_state
->IsMaximized());
479 // First click will go to a client
480 delegate
.set_window_component(HTCLIENT
);
481 aura::Window
* root
= Shell::GetPrimaryRootWindow();
482 ui::test::EventGenerator
generator(root
, window
.get());
483 generator
.ClickLeftButton();
484 EXPECT_FALSE(window_state
->IsMaximized());
486 // Second click will go to the header
487 delegate
.set_window_component(HTCAPTION
);
488 ClickButtonWithFlags(&generator
, ui::EF_LEFT_MOUSE_BUTTON
,
489 ui::EF_IS_DOUBLE_CLICK
);
490 EXPECT_FALSE(window_state
->IsMaximized());
493 // Verifies that double tapping in the header does not maximize if the target
494 // component has changed.
495 TEST_F(WorkspaceEventHandlerTest
, DoubleTapTwoDifferentTargetsDoesntMaximize
) {
496 aura::test::TestWindowDelegate delegate
;
497 scoped_ptr
<aura::Window
> window(
498 CreateTestWindow(&delegate
, gfx::Rect(1, 2, 30, 40)));
499 window
->SetProperty(aura::client::kCanMaximizeKey
, true);
501 wm::WindowState
* window_state
= wm::GetWindowState(window
.get());
502 gfx::Rect restore_bounds
= window
->bounds();
503 gfx::Rect work_area_in_parent
= ScreenUtil::GetDisplayWorkAreaBoundsInParent(
506 EXPECT_FALSE(window_state
->IsMaximized());
508 // First tap will go to a client
509 delegate
.set_window_component(HTCLIENT
);
510 aura::Window
* root
= Shell::GetPrimaryRootWindow();
511 ui::test::EventGenerator
generator(root
, window
.get());
512 generator
.GestureTapAt(gfx::Point(25, 25));
513 EXPECT_FALSE(window_state
->IsMaximized());
515 // Second tap will go to the header
516 delegate
.set_window_component(HTCAPTION
);
517 generator
.GestureTapAt(gfx::Point(25, 25));
518 EXPECT_FALSE(window_state
->IsMaximized());
521 TEST_F(WorkspaceEventHandlerTest
,
522 RightClickDuringDoubleClickDoesntMaximize
) {
523 aura::test::TestWindowDelegate delegate
;
524 scoped_ptr
<aura::Window
> window(
525 CreateTestWindow(&delegate
, gfx::Rect(1, 2, 30, 40)));
526 window
->SetProperty(aura::client::kCanMaximizeKey
, true);
528 wm::WindowState
* window_state
= wm::GetWindowState(window
.get());
529 gfx::Rect restore_bounds
= window
->bounds();
530 gfx::Rect work_area_in_parent
= ScreenUtil::GetDisplayWorkAreaBoundsInParent(
533 EXPECT_FALSE(window_state
->IsMaximized());
535 // First click will go to a client
536 delegate
.set_window_component(HTCLIENT
);
537 aura::Window
* root
= Shell::GetPrimaryRootWindow();
538 ui::test::EventGenerator
generator(root
, window
.get());
539 generator
.ClickLeftButton();
540 EXPECT_FALSE(window_state
->IsMaximized());
542 // Second click will go to the header
543 delegate
.set_window_component(HTCAPTION
);
544 generator
.PressRightButton();
545 generator
.ReleaseRightButton();
546 EXPECT_FALSE(window_state
->IsMaximized());
547 ClickButtonWithFlags(&generator
, ui::EF_LEFT_MOUSE_BUTTON
,
548 ui::EF_IS_DOUBLE_CLICK
);
549 EXPECT_FALSE(window_state
->IsMaximized());