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: third_party/WebKit/Source/web/tests/WebViewTest.cpp

Issue 1845193002: Fix long-press image selection inside editables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Actually use adjustedHitTestResult Created 4 years, 8 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 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 event.type = WebInputEvent::GestureTap; 1578 event.type = WebInputEvent::GestureTap;
1579 event.sourceDevice = WebGestureDeviceTouchscreen; 1579 event.sourceDevice = WebGestureDeviceTouchscreen;
1580 event.x = 3; 1580 event.x = 3;
1581 event.y = 8; 1581 event.y = 8;
1582 EXPECT_EQ(WebInputEventResult::NotHandled, webView->handleInputEvent(event)) ; 1582 EXPECT_EQ(WebInputEventResult::NotHandled, webView->handleInputEvent(event)) ;
1583 webView->close(); 1583 webView->close();
1584 // Explicitly close as the frame as no frame client to do so on frameDetache d(). 1584 // Explicitly close as the frame as no frame client to do so on frameDetache d().
1585 localFrame->close(); 1585 localFrame->close();
1586 } 1586 }
1587 1587
1588 #if OS(ANDROID)
1589 TEST_F(WebViewTest, LongPressSelection) 1588 TEST_F(WebViewTest, LongPressSelection)
1590 { 1589 {
1591 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_selection.html")); 1590 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_selection.html"));
1592 1591
1593 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ selection.html", true); 1592 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ selection.html", true);
1594 webView->resize(WebSize(500, 300)); 1593 webView->resize(WebSize(500, 300));
1595 webView->updateAllLifecyclePhases(); 1594 webView->updateAllLifecyclePhases();
1596 runPendingTasks(); 1595 runPendingTasks();
1597 1596
1598 WebString target = WebString::fromUTF8("target"); 1597 WebString target = WebString::fromUTF8("target");
(...skipping 15 matching lines...) Expand all
1614 webView->updateAllLifecyclePhases(); 1613 webView->updateAllLifecyclePhases();
1615 runPendingTasks(); 1614 runPendingTasks();
1616 1615
1617 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox"); 1616 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox");
1618 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 1617 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1619 1618
1620 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, blanklinestextbo x)); 1619 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, blanklinestextbo x));
1621 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); 1620 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
1622 } 1621 }
1623 1622
1623 TEST_F(WebViewTest, LongPressImageTextarea)
1624 {
1625 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_image_contenteditable.html"));
1626
1627 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ image_contenteditable.html", true);
1628 webView->resize(WebSize(500, 300));
1629 webView->updateAllLifecyclePhases();
1630 runPendingTasks();
1631
1632 WebString image = WebString::fromUTF8("purpleimage");
1633
1634 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, image));
1635 size_t location, length;
1636 EXPECT_TRUE(toWebViewImpl(webView)->caretOrSelectionRange(&location, &length ));
1637 EXPECT_EQ(0UL, location);
1638 EXPECT_EQ(1UL, length);
1639 }
1640
1624 TEST_F(WebViewTest, BlinkCaretOnTypingAfterLongPress) 1641 TEST_F(WebViewTest, BlinkCaretOnTypingAfterLongPress)
1625 { 1642 {
1626 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("blink_caret_on_typing_after_long_press.html")); 1643 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("blink_caret_on_typing_after_long_press.html"));
1627 1644
1628 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "blink_care t_on_typing_after_long_press.html", true); 1645 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "blink_care t_on_typing_after_long_press.html", true);
1629 webView->resize(WebSize(640, 480)); 1646 webView->resize(WebSize(640, 480));
1630 webView->updateAllLifecyclePhases(); 1647 webView->updateAllLifecyclePhases();
1631 runPendingTasks(); 1648 runPendingTasks();
1632 1649
1633 WebString target = WebString::fromUTF8("target"); 1650 WebString target = WebString::fromUTF8("target");
1634 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webView->mainFrame()); 1651 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webView->mainFrame());
1635 1652
1636 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); 1653 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target));
1637 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); 1654 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended());
1638 1655
1639 WebKeyboardEvent keyEvent; 1656 WebKeyboardEvent keyEvent;
1640 keyEvent.type = WebInputEvent::RawKeyDown; 1657 keyEvent.type = WebInputEvent::RawKeyDown;
1641 webView->handleInputEvent(keyEvent); 1658 webView->handleInputEvent(keyEvent);
1642 keyEvent.type = WebInputEvent::KeyUp; 1659 keyEvent.type = WebInputEvent::KeyUp;
1643 webView->handleInputEvent(keyEvent); 1660 webView->handleInputEvent(keyEvent);
1644 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); 1661 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended());
1645 } 1662 }
1646 #endif
1647 1663
1648 TEST_F(WebViewTest, BlinkCaretOnClosingContextMenu) 1664 TEST_F(WebViewTest, BlinkCaretOnClosingContextMenu)
1649 { 1665 {
1650 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("form.html")); 1666 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("form.html"));
1651 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html" , true); 1667 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html" , true);
1652 1668
1653 webView->setInitialFocus(false); 1669 webView->setInitialFocus(false);
1654 runPendingTasks(); 1670 runPendingTasks();
1655 1671
1656 // We suspend caret blinking when pressing with mouse right button. 1672 // We suspend caret blinking when pressing with mouse right button.
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after
3245 frame->setAutofillClient(&client); 3261 frame->setAutofillClient(&client);
3246 webView->setInitialFocus(false); 3262 webView->setInitialFocus(false);
3247 3263
3248 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); 3264 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str())));
3249 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3265 EXPECT_EQ(1, client.textChangesFromUserGesture());
3250 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3266 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3251 frame->setAutofillClient(0); 3267 frame->setAutofillClient(0);
3252 } 3268 }
3253 3269
3254 } // namespace blink 3270 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698