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 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1458 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1458 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
1459 ScrollableArea* scrollableArea = &pinchViewport; | 1459 ScrollableArea* scrollableArea = &pinchViewport; |
1460 | 1460 |
1461 webViewImpl()->setPageScaleFactor(1.0); | 1461 webViewImpl()->setPageScaleFactor(1.0); |
1462 EXPECT_FLOAT_POINT_EQ(DoublePoint(), scrollableArea->maximumScrollPositionDo uble()); | 1462 EXPECT_FLOAT_POINT_EQ(DoublePoint(), scrollableArea->maximumScrollPositionDo uble()); |
1463 | 1463 |
1464 webViewImpl()->setPageScaleFactor(2); | 1464 webViewImpl()->setPageScaleFactor(2); |
1465 EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.), scrollableArea->max imumScrollPositionDouble()); | 1465 EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.), scrollableArea->max imumScrollPositionDouble()); |
1466 } | 1466 } |
1467 | 1467 |
1468 // Tests that the maximum scroll offset of the viewport can be fractional. | |
Rick Byers
2015/03/05 17:56:20
looks like you're not actually testing for fractio
bokan
2015/03/06 22:07:20
Done.
| |
1469 TEST_F(PinchViewportTest, TestCoordinateTransforms) | |
1470 { | |
1471 initializeWithAndroidSettings(); | |
1472 webViewImpl()->resize(IntSize(800, 600)); | |
1473 registerMockedHttpURLLoad("content-width-1000.html"); | |
1474 navigateTo(m_baseURL + "content-width-1000.html"); | |
1475 | |
1476 PinchViewport& pinchViewport = webViewImpl()->page()->frameHost().pinchViewp ort(); | |
1477 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | |
1478 | |
1479 // At scale = 1 the transform should be a no-op. | |
1480 pinchViewport.setScale(1); | |
1481 EXPECT_FLOAT_POINT_EQ(FloatPoint(314, 273), pinchViewport.viewportToRootFram e(FloatPoint(314, 273))); | |
1482 EXPECT_FLOAT_POINT_EQ(FloatPoint(314, 273), pinchViewport.rootFrameToViewpor t(FloatPoint(314, 273))); | |
1483 | |
1484 // At scale = 2. | |
1485 pinchViewport.setScale(2); | |
1486 EXPECT_FLOAT_POINT_EQ(FloatPoint(55, 75), pinchViewport.viewportToRootFrame( FloatPoint(110, 150))); | |
1487 EXPECT_FLOAT_POINT_EQ(FloatPoint(110, 150), pinchViewport.rootFrameToViewpor t(FloatPoint(55, 75))); | |
1488 | |
1489 // At scale = 2 and with the pinch viewport offset. | |
1490 pinchViewport.setLocation(FloatPoint(10, 12)); | |
1491 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), pinchViewport.viewportToRootFrame( FloatPoint(80, 100))); | |
1492 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport (FloatPoint(50, 62))); | |
1493 | |
1494 // Scrolling the main frame should have no effect. | |
1495 frameView.scrollTo(DoublePoint(100, 120)); | |
1496 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), pinchViewport.viewportToRootFrame( FloatPoint(80, 100))); | |
1497 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport (FloatPoint(50, 62))); | |
1498 } | |
1499 | |
1468 } // namespace | 1500 } // namespace |
OLD | NEW |