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

Side by Side Diff: Source/web/tests/WebViewTest.cpp

Issue 1071383002: Round when calculating minimum height of WebViews (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added test that rounds down Created 5 years, 7 months 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
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 2342
2343 WebSize size = webView->contentsPreferredMinimumSize(); 2343 WebSize size = webView->contentsPreferredMinimumSize();
2344 EXPECT_EQ(100, size.width); 2344 EXPECT_EQ(100, size.width);
2345 EXPECT_EQ(100, size.height); 2345 EXPECT_EQ(100, size.height);
2346 2346
2347 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(2.0)); 2347 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(2.0));
2348 size = webView->contentsPreferredMinimumSize(); 2348 size = webView->contentsPreferredMinimumSize();
2349 EXPECT_EQ(200, size.width); 2349 EXPECT_EQ(200, size.width);
2350 EXPECT_EQ(200, size.height); 2350 EXPECT_EQ(200, size.height);
2351 2351
2352 // Verify that both width and height are rounded (in this case up)
2353 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(0.9995));
2354 size = webView->contentsPreferredMinimumSize();
2355 EXPECT_EQ(100, size.width);
2356 EXPECT_EQ(100, size.height);
2357
2358 // Verify that both width and height are rounded (in this case down)
2359 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1.0005));
2360 size = webView->contentsPreferredMinimumSize();
2361 EXPECT_EQ(100, size.width);
2362 EXPECT_EQ(100, size.height);
2363
2352 url = m_baseURL + "specify_size.html?1.5px:1.5px"; 2364 url = m_baseURL + "specify_size.html?1.5px:1.5px";
2353 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html"); 2365 URLTestHelpers::registerMockedURLLoad(toKURL(url), "specify_size.html");
2354 webView = m_webViewHelper.initializeAndLoad(url, true); 2366 webView = m_webViewHelper.initializeAndLoad(url, true);
2355 2367
2356 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1)); 2368 webView->setZoomLevel(WebView::zoomFactorToZoomLevel(1));
2357 size = webView->contentsPreferredMinimumSize(); 2369 size = webView->contentsPreferredMinimumSize();
2358 EXPECT_EQ(2, size.width); 2370 EXPECT_EQ(2, size.width);
2359 EXPECT_EQ(2, size.height); 2371 EXPECT_EQ(2, size.height);
2360 } 2372 }
2361 2373
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 // Test without any preventDefault. 2533 // Test without any preventDefault.
2522 client.reset(); 2534 client.reset();
2523 frame->executeScript(WebScriptSource("setTest('none');")); 2535 frame->executeScript(WebScriptSource("setTest('none');"));
2524 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 2536 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
2525 EXPECT_TRUE(client.getWasCalled()); 2537 EXPECT_TRUE(client.getWasCalled());
2526 2538
2527 m_webViewHelper.reset(); // Remove dependency on locally scoped client. 2539 m_webViewHelper.reset(); // Remove dependency on locally scoped client.
2528 } 2540 }
2529 2541
2530 } // namespace 2542 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698