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

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

Issue 319643002: Fixed touch selection handle manipulation when pinched in. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « Source/web/WebLocalFrameImpl.cpp ('k') | Source/web/tests/data/move_range.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/web/WebLocalFrameImpl.cpp ('k') | Source/web/tests/data/move_range.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698