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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 TEST_F(WebViewTest, BackForwardRestoreScroll) 1227 TEST_F(WebViewTest, BackForwardRestoreScroll)
1228 { 1228 {
1229 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("back_forward_restore_scroll.html")); 1229 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("back_forward_restore_scroll.html"));
1230 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "ba ck_forward_restore_scroll.html"); 1230 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "ba ck_forward_restore_scroll.html");
1231 webViewImpl->resize(WebSize(640, 480)); 1231 webViewImpl->resize(WebSize(640, 480));
1232 webViewImpl->updateAllLifecyclePhases(); 1232 webViewImpl->updateAllLifecyclePhases();
1233 1233
1234 // Emulate a user scroll 1234 // Emulate a user scroll
1235 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 900)); 1235 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 900));
1236 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame()); 1236 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame());
1237 RefPtrWillBePersistent<HistoryItem> item1 = mainFrameLocal->loader().current Item(); 1237 Persistent<HistoryItem> item1 = mainFrameLocal->loader().currentItem();
1238 1238
1239 // Click an anchor 1239 // Click an anchor
1240 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#a")))); 1240 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#a"))));
1241 RefPtrWillBePersistent<HistoryItem> item2 = mainFrameLocal->loader().current Item(); 1241 Persistent<HistoryItem> item2 = mainFrameLocal->loader().currentItem();
1242 1242
1243 // Go back, then forward, then back again. 1243 // Go back, then forward, then back again.
1244 mainFrameLocal->loader().load( 1244 mainFrameLocal->loader().load(
1245 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem( 1245 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1246 item1.get(), UseProtocolCachePolicy)), 1246 item1.get(), UseProtocolCachePolicy)),
1247 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); 1247 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1248 mainFrameLocal->loader().load( 1248 mainFrameLocal->loader().load(
1249 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem( 1249 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1250 item2.get(), UseProtocolCachePolicy)), 1250 item2.get(), UseProtocolCachePolicy)),
1251 FrameLoadTypeBackForward, item2.get(), HistorySameDocumentLoad); 1251 FrameLoadTypeBackForward, item2.get(), HistorySameDocumentLoad);
1252 mainFrameLocal->loader().load( 1252 mainFrameLocal->loader().load(
1253 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem( 1253 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1254 item1.get(), UseProtocolCachePolicy)), 1254 item1.get(), UseProtocolCachePolicy)),
1255 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); 1255 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1256 1256
1257 // Click a different anchor 1257 // Click a different anchor
1258 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#b")))); 1258 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#b"))));
1259 RefPtrWillBePersistent<HistoryItem> item3 = mainFrameLocal->loader().current Item(); 1259 Persistent<HistoryItem> item3 = mainFrameLocal->loader().currentItem();
1260 1260
1261 // Go back, then forward. The scroll position should be properly set on the forward navigation. 1261 // Go back, then forward. The scroll position should be properly set on the forward navigation.
1262 mainFrameLocal->loader().load( 1262 mainFrameLocal->loader().load(
1263 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem( 1263 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1264 item1.get(), UseProtocolCachePolicy)), 1264 item1.get(), UseProtocolCachePolicy)),
1265 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); 1265 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1266 mainFrameLocal->loader().load( 1266 mainFrameLocal->loader().load(
1267 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem( 1267 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1268 item3.get(), UseProtocolCachePolicy)), 1268 item3.get(), UseProtocolCachePolicy)),
1269 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad); 1269 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad);
(...skipping 14 matching lines...) Expand all
1284 // Make the page scale and scroll with the given paremeters. 1284 // Make the page scale and scroll with the given paremeters.
1285 webViewImpl->setPageScaleFactor(2.0f); 1285 webViewImpl->setPageScaleFactor(2.0f);
1286 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111)); 1286 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111));
1287 webViewImpl->setVisualViewportOffset(WebFloatPoint(12, 20)); 1287 webViewImpl->setVisualViewportOffset(WebFloatPoint(12, 20));
1288 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 1288 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
1289 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width); 1289 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width);
1290 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height); 1290 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height);
1291 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); 1291 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x);
1292 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); 1292 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y);
1293 1293
1294 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele ment>>(webViewImpl->mainFrame()->document().body()); 1294 RawPtr<Element> element = static_cast<RawPtr<Element>>(webViewImpl->mainFram e()->document().body());
1295 webViewImpl->enterFullScreenForElement(element.get()); 1295 webViewImpl->enterFullScreenForElement(element.get());
1296 webViewImpl->didEnterFullScreen(); 1296 webViewImpl->didEnterFullScreen();
1297 1297
1298 // Page scale factor must be 1.0 during fullscreen for elements to be sized 1298 // Page scale factor must be 1.0 during fullscreen for elements to be sized
1299 // properly. 1299 // properly.
1300 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); 1300 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor());
1301 1301
1302 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving. 1302 // Make sure fullscreen nesting doesn't disrupt scroll/scale saving.
1303 RefPtrWillBeRawPtr<Element> otherElement = static_cast<PassRefPtrWillBeRawPt r<Element>>(webViewImpl->mainFrame()->document().head()); 1303 RawPtr<Element> otherElement = static_cast<RawPtr<Element>>(webViewImpl->mai nFrame()->document().head());
1304 webViewImpl->enterFullScreenForElement(otherElement.get()); 1304 webViewImpl->enterFullScreenForElement(otherElement.get());
1305 1305
1306 // Confirm that exiting fullscreen restores the parameters. 1306 // Confirm that exiting fullscreen restores the parameters.
1307 webViewImpl->didExitFullScreen(); 1307 webViewImpl->didExitFullScreen();
1308 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 1308 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
1309 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width); 1309 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width);
1310 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height); 1310 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height);
1311 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x); 1311 EXPECT_EQ(12, webViewImpl->visualViewportOffset().x);
1312 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y); 1312 EXPECT_EQ(20, webViewImpl->visualViewportOffset().y);
1313 1313
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1444 void setContentDetectionResult(const WebContentDetectionResult& result) { m_ contentDetectionResult = result; } 1444 void setContentDetectionResult(const WebContentDetectionResult& result) { m_ contentDetectionResult = result; }
1445 1445
1446 private: 1446 private:
1447 bool m_contentDetectionRequested; 1447 bool m_contentDetectionRequested;
1448 bool m_pendingIntentsCancelled; 1448 bool m_pendingIntentsCancelled;
1449 WebURL m_scheduledIntentURL; 1449 WebURL m_scheduledIntentURL;
1450 bool m_wasInMainFrame; 1450 bool m_wasInMainFrame;
1451 WebContentDetectionResult m_contentDetectionResult; 1451 WebContentDetectionResult m_contentDetectionResult;
1452 }; 1452 };
1453 1453
1454 static bool tapElement(WebView* webView, WebInputEvent::Type type, const PassRef PtrWillBeRawPtr<Element>& element) 1454 static bool tapElement(WebView* webView, WebInputEvent::Type type, const RawPtr< Element>& element)
1455 { 1455 {
1456 if (!element) 1456 if (!element)
1457 return false; 1457 return false;
1458 1458
1459 element->scrollIntoViewIfNeeded(); 1459 element->scrollIntoViewIfNeeded();
1460 1460
1461 // TODO(bokan): Technically incorrect, event positions should be in viewport space. crbug.com/371902. 1461 // TODO(bokan): Technically incorrect, event positions should be in viewport space. crbug.com/371902.
1462 IntPoint center = element->screenRect().center(); 1462 IntPoint center = element->screenRect().center();
1463 1463
1464 WebGestureEvent event; 1464 WebGestureEvent event;
1465 event.type = type; 1465 event.type = type;
1466 event.sourceDevice = WebGestureDeviceTouchscreen; 1466 event.sourceDevice = WebGestureDeviceTouchscreen;
1467 event.x = center.x(); 1467 event.x = center.x();
1468 event.y = center.y(); 1468 event.y = center.y();
1469 1469
1470 ASSERT(webView); 1470 ASSERT(webView);
1471 webView->handleInputEvent(event); 1471 webView->handleInputEvent(event);
1472 runPendingTasks(); 1472 runPendingTasks();
1473 return true; 1473 return true;
1474 } 1474 }
1475 1475
1476 static bool tapElementById(WebView* webView, WebInputEvent::Type type, const Web String& id) 1476 static bool tapElementById(WebView* webView, WebInputEvent::Type type, const Web String& id)
1477 { 1477 {
1478 ASSERT(webView); 1478 ASSERT(webView);
1479 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele ment>>(webView->mainFrame()->document().getElementById(id)); 1479 RawPtr<Element> element = static_cast<RawPtr<Element>>(webView->mainFrame()- >document().getElementById(id));
1480 return tapElement(webView, type, element); 1480 return tapElement(webView, type, element);
1481 } 1481 }
1482 1482
1483 TEST_F(WebViewTest, DetectContentAroundPosition) 1483 TEST_F(WebViewTest, DetectContentAroundPosition)
1484 { 1484 {
1485 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_listeners.html")); 1485 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("content_listeners.html"));
1486 1486
1487 ContentDetectorClient client; 1487 ContentDetectorClient client;
1488 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners.html", true, 0, &client); 1488 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners.html", true, 0, &client);
1489 webView->resize(WebSize(500, 300)); 1489 webView->resize(WebSize(500, 300));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners_iframe.html", true, 0, &client); 1541 WebView* webView = m_webViewHelper.initializeAndLoad(m_baseURL + "content_li steners_iframe.html", true, 0, &client);
1542 webView->resize(WebSize(500, 300)); 1542 webView->resize(WebSize(500, 300));
1543 webView->updateAllLifecyclePhases(); 1543 webView->updateAllLifecyclePhases();
1544 runPendingTasks(); 1544 runPendingTasks();
1545 1545
1546 WebString noListener = WebString::fromUTF8("noListener"); 1546 WebString noListener = WebString::fromUTF8("noListener");
1547 WebString frameName = WebString::fromUTF8("innerFrame"); 1547 WebString frameName = WebString::fromUTF8("innerFrame");
1548 1548
1549 WebURL intentURL = toKURL(m_baseURL); 1549 WebURL intentURL = toKURL(m_baseURL);
1550 client.setContentDetectionResult(WebContentDetectionResult(WebRange(), WebSt ring(), intentURL)); 1550 client.setContentDetectionResult(WebContentDetectionResult(WebRange(), WebSt ring(), intentURL));
1551 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele ment>>(webView->findFrameByName(frameName)->document().getElementById(noListener )); 1551 RawPtr<Element> element = static_cast<RawPtr<Element>>(webView->findFrameByN ame(frameName)->document().getElementById(noListener));
1552 EXPECT_TRUE(tapElement(webView, WebInputEvent::GestureTap, element)); 1552 EXPECT_TRUE(tapElement(webView, WebInputEvent::GestureTap, element));
1553 EXPECT_TRUE(client.scheduledIntentURL() == intentURL); 1553 EXPECT_TRUE(client.scheduledIntentURL() == intentURL);
1554 EXPECT_FALSE(client.wasInMainFrame()); 1554 EXPECT_FALSE(client.wasInMainFrame());
1555 1555
1556 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client. 1556 m_webViewHelper.reset(); // Explicitly reset to break dependency on locally scoped client.
1557 } 1557 }
1558 1558
1559 TEST_F(WebViewTest, ClientTapHandling) 1559 TEST_F(WebViewTest, ClientTapHandling)
1560 { 1560 {
1561 TapHandlingWebViewClient client; 1561 TapHandlingWebViewClient client;
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 // This test checks that deleting nodes which have only non-JS-registered touch 2425 // This test checks that deleting nodes which have only non-JS-registered touch
2426 // handlers also removes them from the event handler registry. Note that this 2426 // handlers also removes them from the event handler registry. Note that this
2427 // is different from detaching and re-attaching the same node, which is covered 2427 // is different from detaching and re-attaching the same node, which is covered
2428 // by layout tests under fast/events/. 2428 // by layout tests under fast/events/.
2429 TEST_F(WebViewTest, DeleteElementWithRegisteredHandler) 2429 TEST_F(WebViewTest, DeleteElementWithRegisteredHandler)
2430 { 2430 {
2431 std::string url = m_baseURL + "simple_div.html"; 2431 std::string url = m_baseURL + "simple_div.html";
2432 URLTestHelpers::registerMockedURLLoad(toKURL(url), "simple_div.html"); 2432 URLTestHelpers::registerMockedURLLoad(toKURL(url), "simple_div.html");
2433 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true); 2433 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(url, true);
2434 2434
2435 RefPtrWillBePersistent<Document> document = webViewImpl->mainFrameImpl()->fr ame()->document(); 2435 Persistent<Document> document = webViewImpl->mainFrameImpl()->frame()->docum ent();
2436 Element* div = document->getElementById("div"); 2436 Element* div = document->getElementById("div");
2437 EventHandlerRegistry& registry = document->frameHost()->eventHandlerRegistry (); 2437 EventHandlerRegistry& registry = document->frameHost()->eventHandlerRegistry ();
2438 2438
2439 registry.didAddEventHandler(*div, EventHandlerRegistry::ScrollEvent); 2439 registry.didAddEventHandler(*div, EventHandlerRegistry::ScrollEvent);
2440 EXPECT_TRUE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); 2440 EXPECT_TRUE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent));
2441 2441
2442 TrackExceptionState exceptionState; 2442 TrackExceptionState exceptionState;
2443 div->remove(exceptionState); 2443 div->remove(exceptionState);
2444 #if ENABLE(OILPAN) 2444 #if ENABLE(OILPAN)
2445 // For oilpan we have to force a GC to ensure the event handlers have been r emoved when 2445 // For oilpan we have to force a GC to ensure the event handlers have been r emoved when
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline Point); 3227 result = WebSubstringUtil::attributedSubstringInRange(frame, 5, 5, &baseline Point);
3228 ASSERT_TRUE(!!result); 3228 ASSERT_TRUE(!!result);
3229 3229
3230 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y); 3230 point = WebPoint(baselinePoint.x, frameView->height() - baselinePoint.y);
3231 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi nt); 3231 result = WebSubstringUtil::attributedWordAtPoint(webView, point, baselinePoi nt);
3232 ASSERT_TRUE(!!result); 3232 ASSERT_TRUE(!!result);
3233 } 3233 }
3234 #endif 3234 #endif
3235 3235
3236 } // namespace blink 3236 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698