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

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: Indentation Created 6 years, 10 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
« no previous file with comments | « ash/wm/workspace/workspace_event_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 EXPECT_EQ(work_area2.width(), bounds_in_screen.width()); 195 EXPECT_EQ(work_area2.width(), bounds_in_screen.width());
195 EXPECT_FALSE(window_state->IsMaximized()); 196 EXPECT_FALSE(window_state->IsMaximized());
196 197
197 // Restore. 198 // Restore.
198 wd.set_window_component(HTCAPTION); 199 wd.set_window_component(HTCAPTION);
199 generator2.DoubleClickLeftButton(); 200 generator2.DoubleClickLeftButton();
200 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString()); 201 EXPECT_EQ(restored_bounds.ToString(), window->GetBoundsInScreen().ToString());
201 } 202 }
202 203
203 TEST_F(WorkspaceEventHandlerTest, 204 TEST_F(WorkspaceEventHandlerTest,
204 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) { 205 DoubleClickSingleAxisDoesntResizeVerticalEdgeIfConstrained) {
205 gfx::Rect restored_bounds(10, 10, 50, 50); 206 gfx::Rect restored_bounds(10, 10, 50, 50);
206 aura::test::TestWindowDelegate wd; 207 aura::test::TestWindowDelegate wd;
207 scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds)); 208 scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
208 209
209 wm::ActivateWindow(window.get()); 210 wm::ActivateWindow(window.get());
210 211
211 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( 212 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
212 window.get()).work_area(); 213 window.get()).work_area();
213 214
214 wd.set_maximum_size(gfx::Size(0, 100)); 215 wd.set_maximum_size(gfx::Size(0, 100));
215 216
216 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 217 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
217 window.get()); 218 window.get());
218 // Double-click the top resize edge. 219 // Double-click the top resize edge.
219 wd.set_window_component(HTTOP); 220 wd.set_window_component(HTTOP);
220 generator.DoubleClickLeftButton(); 221 generator.DoubleClickLeftButton();
221 222
222 // The size of the window should be unchanged. 223 // The size of the window should be unchanged.
223 EXPECT_EQ(restored_bounds.y(), window->bounds().y()); 224 EXPECT_EQ(restored_bounds.y(), window->bounds().y());
224 EXPECT_EQ(restored_bounds.height(), window->bounds().height()); 225 EXPECT_EQ(restored_bounds.height(), window->bounds().height());
225 } 226 }
226 227
227 TEST_F(WorkspaceEventHandlerTest, 228 TEST_F(WorkspaceEventHandlerTest,
228 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) { 229 DoubleClickSingleAxisDoesntResizeHorizontalEdgeIfConstrained) {
229 gfx::Rect restored_bounds(10, 10, 50, 50); 230 gfx::Rect restored_bounds(10, 10, 50, 50);
230 aura::test::TestWindowDelegate wd; 231 aura::test::TestWindowDelegate wd;
231 scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds)); 232 scoped_ptr<aura::Window> window(CreateTestWindow(&wd, restored_bounds));
232 233
233 wm::ActivateWindow(window.get()); 234 wm::ActivateWindow(window.get());
234 235
235 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow( 236 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
236 window.get()).work_area(); 237 window.get()).work_area();
237 238
238 wd.set_maximum_size(gfx::Size(100, 0)); 239 wd.set_maximum_size(gfx::Size(100, 0));
239 240
240 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 241 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
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
« no previous file with comments | « 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