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

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

Issue 1668453002: Make empty selection behavior behave like Android EditText. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Apply code review and fix test Created 4 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 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1610 WebString target = WebString::fromUTF8("target"); 1610 WebString target = WebString::fromUTF8("target");
1611 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse"); 1611 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse");
1612 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 1612 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1613 1613
1614 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, onselec tstartfalse)); 1614 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, onselec tstartfalse));
1615 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); 1615 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
1616 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, target) ); 1616 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, target) );
1617 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data())); 1617 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data()));
1618 } 1618 }
1619 1619
1620 TEST_F(WebViewTest, LongPressEmptyTextarea)
1621 {
1622 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_textarea.html"));
1623
1624 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ textarea.html", true);
1625 webView->resize(WebSize(500, 300));
1626 webView->updateAllLifecyclePhases();
1627 runPendingTasks();
1628
1629 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox");
1630 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1631
1632 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureLongPress, blankli nestextbox));
1633 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
1634 }
1635
1620 TEST_F(WebViewTest, BlinkCaretOnTypingAfterLongPress) 1636 TEST_F(WebViewTest, BlinkCaretOnTypingAfterLongPress)
1621 { 1637 {
1622 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("blink_caret_on_typing_after_long_press.html")); 1638 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("blink_caret_on_typing_after_long_press.html"));
1623 1639
1624 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "blink_care t_on_typing_after_long_press.html", true); 1640 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "blink_care t_on_typing_after_long_press.html", true);
1625 webView->resize(WebSize(640, 480)); 1641 webView->resize(WebSize(640, 480));
1626 webView->updateAllLifecyclePhases(); 1642 webView->updateAllLifecyclePhases();
1627 runPendingTasks(); 1643 runPendingTasks();
1628 1644
1629 WebString target = WebString::fromUTF8("target"); 1645 WebString target = WebString::fromUTF8("target");
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
3210 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline Point); 3226 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline Point);
3211 ASSERT_TRUE(!!result); 3227 ASSERT_TRUE(!!result);
3212 3228
3213 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); 3229 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y);
3214 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi nt); 3230 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi nt);
3215 ASSERT_TRUE(!!result); 3231 ASSERT_TRUE(!!result);
3216 } 3232 }
3217 #endif 3233 #endif
3218 3234
3219 } // namespace blink 3235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698