| OLD | NEW |
| 1 #include "config.h" | 1 #include "config.h" |
| 2 | 2 |
| 3 #include "core/frame/FrameView.h" | 3 #include "core/frame/FrameView.h" |
| 4 #include "core/layout/LayoutView.h" | 4 #include "core/layout/LayoutView.h" |
| 5 #include "platform/testing/URLTestHelpers.h" | 5 #include "platform/testing/URLTestHelpers.h" |
| 6 #include "public/platform/Platform.h" | 6 #include "public/platform/Platform.h" |
| 7 #include "public/platform/WebUnitTestSupport.h" | 7 #include "public/platform/WebUnitTestSupport.h" |
| 8 #include "public/web/WebFrame.h" | 8 #include "public/web/WebFrame.h" |
| 9 #include "public/web/WebFrameClient.h" | 9 #include "public/web/WebFrameClient.h" |
| 10 #include "public/web/WebHistoryItem.h" | 10 #include "public/web/WebHistoryItem.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 500)); | 64 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 500)); |
| 65 frame->view()->setWasScrolledByUser(false); | 65 frame->view()->setWasScrolledByUser(false); |
| 66 frame->loader().currentItem()->setPageScaleFactor(2); | 66 frame->loader().currentItem()->setPageScaleFactor(2); |
| 67 frame->loader().currentItem()->setScrollPoint(WebPoint(0, 200)); | 67 frame->loader().currentItem()->setScrollPoint(WebPoint(0, 200)); |
| 68 | 68 |
| 69 // Flip back the wasScrolledByUser flag which was set to true by setPageScal
eFactor | 69 // Flip back the wasScrolledByUser flag which was set to true by setPageScal
eFactor |
| 70 // because otherwise FrameLoader::restoreScrollPositionAndViewState does not
hing. | 70 // because otherwise FrameLoader::restoreScrollPositionAndViewState does not
hing. |
| 71 frame->view()->setWasScrolledByUser(false); | 71 frame->view()->setWasScrolledByUser(false); |
| 72 frame->loader().restoreScrollPositionAndViewState(); | 72 frame->loader().restoreScrollPositionAndViewState(); |
| 73 | 73 |
| 74 // Expect that both scroll and scale were restored, and that it was not a pr
ogrammatic scroll. | 74 // Expect that both scroll and scale were restored. |
| 75 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); | 75 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); |
| 76 EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); | 76 EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); |
| 77 EXPECT_TRUE(frame->view()->wasScrolledByUser()); | |
| 78 } | 77 } |
| 79 | 78 |
| 80 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) | 79 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) |
| 81 { | 80 { |
| 82 registerMockedHttpURLLoad("long_scroll.html"); | 81 registerMockedHttpURLLoad("long_scroll.html"); |
| 83 | 82 |
| 84 FrameTestHelpers::WebViewHelper webViewHelper; | 83 FrameTestHelpers::WebViewHelper webViewHelper; |
| 85 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.
html", true, 0, 0); | 84 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.
html", true, 0, 0); |
| 86 webView->resize(WebSize(1000, 1000)); | 85 webView->resize(WebSize(1000, 1000)); |
| 87 webView->layout(); | 86 webView->layout(); |
| 88 | 87 |
| 89 WebViewImpl* webViewImpl = toWebViewImpl(webView); | 88 WebViewImpl* webViewImpl = toWebViewImpl(webView); |
| 90 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); | 89 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); |
| 91 frame->loader().setLoadType(FrameLoadTypeBackForward); | 90 frame->loader().setLoadType(FrameLoadTypeBackForward); |
| 92 | 91 |
| 93 webViewImpl->setPageScaleFactor(3.0f); | 92 webViewImpl->setPageScaleFactor(3.0f); |
| 94 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 500)); | 93 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 500)); |
| 95 frame->view()->setWasScrolledByUser(false); | 94 frame->view()->setWasScrolledByUser(false); |
| 96 frame->loader().currentItem()->setPageScaleFactor(0); | 95 frame->loader().currentItem()->setPageScaleFactor(0); |
| 97 frame->loader().currentItem()->setScrollPoint(WebPoint(0, 400)); | 96 frame->loader().currentItem()->setScrollPoint(WebPoint(0, 400)); |
| 98 | 97 |
| 99 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale
is zero. | 98 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale
is zero. |
| 100 frame->loader().restoreScrollPositionAndViewState(); | 99 frame->loader().restoreScrollPositionAndViewState(); |
| 101 | 100 |
| 102 // Expect that only the scroll position was restored, and that it was not a
programmatic scroll. | 101 // Expect that only the scroll position was restored. |
| 103 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); | 102 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); |
| 104 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); | 103 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); |
| 105 EXPECT_TRUE(frame->view()->wasScrolledByUser()); | |
| 106 } | 104 } |
| 107 | 105 |
| 108 } | 106 } |
| OLD | NEW |