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

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

Issue 2384033002: reflow comments in web/tests (Closed)
Patch Set: comments (heh!) Created 4 years, 2 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 #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 "public/platform/Platform.h" 5 #include "public/platform/Platform.h"
6 #include "public/platform/WebURLLoaderMockFactory.h" 6 #include "public/platform/WebURLLoaderMockFactory.h"
7 #include "public/web/WebCache.h" 7 #include "public/web/WebCache.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 WebViewImpl* webViewImpl = toWebViewImpl(webView); 51 WebViewImpl* webViewImpl = toWebViewImpl(webView);
52 FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); 52 FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader();
53 loader.setLoadType(FrameLoadTypeBackForward); 53 loader.setLoadType(FrameLoadTypeBackForward);
54 54
55 webViewImpl->setPageScaleFactor(3.0f); 55 webViewImpl->setPageScaleFactor(3.0f);
56 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); 56 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500));
57 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; 57 loader.documentLoader()->initialScrollState().wasScrolledByUser = false;
58 loader.currentItem()->setPageScaleFactor(2); 58 loader.currentItem()->setPageScaleFactor(2);
59 loader.currentItem()->setScrollPoint(WebPoint(0, 200)); 59 loader.currentItem()->setScrollPoint(WebPoint(0, 200));
60 60
61 // Flip back the wasScrolledByUser flag which was set to true by setPageScaleF actor 61 // Flip back the wasScrolledByUser flag which was set to true by
62 // because otherwise FrameLoader::restoreScrollPositionAndViewState does nothi ng. 62 // setPageScaleFactor because otherwise
63 // FrameLoader::restoreScrollPositionAndViewState does nothing.
63 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; 64 loader.documentLoader()->initialScrollState().wasScrolledByUser = false;
64 loader.restoreScrollPositionAndViewState(); 65 loader.restoreScrollPositionAndViewState();
65 66
66 // Expect that both scroll and scale were restored. 67 // Expect that both scroll and scale were restored.
67 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 68 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
68 EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); 69 EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height);
69 } 70 }
70 71
71 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) { 72 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) {
72 registerMockedHttpURLLoad("long_scroll.html"); 73 registerMockedHttpURLLoad("long_scroll.html");
73 74
74 FrameTestHelpers::WebViewHelper webViewHelper; 75 FrameTestHelpers::WebViewHelper webViewHelper;
75 WebView* webView = webViewHelper.initializeAndLoad( 76 WebView* webView = webViewHelper.initializeAndLoad(
76 m_baseURL + "long_scroll.html", true, 0, 0); 77 m_baseURL + "long_scroll.html", true, 0, 0);
77 webView->resize(WebSize(1000, 1000)); 78 webView->resize(WebSize(1000, 1000));
78 webView->updateAllLifecyclePhases(); 79 webView->updateAllLifecyclePhases();
79 80
80 WebViewImpl* webViewImpl = toWebViewImpl(webView); 81 WebViewImpl* webViewImpl = toWebViewImpl(webView);
81 FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); 82 FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader();
82 loader.setLoadType(FrameLoadTypeBackForward); 83 loader.setLoadType(FrameLoadTypeBackForward);
83 84
84 webViewImpl->setPageScaleFactor(3.0f); 85 webViewImpl->setPageScaleFactor(3.0f);
85 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); 86 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500));
86 loader.documentLoader()->initialScrollState().wasScrolledByUser = false; 87 loader.documentLoader()->initialScrollState().wasScrolledByUser = false;
87 loader.currentItem()->setPageScaleFactor(0); 88 loader.currentItem()->setPageScaleFactor(0);
88 loader.currentItem()->setScrollPoint(WebPoint(0, 400)); 89 loader.currentItem()->setScrollPoint(WebPoint(0, 400));
89 90
90 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale i s zero. 91 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale
92 // is zero.
91 loader.restoreScrollPositionAndViewState(); 93 loader.restoreScrollPositionAndViewState();
92 94
93 // Expect that only the scroll position was restored. 95 // Expect that only the scroll position was restored.
94 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); 96 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor());
95 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); 97 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height);
96 } 98 }
97 99
98 } // namespace blink 100 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/PrerenderingTest.cpp ('k') | third_party/WebKit/Source/web/tests/RootScrollerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698