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

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

Issue 1113973002: Remove FrameView::m_inProgrammaticScroll and related plumbing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698