Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2443613002: Rename classes related to top controls (Closed)
Patch Set: fix test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 7336 matching lines...) Expand 10 before | Expand all | Expand 10 after
7347 webViewHelper.initializeAndLoad("about:blank"); 7347 webViewHelper.initializeAndLoad("about:blank");
7348 webViewHelper.resize(WebSize(200, 200)); 7348 webViewHelper.resize(WebSize(200, 200));
7349 webViewHelper.webView()->updateAllLifecyclePhases(); 7349 webViewHelper.webView()->updateAllLifecyclePhases();
7350 7350
7351 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView(); 7351 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView();
7352 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect()); 7352 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), frameView->frameRect());
7353 frameView->setFrameRect(IntRect(100, 100, 200, 200)); 7353 frameView->setFrameRect(IntRect(100, 100, 200, 200));
7354 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect()); 7354 EXPECT_RECT_EQ(IntRect(100, 100, 200, 200), frameView->frameRect());
7355 } 7355 }
7356 7356
7357 TEST_F(WebFrameTest, FrameViewScrollAccountsForTopControls) { 7357 TEST_F(WebFrameTest, FrameViewScrollAccountsForBrowserControls) {
7358 FakeCompositingWebViewClient client; 7358 FakeCompositingWebViewClient client;
7359 registerMockedHttpURLLoad("long_scroll.html"); 7359 registerMockedHttpURLLoad("long_scroll.html");
7360 FrameTestHelpers::WebViewHelper webViewHelper; 7360 FrameTestHelpers::WebViewHelper webViewHelper;
7361 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, nullptr, 7361 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, nullptr,
7362 &client, nullptr, configureAndroid); 7362 &client, nullptr, configureAndroid);
7363 7363
7364 WebViewImpl* webView = webViewHelper.webView(); 7364 WebViewImpl* webView = webViewHelper.webView();
7365 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView(); 7365 FrameView* frameView = webViewHelper.webView()->mainFrameImpl()->frameView();
7366 7366
7367 float topControlsHeight = 40; 7367 float browserControlsHeight = 40;
7368 webView->resizeWithTopControls(WebSize(100, 100), topControlsHeight, false); 7368 webView->resizeWithBrowserControls(WebSize(100, 100), browserControlsHeight,
7369 false);
7369 webView->setPageScaleFactor(2.0f); 7370 webView->setPageScaleFactor(2.0f);
7370 webView->updateAllLifecyclePhases(); 7371 webView->updateAllLifecyclePhases();
7371 7372
7372 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); 7373 webView->mainFrame()->setScrollOffset(WebSize(0, 2000));
7373 EXPECT_SIZE_EQ(ScrollOffset(0, 1900), frameView->scrollOffset()); 7374 EXPECT_SIZE_EQ(ScrollOffset(0, 1900), frameView->scrollOffset());
7374 7375
7375 // Simulate the top controls showing by 20px, thus shrinking the viewport 7376 // Simulate the browser controls showing by 20px, thus shrinking the viewport
7376 // and allowing it to scroll an additional 20px. 7377 // and allowing it to scroll an additional 20px.
7377 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 7378 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
7378 1.0f, 20.0f / topControlsHeight); 7379 1.0f, 20.0f / browserControlsHeight);
7379 EXPECT_SIZE_EQ(ScrollOffset(0, 1920), frameView->maximumScrollOffset()); 7380 EXPECT_SIZE_EQ(ScrollOffset(0, 1920), frameView->maximumScrollOffset());
7380 7381
7381 // Show more, make sure the scroll actually gets clamped. 7382 // Show more, make sure the scroll actually gets clamped.
7382 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 7383 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
7383 1.0f, 20.0f / topControlsHeight); 7384 1.0f, 20.0f / browserControlsHeight);
7384 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); 7385 webView->mainFrame()->setScrollOffset(WebSize(0, 2000));
7385 EXPECT_SIZE_EQ(ScrollOffset(0, 1940), frameView->scrollOffset()); 7386 EXPECT_SIZE_EQ(ScrollOffset(0, 1940), frameView->scrollOffset());
7386 7387
7387 // Hide until there's 10px showing. 7388 // Hide until there's 10px showing.
7388 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 7389 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
7389 1.0f, -30.0f / topControlsHeight); 7390 1.0f, -30.0f / browserControlsHeight);
7390 EXPECT_SIZE_EQ(ScrollOffset(0, 1910), frameView->maximumScrollOffset()); 7391 EXPECT_SIZE_EQ(ScrollOffset(0, 1910), frameView->maximumScrollOffset());
7391 7392
7392 // Simulate a LayoutPart::resize. The frame is resized to accomodate 7393 // Simulate a LayoutPart::resize. The frame is resized to accomodate
7393 // the top controls and Blink's view of the top controls matches that of 7394 // the browser controls and Blink's view of the browser controls matches that
7394 // the CC 7395 // of the CC
7395 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 7396 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
7396 1.0f, 30.0f / topControlsHeight); 7397 1.0f, 30.0f / browserControlsHeight);
7397 webView->resizeWithTopControls(WebSize(100, 60), 40.0f, true); 7398 webView->resizeWithBrowserControls(WebSize(100, 60), 40.0f, true);
7398 webView->updateAllLifecyclePhases(); 7399 webView->updateAllLifecyclePhases();
7399 EXPECT_SIZE_EQ(ScrollOffset(0, 1940), frameView->maximumScrollOffset()); 7400 EXPECT_SIZE_EQ(ScrollOffset(0, 1940), frameView->maximumScrollOffset());
7400 7401
7401 // Now simulate hiding. 7402 // Now simulate hiding.
7402 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 7403 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
7403 1.0f, -10.0f / topControlsHeight); 7404 1.0f, -10.0f / browserControlsHeight);
7404 EXPECT_SIZE_EQ(ScrollOffset(0, 1930), frameView->maximumScrollOffset()); 7405 EXPECT_SIZE_EQ(ScrollOffset(0, 1930), frameView->maximumScrollOffset());
7405 7406
7406 // Reset to original state: 100px widget height, top controls fully hidden. 7407 // Reset to original state: 100px widget height, browser controls fully
7408 // hidden.
7407 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 7409 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
7408 1.0f, -30.0f / topControlsHeight); 7410 1.0f, -30.0f / browserControlsHeight);
7409 webView->resizeWithTopControls(WebSize(100, 100), topControlsHeight, false); 7411 webView->resizeWithBrowserControls(WebSize(100, 100), browserControlsHeight,
7412 false);
7410 webView->updateAllLifecyclePhases(); 7413 webView->updateAllLifecyclePhases();
7411 EXPECT_SIZE_EQ(ScrollOffset(0, 1900), frameView->maximumScrollOffset()); 7414 EXPECT_SIZE_EQ(ScrollOffset(0, 1900), frameView->maximumScrollOffset());
7412 7415
7413 // Show the top controls by just 1px, since we're zoomed in to 2X, that 7416 // Show the browser controls by just 1px, since we're zoomed in to 2X, that
7414 // should allow an extra 0.5px of scrolling in the visual viewport. Make 7417 // should allow an extra 0.5px of scrolling in the visual viewport. Make
7415 // sure we're not losing any pixels when applying the adjustment on the 7418 // sure we're not losing any pixels when applying the adjustment on the
7416 // main frame. 7419 // main frame.
7417 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 7420 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
7418 1.0f, 1.0f / topControlsHeight); 7421 1.0f, 1.0f / browserControlsHeight);
7419 EXPECT_SIZE_EQ(ScrollOffset(0, 1901), frameView->maximumScrollOffset()); 7422 EXPECT_SIZE_EQ(ScrollOffset(0, 1901), frameView->maximumScrollOffset());
7420 7423
7421 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 7424 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
7422 1.0f, 2.0f / topControlsHeight); 7425 1.0f, 2.0f / browserControlsHeight);
7423 EXPECT_SIZE_EQ(ScrollOffset(0, 1903), frameView->maximumScrollOffset()); 7426 EXPECT_SIZE_EQ(ScrollOffset(0, 1903), frameView->maximumScrollOffset());
7424 } 7427 }
7425 7428
7426 TEST_F(WebFrameTest, MaximumScrollPositionCanBeNegative) { 7429 TEST_F(WebFrameTest, MaximumScrollPositionCanBeNegative) {
7427 registerMockedHttpURLLoad("rtl-overview-mode.html"); 7430 registerMockedHttpURLLoad("rtl-overview-mode.html");
7428 7431
7429 FixedLayoutTestWebViewClient client; 7432 FixedLayoutTestWebViewClient client;
7430 client.m_screenInfo.deviceScaleFactor = 1; 7433 client.m_screenInfo.deviceScaleFactor = 1;
7431 int viewportWidth = 640; 7434 int viewportWidth = 640;
7432 int viewportHeight = 480; 7435 int viewportHeight = 480;
(...skipping 2827 matching lines...) Expand 10 before | Expand all | Expand 10 after
10260 webViewHelper.webView()->handleInputEvent(endEvent); 10263 webViewHelper.webView()->handleInputEvent(endEvent);
10261 webViewHelper.webView()->handleInputEvent(updateEvent); 10264 webViewHelper.webView()->handleInputEvent(updateEvent);
10262 10265
10263 // Try a full Begin/Update/End cycle. 10266 // Try a full Begin/Update/End cycle.
10264 webViewHelper.webView()->handleInputEvent(beginEvent); 10267 webViewHelper.webView()->handleInputEvent(beginEvent);
10265 webViewHelper.webView()->handleInputEvent(updateEvent); 10268 webViewHelper.webView()->handleInputEvent(updateEvent);
10266 webViewHelper.webView()->handleInputEvent(endEvent); 10269 webViewHelper.webView()->handleInputEvent(endEvent);
10267 } 10270 }
10268 10271
10269 } // namespace blink 10272 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698