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

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

Issue 1163433003: Remove WebViewImpl helper methods for setting scroll offset. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Renamed outerViewport to layoutViewport Created 5 years, 6 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/tests/WebFrameTest.cpp ('k') | public/web/WebWidget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 { 1151 {
1152 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("200-by-300.html")); 1152 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("200-by-300.html"));
1153 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "20 0-by-300.html"); 1153 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "20 0-by-300.html");
1154 webViewImpl->resize(WebSize(100, 150)); 1154 webViewImpl->resize(WebSize(100, 150));
1155 webViewImpl->layout(); 1155 webViewImpl->layout();
1156 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 1156 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
1157 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 1157 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
1158 1158
1159 // Make the page scale and scroll with the given paremeters. 1159 // Make the page scale and scroll with the given paremeters.
1160 webViewImpl->setPageScaleFactor(2.0f); 1160 webViewImpl->setPageScaleFactor(2.0f);
1161 webViewImpl->setMainFrameScrollOffset(WebPoint(94, 111)); 1161 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111));
1162 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 1162 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
1163 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width); 1163 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width);
1164 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height); 1164 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height);
1165 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame()); 1165 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame());
1166 mainFrameLocal->loader().saveScrollState(); 1166 mainFrameLocal->loader().saveScrollState();
1167 EXPECT_EQ(2.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); 1167 EXPECT_EQ(2.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor());
1168 EXPECT_EQ(94, mainFrameLocal->loader().currentItem()->scrollPoint().x()); 1168 EXPECT_EQ(94, mainFrameLocal->loader().currentItem()->scrollPoint().x());
1169 EXPECT_EQ(111, mainFrameLocal->loader().currentItem()->scrollPoint().y()); 1169 EXPECT_EQ(111, mainFrameLocal->loader().currentItem()->scrollPoint().y());
1170 1170
1171 // Confirm that resetting the page state resets the saved scroll position. 1171 // Confirm that resetting the page state resets the saved scroll position.
1172 // The HistoryController treats a page scale factor of 0.0f as special and a voids 1172 // The HistoryController treats a page scale factor of 0.0f as special and a voids
1173 // restoring it to the WebView. 1173 // restoring it to the WebView.
1174 webViewImpl->resetScrollAndScaleState(); 1174 webViewImpl->resetScrollAndScaleState();
1175 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); 1175 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor());
1176 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 1176 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
1177 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 1177 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
1178 EXPECT_EQ(0.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); 1178 EXPECT_EQ(0.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor());
1179 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().x()); 1179 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().x());
1180 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().y()); 1180 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().y());
1181 } 1181 }
1182 1182
1183 TEST_F(WebViewTest, BackForwardRestoreScroll) 1183 TEST_F(WebViewTest, BackForwardRestoreScroll)
1184 { 1184 {
1185 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("back_forward_restore_scroll.html")); 1185 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("back_forward_restore_scroll.html"));
1186 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "ba ck_forward_restore_scroll.html"); 1186 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "ba ck_forward_restore_scroll.html");
1187 webViewImpl->resize(WebSize(640, 480)); 1187 webViewImpl->resize(WebSize(640, 480));
1188 webViewImpl->layout(); 1188 webViewImpl->layout();
1189 1189
1190 // Emulate a user scroll 1190 // Emulate a user scroll
1191 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 900)); 1191 webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 900));
1192 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame()); 1192 LocalFrame* mainFrameLocal = toLocalFrame(webViewImpl->page()->mainFrame());
1193 RefPtrWillBePersistent<HistoryItem> item1 = mainFrameLocal->loader().current Item(); 1193 RefPtrWillBePersistent<HistoryItem> item1 = mainFrameLocal->loader().current Item();
1194 1194
1195 // Click an anchor 1195 // Click an anchor
1196 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#a")))); 1196 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#a"))));
1197 RefPtrWillBePersistent<HistoryItem> item2 = mainFrameLocal->loader().current Item(); 1197 RefPtrWillBePersistent<HistoryItem> item2 = mainFrameLocal->loader().current Item();
1198 1198
1199 // Go back, then forward, then back again. 1199 // Go back, then forward, then back again.
1200 mainFrameLocal->loader().loadHistoryItem(item1.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad); 1200 mainFrameLocal->loader().loadHistoryItem(item1.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad);
1201 mainFrameLocal->loader().loadHistoryItem(item2.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad); 1201 mainFrameLocal->loader().loadHistoryItem(item2.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad);
(...skipping 15 matching lines...) Expand all
1217 FrameTestHelpers::TestWebViewClient client; 1217 FrameTestHelpers::TestWebViewClient client;
1218 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("200-by-300.html")); 1218 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("200-by-300.html"));
1219 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "20 0-by-300.html", true, 0, &client); 1219 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "20 0-by-300.html", true, 0, &client);
1220 webViewImpl->resize(WebSize(100, 150)); 1220 webViewImpl->resize(WebSize(100, 150));
1221 webViewImpl->layout(); 1221 webViewImpl->layout();
1222 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 1222 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
1223 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); 1223 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height);
1224 1224
1225 // Make the page scale and scroll with the given paremeters. 1225 // Make the page scale and scroll with the given paremeters.
1226 webViewImpl->setPageScaleFactor(2.0f); 1226 webViewImpl->setPageScaleFactor(2.0f);
1227 webViewImpl->setMainFrameScrollOffset(WebPoint(94, 111)); 1227 webViewImpl->mainFrame()->setScrollOffset(WebSize(94, 111));
1228 webViewImpl->setPinchViewportOffset(WebFloatPoint(12, 20)); 1228 webViewImpl->setPinchViewportOffset(WebFloatPoint(12, 20));
1229 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); 1229 EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor());
1230 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width); 1230 EXPECT_EQ(94, webViewImpl->mainFrame()->scrollOffset().width);
1231 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height); 1231 EXPECT_EQ(111, webViewImpl->mainFrame()->scrollOffset().height);
1232 EXPECT_EQ(12, webViewImpl->pinchViewportOffset().x); 1232 EXPECT_EQ(12, webViewImpl->pinchViewportOffset().x);
1233 EXPECT_EQ(20, webViewImpl->pinchViewportOffset().y); 1233 EXPECT_EQ(20, webViewImpl->pinchViewportOffset().y);
1234 1234
1235 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele ment>>(webViewImpl->mainFrame()->document().body()); 1235 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele ment>>(webViewImpl->mainFrame()->document().body());
1236 webViewImpl->enterFullScreenForElement(element.get()); 1236 webViewImpl->enterFullScreenForElement(element.get());
1237 webViewImpl->didEnterFullScreen(); 1237 webViewImpl->didEnterFullScreen();
(...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after
3019 for (size_t i = 0; i < renders.size(); ++i) { 3019 for (size_t i = 0; i < renders.size(); ++i) {
3020 double docStartTime = frame->domWindow()->document()->loader()->timing() .monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; 3020 double docStartTime = frame->domWindow()->document()->loader()->timing() .monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0;
3021 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); 3021 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime());
3022 double docFinishTime = frame->domWindow()->document()->loader()->timing( ).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; 3022 double docFinishTime = frame->domWindow()->document()->loader()->timing( ).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0;
3023 double docDuration = docFinishTime - docStartTime; 3023 double docDuration = docFinishTime - docStartTime;
3024 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); 3024 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration());
3025 } 3025 }
3026 } 3026 }
3027 3027
3028 } // namespace 3028 } // namespace
OLDNEW
« no previous file with comments | « Source/web/tests/WebFrameTest.cpp ('k') | public/web/WebWidget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698