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/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 item.setPageScaleFactor(2); | 591 item.setPageScaleFactor(2); |
592 | 592 |
593 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item, WebHisto
ryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); | 593 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item, WebHisto
ryDifferentDocumentLoad, WebURLRequest::UseProtocolCachePolicy); |
594 | 594 |
595 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 595 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
596 EXPECT_EQ(2, pinchViewport.scale()); | 596 EXPECT_EQ(2, pinchViewport.scale()); |
597 EXPECT_POINT_EQ(IntPoint(100, 150), frame()->view()->scrollPosition()); | 597 EXPECT_POINT_EQ(IntPoint(100, 150), frame()->view()->scrollPosition()); |
598 EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30), pinchViewport.visibleRect().locati
on()); | 598 EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30), pinchViewport.visibleRect().locati
on()); |
599 } | 599 } |
600 | 600 |
| 601 // Test that the coordinates sent into moveRangeSelection are offset by the |
| 602 // pinch viewport's location. |
| 603 TEST_F(PinchViewportTest, TestWebFrameRangeAccountsForPinchViewportScroll) |
| 604 { |
| 605 initializeWithDesktopSettings(); |
| 606 webViewImpl()->settings()->setDefaultFontSize(12); |
| 607 webViewImpl()->resize(WebSize(640, 480)); |
| 608 registerMockedHttpURLLoad("move_range.html"); |
| 609 navigateTo(m_baseURL + "move_range.html"); |
| 610 |
| 611 WebRect baseRect; |
| 612 WebRect extentRect; |
| 613 |
| 614 webViewImpl()->setPageScaleFactor(2); |
| 615 WebFrame* mainFrame = webViewImpl()->mainFrame(); |
| 616 |
| 617 // Select some text and get the base and extent rects (that's the start of |
| 618 // the range and its end). Do a sanity check that the expected text is |
| 619 // selected |
| 620 mainFrame->executeScript(WebScriptSource("selectRange();")); |
| 621 EXPECT_EQ("ir", mainFrame->selectionAsText().utf8()); |
| 622 |
| 623 webViewImpl()->selectionBounds(baseRect, extentRect); |
| 624 WebPoint initialPoint(baseRect.x, baseRect.y); |
| 625 WebPoint endPoint(extentRect.x, extentRect.y); |
| 626 |
| 627 // Move the pinch viewport over and make the selection in the same |
| 628 // screen-space location. The selection should change to two characters to |
| 629 // the right and down one line. |
| 630 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 631 pinchViewport.move(FloatPoint(60, 25)); |
| 632 mainFrame->moveRangeSelection(initialPoint, endPoint); |
| 633 EXPECT_EQ("t ", mainFrame->selectionAsText().utf8()); |
| 634 } |
| 635 |
601 // Test that the scrollFocusedNodeIntoRect method works with the pinch viewport. | 636 // Test that the scrollFocusedNodeIntoRect method works with the pinch viewport. |
602 TEST_F(PinchViewportTest, TestScrollFocusedNodeIntoRect) | 637 TEST_F(PinchViewportTest, TestScrollFocusedNodeIntoRect) |
603 { | 638 { |
604 initializeWithDesktopSettings(); | 639 initializeWithDesktopSettings(); |
605 webViewImpl()->resize(IntSize(500, 300)); | 640 webViewImpl()->resize(IntSize(500, 300)); |
606 | 641 |
607 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 642 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
608 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 643 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
609 | 644 |
610 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 645 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 pinchViewport.scrollIntoView(FloatRect(50, 75, 50, 75)); | 795 pinchViewport.scrollIntoView(FloatRect(50, 75, 50, 75)); |
761 EXPECT_POINT_EQ(IntPoint(50, 75), frame()->view()->scrollPosition()); | 796 EXPECT_POINT_EQ(IntPoint(50, 75), frame()->view()->scrollPosition()); |
762 EXPECT_FLOAT_POINT_EQ(FloatPoint(), pinchViewport.visibleRect().location()); | 797 EXPECT_FLOAT_POINT_EQ(FloatPoint(), pinchViewport.visibleRect().location()); |
763 | 798 |
764 pinchViewport.scrollIntoView(FloatRect(190, 290, 10, 10)); | 799 pinchViewport.scrollIntoView(FloatRect(190, 290, 10, 10)); |
765 EXPECT_POINT_EQ(IntPoint(100, 150), frame()->view()->scrollPosition()); | 800 EXPECT_POINT_EQ(IntPoint(100, 150), frame()->view()->scrollPosition()); |
766 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 75), pinchViewport.visibleRect().locati
on()); | 801 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 75), pinchViewport.visibleRect().locati
on()); |
767 } | 802 } |
768 | 803 |
769 } // namespace | 804 } // namespace |
OLD | NEW |