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

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

Issue 1178273008: Fix PinchViewport::visibleRectInDocument (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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/core/frame/PinchViewport.cpp ('k') | no next file » | 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/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/frame/FrameHost.h" 10 #include "core/frame/FrameHost.h"
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 expectedRect.scale(1 / 3.0f); 455 expectedRect.scale(1 / 3.0f);
456 expectedRect.setLocation(oldLocation); 456 expectedRect.setLocation(oldLocation);
457 pinchViewport.setScale(3); 457 pinchViewport.setScale(3);
458 EXPECT_FLOAT_RECT_EQ(expectedRect, pinchViewport.visibleRect()); 458 EXPECT_FLOAT_RECT_EQ(expectedRect, pinchViewport.visibleRect());
459 459
460 expectedRect.setLocation(FloatPoint(0.25f, 0.333f)); 460 expectedRect.setLocation(FloatPoint(0.25f, 0.333f));
461 pinchViewport.setLocation(expectedRect.location()); 461 pinchViewport.setLocation(expectedRect.location());
462 EXPECT_FLOAT_RECT_EQ(expectedRect, pinchViewport.visibleRect()); 462 EXPECT_FLOAT_RECT_EQ(expectedRect, pinchViewport.visibleRect());
463 } 463 }
464 464
465 // Make sure that the visibleRectInDocument method acurately reflects the scale
466 // and scroll location of the viewport relative to the document.
467 TEST_F(PinchViewportTest, TestVisibleRectInDocument)
468 {
469 initializeWithDesktopSettings();
470 webViewImpl()->resize(IntSize(100, 400));
471
472 registerMockedHttpURLLoad("200-by-800-viewport.html");
473 navigateTo(m_baseURL + "200-by-800-viewport.html");
474
475 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport();
476
477 // Scale the viewport to 2X and move it.
478 pinchViewport.setScale(2);
479 pinchViewport.setLocation(FloatPoint(10, 15));
480 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), pinchViewport.visibleRectIn Document());
481
482 // Scroll the layout viewport. Ensure its offset is reflected in visibleRect InDocument().
483 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
484 frameView.setScrollPosition(DoublePoint(40, 100), ProgrammaticScroll);
485 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), pinchViewport.visibleRectI nDocument());
486 }
487
465 TEST_F(PinchViewportTest, TestFractionalScrollOffsetIsNotOverwritten) 488 TEST_F(PinchViewportTest, TestFractionalScrollOffsetIsNotOverwritten)
466 { 489 {
467 initializeWithAndroidSettings(); 490 initializeWithAndroidSettings();
468 webViewImpl()->resize(IntSize(200, 250)); 491 webViewImpl()->resize(IntSize(200, 250));
469 492
470 registerMockedHttpURLLoad("200-by-800-viewport.html"); 493 registerMockedHttpURLLoad("200-by-800-viewport.html");
471 navigateTo(m_baseURL + "200-by-800-viewport.html"); 494 navigateTo(m_baseURL + "200-by-800-viewport.html");
472 495
473 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 496 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
474 frameView.scrollTo(DoublePoint(0, 10.5)); 497 frameView.scrollTo(DoublePoint(0, 10.5));
(...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); 1681 registerMockedHttpURLLoad("window_dimensions_wide_div.html");
1659 webViewImpl()->resize(IntSize(800, 600)); 1682 webViewImpl()->resize(IntSize(800, 600));
1660 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); 1683 navigateTo(m_baseURL + "window_dimensions_wide_div.html");
1661 1684
1662 Element* output = frame()->document()->getElementById("output"); 1685 Element* output = frame()->document()->getElementById("output");
1663 ASSERT(output); 1686 ASSERT(output);
1664 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii(). data())); 1687 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii(). data()));
1665 } 1688 }
1666 1689
1667 } // namespace 1690 } // namespace
OLDNEW
« no previous file with comments | « Source/core/frame/PinchViewport.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698