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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 baseURL); 798 baseURL);
799 webViewImpl->setInitialFocus(false); 799 webViewImpl->setInitialFocus(false);
800 800
801 // Add id="foo" to <path>, thus triggering the condition described above. 801 // Add id="foo" to <path>, thus triggering the condition described above.
802 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 802 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
803 document->body() 803 document->body()
804 ->querySelector("path", ASSERT_NO_EXCEPTION) 804 ->querySelector("path", ASSERT_NO_EXCEPTION)
805 ->setIdAttribute("foo"); 805 ->setIdAttribute("foo");
806 806
807 // This should not DCHECK. 807 // This should not DCHECK.
808 EXPECT_EQ(WebTextInputTypeText, webViewImpl->mainFrameImpl() 808 EXPECT_EQ(WebTextInputTypeText,
809 ->inputMethodController() 809 webViewImpl->mainFrameImpl()
810 ->textInputInfo() 810 ->inputMethodController()
811 .type); 811 ->textInputInfo()
812 .type);
812 } 813 }
813 814
814 void WebViewTest::testInputMode(WebTextInputMode expectedInputMode, 815 void WebViewTest::testInputMode(WebTextInputMode expectedInputMode,
815 const std::string& htmlFile) { 816 const std::string& htmlFile) {
816 registerMockedHttpURLLoad(htmlFile); 817 registerMockedHttpURLLoad(htmlFile);
817 WebViewImpl* webViewImpl = 818 WebViewImpl* webViewImpl =
818 m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile); 819 m_webViewHelper.initializeAndLoad(m_baseURL + htmlFile);
819 webViewImpl->setInitialFocus(false); 820 webViewImpl->setInitialFocus(false);
820 EXPECT_EQ(expectedInputMode, webViewImpl->mainFrameImpl() 821 EXPECT_EQ(expectedInputMode,
821 ->inputMethodController() 822 webViewImpl->mainFrameImpl()
822 ->textInputInfo() 823 ->inputMethodController()
823 .inputMode); 824 ->textInputInfo()
825 .inputMode);
824 } 826 }
825 827
826 TEST_P(WebViewTest, InputMode) { 828 TEST_P(WebViewTest, InputMode) {
827 testInputMode(WebTextInputMode::kWebTextInputModeDefault, 829 testInputMode(WebTextInputMode::kWebTextInputModeDefault,
828 "input_mode_default.html"); 830 "input_mode_default.html");
829 testInputMode(WebTextInputMode::kWebTextInputModeDefault, 831 testInputMode(WebTextInputMode::kWebTextInputModeDefault,
830 "input_mode_default_unknown.html"); 832 "input_mode_default_unknown.html");
831 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, 833 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim,
832 "input_mode_default_verbatim.html"); 834 "input_mode_default_verbatim.html");
833 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim, 835 testInputMode(WebTextInputMode::kWebTextInputModeVerbatim,
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 1669
1668 // Click an anchor 1670 // Click an anchor
1669 mainFrameLocal->loader().load(FrameLoadRequest( 1671 mainFrameLocal->loader().load(FrameLoadRequest(
1670 mainFrameLocal->document(), 1672 mainFrameLocal->document(),
1671 ResourceRequest(mainFrameLocal->document()->completeURL("#a")))); 1673 ResourceRequest(mainFrameLocal->document()->completeURL("#a"))));
1672 Persistent<HistoryItem> item2 = mainFrameLocal->loader().currentItem(); 1674 Persistent<HistoryItem> item2 = mainFrameLocal->loader().currentItem();
1673 1675
1674 // Go back, then forward, then back again. 1676 // Go back, then forward, then back again.
1675 mainFrameLocal->loader().load( 1677 mainFrameLocal->loader().load(
1676 FrameLoadRequest( 1678 FrameLoadRequest(
1677 nullptr, FrameLoader::resourceRequestFromHistoryItem( 1679 nullptr,
1678 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), 1680 FrameLoader::resourceRequestFromHistoryItem(
1681 item1.get(), WebCachePolicy::UseProtocolCachePolicy)),
1679 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); 1682 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1680 mainFrameLocal->loader().load( 1683 mainFrameLocal->loader().load(
1681 FrameLoadRequest( 1684 FrameLoadRequest(
1682 nullptr, FrameLoader::resourceRequestFromHistoryItem( 1685 nullptr,
1683 item2.get(), WebCachePolicy::UseProtocolCachePolicy)), 1686 FrameLoader::resourceRequestFromHistoryItem(
1687 item2.get(), WebCachePolicy::UseProtocolCachePolicy)),
1684 FrameLoadTypeBackForward, item2.get(), HistorySameDocumentLoad); 1688 FrameLoadTypeBackForward, item2.get(), HistorySameDocumentLoad);
1685 mainFrameLocal->loader().load( 1689 mainFrameLocal->loader().load(
1686 FrameLoadRequest( 1690 FrameLoadRequest(
1687 nullptr, FrameLoader::resourceRequestFromHistoryItem( 1691 nullptr,
1688 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), 1692 FrameLoader::resourceRequestFromHistoryItem(
1693 item1.get(), WebCachePolicy::UseProtocolCachePolicy)),
1689 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); 1694 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1690 1695
1691 // Click a different anchor 1696 // Click a different anchor
1692 mainFrameLocal->loader().load(FrameLoadRequest( 1697 mainFrameLocal->loader().load(FrameLoadRequest(
1693 mainFrameLocal->document(), 1698 mainFrameLocal->document(),
1694 ResourceRequest(mainFrameLocal->document()->completeURL("#b")))); 1699 ResourceRequest(mainFrameLocal->document()->completeURL("#b"))));
1695 Persistent<HistoryItem> item3 = mainFrameLocal->loader().currentItem(); 1700 Persistent<HistoryItem> item3 = mainFrameLocal->loader().currentItem();
1696 1701
1697 // Go back, then forward. The scroll position should be properly set on the 1702 // Go back, then forward. The scroll position should be properly set on the
1698 // forward navigation. 1703 // forward navigation.
1699 mainFrameLocal->loader().load( 1704 mainFrameLocal->loader().load(
1700 FrameLoadRequest( 1705 FrameLoadRequest(
1701 nullptr, FrameLoader::resourceRequestFromHistoryItem( 1706 nullptr,
1702 item1.get(), WebCachePolicy::UseProtocolCachePolicy)), 1707 FrameLoader::resourceRequestFromHistoryItem(
1708 item1.get(), WebCachePolicy::UseProtocolCachePolicy)),
1703 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad); 1709 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1704 mainFrameLocal->loader().load( 1710 mainFrameLocal->loader().load(
1705 FrameLoadRequest( 1711 FrameLoadRequest(
1706 nullptr, FrameLoader::resourceRequestFromHistoryItem( 1712 nullptr,
1707 item3.get(), WebCachePolicy::UseProtocolCachePolicy)), 1713 FrameLoader::resourceRequestFromHistoryItem(
1714 item3.get(), WebCachePolicy::UseProtocolCachePolicy)),
1708 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad); 1715 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad);
1709 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width); 1716 EXPECT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().width);
1710 EXPECT_GT(webViewImpl->mainFrame()->getScrollOffset().height, 2000); 1717 EXPECT_GT(webViewImpl->mainFrame()->getScrollOffset().height, 2000);
1711 } 1718 }
1712 1719
1713 // Tests that we restore scroll and scale *after* the fullscreen styles are 1720 // Tests that we restore scroll and scale *after* the fullscreen styles are
1714 // removed and the page is laid out. http://crbug.com/625683. 1721 // removed and the page is laid out. http://crbug.com/625683.
1715 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) { 1722 TEST_P(WebViewTest, FullscreenResetScrollAndScaleFullscreenStyles) {
1716 registerMockedHttpURLLoad("fullscreen_style.html"); 1723 registerMockedHttpURLLoad("fullscreen_style.html");
1717 WebViewImpl* webViewImpl = 1724 WebViewImpl* webViewImpl =
1718 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html"); 1725 m_webViewHelper.initializeAndLoad(m_baseURL + "fullscreen_style.html");
1719 webViewImpl->resize(WebSize(800, 600)); 1726 webViewImpl->resize(WebSize(800, 600));
1720 webViewImpl->updateAllLifecyclePhases(); 1727 webViewImpl->updateAllLifecyclePhases();
1721 1728
1722 // Scroll the page down. 1729 // Scroll the page down.
1723 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000)); 1730 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 2000));
1724 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1731 ASSERT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1725 1732
1726 // Enter fullscreen. 1733 // Enter fullscreen.
1727 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 1734 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
1728 Element* element = document->getElementById("fullscreenElement"); 1735 Element* element = document->getElementById("fullscreenElement");
1729 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 1736 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
1730 Fullscreen::requestFullscreen(*element); 1737 Fullscreen::requestFullscreen(*element);
1731 webViewImpl->didEnterFullscreen(); 1738 webViewImpl->didEnterFullscreen();
1732 webViewImpl->updateAllLifecyclePhases(); 1739 webViewImpl->updateAllLifecyclePhases();
1733 1740
1734 // Sanity-check. There should be no scrolling possible. 1741 // Sanity-check. There should be no scrolling possible.
1735 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1742 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1736 ASSERT_EQ(0, webViewImpl->mainFrameImpl() 1743 ASSERT_EQ(0,
1737 ->frameView() 1744 webViewImpl->mainFrameImpl()
1738 ->maximumScrollOffset() 1745 ->frameView()
1739 .height()); 1746 ->maximumScrollOffset()
1747 .height());
1740 1748
1741 // Confirm that after exiting and doing a layout, the scroll and scale 1749 // Confirm that after exiting and doing a layout, the scroll and scale
1742 // parameters are reset. The page sets display: none on overflowing elements 1750 // parameters are reset. The page sets display: none on overflowing elements
1743 // while in fullscreen so if we try to restore before the style and layout 1751 // while in fullscreen so if we try to restore before the style and layout
1744 // is applied the offsets will be clamped. 1752 // is applied the offsets will be clamped.
1745 webViewImpl->didExitFullscreen(); 1753 webViewImpl->didExitFullscreen();
1746 EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout()); 1754 EXPECT_TRUE(webViewImpl->mainFrameImpl()->frameView()->needsLayout());
1747 webViewImpl->updateAllLifecyclePhases(); 1755 webViewImpl->updateAllLifecyclePhases();
1748 1756
1749 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1757 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
(...skipping 15 matching lines...) Expand all
1765 // Enter fullscreen. 1773 // Enter fullscreen.
1766 Document* document = webViewImpl->mainFrameImpl()->frame()->document(); 1774 Document* document = webViewImpl->mainFrameImpl()->frame()->document();
1767 Element* element = document->getElementById("fullscreenElement"); 1775 Element* element = document->getElementById("fullscreenElement");
1768 UserGestureIndicator gesture(DocumentUserGestureToken::create(document)); 1776 UserGestureIndicator gesture(DocumentUserGestureToken::create(document));
1769 Fullscreen::requestFullscreen(*element); 1777 Fullscreen::requestFullscreen(*element);
1770 webViewImpl->didEnterFullscreen(); 1778 webViewImpl->didEnterFullscreen();
1771 webViewImpl->updateAllLifecyclePhases(); 1779 webViewImpl->updateAllLifecyclePhases();
1772 1780
1773 // Sanity-check. There should be no scrolling possible. 1781 // Sanity-check. There should be no scrolling possible.
1774 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1782 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1775 ASSERT_EQ(0, webViewImpl->mainFrameImpl() 1783 ASSERT_EQ(0,
1776 ->frameView() 1784 webViewImpl->mainFrameImpl()
1777 ->maximumScrollOffset() 1785 ->frameView()
1778 .height()); 1786 ->maximumScrollOffset()
1787 .height());
1779 1788
1780 // Exit and, without performing a layout, reenter fullscreen again. We 1789 // Exit and, without performing a layout, reenter fullscreen again. We
1781 // shouldn't try to restore the scroll and scale values when we layout to 1790 // shouldn't try to restore the scroll and scale values when we layout to
1782 // enter fullscreen. 1791 // enter fullscreen.
1783 webViewImpl->didExitFullscreen(); 1792 webViewImpl->didExitFullscreen();
1784 Fullscreen::requestFullscreen(*element); 1793 Fullscreen::requestFullscreen(*element);
1785 webViewImpl->didEnterFullscreen(); 1794 webViewImpl->didEnterFullscreen();
1786 webViewImpl->updateAllLifecyclePhases(); 1795 webViewImpl->updateAllLifecyclePhases();
1787 1796
1788 // Sanity-check. There should be no scrolling possible. 1797 // Sanity-check. There should be no scrolling possible.
1789 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height); 1798 ASSERT_EQ(0, webViewImpl->mainFrame()->getScrollOffset().height);
1790 ASSERT_EQ(0, webViewImpl->mainFrameImpl() 1799 ASSERT_EQ(0,
1791 ->frameView() 1800 webViewImpl->mainFrameImpl()
1792 ->maximumScrollOffset() 1801 ->frameView()
1793 .height()); 1802 ->maximumScrollOffset()
1803 .height());
1794 1804
1795 // When we exit now, we should restore the original scroll value. 1805 // When we exit now, we should restore the original scroll value.
1796 webViewImpl->didExitFullscreen(); 1806 webViewImpl->didExitFullscreen();
1797 webViewImpl->updateAllLifecyclePhases(); 1807 webViewImpl->updateAllLifecyclePhases();
1798 1808
1799 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height); 1809 EXPECT_EQ(2000, webViewImpl->mainFrame()->getScrollOffset().height);
1800 } 1810 }
1801 1811
1802 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) { 1812 TEST_P(WebViewTest, EnterFullscreenResetScrollAndScaleState) {
1803 registerMockedHttpURLLoad("200-by-300.html"); 1813 registerMockedHttpURLLoad("200-by-300.html");
(...skipping 2531 matching lines...) Expand 10 before | Expand all | Expand 10 after
4335 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars()); 4345 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars());
4336 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 4346 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
4337 EXPECT_NE(nullptr, 4347 EXPECT_NE(nullptr,
4338 frameView->layoutViewportScrollableArea()->verticalScrollbar()); 4348 frameView->layoutViewportScrollableArea()->verticalScrollbar());
4339 } else { 4349 } else {
4340 EXPECT_NE(nullptr, frameView->verticalScrollbar()); 4350 EXPECT_NE(nullptr, frameView->verticalScrollbar());
4341 } 4351 }
4342 } 4352 }
4343 4353
4344 } // namespace blink 4354 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/WebPluginContainerTest.cpp ('k') | third_party/WebKit/Source/wtf/DateMath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698