| 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 20 matching lines...) Expand all Loading... |
| 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/frame/VisualViewport.h" | 36 #include "core/frame/VisualViewport.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 "platform/testing/UnitTestHelpers.h" | 39 #include "platform/testing/UnitTestHelpers.h" |
| 40 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
| 41 #include "public/platform/WebCache.h" | |
| 42 #include "public/platform/WebURLLoaderMockFactory.h" | 41 #include "public/platform/WebURLLoaderMockFactory.h" |
| 43 #include "public/web/WebElement.h" | 42 #include "public/web/WebElement.h" |
| 44 #include "public/web/WebSettings.h" | 43 #include "public/web/WebSettings.h" |
| 45 #include "testing/gmock/include/gmock/gmock.h" | 44 #include "testing/gmock/include/gmock/gmock.h" |
| 46 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
| 47 #include "web/WebLocalFrameImpl.h" | 46 #include "web/WebLocalFrameImpl.h" |
| 48 #include "web/tests/FrameTestHelpers.h" | 47 #include "web/tests/FrameTestHelpers.h" |
| 49 | 48 |
| 50 namespace blink { | 49 namespace blink { |
| 51 | 50 |
| 52 // These tests cover browser controls scrolling on main-thread. | 51 // These tests cover browser controls scrolling on main-thread. |
| 53 // 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 |
| 54 // it is not covered here. | 53 // it is not covered here. |
| 55 class BrowserControlsTest : public ::testing::Test { | 54 class BrowserControlsTest : public ::testing::Test { |
| 56 public: | 55 public: |
| 57 BrowserControlsTest() : m_baseURL("http://www.test.com/") { | 56 BrowserControlsTest() : m_baseURL("http://www.test.com/") { |
| 58 registerMockedHttpURLLoad("large-div.html"); | 57 registerMockedHttpURLLoad("large-div.html"); |
| 59 registerMockedHttpURLLoad("overflow-scrolling.html"); | 58 registerMockedHttpURLLoad("overflow-scrolling.html"); |
| 60 registerMockedHttpURLLoad("iframe-scrolling.html"); | 59 registerMockedHttpURLLoad("iframe-scrolling.html"); |
| 61 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); | 60 registerMockedHttpURLLoad("iframe-scrolling-inner.html"); |
| 62 registerMockedHttpURLLoad("percent-height.html"); | 61 registerMockedHttpURLLoad("percent-height.html"); |
| 63 registerMockedHttpURLLoad("vh-height.html"); | 62 registerMockedHttpURLLoad("vh-height.html"); |
| 64 registerMockedHttpURLLoad("vh-height-width-800.html"); | 63 registerMockedHttpURLLoad("vh-height-width-800.html"); |
| 65 registerMockedHttpURLLoad("vh-height-width-800-extra-wide.html"); | 64 registerMockedHttpURLLoad("vh-height-width-800-extra-wide.html"); |
| 66 } | 65 } |
| 67 | 66 |
| 68 ~BrowserControlsTest() override { | 67 ~BrowserControlsTest() override { |
| 69 Platform::current()->getURLLoaderMockFactory()->unregisterAllURLs(); | 68 Platform::current() |
| 70 WebCache::clear(); | 69 ->getURLLoaderMockFactory() |
| 70 ->unregisterAllURLsAndClearMemoryCache(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 WebViewImpl* initialize(const std::string& pageName = "large-div.html") { | 73 WebViewImpl* initialize(const std::string& pageName = "large-div.html") { |
| 74 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); | 74 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); |
| 75 | 75 |
| 76 // Load a page with large body and set viewport size to 400x400 to ensure | 76 // Load a page with large body and set viewport size to 400x400 to ensure |
| 77 // main frame is scrollable. | 77 // main frame is scrollable. |
| 78 m_helper.initializeAndLoad(m_baseURL + pageName, true, nullptr, nullptr, | 78 m_helper.initializeAndLoad(m_baseURL + pageName, true, nullptr, nullptr, |
| 79 nullptr, &configureSettings); | 79 nullptr, &configureSettings); |
| 80 | 80 |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll); | 1000 view->setScrollOffset(view->getScrollOffset(), ProgrammaticScroll); |
| 1001 | 1001 |
| 1002 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); | 1002 ASSERT_EQ(80.f, webView->browserControls().contentOffset()); |
| 1003 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height()); | 1003 EXPECT_EQ(expectedRootOffset, rootViewport->getScrollOffset().height()); |
| 1004 | 1004 |
| 1005 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); | 1005 webView->handleInputEvent(generateEvent(WebInputEvent::GestureScrollEnd)); |
| 1006 } | 1006 } |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 } // namespace blink | 1009 } // namespace blink |
| OLD | NEW |