| 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 15 matching lines...) Expand all Loading... |
| 26 #include "public/web/WebFrameClient.h" | 26 #include "public/web/WebFrameClient.h" |
| 27 #include "public/web/WebInputEvent.h" | 27 #include "public/web/WebInputEvent.h" |
| 28 #include "public/web/WebScriptSource.h" | 28 #include "public/web/WebScriptSource.h" |
| 29 #include "public/web/WebSettings.h" | 29 #include "public/web/WebSettings.h" |
| 30 #include "public/web/WebViewClient.h" | 30 #include "public/web/WebViewClient.h" |
| 31 #include "web/WebLocalFrameImpl.h" | 31 #include "web/WebLocalFrameImpl.h" |
| 32 #include "web/tests/FrameTestHelpers.h" | 32 #include "web/tests/FrameTestHelpers.h" |
| 33 #include <gmock/gmock.h> | 33 #include <gmock/gmock.h> |
| 34 #include <gtest/gtest.h> | 34 #include <gtest/gtest.h> |
| 35 | 35 |
| 36 #include <string> |
| 37 |
| 36 #define ASSERT_POINT_EQ(expected, actual) \ | 38 #define ASSERT_POINT_EQ(expected, actual) \ |
| 37 do { \ | 39 do { \ |
| 38 ASSERT_EQ((expected).x(), (actual).x()); \ | 40 ASSERT_EQ((expected).x(), (actual).x()); \ |
| 39 ASSERT_EQ((expected).y(), (actual).y()); \ | 41 ASSERT_EQ((expected).y(), (actual).y()); \ |
| 40 } while (false) | 42 } while (false) |
| 41 | 43 |
| 42 #define EXPECT_POINT_EQ(expected, actual) \ | 44 #define EXPECT_POINT_EQ(expected, actual) \ |
| 43 do { \ | 45 do { \ |
| 44 EXPECT_EQ((expected).x(), (actual).x()); \ | 46 EXPECT_EQ((expected).x(), (actual).x()); \ |
| 45 EXPECT_EQ((expected).y(), (actual).y()); \ | 47 EXPECT_EQ((expected).y(), (actual).y()); \ |
| (...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 EXPECT_FLOAT_POINT_EQ(FloatPoint(50.5, 62.4), pinchViewport.viewportToRootFr
ame(FloatPoint(81, 100.8))); | 1708 EXPECT_FLOAT_POINT_EQ(FloatPoint(50.5, 62.4), pinchViewport.viewportToRootFr
ame(FloatPoint(81, 100.8))); |
| 1707 EXPECT_FLOAT_POINT_EQ(FloatPoint(81, 100.8), pinchViewport.rootFrameToViewpo
rt(FloatPoint(50.5, 62.4))); | 1709 EXPECT_FLOAT_POINT_EQ(FloatPoint(81, 100.8), pinchViewport.rootFrameToViewpo
rt(FloatPoint(50.5, 62.4))); |
| 1708 | 1710 |
| 1709 | 1711 |
| 1710 // Scrolling the main frame should have no effect. | 1712 // Scrolling the main frame should have no effect. |
| 1711 frameView.scrollTo(DoublePoint(100, 120)); | 1713 frameView.scrollTo(DoublePoint(100, 120)); |
| 1712 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), pinchViewport.viewportToRootFrame(
FloatPoint(80, 100))); | 1714 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), pinchViewport.viewportToRootFrame(
FloatPoint(80, 100))); |
| 1713 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport
(FloatPoint(50, 62))); | 1715 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport
(FloatPoint(50, 62))); |
| 1714 } | 1716 } |
| 1715 | 1717 |
| 1718 // Tests that the window dimensions are available before a full layout occurs. |
| 1719 // More specifically, it checks that the innerWidth and innerHeight window |
| 1720 // properties will trigger a layout which will cause an update to viewport |
| 1721 // constraints and a refreshed initial scale. crbug.com/466718 |
| 1722 TEST_F(PinchViewportTest, WindowDimensionsOnLoad) |
| 1723 { |
| 1724 initializeWithAndroidSettings(); |
| 1725 registerMockedHttpURLLoad("window_dimensions.html"); |
| 1726 webViewImpl()->resize(IntSize(800, 600)); |
| 1727 navigateTo(m_baseURL + "window_dimensions.html"); |
| 1728 |
| 1729 Element* output = frame()->document()->getElementById("output"); |
| 1730 ASSERT(output); |
| 1731 EXPECT_EQ(std::string("1600x1200"), std::string(output->innerHTML().ascii().
data())); |
| 1732 } |
| 1733 |
| 1734 // Similar to above but make sure the initial scale is updated with the content |
| 1735 // width for a very wide page. That is, make that innerWidth/Height actually |
| 1736 // trigger a layout of the content, and not just an update of the viepwort. |
| 1737 // crbug.com/466718 |
| 1738 TEST_F(PinchViewportTest, WindowDimensionsOnLoadWideContent) |
| 1739 { |
| 1740 initializeWithAndroidSettings(); |
| 1741 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); |
| 1742 webViewImpl()->resize(IntSize(800, 600)); |
| 1743 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); |
| 1744 |
| 1745 Element* output = frame()->document()->getElementById("output"); |
| 1746 ASSERT(output); |
| 1747 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii().
data())); |
| 1748 } |
| 1749 |
| 1716 } // namespace | 1750 } // namespace |
| OLD | NEW |