| 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/BrowserControls.h" | 30 #include "core/frame/BrowserControls.h" |
| 31 | 31 |
| 32 #include "core/dom/ClientRect.h" | 32 #include "core/dom/ClientRect.h" |
| 33 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
| 34 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
| 35 #include "core/frame/VisualViewport.h" | 35 #include "core/frame/VisualViewport.h" |
| 36 #include "core/page/Page.h" | 36 #include "core/page/Page.h" |
| 37 #include "platform/testing/URLTestHelpers.h" | 37 #include "platform/testing/URLTestHelpers.h" |
| 38 #include "platform/testing/UnitTestHelpers.h" | 38 #include "platform/testing/UnitTestHelpers.h" |
| 39 #include "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
| 40 #include "public/platform/WebCoalescedInputEvent.h" |
| 40 #include "public/platform/WebURLLoaderMockFactory.h" | 41 #include "public/platform/WebURLLoaderMockFactory.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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 62 RegisterMockedHttpURLLoad("vh-height-width-800.html"); | 63 RegisterMockedHttpURLLoad("vh-height-width-800.html"); |
| 63 RegisterMockedHttpURLLoad("vh-height-width-800-extra-wide.html"); | 64 RegisterMockedHttpURLLoad("vh-height-width-800-extra-wide.html"); |
| 64 } | 65 } |
| 65 | 66 |
| 66 ~BrowserControlsTest() override { | 67 ~BrowserControlsTest() override { |
| 67 Platform::Current() | 68 Platform::Current() |
| 68 ->GetURLLoaderMockFactory() | 69 ->GetURLLoaderMockFactory() |
| 69 ->UnregisterAllURLsAndClearMemoryCache(); | 70 ->UnregisterAllURLsAndClearMemoryCache(); |
| 70 } | 71 } |
| 71 | 72 |
| 72 WebViewImpl* Initialize(const std::string& page_name = "large-div.html") { | 73 WebViewBase* Initialize(const std::string& page_name = "large-div.html") { |
| 73 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); | 74 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); |
| 74 | 75 |
| 75 // 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 |
| 76 // main frame is scrollable. | 77 // main frame is scrollable. |
| 77 helper_.InitializeAndLoad(base_url_ + page_name, true, nullptr, nullptr, | 78 helper_.InitializeAndLoad(base_url_ + page_name, true, nullptr, nullptr, |
| 78 nullptr, &ConfigureSettings); | 79 nullptr, &ConfigureSettings); |
| 79 | 80 |
| 80 GetWebViewImpl()->Resize(IntSize(400, 400)); | 81 GetWebView()->Resize(IntSize(400, 400)); |
| 81 return GetWebViewImpl(); | 82 return GetWebView(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 static void ConfigureSettings(WebSettings* settings) { | 85 static void ConfigureSettings(WebSettings* settings) { |
| 85 settings->SetJavaScriptEnabled(true); | 86 settings->SetJavaScriptEnabled(true); |
| 86 settings->SetAcceleratedCompositingEnabled(true); | 87 settings->SetAcceleratedCompositingEnabled(true); |
| 87 settings->SetPreferCompositingToLCDTextEnabled(true); | 88 settings->SetPreferCompositingToLCDTextEnabled(true); |
| 88 // Android settings | 89 // Android settings |
| 89 settings->SetViewportEnabled(true); | 90 settings->SetViewportEnabled(true); |
| 90 settings->SetViewportMetaEnabled(true); | 91 settings->SetViewportMetaEnabled(true); |
| 91 settings->SetShrinksViewportContentToFit(true); | 92 settings->SetShrinksViewportContentToFit(true); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 107 event.x = 100; | 108 event.x = 100; |
| 108 event.y = 100; | 109 event.y = 100; |
| 109 if (type == WebInputEvent::kGestureScrollUpdate) { | 110 if (type == WebInputEvent::kGestureScrollUpdate) { |
| 110 event.data.scroll_update.delta_x = delta_x; | 111 event.data.scroll_update.delta_x = delta_x; |
| 111 event.data.scroll_update.delta_y = delta_y; | 112 event.data.scroll_update.delta_y = delta_y; |
| 112 } | 113 } |
| 113 return WebCoalescedInputEvent(event); | 114 return WebCoalescedInputEvent(event); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void VerticalScroll(float delta_y) { | 117 void VerticalScroll(float delta_y) { |
| 117 GetWebViewImpl()->HandleInputEvent( | 118 GetWebView()->HandleInputEvent( |
| 118 GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 119 GenerateEvent(WebInputEvent::kGestureScrollBegin)); |
| 119 GetWebViewImpl()->HandleInputEvent( | 120 GetWebView()->HandleInputEvent( |
| 120 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, delta_y)); | 121 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, delta_y)); |
| 121 GetWebViewImpl()->HandleInputEvent( | 122 GetWebView()->HandleInputEvent( |
| 122 GenerateEvent(WebInputEvent::kGestureScrollEnd)); | 123 GenerateEvent(WebInputEvent::kGestureScrollEnd)); |
| 123 } | 124 } |
| 124 | 125 |
| 125 Element* GetElementById(const WebString& id) { | 126 Element* GetElementById(const WebString& id) { |
| 126 return static_cast<Element*>( | 127 return static_cast<Element*>( |
| 127 GetWebViewImpl()->MainFrame()->GetDocument().GetElementById(id)); | 128 GetWebView()->MainFrame()->GetDocument().GetElementById(id)); |
| 128 } | 129 } |
| 129 | 130 |
| 130 WebViewImpl* GetWebViewImpl() const { return helper_.WebView(); } | 131 WebViewBase* GetWebView() const { return helper_.WebView(); } |
| 131 LocalFrame* GetFrame() const { | 132 LocalFrame* GetFrame() const { |
| 132 return helper_.WebView()->MainFrameImpl()->GetFrame(); | 133 return helper_.WebView()->MainFrameImpl()->GetFrame(); |
| 133 } | 134 } |
| 134 VisualViewport& GetVisualViewport() const { | 135 VisualViewport& GetVisualViewport() const { |
| 135 return helper_.WebView()->GetPage()->GetVisualViewport(); | 136 return helper_.WebView()->GetPage()->GetVisualViewport(); |
| 136 } | 137 } |
| 137 | 138 |
| 138 private: | 139 private: |
| 139 std::string base_url_; | 140 std::string base_url_; |
| 140 FrameTestHelpers::WebViewHelper helper_; | 141 FrameTestHelpers::WebViewHelper helper_; |
| 141 }; | 142 }; |
| 142 | 143 |
| 143 #define EXPECT_SIZE_EQ(expected, actual) \ | 144 #define EXPECT_SIZE_EQ(expected, actual) \ |
| 144 do { \ | 145 do { \ |
| 145 EXPECT_FLOAT_EQ((expected).Width(), (actual).Width()); \ | 146 EXPECT_FLOAT_EQ((expected).Width(), (actual).Width()); \ |
| 146 EXPECT_FLOAT_EQ((expected).Height(), (actual).Height()); \ | 147 EXPECT_FLOAT_EQ((expected).Height(), (actual).Height()); \ |
| 147 } while (false) | 148 } while (false) |
| 148 | 149 |
| 149 // Disable these tests on Mac OSX until further investigation. | 150 // Disable these tests on Mac OSX until further investigation. |
| 150 // Local build on Mac is OK but the bot fails. This is not an issue as | 151 // Local build on Mac is OK but the bot fails. This is not an issue as |
| 151 // Browser Controls are currently only used on Android. | 152 // Browser Controls are currently only used on Android. |
| 152 #if OS(MACOSX) | 153 #if OS(MACOSX) |
| 153 #define MAYBE(test) DISABLED_##test | 154 #define MAYBE(test) DISABLED_##test |
| 154 #else | 155 #else |
| 155 #define MAYBE(test) test | 156 #define MAYBE(test) test |
| 156 #endif | 157 #endif |
| 157 | 158 |
| 158 // Scrolling down should hide browser controls. | 159 // Scrolling down should hide browser controls. |
| 159 TEST_F(BrowserControlsTest, MAYBE(HideOnScrollDown)) { | 160 TEST_F(BrowserControlsTest, MAYBE(HideOnScrollDown)) { |
| 160 WebViewImpl* web_view = Initialize(); | 161 WebViewBase* web_view = Initialize(); |
| 161 // initialize browser controls to be shown. | 162 // initialize browser controls to be shown. |
| 162 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); | 163 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); |
| 163 web_view->GetBrowserControls().SetShownRatio(1); | 164 web_view->GetBrowserControls().SetShownRatio(1); |
| 164 | 165 |
| 165 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 166 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); |
| 166 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 167 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 167 | 168 |
| 168 // Browser controls should be scrolled partially and page should not scroll. | 169 // Browser controls should be scrolled partially and page should not scroll. |
| 169 web_view->HandleInputEvent( | 170 web_view->HandleInputEvent( |
| 170 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, -25.f)); | 171 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, -25.f)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 187 web_view->HandleInputEvent( | 188 web_view->HandleInputEvent( |
| 188 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, -20.f)); | 189 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, -20.f)); |
| 189 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 190 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 190 EXPECT_SIZE_EQ( | 191 EXPECT_SIZE_EQ( |
| 191 ScrollOffset(0, 35), | 192 ScrollOffset(0, 35), |
| 192 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 193 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 193 } | 194 } |
| 194 | 195 |
| 195 // Scrolling up should show browser controls. | 196 // Scrolling up should show browser controls. |
| 196 TEST_F(BrowserControlsTest, MAYBE(ShowOnScrollUp)) { | 197 TEST_F(BrowserControlsTest, MAYBE(ShowOnScrollUp)) { |
| 197 WebViewImpl* web_view = Initialize(); | 198 WebViewBase* web_view = Initialize(); |
| 198 // initialize browser controls to be hidden. | 199 // initialize browser controls to be hidden. |
| 199 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, false); | 200 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, false); |
| 200 web_view->GetBrowserControls().SetShownRatio(0); | 201 web_view->GetBrowserControls().SetShownRatio(0); |
| 201 | 202 |
| 202 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 203 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); |
| 203 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 204 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 204 | 205 |
| 205 web_view->HandleInputEvent( | 206 web_view->HandleInputEvent( |
| 206 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, 10.f)); | 207 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, 10.f)); |
| 207 EXPECT_FLOAT_EQ(10.f, web_view->GetBrowserControls().ContentOffset()); | 208 EXPECT_FLOAT_EQ(10.f, web_view->GetBrowserControls().ContentOffset()); |
| 208 EXPECT_SIZE_EQ( | 209 EXPECT_SIZE_EQ( |
| 209 ScrollOffset(0, 0), | 210 ScrollOffset(0, 0), |
| 210 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 211 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 211 | 212 |
| 212 web_view->HandleInputEvent( | 213 web_view->HandleInputEvent( |
| 213 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, 50.f)); | 214 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, 50.f)); |
| 214 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 215 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 215 EXPECT_SIZE_EQ( | 216 EXPECT_SIZE_EQ( |
| 216 ScrollOffset(0, 0), | 217 ScrollOffset(0, 0), |
| 217 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 218 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 218 } | 219 } |
| 219 | 220 |
| 220 // Scrolling up after previous scroll downs should cause browser controls to be | 221 // Scrolling up after previous scroll downs should cause browser controls to be |
| 221 // shown only after all previously scrolled down amount is compensated. | 222 // shown only after all previously scrolled down amount is compensated. |
| 222 TEST_F(BrowserControlsTest, MAYBE(ScrollDownThenUp)) { | 223 TEST_F(BrowserControlsTest, MAYBE(ScrollDownThenUp)) { |
| 223 WebViewImpl* web_view = Initialize(); | 224 WebViewBase* web_view = Initialize(); |
| 224 // initialize browser controls to be shown and position page at 100px. | 225 // initialize browser controls to be shown and position page at 100px. |
| 225 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); | 226 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); |
| 226 web_view->GetBrowserControls().SetShownRatio(1); | 227 web_view->GetBrowserControls().SetShownRatio(1); |
| 227 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 100), | 228 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 100), |
| 228 kProgrammaticScroll); | 229 kProgrammaticScroll); |
| 229 | 230 |
| 230 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 231 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); |
| 231 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 232 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 232 | 233 |
| 233 // Scroll down to completely hide browser controls. Excess deltaY (100px) | 234 // Scroll down to completely hide browser controls. Excess deltaY (100px) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, 70.f)); | 270 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, 70.f)); |
| 270 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 271 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 271 EXPECT_SIZE_EQ( | 272 EXPECT_SIZE_EQ( |
| 272 ScrollOffset(0, 50), | 273 ScrollOffset(0, 50), |
| 273 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 274 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 274 } | 275 } |
| 275 | 276 |
| 276 // Scrolling down should always cause visible browser controls to start hiding | 277 // Scrolling down should always cause visible browser controls to start hiding |
| 277 // even if we have been scrolling up previously. | 278 // even if we have been scrolling up previously. |
| 278 TEST_F(BrowserControlsTest, MAYBE(ScrollUpThenDown)) { | 279 TEST_F(BrowserControlsTest, MAYBE(ScrollUpThenDown)) { |
| 279 WebViewImpl* web_view = Initialize(); | 280 WebViewBase* web_view = Initialize(); |
| 280 // initialize browser controls to be hidden and position page at 100px. | 281 // initialize browser controls to be hidden and position page at 100px. |
| 281 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, false); | 282 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, false); |
| 282 web_view->GetBrowserControls().SetShownRatio(0); | 283 web_view->GetBrowserControls().SetShownRatio(0); |
| 283 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 100), | 284 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 100), |
| 284 kProgrammaticScroll); | 285 kProgrammaticScroll); |
| 285 | 286 |
| 286 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 287 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); |
| 287 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 288 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 288 | 289 |
| 289 // Scroll up to completely show browser controls. Excess deltaY (50px) should | 290 // Scroll up to completely show browser controls. Excess deltaY (50px) should |
| (...skipping 16 matching lines...) Expand all Loading... |
| 306 web_view->HandleInputEvent( | 307 web_view->HandleInputEvent( |
| 307 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, -60.f)); | 308 GenerateEvent(WebInputEvent::kGestureScrollUpdate, 0, -60.f)); |
| 308 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 309 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 309 EXPECT_SIZE_EQ( | 310 EXPECT_SIZE_EQ( |
| 310 ScrollOffset(0, 100), | 311 ScrollOffset(0, 100), |
| 311 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 312 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 312 } | 313 } |
| 313 | 314 |
| 314 // Browser controls should not consume horizontal scroll. | 315 // Browser controls should not consume horizontal scroll. |
| 315 TEST_F(BrowserControlsTest, MAYBE(HorizontalScroll)) { | 316 TEST_F(BrowserControlsTest, MAYBE(HorizontalScroll)) { |
| 316 WebViewImpl* web_view = Initialize(); | 317 WebViewBase* web_view = Initialize(); |
| 317 // initialize browser controls to be shown. | 318 // initialize browser controls to be shown. |
| 318 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); | 319 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); |
| 319 web_view->GetBrowserControls().SetShownRatio(1); | 320 web_view->GetBrowserControls().SetShownRatio(1); |
| 320 | 321 |
| 321 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 322 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); |
| 322 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 323 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 323 | 324 |
| 324 // Browser controls should not consume horizontal scroll. | 325 // Browser controls should not consume horizontal scroll. |
| 325 web_view->HandleInputEvent( | 326 web_view->HandleInputEvent( |
| 326 GenerateEvent(WebInputEvent::kGestureScrollUpdate, -110.f, -100.f)); | 327 GenerateEvent(WebInputEvent::kGestureScrollUpdate, -110.f, -100.f)); |
| 327 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 328 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 328 EXPECT_SIZE_EQ( | 329 EXPECT_SIZE_EQ( |
| 329 ScrollOffset(110, 50), | 330 ScrollOffset(110, 50), |
| 330 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 331 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 331 | 332 |
| 332 web_view->HandleInputEvent( | 333 web_view->HandleInputEvent( |
| 333 GenerateEvent(WebInputEvent::kGestureScrollUpdate, -40.f, 0)); | 334 GenerateEvent(WebInputEvent::kGestureScrollUpdate, -40.f, 0)); |
| 334 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 335 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 335 EXPECT_SIZE_EQ( | 336 EXPECT_SIZE_EQ( |
| 336 ScrollOffset(150, 50), | 337 ScrollOffset(150, 50), |
| 337 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 338 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 338 } | 339 } |
| 339 | 340 |
| 340 // Page scale should not impact browser controls scrolling | 341 // Page scale should not impact browser controls scrolling |
| 341 TEST_F(BrowserControlsTest, MAYBE(PageScaleHasNoImpact)) { | 342 TEST_F(BrowserControlsTest, MAYBE(PageScaleHasNoImpact)) { |
| 342 WebViewImpl* web_view = Initialize(); | 343 WebViewBase* web_view = Initialize(); |
| 343 GetWebViewImpl()->SetDefaultPageScaleLimits(0.25f, 5); | 344 GetWebView()->SetDefaultPageScaleLimits(0.25f, 5); |
| 344 web_view->SetPageScaleFactor(2.0); | 345 web_view->SetPageScaleFactor(2.0); |
| 345 | 346 |
| 346 // Initialize browser controls to be shown. | 347 // Initialize browser controls to be shown. |
| 347 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); | 348 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); |
| 348 web_view->GetBrowserControls().SetShownRatio(1); | 349 web_view->GetBrowserControls().SetShownRatio(1); |
| 349 | 350 |
| 350 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); | 351 web_view->HandleInputEvent(GenerateEvent(WebInputEvent::kGestureScrollBegin)); |
| 351 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 352 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 352 | 353 |
| 353 // Browser controls should be scrolled partially and page should not scroll. | 354 // Browser controls should be scrolled partially and page should not scroll. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 388 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 388 EXPECT_SIZE_EQ(ScrollOffset(0, 0), | 389 EXPECT_SIZE_EQ(ScrollOffset(0, 0), |
| 389 GetFrame()->View()->GetScrollableArea()->GetScrollOffset()); | 390 GetFrame()->View()->GetScrollableArea()->GetScrollOffset()); |
| 390 } | 391 } |
| 391 | 392 |
| 392 // Some scroll deltas result in a shownRatio that can't be realized in a | 393 // Some scroll deltas result in a shownRatio that can't be realized in a |
| 393 // floating-point number. Make sure that if the browser controls aren't fully | 394 // floating-point number. Make sure that if the browser controls aren't fully |
| 394 // scrolled, scrollBy doesn't return any excess delta. i.e. There should be no | 395 // scrolled, scrollBy doesn't return any excess delta. i.e. There should be no |
| 395 // slippage between the content and browser controls. | 396 // slippage between the content and browser controls. |
| 396 TEST_F(BrowserControlsTest, MAYBE(FloatingPointSlippage)) { | 397 TEST_F(BrowserControlsTest, MAYBE(FloatingPointSlippage)) { |
| 397 WebViewImpl* web_view = Initialize(); | 398 WebViewBase* web_view = Initialize(); |
| 398 GetWebViewImpl()->SetDefaultPageScaleLimits(0.25f, 5); | 399 GetWebView()->SetDefaultPageScaleLimits(0.25f, 5); |
| 399 web_view->SetPageScaleFactor(2.0); | 400 web_view->SetPageScaleFactor(2.0); |
| 400 | 401 |
| 401 // Initialize browser controls to be shown. | 402 // Initialize browser controls to be shown. |
| 402 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); | 403 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); |
| 403 web_view->GetBrowserControls().SetShownRatio(1); | 404 web_view->GetBrowserControls().SetShownRatio(1); |
| 404 | 405 |
| 405 web_view->GetBrowserControls().ScrollBegin(); | 406 web_view->GetBrowserControls().ScrollBegin(); |
| 406 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 407 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 407 | 408 |
| 408 // This will result in a 20px scroll to the browser controls so the show ratio | 409 // This will result in a 20px scroll to the browser controls so the show ratio |
| 409 // will be 30/50 == 0.6 which is not representible in a float. Make sure | 410 // will be 30/50 == 0.6 which is not representible in a float. Make sure |
| 410 // that scroll still consumes the whole delta. | 411 // that scroll still consumes the whole delta. |
| 411 FloatSize remaining_delta = | 412 FloatSize remaining_delta = |
| 412 web_view->GetBrowserControls().ScrollBy(FloatSize(0, 10)); | 413 web_view->GetBrowserControls().ScrollBy(FloatSize(0, 10)); |
| 413 EXPECT_EQ(0, remaining_delta.Height()); | 414 EXPECT_EQ(0, remaining_delta.Height()); |
| 414 } | 415 } |
| 415 | 416 |
| 416 // Scrollable subregions should scroll before browser controls | 417 // Scrollable subregions should scroll before browser controls |
| 417 TEST_F(BrowserControlsTest, MAYBE(ScrollableSubregionScrollFirst)) { | 418 TEST_F(BrowserControlsTest, MAYBE(ScrollableSubregionScrollFirst)) { |
| 418 WebViewImpl* web_view = Initialize("overflow-scrolling.html"); | 419 WebViewBase* web_view = Initialize("overflow-scrolling.html"); |
| 419 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); | 420 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); |
| 420 web_view->GetBrowserControls().SetShownRatio(1); | 421 web_view->GetBrowserControls().SetShownRatio(1); |
| 421 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 50), | 422 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 50), |
| 422 kProgrammaticScroll); | 423 kProgrammaticScroll); |
| 423 | 424 |
| 424 // Test scroll down | 425 // Test scroll down |
| 425 // Scroll down should scroll the overflow div first but browser controls and | 426 // Scroll down should scroll the overflow div first but browser controls and |
| 426 // main frame should not scroll. | 427 // main frame should not scroll. |
| 427 VerticalScroll(-800.f); | 428 VerticalScroll(-800.f); |
| 428 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 429 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // Continued scroll down up scroll up the main frame | 465 // Continued scroll down up scroll up the main frame |
| 465 VerticalScroll(40.f); | 466 VerticalScroll(40.f); |
| 466 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 467 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 467 EXPECT_SIZE_EQ( | 468 EXPECT_SIZE_EQ( |
| 468 ScrollOffset(0, 50), | 469 ScrollOffset(0, 50), |
| 469 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 470 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 470 } | 471 } |
| 471 | 472 |
| 472 // Scrollable iframes should scroll before browser controls | 473 // Scrollable iframes should scroll before browser controls |
| 473 TEST_F(BrowserControlsTest, MAYBE(ScrollableIframeScrollFirst)) { | 474 TEST_F(BrowserControlsTest, MAYBE(ScrollableIframeScrollFirst)) { |
| 474 WebViewImpl* web_view = Initialize("iframe-scrolling.html"); | 475 WebViewBase* web_view = Initialize("iframe-scrolling.html"); |
| 475 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); | 476 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); |
| 476 web_view->GetBrowserControls().SetShownRatio(1); | 477 web_view->GetBrowserControls().SetShownRatio(1); |
| 477 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 50), | 478 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 50), |
| 478 kProgrammaticScroll); | 479 kProgrammaticScroll); |
| 479 | 480 |
| 480 // Test scroll down | 481 // Test scroll down |
| 481 // Scroll down should scroll the iframe first but browser controls and main | 482 // Scroll down should scroll the iframe first but browser controls and main |
| 482 // frame should not scroll. | 483 // frame should not scroll. |
| 483 VerticalScroll(-800.f); | 484 VerticalScroll(-800.f); |
| 484 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 485 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 // Continued scroll down up scroll up the main frame | 521 // Continued scroll down up scroll up the main frame |
| 521 VerticalScroll(40.f); | 522 VerticalScroll(40.f); |
| 522 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 523 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 523 EXPECT_SIZE_EQ( | 524 EXPECT_SIZE_EQ( |
| 524 ScrollOffset(0, 50), | 525 ScrollOffset(0, 50), |
| 525 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 526 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 526 } | 527 } |
| 527 | 528 |
| 528 // Browser controls visibility should remain consistent when height is changed. | 529 // Browser controls visibility should remain consistent when height is changed. |
| 529 TEST_F(BrowserControlsTest, MAYBE(HeightChangeMaintainsVisibility)) { | 530 TEST_F(BrowserControlsTest, MAYBE(HeightChangeMaintainsVisibility)) { |
| 530 WebViewImpl* web_view = Initialize(); | 531 WebViewBase* web_view = Initialize(); |
| 531 web_view->ResizeWithBrowserControls(web_view->Size(), 20.f, false); | 532 web_view->ResizeWithBrowserControls(web_view->Size(), 20.f, false); |
| 532 web_view->GetBrowserControls().SetShownRatio(0); | 533 web_view->GetBrowserControls().SetShownRatio(0); |
| 533 | 534 |
| 534 web_view->ResizeWithBrowserControls(web_view->Size(), 20.f, false); | 535 web_view->ResizeWithBrowserControls(web_view->Size(), 20.f, false); |
| 535 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 536 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 536 | 537 |
| 537 web_view->ResizeWithBrowserControls(web_view->Size(), 40.f, false); | 538 web_view->ResizeWithBrowserControls(web_view->Size(), 40.f, false); |
| 538 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 539 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 539 | 540 |
| 540 // Scroll up to show browser controls. | 541 // Scroll up to show browser controls. |
| 541 VerticalScroll(40.f); | 542 VerticalScroll(40.f); |
| 542 EXPECT_FLOAT_EQ(40.f, web_view->GetBrowserControls().ContentOffset()); | 543 EXPECT_FLOAT_EQ(40.f, web_view->GetBrowserControls().ContentOffset()); |
| 543 | 544 |
| 544 // Changing height of a fully shown browser controls should correctly adjust | 545 // Changing height of a fully shown browser controls should correctly adjust |
| 545 // content offset | 546 // content offset |
| 546 web_view->ResizeWithBrowserControls(web_view->Size(), 30.f, false); | 547 web_view->ResizeWithBrowserControls(web_view->Size(), 30.f, false); |
| 547 EXPECT_FLOAT_EQ(30.f, web_view->GetBrowserControls().ContentOffset()); | 548 EXPECT_FLOAT_EQ(30.f, web_view->GetBrowserControls().ContentOffset()); |
| 548 } | 549 } |
| 549 | 550 |
| 550 // Zero delta should not have any effect on browser controls. | 551 // Zero delta should not have any effect on browser controls. |
| 551 TEST_F(BrowserControlsTest, MAYBE(ZeroHeightMeansNoEffect)) { | 552 TEST_F(BrowserControlsTest, MAYBE(ZeroHeightMeansNoEffect)) { |
| 552 WebViewImpl* web_view = Initialize(); | 553 WebViewBase* web_view = Initialize(); |
| 553 web_view->ResizeWithBrowserControls(web_view->Size(), 0, false); | 554 web_view->ResizeWithBrowserControls(web_view->Size(), 0, false); |
| 554 web_view->GetBrowserControls().SetShownRatio(0); | 555 web_view->GetBrowserControls().SetShownRatio(0); |
| 555 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 100), | 556 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 100), |
| 556 kProgrammaticScroll); | 557 kProgrammaticScroll); |
| 557 | 558 |
| 558 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 559 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 559 | 560 |
| 560 VerticalScroll(20.f); | 561 VerticalScroll(20.f); |
| 561 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 562 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 562 EXPECT_SIZE_EQ( | 563 EXPECT_SIZE_EQ( |
| 563 ScrollOffset(0, 80), | 564 ScrollOffset(0, 80), |
| 564 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 565 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 565 | 566 |
| 566 VerticalScroll(-30.f); | 567 VerticalScroll(-30.f); |
| 567 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 568 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 568 EXPECT_SIZE_EQ( | 569 EXPECT_SIZE_EQ( |
| 569 ScrollOffset(0, 110), | 570 ScrollOffset(0, 110), |
| 570 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); | 571 GetFrame()->View()->LayoutViewportScrollableArea()->GetScrollOffset()); |
| 571 | 572 |
| 572 web_view->GetBrowserControls().SetShownRatio(1); | 573 web_view->GetBrowserControls().SetShownRatio(1); |
| 573 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); | 574 EXPECT_FLOAT_EQ(0.f, web_view->GetBrowserControls().ContentOffset()); |
| 574 } | 575 } |
| 575 | 576 |
| 576 // Browser controls should not hide when scrolling up past limit | 577 // Browser controls should not hide when scrolling up past limit |
| 577 TEST_F(BrowserControlsTest, MAYBE(ScrollUpPastLimitDoesNotHide)) { | 578 TEST_F(BrowserControlsTest, MAYBE(ScrollUpPastLimitDoesNotHide)) { |
| 578 WebViewImpl* web_view = Initialize(); | 579 WebViewBase* web_view = Initialize(); |
| 579 // Initialize browser controls to be shown | 580 // Initialize browser controls to be shown |
| 580 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); | 581 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, true); |
| 581 web_view->GetBrowserControls().SetShownRatio(1); | 582 web_view->GetBrowserControls().SetShownRatio(1); |
| 582 // Use 2x scale so that both visual viewport and frameview are scrollable | 583 // Use 2x scale so that both visual viewport and frameview are scrollable |
| 583 web_view->SetPageScaleFactor(2.0); | 584 web_view->SetPageScaleFactor(2.0); |
| 584 | 585 |
| 585 // Fully scroll frameview but visualviewport remains scrollable | 586 // Fully scroll frameview but visualviewport remains scrollable |
| 586 web_view->MainFrame()->SetScrollOffset(WebSize(0, 10000)); | 587 web_view->MainFrame()->SetScrollOffset(WebSize(0, 10000)); |
| 587 GetVisualViewport().SetLocation(FloatPoint(0, 0)); | 588 GetVisualViewport().SetLocation(FloatPoint(0, 0)); |
| 588 VerticalScroll(-10.f); | 589 VerticalScroll(-10.f); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 601 GetVisualViewport().SetLocation(FloatPoint(0, 10000)); | 602 GetVisualViewport().SetLocation(FloatPoint(0, 10000)); |
| 602 VerticalScroll(-30.f); | 603 VerticalScroll(-30.f); |
| 603 // Browser controls should not move because neither frameview nor visual | 604 // Browser controls should not move because neither frameview nor visual |
| 604 // viewport | 605 // viewport |
| 605 // are scrollable | 606 // are scrollable |
| 606 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 607 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 607 } | 608 } |
| 608 | 609 |
| 609 // Browser controls should honor its constraints | 610 // Browser controls should honor its constraints |
| 610 TEST_F(BrowserControlsTest, MAYBE(StateConstraints)) { | 611 TEST_F(BrowserControlsTest, MAYBE(StateConstraints)) { |
| 611 WebViewImpl* web_view = Initialize(); | 612 WebViewBase* web_view = Initialize(); |
| 612 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, false); | 613 web_view->ResizeWithBrowserControls(web_view->Size(), 50.f, false); |
| 613 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 100), | 614 GetFrame()->View()->GetScrollableArea()->SetScrollOffset(ScrollOffset(0, 100), |
| 614 kProgrammaticScroll); | 615 kProgrammaticScroll); |
| 615 | 616 |
| 616 // Setting permitted state should change the content offset to match the | 617 // Setting permitted state should change the content offset to match the |
| 617 // constraint. | 618 // constraint. |
| 618 web_view->UpdateBrowserControlsState(kWebBrowserControlsShown, | 619 web_view->UpdateBrowserControlsState(kWebBrowserControlsShown, |
| 619 kWebBrowserControlsShown, false); | 620 kWebBrowserControlsShown, false); |
| 620 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); | 621 EXPECT_FLOAT_EQ(50.f, web_view->GetBrowserControls().ContentOffset()); |
| 621 | 622 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 | 682 |
| 682 web_view->UpdateBrowserControlsState(kWebBrowserControlsShown, | 683 web_view->UpdateBrowserControlsState(kWebBrowserControlsShown, |
| 683 kWebBrowserControlsBoth, false); | 684 kWebBrowserControlsBoth, false); |
| 684 EXPECT_FLOAT_EQ(50, web_view->GetBrowserControls().ContentOffset()); | 685 EXPECT_FLOAT_EQ(50, web_view->GetBrowserControls().ContentOffset()); |
| 685 } | 686 } |
| 686 | 687 |
| 687 // Ensure that browser controls do not affect the layout by showing and hiding | 688 // Ensure that browser controls do not affect the layout by showing and hiding |
| 688 // except for position: fixed elements. | 689 // except for position: fixed elements. |
| 689 TEST_F(BrowserControlsTest, MAYBE(DontAffectLayoutHeight)) { | 690 TEST_F(BrowserControlsTest, MAYBE(DontAffectLayoutHeight)) { |
| 690 // Initialize with the browser controls showing. | 691 // Initialize with the browser controls showing. |
| 691 WebViewImpl* web_view = Initialize("percent-height.html"); | 692 WebViewBase* web_view = Initialize("percent-height.html"); |
| 692 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); | 693 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 693 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, | 694 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, |
| 694 kWebBrowserControlsShown, false); | 695 kWebBrowserControlsShown, false); |
| 695 web_view->GetBrowserControls().SetShownRatio(1); | 696 web_view->GetBrowserControls().SetShownRatio(1); |
| 696 web_view->UpdateAllLifecyclePhases(); | 697 web_view->UpdateAllLifecyclePhases(); |
| 697 | 698 |
| 698 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); | 699 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); |
| 699 | 700 |
| 700 // When the browser controls are showing, there's 300px for the layout height | 701 // When the browser controls are showing, there's 300px for the layout height |
| 701 // so | 702 // so |
| (...skipping 23 matching lines...) Expand all Loading... |
| 725 | 726 |
| 726 // The layout size should not change as a result of browser controls hiding. | 727 // The layout size should not change as a result of browser controls hiding. |
| 727 EXPECT_EQ(300, | 728 EXPECT_EQ(300, |
| 728 GetFrame()->View()->GetLayoutSize(kIncludeScrollbars).Height()); | 729 GetFrame()->View()->GetLayoutSize(kIncludeScrollbars).Height()); |
| 729 } | 730 } |
| 730 | 731 |
| 731 // Ensure that browser controls do not affect the layout by showing and hiding | 732 // Ensure that browser controls do not affect the layout by showing and hiding |
| 732 // except for position: fixed elements. | 733 // except for position: fixed elements. |
| 733 TEST_F(BrowserControlsTest, MAYBE(AffectLayoutHeightWhenConstrained)) { | 734 TEST_F(BrowserControlsTest, MAYBE(AffectLayoutHeightWhenConstrained)) { |
| 734 // Initialize with the browser controls showing. | 735 // Initialize with the browser controls showing. |
| 735 WebViewImpl* web_view = Initialize("percent-height.html"); | 736 WebViewBase* web_view = Initialize("percent-height.html"); |
| 736 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); | 737 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 737 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, | 738 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, |
| 738 kWebBrowserControlsShown, false); | 739 kWebBrowserControlsShown, false); |
| 739 web_view->GetBrowserControls().SetShownRatio(1); | 740 web_view->GetBrowserControls().SetShownRatio(1); |
| 740 web_view->UpdateAllLifecyclePhases(); | 741 web_view->UpdateAllLifecyclePhases(); |
| 741 | 742 |
| 742 Element* abs_pos = GetElementById(WebString::FromUTF8("abs")); | 743 Element* abs_pos = GetElementById(WebString::FromUTF8("abs")); |
| 743 Element* fixed_pos = GetElementById(WebString::FromUTF8("fixed")); | 744 Element* fixed_pos = GetElementById(WebString::FromUTF8("fixed")); |
| 744 | 745 |
| 745 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); | 746 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 EXPECT_FLOAT_EQ(200.f, abs_pos->getBoundingClientRect()->height()); | 812 EXPECT_FLOAT_EQ(200.f, abs_pos->getBoundingClientRect()->height()); |
| 812 EXPECT_FLOAT_EQ(200.f, fixed_pos->getBoundingClientRect()->height()); | 813 EXPECT_FLOAT_EQ(200.f, fixed_pos->getBoundingClientRect()->height()); |
| 813 | 814 |
| 814 EXPECT_EQ(400, | 815 EXPECT_EQ(400, |
| 815 GetFrame()->View()->GetLayoutSize(kIncludeScrollbars).Height()); | 816 GetFrame()->View()->GetLayoutSize(kIncludeScrollbars).Height()); |
| 816 } | 817 } |
| 817 | 818 |
| 818 // Ensure that browser controls do not affect vh units. | 819 // Ensure that browser controls do not affect vh units. |
| 819 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnits)) { | 820 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnits)) { |
| 820 // Initialize with the browser controls showing. | 821 // Initialize with the browser controls showing. |
| 821 WebViewImpl* web_view = Initialize("vh-height.html"); | 822 WebViewBase* web_view = Initialize("vh-height.html"); |
| 822 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); | 823 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 823 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, | 824 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, |
| 824 kWebBrowserControlsShown, false); | 825 kWebBrowserControlsShown, false); |
| 825 web_view->GetBrowserControls().SetShownRatio(1); | 826 web_view->GetBrowserControls().SetShownRatio(1); |
| 826 web_view->UpdateAllLifecyclePhases(); | 827 web_view->UpdateAllLifecyclePhases(); |
| 827 | 828 |
| 828 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); | 829 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); |
| 829 | 830 |
| 830 // 'vh' units should be based on the viewport when the browser controls are | 831 // 'vh' units should be based on the viewport when the browser controls are |
| 831 // hidden. | 832 // hidden. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 853 // The viewport size used for vh units should not change as a result of top | 854 // The viewport size used for vh units should not change as a result of top |
| 854 // controls hiding. | 855 // controls hiding. |
| 855 EXPECT_EQ(400, GetFrame()->View()->ViewportSizeForViewportUnits().Height()); | 856 EXPECT_EQ(400, GetFrame()->View()->ViewportSizeForViewportUnits().Height()); |
| 856 } | 857 } |
| 857 | 858 |
| 858 // Ensure that on a legacy page (there's a non-1 minimum scale) 100vh units fill | 859 // Ensure that on a legacy page (there's a non-1 minimum scale) 100vh units fill |
| 859 // the viewport, with browser controls hidden, when the viewport encompasses the | 860 // the viewport, with browser controls hidden, when the viewport encompasses the |
| 860 // layout width. | 861 // layout width. |
| 861 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnitsWithScale)) { | 862 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnitsWithScale)) { |
| 862 // Initialize with the browser controls showing. | 863 // Initialize with the browser controls showing. |
| 863 WebViewImpl* web_view = Initialize("vh-height-width-800.html"); | 864 WebViewBase* web_view = Initialize("vh-height-width-800.html"); |
| 864 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); | 865 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 865 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, | 866 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, |
| 866 kWebBrowserControlsShown, false); | 867 kWebBrowserControlsShown, false); |
| 867 web_view->GetBrowserControls().SetShownRatio(1); | 868 web_view->GetBrowserControls().SetShownRatio(1); |
| 868 web_view->UpdateAllLifecyclePhases(); | 869 web_view->UpdateAllLifecyclePhases(); |
| 869 | 870 |
| 870 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); | 871 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); |
| 871 | 872 |
| 872 // Device viewport is 400px but the page is width=800 so minimum-scale | 873 // Device viewport is 400px but the page is width=800 so minimum-scale |
| 873 // should be 0.5. This is also the scale at which the viewport fills the | 874 // should be 0.5. This is also the scale at which the viewport fills the |
| (...skipping 29 matching lines...) Expand all Loading... |
| 903 // controls hiding. | 904 // controls hiding. |
| 904 EXPECT_EQ(800, GetFrame()->View()->ViewportSizeForViewportUnits().Height()); | 905 EXPECT_EQ(800, GetFrame()->View()->ViewportSizeForViewportUnits().Height()); |
| 905 } | 906 } |
| 906 | 907 |
| 907 // Ensure that on a legacy page (there's a non-1 minimum scale) whose viewport | 908 // Ensure that on a legacy page (there's a non-1 minimum scale) whose viewport |
| 908 // at minimum-scale is larger than the layout size, 100vh units fill the | 909 // at minimum-scale is larger than the layout size, 100vh units fill the |
| 909 // viewport, with browser controls hidden, when the viewport is scaled such that | 910 // viewport, with browser controls hidden, when the viewport is scaled such that |
| 910 // its width equals the layout width. | 911 // its width equals the layout width. |
| 911 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnitsUseLayoutSize)) { | 912 TEST_F(BrowserControlsTest, MAYBE(DontAffectVHUnitsUseLayoutSize)) { |
| 912 // Initialize with the browser controls showing. | 913 // Initialize with the browser controls showing. |
| 913 WebViewImpl* web_view = Initialize("vh-height-width-800-extra-wide.html"); | 914 WebViewBase* web_view = Initialize("vh-height-width-800-extra-wide.html"); |
| 914 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); | 915 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 915 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, | 916 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, |
| 916 kWebBrowserControlsShown, false); | 917 kWebBrowserControlsShown, false); |
| 917 web_view->GetBrowserControls().SetShownRatio(1); | 918 web_view->GetBrowserControls().SetShownRatio(1); |
| 918 web_view->UpdateAllLifecyclePhases(); | 919 web_view->UpdateAllLifecyclePhases(); |
| 919 | 920 |
| 920 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); | 921 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); |
| 921 | 922 |
| 922 // Device viewport is 400px and page is width=800 but there's an element | 923 // Device viewport is 400px and page is width=800 but there's an element |
| 923 // that's 1600px wide so the minimum scale is 0.25 to encompass that. | 924 // that's 1600px wide so the minimum scale is 0.25 to encompass that. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 937 TEST_F(BrowserControlsTest, | 938 TEST_F(BrowserControlsTest, |
| 938 MAYBE(AnchorViewportDuringbrowserControlsAdjustment)) { | 939 MAYBE(AnchorViewportDuringbrowserControlsAdjustment)) { |
| 939 int content_height = 1016; | 940 int content_height = 1016; |
| 940 int layout_viewport_height = 500; | 941 int layout_viewport_height = 500; |
| 941 int visual_viewport_height = 500; | 942 int visual_viewport_height = 500; |
| 942 int browser_controls_height = 100; | 943 int browser_controls_height = 100; |
| 943 int page_scale = 2; | 944 int page_scale = 2; |
| 944 int min_scale = 1; | 945 int min_scale = 1; |
| 945 | 946 |
| 946 // Initialize with the browser controls showing. | 947 // Initialize with the browser controls showing. |
| 947 WebViewImpl* web_view = Initialize("large-div.html"); | 948 WebViewBase* web_view = Initialize("large-div.html"); |
| 948 GetWebViewImpl()->SetDefaultPageScaleLimits(min_scale, 5); | 949 GetWebView()->SetDefaultPageScaleLimits(min_scale, 5); |
| 949 web_view->ResizeWithBrowserControls(WebSize(800, layout_viewport_height), | 950 web_view->ResizeWithBrowserControls(WebSize(800, layout_viewport_height), |
| 950 browser_controls_height, true); | 951 browser_controls_height, true); |
| 951 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, | 952 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, |
| 952 kWebBrowserControlsShown, false); | 953 kWebBrowserControlsShown, false); |
| 953 web_view->GetBrowserControls().SetShownRatio(1); | 954 web_view->GetBrowserControls().SetShownRatio(1); |
| 954 web_view->UpdateAllLifecyclePhases(); | 955 web_view->UpdateAllLifecyclePhases(); |
| 955 | 956 |
| 956 FrameView* view = GetFrame()->View(); | 957 FrameView* view = GetFrame()->View(); |
| 957 ScrollableArea* root_viewport = GetFrame()->View()->GetScrollableArea(); | 958 ScrollableArea* root_viewport = GetFrame()->View()->GetScrollableArea(); |
| 958 | 959 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 } | 1021 } |
| 1021 | 1022 |
| 1022 // Ensure that vh units are correct when browser controls are in a locked | 1023 // Ensure that vh units are correct when browser controls are in a locked |
| 1023 // state. That is, normally we need to add the browser controls height to vh | 1024 // state. That is, normally we need to add the browser controls height to vh |
| 1024 // units since 100vh includes the browser controls even if they're hidden while | 1025 // units since 100vh includes the browser controls even if they're hidden while |
| 1025 // the ICB height does not. When the controls are locked hidden, the ICB size | 1026 // the ICB height does not. When the controls are locked hidden, the ICB size |
| 1026 // is the full viewport height so there's no need to add the browser controls | 1027 // is the full viewport height so there's no need to add the browser controls |
| 1027 // height. crbug.com/688738. | 1028 // height. crbug.com/688738. |
| 1028 TEST_F(BrowserControlsTest, MAYBE(ViewportUnitsWhenControlsLocked)) { | 1029 TEST_F(BrowserControlsTest, MAYBE(ViewportUnitsWhenControlsLocked)) { |
| 1029 // Initialize with the browser controls showing. | 1030 // Initialize with the browser controls showing. |
| 1030 WebViewImpl* web_view = Initialize("vh-height.html"); | 1031 WebViewBase* web_view = Initialize("vh-height.html"); |
| 1031 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); | 1032 web_view->ResizeWithBrowserControls(WebSize(400, 300), 100.f, true); |
| 1032 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, | 1033 web_view->UpdateBrowserControlsState(kWebBrowserControlsBoth, |
| 1033 kWebBrowserControlsShown, false); | 1034 kWebBrowserControlsShown, false); |
| 1034 web_view->GetBrowserControls().SetShownRatio(1); | 1035 web_view->GetBrowserControls().SetShownRatio(1); |
| 1035 web_view->UpdateAllLifecyclePhases(); | 1036 web_view->UpdateAllLifecyclePhases(); |
| 1036 | 1037 |
| 1037 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); | 1038 ASSERT_EQ(100.f, web_view->GetBrowserControls().ContentOffset()); |
| 1038 ASSERT_EQ(300, GetFrame()->View()->GetLayoutSize().Height()); | 1039 ASSERT_EQ(300, GetFrame()->View()->GetLayoutSize().Height()); |
| 1039 | 1040 |
| 1040 Element* abs_pos = GetElementById(WebString::FromUTF8("abs")); | 1041 Element* abs_pos = GetElementById(WebString::FromUTF8("abs")); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1071 | 1072 |
| 1072 // Make sure we're not adding the browser controls height to the vh units as | 1073 // Make sure we're not adding the browser controls height to the vh units as |
| 1073 // when they're locked to hidden, the ICB fills the entire viewport already. | 1074 // when they're locked to hidden, the ICB fills the entire viewport already. |
| 1074 EXPECT_FLOAT_EQ(200.f, abs_pos->getBoundingClientRect()->height()); | 1075 EXPECT_FLOAT_EQ(200.f, abs_pos->getBoundingClientRect()->height()); |
| 1075 EXPECT_FLOAT_EQ(200.f, fixed_pos->getBoundingClientRect()->height()); | 1076 EXPECT_FLOAT_EQ(200.f, fixed_pos->getBoundingClientRect()->height()); |
| 1076 EXPECT_EQ(400, GetFrame()->View()->ViewportSizeForViewportUnits().Height()); | 1077 EXPECT_EQ(400, GetFrame()->View()->ViewportSizeForViewportUnits().Height()); |
| 1077 } | 1078 } |
| 1078 } | 1079 } |
| 1079 | 1080 |
| 1080 } // namespace blink | 1081 } // namespace blink |
| OLD | NEW |