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

Side by Side Diff: ui/aura/window_event_dispatcher_unittest.cc

Issue 2858633005: Add WindowEventDispatcherTest.TouchDownState for Env::is_touch_down(). (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | 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 "ui/aura/window_event_dispatcher.h" 5 #include "ui/aura/window_event_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown()); 158 EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
159 159
160 ui::TouchEvent touch_pressed_event( 160 ui::TouchEvent touch_pressed_event(
161 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(), 161 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(),
162 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0)); 162 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
163 host()->dispatcher()->RepostEvent(&touch_pressed_event); 163 host()->dispatcher()->RepostEvent(&touch_pressed_event);
164 RunAllPendingInMessageLoop(); 164 RunAllPendingInMessageLoop();
165 EXPECT_TRUE(Env::GetInstance()->is_touch_down()); 165 EXPECT_TRUE(Env::GetInstance()->is_touch_down());
166 } 166 }
167 167
168 // Check that we correctly track whether any touch devices are down in response
169 // to touch press and release events with two WindowTreeHost.
170 TEST_P(WindowEventDispatcherTest, TouchDownState) {
171 std::unique_ptr<WindowTreeHost> second_host(
172 WindowTreeHost::Create(gfx::Rect(20, 30, 100, 50)));
173 second_host->InitHost();
174 second_host->window()->Show();
175
176 ui::TouchEvent touch_pressed_event1(
177 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(),
178 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
179 ui::TouchEvent touch_pressed_event2(
180 ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(),
181 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
182 ui::TouchEvent touch_released_event1(
183 ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), ui::EventTimeForNow(),
184 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
185 ui::TouchEvent touch_released_event2(
186 ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), ui::EventTimeForNow(),
187 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
188
189 EXPECT_FALSE(Env::GetInstance()->is_touch_down());
190 host()->dispatcher()->OnEventFromSource(&touch_pressed_event1);
191 EXPECT_TRUE(Env::GetInstance()->is_touch_down());
192 second_host->dispatcher()->OnEventFromSource(&touch_pressed_event2);
193 EXPECT_TRUE(Env::GetInstance()->is_touch_down());
194 host()->dispatcher()->OnEventFromSource(&touch_released_event1);
195 EXPECT_TRUE(Env::GetInstance()->is_touch_down());
196 second_host->dispatcher()->OnEventFromSource(&touch_released_event2);
197 EXPECT_FALSE(Env::GetInstance()->is_touch_down());
198 }
199
168 // Check that we correctly track the state of the mouse buttons in response to 200 // Check that we correctly track the state of the mouse buttons in response to
169 // button press and release events. 201 // button press and release events.
170 TEST_P(WindowEventDispatcherTest, MouseButtonState) { 202 TEST_P(WindowEventDispatcherTest, MouseButtonState) {
171 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown()); 203 EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown());
172 204
173 gfx::Point location; 205 gfx::Point location;
174 std::unique_ptr<ui::MouseEvent> event; 206 std::unique_ptr<ui::MouseEvent> event;
175 207
176 // Press the left button. 208 // Press the left button.
177 event.reset(new ui::MouseEvent( 209 event.reset(new ui::MouseEvent(
(...skipping 2737 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count()); 2947 EXPECT_EQ(1, last_event_location_delegate.mouse_event_count());
2916 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count()); 2948 EXPECT_EQ(1, last_event_location_delegate.nested_message_loop_count());
2917 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location()); 2949 EXPECT_EQ(mouse_location, last_event_location_delegate.last_mouse_location());
2918 2950
2919 // After dispatch the location should fallback to that of the 2951 // After dispatch the location should fallback to that of the
2920 // WindowTreeClient, which defaults to 0,0. 2952 // WindowTreeClient, which defaults to 0,0.
2921 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location()); 2953 EXPECT_EQ(gfx::Point(0, 0), Env::GetInstance()->last_mouse_location());
2922 } 2954 }
2923 2955
2924 } // namespace aura 2956 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698