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

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

Issue 225303014: [Pinch-to-zoom] Moved scale factor into PinchViewport (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed layout test breakage Created 6 years, 8 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 <gtest/gtest.h> 3 #include <gtest/gtest.h>
4 #include "FrameTestHelpers.h" 4 #include "FrameTestHelpers.h"
5 #include "URLTestHelpers.h" 5 #include "URLTestHelpers.h"
6 #include "WebFrame.h" 6 #include "WebFrame.h"
7 #include "WebFrameClient.h" 7 #include "WebFrameClient.h"
8 #include "WebFrameImpl.h" 8 #include "WebFrameImpl.h"
9 #include "WebHistoryItem.h" 9 #include "WebHistoryItem.h"
10 #include "WebInputEvent.h" 10 #include "WebInputEvent.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 FrameTestHelpers::WebViewHelper webViewHelper; 55 FrameTestHelpers::WebViewHelper webViewHelper;
56 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll. html", true, 0, 0); 56 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll. html", true, 0, 0);
57 webView->resize(WebSize(1000, 1000)); 57 webView->resize(WebSize(1000, 1000));
58 webView->layout(); 58 webView->layout();
59 59
60 WebViewImpl* webViewImpl = toWebViewImpl(webView); 60 WebViewImpl* webViewImpl = toWebViewImpl(webView);
61 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); 61 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame();
62 frame->loader().setLoadType(FrameLoadTypeBackForward); 62 frame->loader().setLoadType(FrameLoadTypeBackForward);
63 63
64 webViewImpl->setPageScaleFactor(3.0f, WebPoint(0, 500)); 64 webViewImpl->setPageScaleFactor(3.0f);
65 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 500));
65 frame->view()->setWasScrolledByUser(false); 66 frame->view()->setWasScrolledByUser(false);
66 frame->loader().currentItem()->setPageScaleFactor(2); 67 frame->loader().currentItem()->setPageScaleFactor(2);
67 frame->loader().currentItem()->setScrollPoint(WebPoint(0, 200)); 68 frame->loader().currentItem()->setScrollPoint(WebPoint(0, 200));
68 69
69 // Flip back the wasScrolledByUser flag which was set to true by setPageScal eFactor 70 // Flip back the wasScrolledByUser flag which was set to true by setPageScal eFactor
70 // because otherwise FrameLoader::restoreScrollPositionAndViewState does not hing. 71 // because otherwise FrameLoader::restoreScrollPositionAndViewState does not hing.
71 frame->view()->setWasScrolledByUser(false); 72 frame->view()->setWasScrolledByUser(false);
72 frame->loader().restoreScrollPositionAndViewState(); 73 frame->loader().restoreScrollPositionAndViewState();
73 74
74 // Expect that both scroll and scale were restored, and that it was not a pr ogrammatic scroll. 75 // Expect that both scroll and scale were restored, and that it was not a pr ogrammatic scroll.
75 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 76 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
76 EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); 77 EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height);
77 EXPECT_TRUE(frame->view()->wasScrolledByUser()); 78 EXPECT_TRUE(frame->view()->wasScrolledByUser());
78 } 79 }
79 80
80 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) 81 TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale)
81 { 82 {
82 registerMockedHttpURLLoad("long_scroll.html"); 83 registerMockedHttpURLLoad("long_scroll.html");
83 84
84 FrameTestHelpers::WebViewHelper webViewHelper; 85 FrameTestHelpers::WebViewHelper webViewHelper;
85 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll. html", true, 0, 0); 86 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll. html", true, 0, 0);
86 webView->resize(WebSize(1000, 1000)); 87 webView->resize(WebSize(1000, 1000));
87 webView->layout(); 88 webView->layout();
88 89
89 WebViewImpl* webViewImpl = toWebViewImpl(webView); 90 WebViewImpl* webViewImpl = toWebViewImpl(webView);
90 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame(); 91 LocalFrame* frame = webViewImpl->mainFrameImpl()->frame();
91 frame->loader().setLoadType(FrameLoadTypeBackForward); 92 frame->loader().setLoadType(FrameLoadTypeBackForward);
92 93
93 webViewImpl->setPageScaleFactor(3.0f, WebPoint(0, 500)); 94 webViewImpl->setPageScaleFactor(3.0f);
95 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 500));
94 frame->view()->setWasScrolledByUser(false); 96 frame->view()->setWasScrolledByUser(false);
95 frame->loader().currentItem()->setPageScaleFactor(0); 97 frame->loader().currentItem()->setPageScaleFactor(0);
96 frame->loader().currentItem()->setScrollPoint(WebPoint(0, 400)); 98 frame->loader().currentItem()->setScrollPoint(WebPoint(0, 400));
97 99
98 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale is zero. 100 // FrameLoader::restoreScrollPositionAndViewState flows differently if scale is zero.
99 frame->loader().restoreScrollPositionAndViewState(); 101 frame->loader().restoreScrollPositionAndViewState();
100 102
101 // Expect that only the scroll position was restored, and that it was not a programmatic scroll. 103 // Expect that only the scroll position was restored, and that it was not a programmatic scroll.
102 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); 104 EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor());
103 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); 105 EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height);
104 EXPECT_TRUE(frame->view()->wasScrolledByUser()); 106 EXPECT_TRUE(frame->view()->wasScrolledByUser());
105 } 107 }
106 108
107 } 109 }
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