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

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

Issue 952973003: Remove dead code from unit tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « Source/web/tests/PageSerializerTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str())); 221 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU RL.c_str()), WebString::fromUTF8(fileName.c_str()));
222 } 222 }
223 223
224 void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResi ze, 224 void testAutoResize(const WebSize& minAutoResize, const WebSize& maxAutoResi ze,
225 const std::string& pageWidth, const std::string& pageHei ght, 225 const std::string& pageWidth, const std::string& pageHei ght,
226 int expectedWidth, int expectedHeight, 226 int expectedWidth, int expectedHeight,
227 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState); 227 HorizontalScrollbarState expectedHorizontalState, Vertic alScrollbarState expectedVerticalState);
228 228
229 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile); 229 void testTextInputType(WebTextInputType expectedType, const std::string& htm lFile);
230 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile); 230 void testInputMode(const WebString& expectedInputMode, const std::string& ht mlFile);
231 void testSelectionRootBounds(const char* htmlFile, float pageScaleFactor);
232 231
233 std::string m_baseURL; 232 std::string m_baseURL;
234 FrameTestHelpers::WebViewHelper m_webViewHelper; 233 FrameTestHelpers::WebViewHelper m_webViewHelper;
235 }; 234 };
236 235
237 TEST_F(WebViewTest, SaveImageAt) 236 TEST_F(WebViewTest, SaveImageAt)
238 { 237 {
239 SaveImageFromDataURLWebViewClient client; 238 SaveImageFromDataURLWebViewClient client;
240 239
241 std::string url = m_baseURL + "image-with-data-url.html"; 240 std::string url = m_baseURL + "image-with-data-url.html";
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#b")))); 999 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#b"))));
1001 RefPtrWillBePersistent<HistoryItem> item3 = mainFrameLocal->loader().current Item(); 1000 RefPtrWillBePersistent<HistoryItem> item3 = mainFrameLocal->loader().current Item();
1002 1001
1003 // Go back, then forward. The scroll position should be properly set on the forward navigation. 1002 // Go back, then forward. The scroll position should be properly set on the forward navigation.
1004 mainFrameLocal->loader().loadHistoryItem(item1.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad); 1003 mainFrameLocal->loader().loadHistoryItem(item1.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad);
1005 mainFrameLocal->loader().loadHistoryItem(item3.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad); 1004 mainFrameLocal->loader().loadHistoryItem(item3.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad);
1006 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 1005 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
1007 EXPECT_GT(webViewImpl->mainFrame()->scrollOffset().height, 2000); 1006 EXPECT_GT(webViewImpl->mainFrame()->scrollOffset().height, 2000);
1008 } 1007 }
1009 1008
1010 class EnterFullscreenWebViewClient : public FrameTestHelpers::TestWebViewClient {
1011 public:
1012 // WebViewClient methods
1013 virtual bool enterFullScreen() { return true; }
1014 virtual void exitFullScreen() { }
1015 };
1016
1017
1018 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) 1009 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState)
1019 { 1010 {
1020 EnterFullscreenWebViewClient client; 1011 FrameTestHelpers::TestWebViewClient client;
1021 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("hello_world.html")); 1012 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("hello_world.html"));
1022 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he llo_world.html", true, 0, &client); 1013 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he llo_world.html", true, 0, &client);
1023 webViewImpl->resize(WebSize(640, 480)); 1014 webViewImpl->resize(WebSize(640, 480));
1024 webViewImpl->layout(); 1015 webViewImpl->layout();
1025 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 1016 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
1026 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 1017 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
1027 1018
1028 // Make the page scale and scroll with the given paremeters. 1019 // Make the page scale and scroll with the given paremeters.
1029 webViewImpl->setPageScaleFactor(2.0f); 1020 webViewImpl->setPageScaleFactor(2.0f);
1030 webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); 1021 webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84));
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 #if ENABLE(OILPAN) 1981 #if ENABLE(OILPAN)
1991 // For oilpan we have to force a GC to ensure the event handlers have been r emoved when 1982 // For oilpan we have to force a GC to ensure the event handlers have been r emoved when
1992 // checking below. We do a precise GC (collectAllGarbage does not scan the s tack) 1983 // checking below. We do a precise GC (collectAllGarbage does not scan the s tack)
1993 // to ensure the div element dies. This is also why the Document is in a Per sistent 1984 // to ensure the div element dies. This is also why the Document is in a Per sistent
1994 // since we want that to stay around. 1985 // since we want that to stay around.
1995 Heap::collectAllGarbage(); 1986 Heap::collectAllGarbage();
1996 #endif 1987 #endif
1997 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent)); 1988 EXPECT_FALSE(registry.hasEventHandlers(EventHandlerRegistry::ScrollEvent));
1998 } 1989 }
1999 1990
2000 static WebRect ExpectedRootBounds(Document* document, float scaleFactor)
2001 {
2002 Element* element = document->getElementById("root");
2003 if (!element)
2004 element = document->getElementById("target");
2005 if (element->hasTagName(HTMLNames::iframeTag))
2006 return ExpectedRootBounds(toHTMLIFrameElement(element)->contentDocument( ), scaleFactor);
2007
2008 IntRect boundingBox;
2009 if (element->hasTagName(HTMLNames::htmlTag))
2010 boundingBox = IntRect(IntPoint(0, 0), document->frame()->view()->content sSize());
2011 else
2012 boundingBox = element->pixelSnappedBoundingBox();
2013 boundingBox = document->frame()->view()->contentsToWindow(boundingBox);
2014 boundingBox.scale(scaleFactor);
2015 return boundingBox;
2016 }
2017
2018 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF actor)
2019 {
2020 std::string url = m_baseURL + htmlFile;
2021
2022 WebView* webView = m_webViewHelper.initializeAndLoad(url, true);
2023 webView->resize(WebSize(640, 480));
2024 webView->setPageScaleFactor(pageScaleFactor);
2025 webView->layout();
2026 runPendingTasks();
2027
2028 WebLocalFrameImpl* frame = toWebLocalFrameImpl(webView->mainFrame());
2029 EXPECT_TRUE(frame->frame()->document()->isHTMLDocument());
2030 HTMLDocument* document = toHTMLDocument(frame->frame()->document());
2031
2032 WebRect anchor, focus;
2033 webView->selectionBounds(anchor, focus);
2034 IntRect expectedIntRect = ExpectedRootBounds(document, webView->pageScaleFac tor());
2035 ASSERT_TRUE(expectedIntRect.contains(anchor));
2036 // The "overflow" tests have the focus boundary outside of the element box.
2037 ASSERT_EQ(url.find("overflow") == std::string::npos, expectedIntRect.contain s(focus));
2038 }
2039
2040 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView Client { 1991 class NonUserInputTextUpdateWebViewClient : public FrameTestHelpers::TestWebView Client {
2041 public: 1992 public:
2042 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { } 1993 NonUserInputTextUpdateWebViewClient() : m_textIsUpdated(false) { }
2043 1994
2044 // WebWidgetClient methods 1995 // WebWidgetClient methods
2045 virtual void didUpdateTextOfFocusedElementByNonUserInput() override 1996 virtual void didUpdateTextOfFocusedElementByNonUserInput() override
2046 { 1997 {
2047 m_textIsUpdated = true; 1998 m_textIsUpdated = true;
2048 } 1999 }
2049 2000
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2438 // Test without any preventDefault. 2389 // Test without any preventDefault.
2439 client.reset(); 2390 client.reset();
2440 frame->executeScript(WebScriptSource("setTest('none');")); 2391 frame->executeScript(WebScriptSource("setTest('none');"));
2441 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 2392 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
2442 EXPECT_TRUE(client.getWasCalled()); 2393 EXPECT_TRUE(client.getWasCalled());
2443 2394
2444 m_webViewHelper.reset(); // Remove dependency on locally scoped client. 2395 m_webViewHelper.reset(); // Remove dependency on locally scoped client.
2445 } 2396 }
2446 2397
2447 } // namespace 2398 } // namespace
OLDNEW
« no previous file with comments | « Source/web/tests/PageSerializerTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698