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

Side by Side Diff: content/browser/web_contents/touch_editable_impl_aura_browsertest.cc

Issue 572593002: Revert of Clean up GestureEventDetails constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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 "content/browser/web_contents/touch_editable_impl_aura.h" 5 #include "content/browser/web_contents/touch_editable_impl_aura.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( 200 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
201 web_contents->GetRenderWidgetHostView()); 201 web_contents->GetRenderWidgetHostView());
202 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); 202 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva);
203 203
204 // Long press to select word. 204 // Long press to select word.
205 ui::GestureEvent long_press( 205 ui::GestureEvent long_press(
206 10, 206 10,
207 10, 207 10,
208 0, 208 0,
209 ui::EventTimeForNow(), 209 ui::EventTimeForNow(),
210 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 210 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
211 touch_editable->Reset(); 211 touch_editable->Reset();
212 rwhva->OnGestureEvent(&long_press); 212 rwhva->OnGestureEvent(&long_press);
213 touch_editable->WaitForSelectionChangeCallback(); 213 touch_editable->WaitForSelectionChangeCallback();
214 214
215 // Check if selection handles are showing. 215 // Check if selection handles are showing.
216 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 216 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
217 217
218 scoped_ptr<base::Value> value = 218 scoped_ptr<base::Value> value =
219 content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); 219 content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
220 std::string selection; 220 std::string selection;
221 value->GetAsString(&selection); 221 value->GetAsString(&selection);
222 EXPECT_STREQ("Some", selection.c_str()); 222 EXPECT_STREQ("Some", selection.c_str());
223 223
224 // Start scrolling. Handles should get hidden. 224 // Start scrolling. Handles should get hidden.
225 ui::GestureEvent scroll_begin( 225 ui::GestureEvent scroll_begin(
226 10, 226 10,
227 10, 227 10,
228 0, 228 0,
229 ui::EventTimeForNow(), 229 ui::EventTimeForNow(),
230 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN)); 230 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0));
231 rwhva->OnGestureEvent(&scroll_begin); 231 rwhva->OnGestureEvent(&scroll_begin);
232 EXPECT_FALSE(GetTouchSelectionController(touch_editable)); 232 EXPECT_FALSE(GetTouchSelectionController(touch_editable));
233 233
234 // Handles should come back after scroll ends. 234 // Handles should come back after scroll ends.
235 ui::GestureEvent scroll_end( 235 ui::GestureEvent scroll_end(
236 10, 236 10,
237 10, 237 10,
238 0, 238 0,
239 ui::EventTimeForNow(), 239 ui::EventTimeForNow(),
240 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END)); 240 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END, 0, 0));
241 rwhva->OnGestureEvent(&scroll_end); 241 rwhva->OnGestureEvent(&scroll_end);
242 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 242 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
243 } 243 }
244 244
245 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 245 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
246 TouchSelectionOnLongPressTest) { 246 TouchSelectionOnLongPressTest) {
247 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html")); 247 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html"));
248 WebContentsImpl* web_contents = 248 WebContentsImpl* web_contents =
249 static_cast<WebContentsImpl*>(shell()->web_contents()); 249 static_cast<WebContentsImpl*>(shell()->web_contents());
250 RenderFrameHost* main_frame = web_contents->GetMainFrame(); 250 RenderFrameHost* main_frame = web_contents->GetMainFrame();
251 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( 251 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>(
252 web_contents->GetView()); 252 web_contents->GetView());
253 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura; 253 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura;
254 view_aura->SetTouchEditableForTest(touch_editable); 254 view_aura->SetTouchEditableForTest(touch_editable);
255 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( 255 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
256 web_contents->GetRenderWidgetHostView()); 256 web_contents->GetRenderWidgetHostView());
257 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); 257 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva);
258 258
259 // Long press to select word. 259 // Long press to select word.
260 ui::GestureEvent long_press( 260 ui::GestureEvent long_press(
261 10, 261 10,
262 10, 262 10,
263 0, 263 0,
264 ui::EventTimeForNow(), 264 ui::EventTimeForNow(),
265 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS)); 265 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS, 0, 0));
266 touch_editable->Reset(); 266 touch_editable->Reset();
267 rwhva->OnGestureEvent(&long_press); 267 rwhva->OnGestureEvent(&long_press);
268 touch_editable->WaitForSelectionChangeCallback(); 268 touch_editable->WaitForSelectionChangeCallback();
269 269
270 // Check if selection handles are showing. 270 // Check if selection handles are showing.
271 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 271 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
272 272
273 scoped_ptr<base::Value> value = 273 scoped_ptr<base::Value> value =
274 content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); 274 content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
275 std::string selection; 275 std::string selection;
276 value->GetAsString(&selection); 276 value->GetAsString(&selection);
277 EXPECT_STREQ("Some", selection.c_str()); 277 EXPECT_STREQ("Some", selection.c_str());
278 } 278 }
279 279
280 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 280 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
281 NoTouchSelectionOnDoubleTapTest) { 281 NoTouchSelectionOnDoubleTapTest) {
282 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html")); 282 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html"));
283 WebContentsImpl* web_contents = 283 WebContentsImpl* web_contents =
284 static_cast<WebContentsImpl*>(shell()->web_contents()); 284 static_cast<WebContentsImpl*>(shell()->web_contents());
285 RenderFrameHost* main_frame = web_contents->GetMainFrame(); 285 RenderFrameHost* main_frame = web_contents->GetMainFrame();
286 WebContentsViewAura* view_aura = 286 WebContentsViewAura* view_aura =
287 static_cast<WebContentsViewAura*>(web_contents->GetView()); 287 static_cast<WebContentsViewAura*>(web_contents->GetView());
288 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura; 288 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura;
289 view_aura->SetTouchEditableForTest(touch_editable); 289 view_aura->SetTouchEditableForTest(touch_editable);
290 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( 290 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
291 web_contents->GetRenderWidgetHostView()); 291 web_contents->GetRenderWidgetHostView());
292 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); 292 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva);
293 293
294 // Double-tap to select word. 294 // Double-tap to select word.
295 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); 295 ui::GestureEvent double_tap(
296 details.set_tap_count(2); 296 10,
297 ui::GestureEvent double_tap(10, 10, 0, ui::EventTimeForNow(), details); 297 10,
298 0,
299 ui::EventTimeForNow(),
300 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 2, 0));
298 touch_editable->Reset(); 301 touch_editable->Reset();
299 rwhva->OnGestureEvent(&double_tap); 302 rwhva->OnGestureEvent(&double_tap);
300 touch_editable->WaitForSelectionChangeCallback(); 303 touch_editable->WaitForSelectionChangeCallback();
301 304
302 // Make sure touch selection handles are not showing. 305 // Make sure touch selection handles are not showing.
303 EXPECT_FALSE(GetTouchSelectionController(touch_editable)); 306 EXPECT_FALSE(GetTouchSelectionController(touch_editable));
304 307
305 scoped_ptr<base::Value> value = 308 scoped_ptr<base::Value> value =
306 content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); 309 content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
307 std::string selection; 310 std::string selection;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 value = content::ExecuteScriptAndGetValue(main_frame, 367 value = content::ExecuteScriptAndGetValue(main_frame,
365 "get_cursor_position()"); 368 "get_cursor_position()");
366 int new_cursor_pos = -1; 369 int new_cursor_pos = -1;
367 value->GetAsInteger(&new_cursor_pos); 370 value->GetAsInteger(&new_cursor_pos);
368 EXPECT_NE(-1, new_cursor_pos); 371 EXPECT_NE(-1, new_cursor_pos);
369 // Cursor should have moved. 372 // Cursor should have moved.
370 EXPECT_NE(new_cursor_pos, cursor_pos); 373 EXPECT_NE(new_cursor_pos, cursor_pos);
371 } 374 }
372 375
373 } // namespace content 376 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/gesture_text_selector_unittest.cc ('k') | ui/aura/remote_window_tree_host_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698