| OLD | NEW |
| 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 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | |
| 1173 // restoring it to the WebView. | |
| 1174 webViewImpl->resetScrollAndScaleState(); | 1172 webViewImpl->resetScrollAndScaleState(); |
| 1175 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); | 1173 EXPECT_EQ(1.0f, webViewImpl->pageScaleFactor()); |
| 1176 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); | 1174 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().width); |
| 1177 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); | 1175 EXPECT_EQ(0, webViewImpl->mainFrame()->scrollOffset().height); |
| 1178 EXPECT_EQ(0.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); | 1176 EXPECT_EQ(1.0f, mainFrameLocal->loader().currentItem()->pageScaleFactor()); |
| 1179 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().x()); | 1177 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().x()); |
| 1180 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().y()); | 1178 EXPECT_EQ(0, mainFrameLocal->loader().currentItem()->scrollPoint().y()); |
| 1181 } | 1179 } |
| 1182 | 1180 |
| 1183 TEST_F(WebViewTest, BackForwardRestoreScroll) | 1181 TEST_F(WebViewTest, BackForwardRestoreScroll) |
| 1184 { | 1182 { |
| 1185 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("back_forward_restore_scroll.html")); | 1183 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"); | 1184 WebViewImpl* webViewImpl = m_webViewHelper.initializeAndLoad(m_baseURL + "ba
ck_forward_restore_scroll.html"); |
| 1187 webViewImpl->resize(WebSize(640, 480)); | 1185 webViewImpl->resize(WebSize(640, 480)); |
| 1188 webViewImpl->layout(); | 1186 webViewImpl->layout(); |
| (...skipping 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3019 for (size_t i = 0; i < renders.size(); ++i) { | 3017 for (size_t i = 0; i < renders.size(); ++i) { |
| 3020 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; | 3018 double docStartTime = frame->domWindow()->document()->loader()->timing()
.monotonicTimeToZeroBasedDocumentTime(renderPairs[i].startTime) * 1000.0; |
| 3021 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); | 3019 ASSERT_DOUBLE_EQ(docStartTime, renders[i]->startTime()); |
| 3022 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; | 3020 double docFinishTime = frame->domWindow()->document()->loader()->timing(
).monotonicTimeToZeroBasedDocumentTime(renderPairs[i].finishTime) * 1000.0; |
| 3023 double docDuration = docFinishTime - docStartTime; | 3021 double docDuration = docFinishTime - docStartTime; |
| 3024 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); | 3022 ASSERT_DOUBLE_EQ(docDuration, renders[i]->duration()); |
| 3025 } | 3023 } |
| 3026 } | 3024 } |
| 3027 | 3025 |
| 3028 } // namespace | 3026 } // namespace |
| OLD | NEW |