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

Side by Side Diff: ash/wm/workspace/workspace_event_handler_unittest.cc

Issue 144193002: Only drag or maximize / restore when event has not yet been handled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Panels too, no test for these yet. 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/wm/workspace/workspace_event_handler.h" 5 #include "ash/wm/workspace/workspace_event_handler.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.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/wm/window_state.h" 10 #include "ash/wm/window_state.h"
11 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
12 #include "ash/wm/workspace_controller.h" 12 #include "ash/wm/workspace_controller.h"
13 #include "ash/wm/workspace_controller_test_helper.h" 13 #include "ash/wm/workspace_controller_test_helper.h"
14 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
15 #include "ui/aura/client/window_move_client.h" 15 #include "ui/aura/client/window_move_client.h"
16 #include "ui/aura/root_window.h" 16 #include "ui/aura/root_window.h"
17 #include "ui/aura/test/event_generator.h" 17 #include "ui/aura/test/event_generator.h"
18 #include "ui/aura/test/test_window_delegate.h" 18 #include "ui/aura/test/test_window_delegate.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/base/hit_test.h" 20 #include "ui/base/hit_test.h"
21 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
22 #include "ui/views/corewm/window_util.h"
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
24 #include "base/win/windows_version.h" 25 #include "base/win/windows_version.h"
25 #endif 26 #endif
26 27
27 namespace ash { 28 namespace ash {
28 namespace internal { 29 namespace internal {
29 30
30 class WorkspaceEventHandlerTest : public test::AshTestBase { 31 class WorkspaceEventHandlerTest : public test::AshTestBase {
31 public: 32 public:
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 window.get()); 242 window.get());
242 // Double-click the top resize edge. 243 // Double-click the top resize edge.
243 wd.set_window_component(HTRIGHT); 244 wd.set_window_component(HTRIGHT);
244 generator.DoubleClickLeftButton(); 245 generator.DoubleClickLeftButton();
245 246
246 // The size of the window should be unchanged. 247 // The size of the window should be unchanged.
247 EXPECT_EQ(restored_bounds.x(), window->bounds().x()); 248 EXPECT_EQ(restored_bounds.x(), window->bounds().x());
248 EXPECT_EQ(restored_bounds.width(), window->bounds().width()); 249 EXPECT_EQ(restored_bounds.width(), window->bounds().width());
249 } 250 }
250 251
252 TEST_F(WorkspaceEventHandlerTest,
253 DoubleClickOrTapWithModalChildDoesntMaximize) {
254 aura::test::TestWindowDelegate wd1;
255 aura::test::TestWindowDelegate wd2;
256 scoped_ptr<aura::Window> window(
257 CreateTestWindow(&wd1, gfx::Rect(10, 20, 30, 40)));
258 scoped_ptr<aura::Window> child(
259 CreateTestWindow(&wd2, gfx::Rect(0, 0, 1, 1)));
260 window->SetProperty(aura::client::kCanMaximizeKey, true);
261 wd1.set_window_component(HTCAPTION);
262
263 child->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
264 views::corewm::AddTransientChild(window.get(), child.get());
265
266 wm::WindowState* window_state = wm::GetWindowState(window.get());
267 EXPECT_FALSE(window_state->IsMaximized());
268 aura::Window* root = Shell::GetPrimaryRootWindow();
269 aura::test::EventGenerator generator(root, window.get());
270 generator.DoubleClickLeftButton();
271 EXPECT_EQ("10,20 30x40", window->bounds().ToString());
272 EXPECT_FALSE(window_state->IsMaximized());
273
274 generator.GestureTapAt(gfx::Point(25, 25));
275 generator.GestureTapAt(gfx::Point(25, 25));
276 RunAllPendingInMessageLoop();
277 EXPECT_EQ("10,20 30x40", window->bounds().ToString());
278 EXPECT_FALSE(window_state->IsMaximized());
279 }
280
251 TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) { 281 TEST_F(WorkspaceEventHandlerTest, DoubleClickCaptionTogglesMaximize) {
252 aura::test::TestWindowDelegate wd; 282 aura::test::TestWindowDelegate wd;
253 scoped_ptr<aura::Window> window( 283 scoped_ptr<aura::Window> window(
254 CreateTestWindow(&wd, gfx::Rect(1, 2, 30, 40))); 284 CreateTestWindow(&wd, gfx::Rect(1, 2, 30, 40)));
255 window->SetProperty(aura::client::kCanMaximizeKey, true); 285 window->SetProperty(aura::client::kCanMaximizeKey, true);
256 wd.set_window_component(HTCAPTION); 286 wd.set_window_component(HTCAPTION);
257 287
258 wm::WindowState* window_state = wm::GetWindowState(window.get()); 288 wm::WindowState* window_state = wm::GetWindowState(window.get());
259 EXPECT_FALSE(window_state->IsMaximized()); 289 EXPECT_FALSE(window_state->IsMaximized());
260 aura::Window* root = Shell::GetPrimaryRootWindow(); 290 aura::Window* root = Shell::GetPrimaryRootWindow();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 ASSERT_TRUE(aura::client::GetWindowMoveClient(window->GetRootWindow())); 372 ASSERT_TRUE(aura::client::GetWindowMoveClient(window->GetRootWindow()));
343 base::MessageLoop::current()->DeleteSoon(FROM_HERE, window.get()); 373 base::MessageLoop::current()->DeleteSoon(FROM_HERE, window.get());
344 aura::client::GetWindowMoveClient(window->GetRootWindow()) 374 aura::client::GetWindowMoveClient(window->GetRootWindow())
345 ->RunMoveLoop(window.release(), 375 ->RunMoveLoop(window.release(),
346 gfx::Vector2d(), 376 gfx::Vector2d(),
347 aura::client::WINDOW_MOVE_SOURCE_MOUSE); 377 aura::client::WINDOW_MOVE_SOURCE_MOUSE);
348 } 378 }
349 379
350 } // namespace internal 380 } // namespace internal
351 } // namespace ash 381 } // namespace ash
OLDNEW
« ash/wm/toplevel_window_event_handler.cc ('K') | « ash/wm/workspace/workspace_event_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698