Chromium Code Reviews| Index: Source/web/tests/PinchViewportTest.cpp |
| diff --git a/Source/web/tests/PinchViewportTest.cpp b/Source/web/tests/PinchViewportTest.cpp |
| index 5e34221f8fe38c5d14032894b48dcb345c6c90fe..829ae31e9049118a932eec09250410a85562172f 100644 |
| --- a/Source/web/tests/PinchViewportTest.cpp |
| +++ b/Source/web/tests/PinchViewportTest.cpp |
| @@ -155,6 +155,13 @@ public: |
| settings->setShrinksViewportContentToFit(true); |
| } |
| + static void resizesAreOrientationChanges(WebSettings* settings) |
| + { |
| + configureSettings(settings); |
| + settings->setViewportEnabled(true); |
| + settings->setMainFrameResizesAreOrientationChanges(true); |
|
bokan
2014/09/16 19:46:48
Does anything break if you just add setMainFrameRe
timav
2014/09/16 21:44:51
Nothing breaks in the existing tests, but for my o
bokan
2014/09/16 22:03:19
Hmm...you shouldn't need that. What was the proble
|
| + } |
| + |
| protected: |
| std::string m_baseURL; |
| FrameTestHelpers::TestWebViewClient m_mockWebViewClient; |
| @@ -193,6 +200,106 @@ TEST_F(PinchViewportTest, TestResize) |
| EXPECT_SIZE_EQ(newViewportSize, pinchViewport.size()); |
| } |
| +// Test that the PinchViewport works as expected in case of a scaled |
| +// and scrolled viewport - scroll down. |
| +TEST_F(PinchViewportTest, TestResizeAfterVerticalScroll) |
| +{ |
| + /* |
| + 200 200 |
| + --------------------- --------------------- |
| + | | | | |
| + | | | | |
| + | | | | |
| + |150 | | | |
| + | | | | |
| + | | |175 | |
| + | | | | |
| + |---------- |300 | |300 |
| + | | | -------> | | |
| + |75 | | |-------------- | |
| + | | | |50 | | |
| + o---- |150 | o----- |100 | |
| + | |60 | | | |40 | | |
| + | | | | |____| | | |
| + |---- | | |-------------- | |
| + --------------------- --------------------- |
|
bokan
2014/09/16 19:46:48
ASCII art is super helpful, nice! The anchor shoul
timav
2014/09/16 21:44:52
Right, and I keep forgetting about that.
I can mo
|
| + |
| + */ |
| + |
| + initializeWithDesktopSettings(resizesAreOrientationChanges); |
|
bokan
2014/09/16 19:46:48
use initializeWithAndroidSettings() and move the m
timav
2014/09/16 21:44:51
Done.
|
| + |
| + registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| + navigateTo(m_baseURL + "200-by-300-viewport.html"); |
| + |
| + webViewImpl()->resize(IntSize(100, 150)); |
| + webViewImpl()->layout(); |
| + |
| + // Scroll main frame to the bottom of the document |
| + webViewImpl()->setMainFrameScrollOffset(WebPoint(0, 150)); |
| + |
| + webViewImpl()->setPageScaleFactor(2.5); |
| + |
| + PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| + pinchViewport.setLocation(FloatPoint(0, 75)); |
| + |
| + // Verify the initial size of the pinch viewport in the CSS pixels |
| + EXPECT_FLOAT_SIZE_EQ(FloatSize(40, 60), pinchViewport.visibleRect().size()); |
| + |
| + webViewImpl()->resize(IntSize(150, 100)); |
| + webViewImpl()->layout(); |
| + |
| + EXPECT_FLOAT_SIZE_EQ(FloatSize(60, 40), pinchViewport.visibleRect().size()); |
| + EXPECT_POINT_EQ(IntPoint(0, 175), frame()->view()->scrollPosition()); |
| + EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 50), pinchViewport.location()); |
| +} |
| + |
| +// Test that the PinchViewport works as expected in case if a scaled |
| +// and scrolled viewport - scroll right. |
| +TEST_F(PinchViewportTest, TestResizeAfterHorizontalScroll) |
| +{ |
| + /* |
| + 200 200 |
| + ---------------o----- ---------------o----- |
| + | | | || | | | | |
| + | | 50 |40 || | | |_____| |
| + | | -----| | | 90 60 | |
| + | | | | | | |
| + | | | | ---------------| |
| + | 100 | 100 | | 50 150 | |
| + | | | | | |
| + | ----------| | | |
| + | | -------> | | |
| + | | | | |
| + |
| + */ |
| + |
| + initializeWithDesktopSettings(resizesAreOrientationChanges); |
| + |
| + registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| + navigateTo(m_baseURL + "200-by-300-viewport.html"); |
| + |
| + webViewImpl()->resize(IntSize(100, 150)); |
| + webViewImpl()->layout(); |
|
bokan
2014/09/16 19:46:48
you shouldn't need this layout (there's a layout c
timav
2014/09/16 21:44:51
Done.
|
| + |
| + // Scroll main frame to the right of the document |
| + webViewImpl()->setMainFrameScrollOffset(WebPoint(100, 0)); |
| + |
| + webViewImpl()->setPageScaleFactor(2.5); |
| + |
| + PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| + pinchViewport.setLocation(FloatPoint(50, 0)); |
| + |
| + // Verify the initial size of the pinch viewport in the CSS pixels |
| + EXPECT_FLOAT_SIZE_EQ(FloatSize(40, 60), pinchViewport.visibleRect().size()); |
| + |
| + webViewImpl()->resize(IntSize(150, 100)); |
| + webViewImpl()->layout(); |
| + |
| + EXPECT_FLOAT_SIZE_EQ(FloatSize(60, 40), pinchViewport.visibleRect().size()); |
| + EXPECT_POINT_EQ(IntPoint(50, 0), frame()->view()->scrollPosition()); |
| + EXPECT_FLOAT_POINT_EQ(FloatPoint(90, 0), pinchViewport.location()); |
| +} |
| + |
| static void disableAcceleratedCompositing(WebSettings* settings) |
| { |
| PinchViewportTest::configureSettings(settings); |