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

Side by Side Diff: ash/wm/window_modality_controller_unittest.cc

Issue 10763004: ash: Fix touch-event handling for modal windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-win-aura Created 8 years, 5 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/window_modality_controller.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/window_modality_controller.h" 5 #include "ash/wm/window_modality_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/test/capture_tracking_view.h" 9 #include "ash/test/capture_tracking_view.h"
10 #include "ash/wm/window_util.h" 10 #include "ash/wm/window_util.h"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 gfx::Point modal_center(modal_view->width() / 2, modal_view->height() / 2); 274 gfx::Point modal_center(modal_view->width() / 2, modal_view->height() / 2);
275 views::View::ConvertPointToScreen(modal_view, &modal_center); 275 views::View::ConvertPointToScreen(modal_view, &modal_center);
276 generator.MoveMouseTo(modal_center, 1); 276 generator.MoveMouseTo(modal_center, 1);
277 generator.PressLeftButton(); 277 generator.PressLeftButton();
278 EXPECT_TRUE(modal_view->got_press()); 278 EXPECT_TRUE(modal_view->got_press());
279 EXPECT_FALSE(modal_view->got_capture_lost()); 279 EXPECT_FALSE(modal_view->got_capture_lost());
280 EXPECT_FALSE(view->got_capture_lost()); 280 EXPECT_FALSE(view->got_capture_lost());
281 EXPECT_FALSE(view->got_press()); 281 EXPECT_FALSE(view->got_press());
282 } 282 }
283 283
284 class TouchTrackerWindowDelegate : public aura::test::TestWindowDelegate {
285 public:
286 TouchTrackerWindowDelegate() : received_touch_(false) {}
287 virtual ~TouchTrackerWindowDelegate() {}
288
289 void reset() {
290 received_touch_ = false;
291 }
292
293 bool received_touch() const { return received_touch_; }
294
295 private:
296 // Overridden from aura::test::TestWindowDelegate.
297 virtual ui::TouchStatus OnTouchEvent(aura::TouchEvent* event) OVERRIDE {
298 received_touch_ = true;
299 return aura::test::TestWindowDelegate::OnTouchEvent(event);
300 }
301
302 bool received_touch_;
303
304 DISALLOW_COPY_AND_ASSIGN(TouchTrackerWindowDelegate);
305 };
306
307 // Modality should prevent events from being passed to the transient parent.
308 TEST_F(WindowModalityControllerTest, TouchEvent) {
309 TouchTrackerWindowDelegate d1;
310 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate(&d1,
311 -1, gfx::Rect(0, 0, 100, 100), NULL));
312 TouchTrackerWindowDelegate d11;
313 scoped_ptr<aura::Window> w11(aura::test::CreateTestWindowWithDelegate(&d11,
314 -11, gfx::Rect(20, 20, 50, 50), NULL));
315
316 w1->AddTransientChild(w11.get());
317 d1.reset();
318 d11.reset();
319
320 {
321 // Clicking a point within w1 should activate that window.
322 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
323 gfx::Point(10, 10));
324 generator.PressMoveAndReleaseTouchTo(gfx::Point(10, 10));
325 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
326 EXPECT_TRUE(d1.received_touch());
327 EXPECT_FALSE(d11.received_touch());
328 }
329
330 w11->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
331 d1.reset();
332 d11.reset();
333
334 {
335 // Clicking a point within w1 should activate w11.
336 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
337 gfx::Point(10, 10));
338 generator.PressMoveAndReleaseTouchTo(gfx::Point(10, 10));
339 EXPECT_TRUE(wm::IsActiveWindow(w11.get()));
340 EXPECT_FALSE(d1.received_touch());
341 EXPECT_FALSE(d11.received_touch());
342 }
343 }
284 344
285 } // namespace internal 345 } // namespace internal
286 } // namespace ash 346 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_modality_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698