| OLD | NEW |
| 1 #include "core/frame/FrameView.h" | 1 #include "core/frame/FrameView.h" |
| 2 #include "core/layout/LayoutView.h" | 2 #include "core/layout/LayoutView.h" |
| 3 #include "core/loader/DocumentLoader.h" | 3 #include "core/loader/DocumentLoader.h" |
| 4 #include "core/loader/FrameLoader.h" | 4 #include "core/loader/FrameLoader.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" |
| 11 #include "public/web/WebInputEvent.h" | 11 #include "public/web/WebInputEvent.h" |
| 12 #include "public/web/WebScriptSource.h" | 12 #include "public/web/WebScriptSource.h" |
| 13 #include "public/web/WebSettings.h" | 13 #include "public/web/WebSettings.h" |
| 14 #include "public/web/WebView.h" | 14 #include "public/web/WebView.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "web/WebLocalFrameImpl.h" | 16 #include "web/WebLocalFrameImpl.h" |
| 17 #include "web/WebViewImpl.h" | 17 #include "web/WebViewImpl.h" |
| 18 #include "web/tests/FrameTestHelpers.h" | 18 #include "web/tests/FrameTestHelpers.h" |
| 19 | 19 |
| 20 namespace blink { | 20 namespace blink { |
| 21 | 21 |
| 22 class MockWebFrameClient : public WebFrameClient { | |
| 23 }; | |
| 24 | |
| 25 class ProgrammaticScrollTest : public testing::Test { | 22 class ProgrammaticScrollTest : public testing::Test { |
| 26 public: | 23 public: |
| 27 ProgrammaticScrollTest() | 24 ProgrammaticScrollTest() |
| 28 : m_baseURL("http://www.test.com/") | 25 : m_baseURL("http://www.test.com/") |
| 29 { | 26 { |
| 30 } | 27 } |
| 31 | 28 |
| 32 void TearDown() override | 29 void TearDown() override |
| 33 { | 30 { |
| 34 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 31 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); |
| 35 } | 32 } |
| 36 | 33 |
| 37 protected: | 34 protected: |
| 38 | 35 |
| 39 void registerMockedHttpURLLoad(const std::string& fileName) | 36 void registerMockedHttpURLLoad(const std::string& fileName) |
| 40 { | 37 { |
| 41 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 38 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
| 42 } | 39 } |
| 43 | 40 |
| 44 std::string m_baseURL; | 41 std::string m_baseURL; |
| 45 MockWebFrameClient m_mockWebFrameClient; | 42 FrameTestHelpers::TestWebFrameClient m_mockWebFrameClient; |
| 46 }; | 43 }; |
| 47 | 44 |
| 48 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) | 45 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) |
| 49 { | 46 { |
| 50 registerMockedHttpURLLoad("long_scroll.html"); | 47 registerMockedHttpURLLoad("long_scroll.html"); |
| 51 | 48 |
| 52 FrameTestHelpers::WebViewHelper webViewHelper; | 49 FrameTestHelpers::WebViewHelper webViewHelper; |
| 53 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.
html", true, 0, 0); | 50 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.
html", true, 0, 0); |
| 54 webView->resize(WebSize(1000, 1000)); | 51 webView->resize(WebSize(1000, 1000)); |
| 55 webView->updateAllLifecyclePhases(); | 52 webView->updateAllLifecyclePhases(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 92 |
| 96 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale
is zero. | 93 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale
is zero. |
| 97 loader.restoreScrollPositionAndViewState(); | 94 loader.restoreScrollPositionAndViewState(); |
| 98 | 95 |
| 99 // Expect that only the scroll position was restored. | 96 // Expect that only the scroll position was restored. |
| 100 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); | 97 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); |
| 101 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); | 98 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); |
| 102 } | 99 } |
| 103 | 100 |
| 104 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |