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

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

Issue 1403893003: Plumb gesture source value through Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Convert more tests (related to CL) to use Touchscreen. Created 5 years, 2 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 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 if (!element) 1449 if (!element)
1450 return false; 1450 return false;
1451 1451
1452 element->scrollIntoViewIfNeeded(); 1452 element->scrollIntoViewIfNeeded();
1453 1453
1454 // TODO(bokan): Technically incorrect, event positions should be in viewport space. crbug.com/371902. 1454 // TODO(bokan): Technically incorrect, event positions should be in viewport space. crbug.com/371902.
1455 IntPoint center = element->screenRect().center(); 1455 IntPoint center = element->screenRect().center();
1456 1456
1457 WebGestureEvent event; 1457 WebGestureEvent event;
1458 event.type = type; 1458 event.type = type;
1459 event.sourceDevice = WebGestureDeviceTouchscreen;
1459 event.x = center.x(); 1460 event.x = center.x();
1460 event.y = center.y(); 1461 event.y = center.y();
1461 1462
1462 webView->handleInputEvent(event); 1463 webView->handleInputEvent(event);
1463 runPendingTasks(); 1464 runPendingTasks();
1464 return true; 1465 return true;
1465 } 1466 }
1466 1467
1467 TEST_F(WebViewTest, DetectContentAroundPosition) 1468 TEST_F(WebViewTest, DetectContentAroundPosition)
1468 { 1469 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 EXPECT_FALSE(client.scheduledIntentURL().isValid()); 1502 EXPECT_FALSE(client.scheduledIntentURL().isValid());
1502 1503
1503 WebURL intentURL = toKURL(m_baseURL); 1504 WebURL intentURL = toKURL(m_baseURL);
1504 client.setContentDetectionResult(WebContentDetectionResult(WebRange(), WebSt ring(), intentURL)); 1505 client.setContentDetectionResult(WebContentDetectionResult(WebRange(), WebSt ring(), intentURL));
1505 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, noListener)); 1506 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, noListener));
1506 EXPECT_TRUE(client.scheduledIntentURL() == intentURL); 1507 EXPECT_TRUE(client.scheduledIntentURL() == intentURL);
1507 1508
1508 // Tapping elsewhere should cancel the scheduled intent. 1509 // Tapping elsewhere should cancel the scheduled intent.
1509 WebGestureEvent event; 1510 WebGestureEvent event;
1510 event.type = WebInputEvent::GestureTap; 1511 event.type = WebInputEvent::GestureTap;
1512 event.sourceDevice = WebGestureDeviceTouchscreen;
1511 webView->handleInputEvent(event); 1513 webView->handleInputEvent(event);
1512 runPendingTasks(); 1514 runPendingTasks();
1513 EXPECT_TRUE(client.pendingIntentsCancelled()); 1515 EXPECT_TRUE(client.pendingIntentsCancelled());
1514 1516
1515 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 1517 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
1516 } 1518 }
1517 1519
1518 TEST_F(WebViewTest, ClientTapHandling) 1520 TEST_F(WebViewTest, ClientTapHandling)
1519 { 1521 {
1520 TapHandlingWebViewClient client; 1522 TapHandlingWebViewClient client;
1521 client.reset(); 1523 client.reset();
1522 WebView* webView = m_webViewHelper.initializeAndLoad("about:blank", true, 0, &client); 1524 WebView* webView = m_webViewHelper.initializeAndLoad("about:blank", true, 0, &client);
1523 WebGestureEvent event; 1525 WebGestureEvent event;
1524 event.type = WebInputEvent::GestureTap; 1526 event.type = WebInputEvent::GestureTap;
1527 event.sourceDevice = WebGestureDeviceTouchscreen;
1525 event.x = 3; 1528 event.x = 3;
1526 event.y = 8; 1529 event.y = 8;
1527 webView->handleInputEvent(event); 1530 webView->handleInputEvent(event);
1528 runPendingTasks(); 1531 runPendingTasks();
1529 EXPECT_EQ(3, client.tapX()); 1532 EXPECT_EQ(3, client.tapX());
1530 EXPECT_EQ(8, client.tapY()); 1533 EXPECT_EQ(8, client.tapY());
1531 client.reset(); 1534 client.reset();
1532 event.type = WebInputEvent::GestureLongPress; 1535 event.type = WebInputEvent::GestureLongPress;
1533 event.x = 25; 1536 event.x = 25;
1534 event.y = 7; 1537 event.y = 7;
1535 webView->handleInputEvent(event); 1538 webView->handleInputEvent(event);
1536 runPendingTasks(); 1539 runPendingTasks();
1537 EXPECT_EQ(25, client.longpressX()); 1540 EXPECT_EQ(25, client.longpressX());
1538 EXPECT_EQ(7, client.longpressY()); 1541 EXPECT_EQ(7, client.longpressY());
1539 1542
1540 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 1543 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
1541 } 1544 }
1542 1545
1543 TEST_F(WebViewTest, ClientTapHandlingNullWebViewClient) 1546 TEST_F(WebViewTest, ClientTapHandlingNullWebViewClient)
1544 { 1547 {
1545 WebViewImpl* webView = WebViewImpl::create(nullptr); 1548 WebViewImpl* webView = WebViewImpl::create(nullptr);
1546 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , nullptr); 1549 WebLocalFrame* localFrame = WebLocalFrame::create(WebTreeScopeType::Document , nullptr);
1547 webView->setMainFrame(localFrame); 1550 webView->setMainFrame(localFrame);
1548 WebGestureEvent event; 1551 WebGestureEvent event;
1549 event.type = WebInputEvent::GestureTap; 1552 event.type = WebInputEvent::GestureTap;
1553 event.sourceDevice = WebGestureDeviceTouchscreen;
1550 event.x = 3; 1554 event.x = 3;
1551 event.y = 8; 1555 event.y = 8;
1552 EXPECT_FALSE(webView->handleInputEvent(event)); 1556 EXPECT_FALSE(webView->handleInputEvent(event));
1553 webView->close(); 1557 webView->close();
1554 // Explicitly close as the frame as no frame client to do so on frameDetache d(). 1558 // Explicitly close as the frame as no frame client to do so on frameDetache d().
1555 localFrame->close(); 1559 localFrame->close();
1556 } 1560 }
1557 1561
1558 #if OS(ANDROID) 1562 #if OS(ANDROID)
1559 TEST_F(WebViewTest, LongPressSelection) 1563 TEST_F(WebViewTest, LongPressSelection)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 1637
1634 int pageWidth = 640; 1638 int pageWidth = 640;
1635 int pageHeight = 480; 1639 int pageHeight = 480;
1636 webViewImpl->resize(WebSize(pageWidth, pageHeight)); 1640 webViewImpl->resize(WebSize(pageWidth, pageHeight));
1637 1641
1638 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); 1642 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/");
1639 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), "<a href='http:// www.test.com' style='position: absolute; left: 20px; top: 20px; width: 200px; tr ansform:translateZ(0);'>A link to highlight</a>", baseURL); 1643 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), "<a href='http:// www.test.com' style='position: absolute; left: 20px; top: 20px; width: 200px; tr ansform:translateZ(0);'>A link to highlight</a>", baseURL);
1640 1644
1641 WebGestureEvent event; 1645 WebGestureEvent event;
1642 event.type = WebInputEvent::GestureShowPress; 1646 event.type = WebInputEvent::GestureShowPress;
1647 event.sourceDevice = WebGestureDeviceTouchscreen;
1643 event.x = 20; 1648 event.x = 20;
1644 event.y = 20; 1649 event.y = 20;
1645 1650
1646 // Just make sure we don't hit any asserts. 1651 // Just make sure we don't hit any asserts.
1647 webViewImpl->handleInputEvent(event); 1652 webViewImpl->handleInputEvent(event);
1648 } 1653 }
1649 1654
1650 class MockAutofillClient : public WebAutofillClient { 1655 class MockAutofillClient : public WebAutofillClient {
1651 public: 1656 public:
1652 MockAutofillClient() 1657 MockAutofillClient()
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 WebFrame* frame = mainWebView.webView()->mainFrame(); 3106 WebFrame* frame = mainWebView.webView()->mainFrame();
3102 v8::HandleScope scope(v8::Isolate::GetCurrent()); 3107 v8::HandleScope scope(v8::Isolate::GetCurrent());
3103 v8::Local<v8::Value> v8Value = frame->executeScriptAndReturnValue(WebScriptS ource("var win = window.open('javascript:false'); win.document")); 3108 v8::Local<v8::Value> v8Value = frame->executeScriptAndReturnValue(WebScriptS ource("var win = window.open('javascript:false'); win.document"));
3104 ASSERT_TRUE(v8Value->IsObject()); 3109 ASSERT_TRUE(v8Value->IsObject());
3105 Document* document = V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent (), v8Value); 3110 Document* document = V8Document::toImplWithTypeCheck(v8::Isolate::GetCurrent (), v8Value);
3106 ASSERT_TRUE(document); 3111 ASSERT_TRUE(document);
3107 EXPECT_FALSE(document->frame()->isLoading()); 3112 EXPECT_FALSE(document->frame()->isLoading());
3108 } 3113 }
3109 3114
3110 } // namespace blink 3115 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp ('k') | third_party/WebKit/public/platform/WebGestureDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698