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

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

Issue 1156473002: Refactor FrameLoader loading interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressed comments 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
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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 // Emulate a user scroll 1190 // Emulate a user scroll
1191 webViewImpl->setMainFrameScrollOffset(WebPoint(0, 900)); 1191 webViewImpl->setMainFrameScrollOffset(WebPoint(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().load(
1201 mainFrameLocal->loader().loadHistoryItem(item2.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad); 1201 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1202 mainFrameLocal->loader().loadHistoryItem(item1.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad); 1202 item1.get(), UseProtocolCachePolicy)),
1203 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1204 mainFrameLocal->loader().load(
1205 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1206 item2.get(), UseProtocolCachePolicy)),
1207 FrameLoadTypeBackForward, item2.get(), HistorySameDocumentLoad);
1208 mainFrameLocal->loader().load(
1209 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1210 item1.get(), UseProtocolCachePolicy)),
1211 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1203 1212
1204 // Click a different anchor 1213 // Click a different anchor
1205 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#b")))); 1214 mainFrameLocal->loader().load(FrameLoadRequest(mainFrameLocal->document(), R esourceRequest(mainFrameLocal->document()->completeURL("#b"))));
1206 RefPtrWillBePersistent<HistoryItem> item3 = mainFrameLocal->loader().current Item(); 1215 RefPtrWillBePersistent<HistoryItem> item3 = mainFrameLocal->loader().current Item();
1207 1216
1208 // Go back, then forward. The scroll position should be properly set on the forward navigation. 1217 // Go back, then forward. The scroll position should be properly set on the forward navigation.
1209 mainFrameLocal->loader().loadHistoryItem(item1.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad); 1218 mainFrameLocal->loader().load(
1210 mainFrameLocal->loader().loadHistoryItem(item3.get(), FrameLoadTypeBackForwa rd, HistorySameDocumentLoad); 1219 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1220 item1.get(), UseProtocolCachePolicy)),
1221 FrameLoadTypeBackForward, item1.get(), HistorySameDocumentLoad);
1222 mainFrameLocal->loader().load(
1223 FrameLoadRequest(nullptr, FrameLoader::resourceRequestFromHistoryItem(
1224 item3.get(), UseProtocolCachePolicy)),
1225 FrameLoadTypeBackForward, item3.get(), HistorySameDocumentLoad);
1211 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); 1226 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width);
1212 EXPECT_GT(webViewImpl->mainFrame()->scrollOffset().height, 2000); 1227 EXPECT_GT(webViewImpl->mainFrame()->scrollOffset().height, 2000);
1213 } 1228 }
1214 1229
1215 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState) 1230 TEST_F(WebViewTest, EnterFullscreenResetScrollAndScaleState)
1216 { 1231 {
1217 FrameTestHelpers::TestWebViewClient client; 1232 FrameTestHelpers::TestWebViewClient client;
1218 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("200-by-300.html")); 1233 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); 1234 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "20 0-by-300.html", true, 0, &client);
1220 webViewImpl->resize(WebSize(100, 150)); 1235 webViewImpl->resize(WebSize(100, 150));
(...skipping 1798 matching lines...) Expand 10 before | Expand all | Expand 10 after
3019 for (size_t i = 0; i < renders.size(); ++i) { 3034 for (size_t i = 0; i < renders.size(); ++i) {
3020 double docStartTime = frame->domWindow()->document()->loader()->timing() .monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; 3035 double docStartTime = frame->domWindow()->document()->loader()->timing() .monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0;
3021 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); 3036 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime());
3022 double docFinishTime = frame->domWindow()->document()->loader()->timing( ).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; 3037 double docFinishTime = frame->domWindow()->document()->loader()->timing( ).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0;
3023 double docDuration = docFinishTime - docStartTime; 3038 double docDuration = docFinishTime - docStartTime;
3024 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); 3039 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration());
3025 } 3040 }
3026 } 3041 }
3027 3042
3028 } // namespace 3043 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698