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

Side by Side Diff: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 2646963002: Stop dismissing selection handles when selection is kept (Closed)
Patch Set: rebased on amaralp@'s CLs Created 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse"); 2337 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse");
2338 WebLocalFrameImpl* frame = webView->mainFrameImpl(); 2338 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2339 2339
2340 EXPECT_TRUE( 2340 EXPECT_TRUE(
2341 tapElementById(WebInputEvent::GestureLongPress, onselectstartfalse)); 2341 tapElementById(WebInputEvent::GestureLongPress, onselectstartfalse));
2342 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); 2342 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
2343 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); 2343 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target));
2344 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data())); 2344 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data()));
2345 } 2345 }
2346 2346
2347 TEST_P(WebViewTest, FinishComposingTextDoesNotDismissHandles) {
2348 registerMockedHttpURLLoad("longpress_selection.html");
2349
2350 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2351 m_baseURL + "longpress_selection.html", true);
2352 webView->resize(WebSize(500, 300));
2353 webView->updateAllLifecyclePhases();
2354 runPendingTasks();
2355
2356 WebString target = WebString::fromUTF8("target");
2357 WebLocalFrameImpl* frame = webView->mainFrameImpl();
2358 WebInputMethodController* activeInputMethodController =
2359 frame->frameWidget()->getActiveWebInputMethodController();
2360 EXPECT_TRUE(tapElementById(WebInputEvent::GestureTap, target));
2361 WebVector<WebCompositionUnderline> emptyUnderlines;
2362 frame->setEditableSelectionOffsets(8, 8);
2363 EXPECT_TRUE(activeInputMethodController->setComposition(
2364 "12345", emptyUnderlines, 8, 13));
2365 EXPECT_TRUE(frame->frame()->inputMethodController().hasComposition());
2366 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
2367 EXPECT_FALSE(frame->frame()->selection().isHandleVisible());
2368
2369 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target));
2370 EXPECT_EQ("testword12345",
2371 std::string(frame->selectionAsText().utf8().data()));
2372 EXPECT_TRUE(frame->frame()->selection().isHandleVisible());
2373
2374 // Check that finishComposingText(KeepSelection) does not dismiss handles.
2375 activeInputMethodController->finishComposingText(
2376 WebInputMethodController::KeepSelection);
2377 EXPECT_TRUE(frame->frame()->selection().isHandleVisible());
2378 }
2379
2347 #if !OS(MACOSX) 2380 #if !OS(MACOSX)
2348 TEST_P(WebViewTest, TouchDoesntSelectEmptyTextarea) { 2381 TEST_P(WebViewTest, TouchDoesntSelectEmptyTextarea) {
2349 registerMockedHttpURLLoad("longpress_textarea.html"); 2382 registerMockedHttpURLLoad("longpress_textarea.html");
2350 2383
2351 WebViewImpl* webView = m_webViewHelper.initializeAndLoad( 2384 WebViewImpl* webView = m_webViewHelper.initializeAndLoad(
2352 m_baseURL + "longpress_textarea.html", true); 2385 m_baseURL + "longpress_textarea.html", true);
2353 webView->resize(WebSize(500, 300)); 2386 webView->resize(WebSize(500, 300));
2354 webView->updateAllLifecyclePhases(); 2387 webView->updateAllLifecyclePhases();
2355 runPendingTasks(); 2388 runPendingTasks();
2356 2389
(...skipping 1849 matching lines...) Expand 10 before | Expand all | Expand 10 after
4206 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); 4239 EXPECT_EQ(expectedWidth, vwElement->offsetWidth());
4207 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); 4240 EXPECT_EQ(expectedHeight, vwElement->offsetHeight());
4208 4241
4209 webView->resize(WebSize(800, 600)); 4242 webView->resize(WebSize(800, 600));
4210 frame->printEnd(); 4243 frame->printEnd();
4211 4244
4212 EXPECT_EQ(800, vwElement->offsetWidth()); 4245 EXPECT_EQ(800, vwElement->offsetWidth());
4213 } 4246 }
4214 4247
4215 } // namespace blink 4248 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698