| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/frame/PinchViewport.h" | 7 #include "core/frame/PinchViewport.h" |
| 8 | 8 |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 EXPECT_POINT_EQ(expectedLocation, frameView.scrollableArea()->visibleContent
RectDouble().location()); | 283 EXPECT_POINT_EQ(expectedLocation, frameView.scrollableArea()->visibleContent
RectDouble().location()); |
| 284 | 284 |
| 285 webViewImpl()->resize(IntSize(800, 600)); | 285 webViewImpl()->resize(IntSize(800, 600)); |
| 286 | 286 |
| 287 EXPECT_POINT_EQ(expectedLocation, frameView.scrollableArea()->visibleContent
RectDouble().location()); | 287 EXPECT_POINT_EQ(expectedLocation, frameView.scrollableArea()->visibleContent
RectDouble().location()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 | 290 |
| 291 // Test that the PinchViewport works as expected in case of a scaled | 291 // Test that the PinchViewport works as expected in case of a scaled |
| 292 // and scrolled viewport - scroll down. | 292 // and scrolled viewport - scroll down. |
| 293 TEST_F(PinchViewportTest, TestResizeAfterVerticalScroll) | 293 TEST_P(ParameterizedPinchViewportTest, TestResizeAfterVerticalScroll) |
| 294 { | 294 { |
| 295 /* | 295 /* |
| 296 200 200 | 296 200 200 |
| 297 | | | | | 297 | | | | |
| 298 | | | | | 298 | | | | |
| 299 | | 800 | | 800 | 299 | | 800 | | 800 |
| 300 |-------------------| | | | 300 |-------------------| | | |
| 301 | | | | | 301 | | | | |
| 302 | | | | | 302 | | | | |
| 303 | | | | | 303 | | | | |
| (...skipping 21 matching lines...) Expand all Loading... |
| 325 | 325 |
| 326 initializeWithAndroidSettings(); | 326 initializeWithAndroidSettings(); |
| 327 | 327 |
| 328 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 328 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
| 329 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 329 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
| 330 | 330 |
| 331 webViewImpl()->resize(IntSize(100, 200)); | 331 webViewImpl()->resize(IntSize(100, 200)); |
| 332 | 332 |
| 333 // Scroll main frame to the bottom of the document | 333 // Scroll main frame to the bottom of the document |
| 334 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 400)); | 334 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 400)); |
| 335 EXPECT_POINT_EQ(IntPoint(0, 400), frame()->view()->scrollPosition()); | 335 EXPECT_POINT_EQ(IntPoint(0, 400), frame()->view()->layoutViewportScrollableA
rea()->scrollPosition()); |
| 336 | 336 |
| 337 webViewImpl()->setPageScaleFactor(2.0); | 337 webViewImpl()->setPageScaleFactor(2.0); |
| 338 | 338 |
| 339 // Scroll pinch viewport to the bottom of the main frame | 339 // Scroll pinch viewport to the bottom of the main frame |
| 340 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 340 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 341 pinchViewport.setLocation(FloatPoint(0, 300)); | 341 pinchViewport.setLocation(FloatPoint(0, 300)); |
| 342 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 300), pinchViewport.location()); | 342 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 300), pinchViewport.location()); |
| 343 | 343 |
| 344 // Verify the initial size of the pinch viewport in the CSS pixels | 344 // Verify the initial size of the pinch viewport in the CSS pixels |
| 345 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 100), pinchViewport.visibleRect().size())
; | 345 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 100), pinchViewport.visibleRect().size())
; |
| 346 | 346 |
| 347 // Perform the resizing | 347 // Perform the resizing |
| 348 webViewImpl()->resize(IntSize(200, 100)); | 348 webViewImpl()->resize(IntSize(200, 100)); |
| 349 | 349 |
| 350 // After resizing the scale changes 2.0 -> 4.0 | 350 // After resizing the scale changes 2.0 -> 4.0 |
| 351 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), pinchViewport.visibleRect().size()); | 351 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), pinchViewport.visibleRect().size()); |
| 352 | 352 |
| 353 EXPECT_POINT_EQ(IntPoint(0, 625), frame()->view()->scrollPosition()); | 353 EXPECT_POINT_EQ(IntPoint(0, 625), frame()->view()->layoutViewportScrollableA
rea()->scrollPosition()); |
| 354 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 75), pinchViewport.location()); | 354 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 75), pinchViewport.location()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 // Test that the PinchViewport works as expected in case if a scaled | 357 // Test that the PinchViewport works as expected in case if a scaled |
| 358 // and scrolled viewport - scroll right. | 358 // and scrolled viewport - scroll right. |
| 359 TEST_P(ParameterizedPinchViewportTest, TestResizeAfterHorizontalScroll) | 359 TEST_P(ParameterizedPinchViewportTest, TestResizeAfterHorizontalScroll) |
| 360 { | 360 { |
| 361 /* | 361 /* |
| 362 200 200 | 362 200 200 |
| 363 ---------------o----- ---------------o----- | 363 ---------------o----- ---------------o----- |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1717 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); | 1717 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); |
| 1718 webViewImpl()->resize(IntSize(800, 600)); | 1718 webViewImpl()->resize(IntSize(800, 600)); |
| 1719 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); | 1719 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); |
| 1720 | 1720 |
| 1721 Element* output = frame()->document()->getElementById("output"); | 1721 Element* output = frame()->document()->getElementById("output"); |
| 1722 ASSERT(output); | 1722 ASSERT(output); |
| 1723 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii().
data())); | 1723 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii().
data())); |
| 1724 } | 1724 } |
| 1725 | 1725 |
| 1726 } // namespace | 1726 } // namespace |
| OLD | NEW |