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

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: Disable Mac-only failure (Mac doesn't support long-press anyway) 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");
1599 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse"); 1598 WebString onselectstartfalse = WebString::fromUTF8("onselectstartfalse");
1600 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 1599 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1601 1600
1602 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, onselectstartfal se)); 1601 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, onselectstartfal se));
1603 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); 1602 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
1604 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); 1603 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target));
1605 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data())); 1604 EXPECT_EQ("testword", std::string(frame->selectionAsText().utf8().data()));
1606 } 1605 }
1607 1606
1607 #if !OS(MACOSX)
1608 TEST_F(WebViewTest, LongPressEmptyTextarea) 1608 TEST_F(WebViewTest, LongPressEmptyTextarea)
1609 { 1609 {
1610 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_textarea.html")); 1610 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_textarea.html"));
1611 1611
1612 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ textarea.html", true); 1612 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ textarea.html", true);
1613 webView->resize(WebSize(500, 300)); 1613 webView->resize(WebSize(500, 300));
1614 webView->updateAllLifecyclePhases(); 1614 webView->updateAllLifecyclePhases();
1615 runPendingTasks(); 1615 runPendingTasks();
1616 1616
1617 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox"); 1617 WebString blanklinestextbox = WebString::fromUTF8("blanklinestextbox");
1618 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame()); 1618 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
1619 1619
1620 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, blanklinestextbo x)); 1620 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, blanklinestextbo x));
1621 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data())); 1621 EXPECT_EQ("", std::string(frame->selectionAsText().utf8().data()));
1622 } 1622 }
1623 #endif
1624
1625 TEST_F(WebViewTest, LongPressImageTextarea)
1626 {
1627 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("longpress_image_contenteditable.html"));
1628
1629 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "longpress_ image_contenteditable.html", true);
1630 webView->resize(WebSize(500, 300));
1631 webView->updateAllLifecyclePhases();
1632 runPendingTasks();
1633
1634 WebString image = WebString::fromUTF8("purpleimage");
1635
1636 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, image));
1637 size_t location, length;
1638 EXPECT_TRUE(toWebViewImpl(webView)->caretOrSelectionRange(&location, &length ));
1639 EXPECT_EQ(0UL, location);
1640 EXPECT_EQ(1UL, length);
1641 }
1623 1642
1624 TEST_F(WebViewTest, BlinkCaretOnTypingAfterLongPress) 1643 TEST_F(WebViewTest, BlinkCaretOnTypingAfterLongPress)
1625 { 1644 {
1626 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("blink_caret_on_typing_after_long_press.html")); 1645 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("blink_caret_on_typing_after_long_press.html"));
1627 1646
1628 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "blink_care t_on_typing_after_long_press.html", true); 1647 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "blink_care t_on_typing_after_long_press.html", true);
1629 webView->resize(WebSize(640, 480)); 1648 webView->resize(WebSize(640, 480));
1630 webView->updateAllLifecyclePhases(); 1649 webView->updateAllLifecyclePhases();
1631 runPendingTasks(); 1650 runPendingTasks();
1632 1651
1633 WebString target = WebString::fromUTF8("target"); 1652 WebString target = WebString::fromUTF8("target");
1634 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webView->mainFrame()); 1653 WebLocalFrameImpl* mainFrame = toWebLocalFrameImpl(webView->mainFrame());
1635 1654
1636 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target)); 1655 EXPECT_TRUE(tapElementById(WebInputEvent::GestureLongPress, target));
1637 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); 1656 EXPECT_TRUE(mainFrame->frame()->selection().isCaretBlinkingSuspended());
1638 1657
1639 WebKeyboardEvent keyEvent; 1658 WebKeyboardEvent keyEvent;
1640 keyEvent.type = WebInputEvent::RawKeyDown; 1659 keyEvent.type = WebInputEvent::RawKeyDown;
1641 webView->handleInputEvent(keyEvent); 1660 webView->handleInputEvent(keyEvent);
1642 keyEvent.type = WebInputEvent::KeyUp; 1661 keyEvent.type = WebInputEvent::KeyUp;
1643 webView->handleInputEvent(keyEvent); 1662 webView->handleInputEvent(keyEvent);
1644 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended()); 1663 EXPECT_FALSE(mainFrame->frame()->selection().isCaretBlinkingSuspended());
1645 } 1664 }
1646 #endif
1647 1665
1648 TEST_F(WebViewTest, BlinkCaretOnClosingContextMenu) 1666 TEST_F(WebViewTest, BlinkCaretOnClosingContextMenu)
1649 { 1667 {
1650 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("form.html")); 1668 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("form.html"));
1651 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html" , true); 1669 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "form.html" , true);
1652 1670
1653 webView->setInitialFocus(false); 1671 webView->setInitialFocus(false);
1654 runPendingTasks(); 1672 runPendingTasks();
1655 1673
1656 // We suspend caret blinking when pressing with mouse right button. 1674 // 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); 3263 frame->setAutofillClient(&client);
3246 webView->setInitialFocus(false); 3264 webView->setInitialFocus(false);
3247 3265
3248 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str()))); 3266 EXPECT_TRUE(webView->confirmComposition(WebString::fromUTF8(std::string("hel lo").c_str())));
3249 EXPECT_EQ(1, client.textChangesFromUserGesture()); 3267 EXPECT_EQ(1, client.textChangesFromUserGesture());
3250 EXPECT_FALSE(UserGestureIndicator::processingUserGesture()); 3268 EXPECT_FALSE(UserGestureIndicator::processingUserGesture());
3251 frame->setAutofillClient(0); 3269 frame->setAutofillClient(0);
3252 } 3270 }
3253 3271
3254 } // namespace blink 3272 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698