OLD | NEW |
---|---|
1 #include "core/frame/FrameView.h" | 1 #include "core/frame/FrameView.h" |
2 #include "core/loader/DocumentLoader.h" | 2 #include "core/loader/DocumentLoader.h" |
3 #include "core/loader/FrameLoader.h" | 3 #include "core/loader/FrameLoader.h" |
4 #include "platform/testing/URLTestHelpers.h" | 4 #include "platform/testing/URLTestHelpers.h" |
5 #include "platform/testing/UnitTestHelpers.h" | |
5 #include "public/platform/Platform.h" | 6 #include "public/platform/Platform.h" |
6 #include "public/platform/WebInputEvent.h" | 7 #include "public/platform/WebInputEvent.h" |
7 #include "public/platform/WebURLLoaderMockFactory.h" | 8 #include "public/platform/WebURLLoaderMockFactory.h" |
8 #include "public/web/WebCache.h" | 9 #include "public/web/WebCache.h" |
9 #include "public/web/WebFrame.h" | 10 #include "public/web/WebFrame.h" |
10 #include "public/web/WebFrameClient.h" | 11 #include "public/web/WebFrameClient.h" |
11 #include "public/web/WebHistoryItem.h" | 12 #include "public/web/WebHistoryItem.h" |
12 #include "public/web/WebScriptSource.h" | 13 #include "public/web/WebScriptSource.h" |
13 #include "public/web/WebSettings.h" | 14 #include "public/web/WebSettings.h" |
14 #include "public/web/WebView.h" | 15 #include "public/web/WebView.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "web/WebLocalFrameImpl.h" | 17 #include "web/WebLocalFrameImpl.h" |
17 #include "web/WebViewImpl.h" | 18 #include "web/WebViewImpl.h" |
18 #include "web/tests/FrameTestHelpers.h" | 19 #include "web/tests/FrameTestHelpers.h" |
19 | 20 |
20 namespace blink { | 21 namespace blink { |
21 | 22 |
22 class ProgrammaticScrollTest : public testing::Test { | 23 class ProgrammaticScrollTest : public ::testing::Test { |
23 public: | 24 public: |
24 ProgrammaticScrollTest() : m_baseURL("http://www.test.com/") {} | 25 ProgrammaticScrollTest() : m_baseURL("http://www.test.com/") {} |
25 | 26 |
26 void TearDown() override { | 27 void TearDown() override { |
27 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 28 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
28 WebCache::clear(); | 29 WebCache::clear(); |
29 } | 30 } |
30 | 31 |
31 protected: | 32 protected: |
32 void registerMockedHttpURLLoad(const std::string& fileName) { | 33 void registerMockedHttpURLLoad(const std::string& fileName) { |
33 URLTestHelpers::registerMockedURLFromBaseURL( | 34 URLTestHelpers::registerMockedURLLoadFromBase( |
34 WebString::fromUTF8(m_baseURL.c_str()), | 35 WebString::fromUTF8(m_baseURL.c_str()), testing::webTestDataPath(), |
Takashi Toyoshima
2017/01/26 10:57:58
removing c_str
| |
35 WebString::fromUTF8(fileName.c_str())); | 36 WebString::fromUTF8(fileName.c_str())); |
36 } | 37 } |
37 | 38 |
38 std::string m_baseURL; | 39 std::string m_baseURL; |
39 FrameTestHelpers::TestWebFrameClient m_mockWebFrameClient; | 40 FrameTestHelpers::TestWebFrameClient m_mockWebFrameClient; |
40 }; | 41 }; |
41 | 42 |
42 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) { | 43 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) { |
43 registerMockedHttpURLLoad("long_scroll.html"); | 44 registerMockedHttpURLLoad("long_scroll.html"); |
44 | 45 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale | 92 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale |
92 // is zero. | 93 // is zero. |
93 loader.restoreScrollPositionAndViewState(); | 94 loader.restoreScrollPositionAndViewState(); |
94 | 95 |
95 // Expect that only the scroll position was restored. | 96 // Expect that only the scroll position was restored. |
96 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); | 97 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); |
97 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->getScrollOffset().height); | 98 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->getScrollOffset().height); |
98 } | 99 } |
99 | 100 |
100 } // namespace blink | 101 } // namespace blink |
OLD | NEW |