| OLD | NEW | 
|---|
| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 348     webView->resize(WebSize(100, 100)); | 348     webView->resize(WebSize(100, 100)); | 
| 349     WebPoint hitPoint(75, 75); | 349     WebPoint hitPoint(75, 75); | 
| 350 | 350 | 
| 351     // Image is at top left quandrant, so should not hit it. | 351     // Image is at top left quandrant, so should not hit it. | 
| 352     WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); | 352     WebHitTestResult negativeResult = webView->hitTestResultAt(hitPoint); | 
| 353     ASSERT_EQ(WebNode::ElementNode, negativeResult.node().nodeType()); | 353     ASSERT_EQ(WebNode::ElementNode, negativeResult.node().nodeType()); | 
| 354     EXPECT_FALSE(negativeResult.node().to<WebElement>().hasTagName("img")); | 354     EXPECT_FALSE(negativeResult.node().to<WebElement>().hasTagName("img")); | 
| 355     negativeResult.reset(); | 355     negativeResult.reset(); | 
| 356 | 356 | 
| 357     // Scale page up 2x so image should occupy the whole viewport. | 357     // Scale page up 2x so image should occupy the whole viewport. | 
| 358     webView->setPageScaleFactor(2.0f, WebPoint(0, 0)); | 358     webView->setPageScaleFactor(2.0f); | 
| 359     WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint); | 359     WebHitTestResult positiveResult = webView->hitTestResultAt(hitPoint); | 
| 360     ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType()); | 360     ASSERT_EQ(WebNode::ElementNode, positiveResult.node().nodeType()); | 
| 361     EXPECT_TRUE(positiveResult.node().to<WebElement>().hasTagName("img")); | 361     EXPECT_TRUE(positiveResult.node().to<WebElement>().hasTagName("img")); | 
| 362     positiveResult.reset(); | 362     positiveResult.reset(); | 
| 363 } | 363 } | 
| 364 | 364 | 
| 365 void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma
      xAutoResize, | 365 void WebViewTest::testAutoResize(const WebSize& minAutoResize, const WebSize& ma
      xAutoResize, | 
| 366                                  const std::string& pageWidth, const std::string
      & pageHeight, | 366                                  const std::string& pageWidth, const std::string
      & pageHeight, | 
| 367                                  int expectedWidth, int expectedHeight, | 367                                  int expectedWidth, int expectedHeight, | 
| 368                                  HorizontalScrollbarState expectedHorizontalStat
      e, VerticalScrollbarState expectedVerticalState) | 368                                  HorizontalScrollbarState expectedHorizontalStat
      e, VerticalScrollbarState expectedVerticalState) | 
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 774 TEST_F(WebViewTest, HistoryResetScrollAndScaleState) | 774 TEST_F(WebViewTest, HistoryResetScrollAndScaleState) | 
| 775 { | 775 { | 
| 776     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("hello_world.html")); | 776     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("hello_world.html")); | 
| 777     WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
      llo_world.html"); | 777     WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
      llo_world.html"); | 
| 778     webViewImpl->resize(WebSize(640, 480)); | 778     webViewImpl->resize(WebSize(640, 480)); | 
| 779     webViewImpl->layout(); | 779     webViewImpl->layout(); | 
| 780     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 780     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 
| 781     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 781     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 
| 782 | 782 | 
| 783     // Make the page scale and scroll with the given paremeters. | 783     // Make the page scale and scroll with the given paremeters. | 
| 784     webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); | 784     webViewImpl->setPageScaleFactor(2.0f); | 
|  | 785     webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); | 
| 785     EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 786     EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 
| 786     EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 787     EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 
| 787     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 788     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 
| 788     webViewImpl->page()->mainFrame()->loader().saveScrollState(); | 789     webViewImpl->page()->mainFrame()->loader().saveScrollState(); | 
| 789     EXPECT_EQ(2.0f, webViewImpl->page()->mainFrame()->loader().currentItem()->pa
      geScaleFactor()); | 790     EXPECT_EQ(2.0f, webViewImpl->page()->mainFrame()->loader().currentItem()->pa
      geScaleFactor()); | 
| 790     EXPECT_EQ(116, webViewImpl->page()->mainFrame()->loader().currentItem()->scr
      ollPoint().x()); | 791     EXPECT_EQ(116, webViewImpl->page()->mainFrame()->loader().currentItem()->scr
      ollPoint().x()); | 
| 791     EXPECT_EQ(84, webViewImpl->page()->mainFrame()->loader().currentItem()->scro
      llPoint().y()); | 792     EXPECT_EQ(84, webViewImpl->page()->mainFrame()->loader().currentItem()->scro
      llPoint().y()); | 
| 792 | 793 | 
| 793     // Confirm that resetting the page state resets the saved scroll position. | 794     // Confirm that resetting the page state resets the saved scroll position. | 
| 794     // The HistoryController treats a page scale factor of 0.0f as special and a
      voids | 795     // The HistoryController treats a page scale factor of 0.0f as special and a
      voids | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 814 { | 815 { | 
| 815     EnterFullscreenWebViewClient client; | 816     EnterFullscreenWebViewClient client; | 
| 816     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("hello_world.html")); | 817     URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
      _str()), WebString::fromUTF8("hello_world.html")); | 
| 817     WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
      llo_world.html", true, 0, &client); | 818     WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "he
      llo_world.html", true, 0, &client); | 
| 818     webViewImpl->resize(WebSize(640, 480)); | 819     webViewImpl->resize(WebSize(640, 480)); | 
| 819     webViewImpl->layout(); | 820     webViewImpl->layout(); | 
| 820     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 821     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 
| 821     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 822     EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 
| 822 | 823 | 
| 823     // Make the page scale and scroll with the given paremeters. | 824     // Make the page scale and scroll with the given paremeters. | 
| 824     webViewImpl->setPageScaleFactor(2.0f, WebPoint(116, 84)); | 825     webViewImpl->setPageScaleFactor(2.0f); | 
|  | 826     webViewImpl->setMainFrameScrollOffset(WebPoint(116, 84)); | 
| 825     EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 827     EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 
| 826     EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 828     EXPECT_EQ(116, webViewImpl->mainFrame()->scrollOffset().width); | 
| 827     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 829     EXPECT_EQ(84, webViewImpl->mainFrame()->scrollOffset().height); | 
| 828 | 830 | 
| 829     RefPtr<WebCore::Element> element = static_cast<PassRefPtr<WebCore::Element> 
      >(webViewImpl->mainFrame()->document().body()); | 831     RefPtr<WebCore::Element> element = static_cast<PassRefPtr<WebCore::Element> 
      >(webViewImpl->mainFrame()->document().body()); | 
| 830     webViewImpl->enterFullScreenForElement(element.get()); | 832     webViewImpl->enterFullScreenForElement(element.get()); | 
| 831     webViewImpl->willEnterFullScreen(); | 833     webViewImpl->willEnterFullScreen(); | 
| 832     webViewImpl->didEnterFullScreen(); | 834     webViewImpl->didEnterFullScreen(); | 
| 833 | 835 | 
| 834     // Page scale factor must be 1.0 during fullscreen for elements to be sized | 836     // Page scale factor must be 1.0 during fullscreen for elements to be sized | 
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1671     boundingBox.scale(scaleFactor); | 1673     boundingBox.scale(scaleFactor); | 
| 1672     return boundingBox; | 1674     return boundingBox; | 
| 1673 } | 1675 } | 
| 1674 | 1676 | 
| 1675 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF
      actor) | 1677 void WebViewTest::testSelectionRootBounds(const char* htmlFile, float pageScaleF
      actor) | 
| 1676 { | 1678 { | 
| 1677     std::string url = m_baseURL + htmlFile; | 1679     std::string url = m_baseURL + htmlFile; | 
| 1678 | 1680 | 
| 1679     WebView* webView = m_webViewHelper.initializeAndLoad(url, true); | 1681     WebView* webView = m_webViewHelper.initializeAndLoad(url, true); | 
| 1680     webView->resize(WebSize(640, 480)); | 1682     webView->resize(WebSize(640, 480)); | 
| 1681     webView->setPageScaleFactor(pageScaleFactor, WebPoint(0, 0)); | 1683     webView->setPageScaleFactor(pageScaleFactor); | 
| 1682     webView->layout(); | 1684     webView->layout(); | 
| 1683     runPendingTasks(); | 1685     runPendingTasks(); | 
| 1684 | 1686 | 
| 1685     WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); | 1687     WebFrameImpl* frame = toWebFrameImpl(webView->mainFrame()); | 
| 1686     EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 1688     EXPECT_TRUE(frame->frame()->document()->isHTMLDocument()); | 
| 1687     WebCore::HTMLDocument* document = WebCore::toHTMLDocument(frame->frame()->do
      cument()); | 1689     WebCore::HTMLDocument* document = WebCore::toHTMLDocument(frame->frame()->do
      cument()); | 
| 1688 | 1690 | 
| 1689     WebRect expectedRootBounds = ExpectedRootBounds(document, webView->pageScale
      Factor()); | 1691     WebRect expectedRootBounds = ExpectedRootBounds(document, webView->pageScale
      Factor()); | 
| 1690     WebRect actualRootBounds; | 1692     WebRect actualRootBounds; | 
| 1691     webView->getSelectionRootBounds(actualRootBounds); | 1693     webView->getSelectionRootBounds(actualRootBounds); | 
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1865     client.reset(); | 1867     client.reset(); | 
| 1866     EXPECT_FALSE(client.textIsUpdated()); | 1868     EXPECT_FALSE(client.textIsUpdated()); | 
| 1867     document->setFocusedElement(nullptr); | 1869     document->setFocusedElement(nullptr); | 
| 1868     webViewImpl->setFocus(false); | 1870     webViewImpl->setFocus(false); | 
| 1869     EXPECT_NE(document->focusedElement(), static_cast<WebCore::Element*>(textAre
      aElement)); | 1871     EXPECT_NE(document->focusedElement(), static_cast<WebCore::Element*>(textAre
      aElement)); | 
| 1870     inputElement->setValue("testB3"); | 1872     inputElement->setValue("testB3"); | 
| 1871     EXPECT_FALSE(client.textIsUpdated()); | 1873     EXPECT_FALSE(client.textIsUpdated()); | 
| 1872 } | 1874 } | 
| 1873 | 1875 | 
| 1874 } // namespace | 1876 } // namespace | 
| OLD | NEW | 
|---|