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

Side by Side Diff: ui/views/corewm/capture_controller_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: fix gn Created 6 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
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/wm/core/capture_controller.h" 5 #include "ui/wm/core/capture_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/aura/env.h" 8 #include "ui/aura/env.h"
9 #include "ui/aura/test/aura_test_base.h" 9 #include "ui/aura/test/aura_test_base.h"
10 #include "ui/aura/test/event_generator.h"
11 #include "ui/aura/test/test_screen.h" 10 #include "ui/aura/test/test_screen.h"
12 #include "ui/aura/test/test_window_delegate.h" 11 #include "ui/aura/test/test_window_delegate.h"
13 #include "ui/aura/window.h" 12 #include "ui/aura/window.h"
14 #include "ui/aura/window_event_dispatcher.h" 13 #include "ui/aura/window_event_dispatcher.h"
15 #include "ui/events/event.h" 14 #include "ui/events/event.h"
16 #include "ui/events/event_utils.h" 15 #include "ui/events/event_utils.h"
16 #include "ui/events/test/event_generator.h"
17 #include "ui/views/test/views_test_base.h" 17 #include "ui/views/test/views_test_base.h"
18 #include "ui/views/view.h" 18 #include "ui/views/view.h"
19 #include "ui/views/widget/root_view.h" 19 #include "ui/views/widget/root_view.h"
20 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
21 21
22 #if !defined(OS_CHROMEOS) 22 #if !defined(OS_CHROMEOS)
23 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 23 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
24 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" 24 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h"
25 #endif 25 #endif
26 26
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 w2->SetCapture(); 130 w2->SetCapture();
131 EXPECT_EQ(w2.get(), GetCaptureWindow()); 131 EXPECT_EQ(w2.get(), GetCaptureWindow());
132 EXPECT_EQ(w2.get(), GetSecondCaptureWindow()); 132 EXPECT_EQ(w2.get(), GetSecondCaptureWindow());
133 } 133 }
134 134
135 // Verifies the touch target for the WindowEventDispatcher gets reset on 135 // Verifies the touch target for the WindowEventDispatcher gets reset on
136 // releasing capture. 136 // releasing capture.
137 TEST_F(CaptureControllerTest, TouchTargetResetOnCaptureChange) { 137 TEST_F(CaptureControllerTest, TouchTargetResetOnCaptureChange) {
138 // Create a window inside the WindowEventDispatcher. 138 // Create a window inside the WindowEventDispatcher.
139 scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); 139 scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL));
140 aura::test::EventGenerator event_generator1(root_window()); 140 ui::test::EventGenerator event_generator1(root_window());
141 event_generator1.PressTouch(); 141 event_generator1.PressTouch();
142 w1->SetCapture(); 142 w1->SetCapture();
143 // Both capture clients should return the same capture window. 143 // Both capture clients should return the same capture window.
144 EXPECT_EQ(w1.get(), GetCaptureWindow()); 144 EXPECT_EQ(w1.get(), GetCaptureWindow());
145 EXPECT_EQ(w1.get(), GetSecondCaptureWindow()); 145 EXPECT_EQ(w1.get(), GetSecondCaptureWindow());
146 146
147 // Build a window in the second WindowEventDispatcher and give it capture. 147 // Build a window in the second WindowEventDispatcher and give it capture.
148 // Both capture clients should return the same capture window. 148 // Both capture clients should return the same capture window.
149 scoped_ptr<aura::Window> w2( 149 scoped_ptr<aura::Window> w2(
150 CreateNormalWindow(2, second_host_->window(), NULL)); 150 CreateNormalWindow(2, second_host_->window(), NULL));
151 w2->SetCapture(); 151 w2->SetCapture();
152 EXPECT_EQ(w2.get(), GetCaptureWindow()); 152 EXPECT_EQ(w2.get(), GetCaptureWindow());
153 EXPECT_EQ(w2.get(), GetSecondCaptureWindow()); 153 EXPECT_EQ(w2.get(), GetSecondCaptureWindow());
154 154
155 // Release capture on the window. Releasing capture should reset the touch 155 // Release capture on the window. Releasing capture should reset the touch
156 // target of the first WindowEventDispatcher (as it no longer contains the 156 // target of the first WindowEventDispatcher (as it no longer contains the
157 // capture target). 157 // capture target).
158 w2->ReleaseCapture(); 158 w2->ReleaseCapture();
159 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow()); 159 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow());
160 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow()); 160 EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow());
161 ui::TouchEvent touch_event( 161 ui::TouchEvent touch_event(
162 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, 0, ui::EventTimeForNow(), 1.0f, 162 ui::ET_TOUCH_PRESSED, gfx::Point(), 0, 0, ui::EventTimeForNow(), 1.0f,
163 1.0f, 1.0f, 1.0f); 163 1.0f, 1.0f, 1.0f);
164 EXPECT_EQ(static_cast<ui::GestureConsumer*>(w2.get()), 164 EXPECT_EQ(static_cast<ui::GestureConsumer*>(w2.get()),
165 ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch_event)); 165 ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch_event));
166 } 166 }
167 167
168 } // namespace views 168 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698