| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "core/frame/TopControls.h" | 30 #include "core/frame/TopControls.h" |
| 31 | 31 |
| 32 #include "core/dom/ClientRect.h" | 32 #include "core/dom/ClientRect.h" |
| 33 #include "core/frame/FrameHost.h" | 33 #include "core/frame/FrameHost.h" |
| 34 #include "core/frame/FrameView.h" | 34 #include "core/frame/FrameView.h" |
| 35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 36 #include "core/layout/LayoutView.h" | 36 #include "core/layout/LayoutView.h" |
| 37 #include "core/page/Page.h" | 37 #include "core/page/Page.h" |
| 38 #include "platform/testing/URLTestHelpers.h" | 38 #include "platform/testing/URLTestHelpers.h" |
| 39 #include "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
| 40 #include "public/platform/WebUnitTestSupport.h" | 40 #include "public/platform/WebURLLoaderMockFactory.h" |
| 41 #include "public/web/WebCache.h" |
| 41 #include "public/web/WebElement.h" | 42 #include "public/web/WebElement.h" |
| 42 #include "public/web/WebSettings.h" | 43 #include "public/web/WebSettings.h" |
| 43 #include "testing/gmock/include/gmock/gmock.h" | 44 #include "testing/gmock/include/gmock/gmock.h" |
| 44 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
| 45 #include "web/WebLocalFrameImpl.h" | 46 #include "web/WebLocalFrameImpl.h" |
| 46 #include "web/tests/FrameTestHelpers.h" | 47 #include "web/tests/FrameTestHelpers.h" |
| 47 | 48 |
| 48 namespace blink { | 49 namespace blink { |
| 49 | 50 |
| 50 // These tests cover top controls scrolling on main-thread. | 51 // These tests cover top controls scrolling on main-thread. |
| 51 // The animation for completing a partial show/hide is done in compositor so | 52 // The animation for completing a partial show/hide is done in compositor so |
| 52 // it is not covered here. | 53 // it is not covered here. |
| 53 class TopControlsTest : public testing::Test { | 54 class TopControlsTest : public testing::Test { |
| 54 public: | 55 public: |
| 55 TopControlsTest() | 56 TopControlsTest() |
| 56 : m_baseURL("http://www.test.com/") | 57 : m_baseURL("http://www.test.com/") |
| 57 { | 58 { |
| 58 registerMockedHttpURLLoad("large-div.html"); | 59 registerMockedHttpURLLoad("large-div.html"); |
| 59 registerMockedHttpURLLoad("overflow-scrolling.html"); | 60 registerMockedHttpURLLoad("overflow-scrolling.html"); |
| 60 registerMockedHttpURLLoad("iframe-scrolling.html"); | 61 registerMockedHttpURLLoad("iframe-scrolling.html"); |
| 61 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); | 62 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); |
| 62 registerMockedHttpURLLoad("percent-height.html"); | 63 registerMockedHttpURLLoad("percent-height.html"); |
| 63 registerMockedHttpURLLoad("vh-height.html"); | 64 registerMockedHttpURLLoad("vh-height.html"); |
| 64 registerMockedHttpURLLoad("vh-height-width-800.html"); | 65 registerMockedHttpURLLoad("vh-height-width-800.html"); |
| 65 registerMockedHttpURLLoad("vh-height-width-800-extra-wide.html"); | 66 registerMockedHttpURLLoad("vh-height-width-800-extra-wide.html"); |
| 66 } | 67 } |
| 67 | 68 |
| 68 ~TopControlsTest() override | 69 ~TopControlsTest() override |
| 69 { | 70 { |
| 70 Platform::current()->unitTestSupport()->unregisterAllMockedURLs(); | 71 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); |
| 72 WebCache::clear(); |
| 71 } | 73 } |
| 72 | 74 |
| 73 WebViewImpl* initialize(const std::string& pageName = "large-div.html") | 75 WebViewImpl* initialize(const std::string& pageName = "large-div.html") |
| 74 { | 76 { |
| 75 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); | 77 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); |
| 76 | 78 |
| 77 // Load a page with large body and set viewport size to 400x400 to ensur
e | 79 // Load a page with large body and set viewport size to 400x400 to ensur
e |
| 78 // main frame is scrollable. | 80 // main frame is scrollable. |
| 79 m_helper.initializeAndLoad(m_baseURL + pageName, true, 0, 0, &configureS
ettings); | 81 m_helper.initializeAndLoad(m_baseURL + pageName, true, 0, 0, &configureS
ettings); |
| 80 | 82 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 // that's 1600px wide so the minimum scale is 0.25 to encompass that. | 727 // that's 1600px wide so the minimum scale is 0.25 to encompass that. |
| 726 ASSERT_EQ(0.25f, webView->minimumPageScaleFactor()); | 728 ASSERT_EQ(0.25f, webView->minimumPageScaleFactor()); |
| 727 | 729 |
| 728 // The viewport will match the layout width at scale=0.5 so the height used | 730 // The viewport will match the layout width at scale=0.5 so the height used |
| 729 // for vh should be (300 / 0.5) for the layout height + (100 / 0.5) for top | 731 // for vh should be (300 / 0.5) for the layout height + (100 / 0.5) for top |
| 730 // controls = 800. | 732 // controls = 800. |
| 731 EXPECT_EQ(800, frame()->view()->viewportSizeForViewportUnits().height()); | 733 EXPECT_EQ(800, frame()->view()->viewportSizeForViewportUnits().height()); |
| 732 } | 734 } |
| 733 | 735 |
| 734 } // namespace blink | 736 } // namespace blink |
| OLD | NEW |