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

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

Issue 23441020: Make it possibe to lock the fixedLayoutSize (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: dont need to disable content rects scaling? Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/200-by-300.html » ('j') | 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) 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 while (renderer) { 398 while (renderer) {
399 if (renderer->style()) { 399 if (renderer->style()) {
400 EXPECT_EQ(1, renderer->style()->textAutosizingMultiplier()); 400 EXPECT_EQ(1, renderer->style()->textAutosizingMultiplier());
401 multiplierCheckedAtLeastOnce = true; 401 multiplierCheckedAtLeastOnce = true;
402 } 402 }
403 renderer = renderer->nextInPreOrder(); 403 renderer = renderer->nextInPreOrder();
404 } 404 }
405 EXPECT_TRUE(multiplierCheckedAtLeastOnce); 405 EXPECT_TRUE(multiplierCheckedAtLeastOnce);
406 } 406 }
407 407
408 TEST_F(WebFrameTest, FixedLayoutSizeStopsResizeFromChangingLayoutSize)
409 {
410 registerMockedHttpURLLoad("fixed_layout.html");
411
412 int viewportWidth = 640;
413 int viewportHeight = 480;
414
415 int fixedLayoutWidth = viewportWidth / 2;
416 int fixedLayoutHeight = viewportHeight / 2;
417
418 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout .html");
419 m_webView->enableFixedLayoutMode(true);
420 m_webView->settings()->setViewportEnabled(true);
421 m_webView->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight));
422 m_webView->resize(WebSize(viewportWidth, viewportHeight));
423 m_webView->layout();
424
425 EXPECT_EQ(fixedLayoutWidth, m_webView->fixedLayoutSize().width);
426 EXPECT_EQ(fixedLayoutHeight, m_webView->fixedLayoutSize().height);
427 }
428
429 TEST_F(WebFrameTest, FixedLayoutSizePreventsResizeFromChangingPageScale)
430 {
431 registerMockedHttpURLLoad("fixed_layout.html");
432
433 int viewportWidth = 640;
434 int viewportHeight = 480;
435
436 int fixedLayoutWidth = viewportWidth / 2;
437 int fixedLayoutHeight = viewportHeight / 2;
438
439 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout .html");
440 m_webView->enableFixedLayoutMode(true);
441 m_webView->settings()->setViewportEnabled(true);
442 m_webView->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight));
443 m_webView->resize(WebSize(viewportWidth, viewportHeight));
444 m_webView->layout();
445 float pageScaleFactor = m_webView->pageScaleFactor();
446
447 m_webView->resize(WebSize(viewportWidth * 2, viewportHeight * 2));
448
449 EXPECT_EQ(pageScaleFactor, m_webView->pageScaleFactor());
450 }
451
452 TEST_F(WebFrameTest, FixedLayoutSizePreventsLayoutFromChangingPageScale)
453 {
454 registerMockedHttpURLLoad("fixed_layout.html");
455
456 int viewportWidth = 640;
457 int viewportHeight = 480;
458
459 int fixedLayoutWidth = viewportWidth * 2;
460 int fixedLayoutHeight = viewportHeight * 2;
461
462 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "fixed_layout .html");
463 m_webView->enableFixedLayoutMode(true);
464 m_webView->settings()->setViewportEnabled(true);
465 m_webView->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight));
466 m_webView->resize(WebSize(viewportWidth, viewportHeight));
467 m_webView->layout();
468 float pageScaleFactor = m_webView->pageScaleFactor();
469
470 m_webView->setFixedLayoutSize(WebSize(fixedLayoutWidth, fixedLayoutHeight));
471 m_webView->layout();
472
473 EXPECT_EQ(pageScaleFactor, m_webView->pageScaleFactor());
474 }
475
476 TEST_F(WebFrameTest, PreferredSizeAndContentSizeReportedCorrectlyWithZeroHeightF ixedLayout)
477 {
478 registerMockedHttpURLLoad("200-by-300.html");
479
480 int windowWidth = 100;
481 int windowHeight = 100;
482 int viewportWidth = 100;
483 int viewportHeight = 0;
484 int divWidth = 200;
485 int divHeight = 300;
486
487 FixedLayoutTestWebViewClient client;
488 client.m_screenInfo.deviceScaleFactor = 1;
489
490 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "200-by-300.h tml", true, 0, &client);
491 m_webView->enableFixedLayoutMode(true);
492 m_webView->settings()->setViewportEnabled(true);
493 m_webView->resize(WebSize(windowWidth, windowHeight));
494 m_webView->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight));
495 m_webView->layout();
496
497 EXPECT_EQ(divWidth, m_webView->mainFrame()->contentsSize().width);
498 EXPECT_EQ(divHeight, m_webView->mainFrame()->contentsSize().height);
499
500 EXPECT_EQ(divWidth, m_webView->contentsPreferredMinimumSize().width);
501 EXPECT_EQ(divHeight, m_webView->contentsPreferredMinimumSize().height);
502 }
503
504 TEST_F(WebFrameTest, DisablingFixedLayoutSizeSetsCorrectLayoutSize)
505 {
506 registerMockedHttpURLLoad("no_viewport_tag.html");
507
508 FixedLayoutTestWebViewClient client;
509 client.m_screenInfo.deviceScaleFactor = 1;
510 int viewportWidth = 640;
511 int viewportHeight = 480;
512
513 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_ tag.html", true, 0, &client);
514 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true);
515 m_webView->enableFixedLayoutMode(true);
516 m_webView->settings()->setUseWideViewport(true);
517 m_webView->settings()->setViewportEnabled(true);
518 m_webView->resize(WebSize(viewportWidth, viewportHeight));
519
520 m_webView->setFixedLayoutSize(WebSize(viewportWidth, viewportHeight));
521 EXPECT_TRUE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout());
522 m_webView->layout();
523 EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->conten tsSize().width());
524
525 m_webView->setFixedLayoutSize(WebSize(0, 0));
526 EXPECT_TRUE(webViewImpl()->mainFrameImpl()->frameView()->needsLayout());
527 m_webView->layout();
528 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w idth());
529 }
530
408 TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag) 531 TEST_F(WebFrameTest, DeviceScaleFactorUsesDefaultWithoutViewportTag)
409 { 532 {
410 registerMockedHttpURLLoad("no_viewport_tag.html"); 533 registerMockedHttpURLLoad("no_viewport_tag.html");
411 534
412 int viewportWidth = 640; 535 int viewportWidth = 640;
413 int viewportHeight = 480; 536 int viewportHeight = 480;
414 537
415 FixedLayoutTestWebViewClient client; 538 FixedLayoutTestWebViewClient client;
416 client.m_screenInfo.deviceScaleFactor = 2; 539 client.m_screenInfo.deviceScaleFactor = 2;
417 540
(...skipping 3380 matching lines...) Expand 10 before | Expand all | Expand 10 after
3798 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h tml", true, 0, &client); 3921 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h tml", true, 0, &client);
3799 runPendingTasks(); 3922 runPendingTasks();
3800 3923
3801 EXPECT_EQ(client.startLoadingCount(), 2); 3924 EXPECT_EQ(client.startLoadingCount(), 2);
3802 EXPECT_EQ(client.stopLoadingCount(), 2); 3925 EXPECT_EQ(client.stopLoadingCount(), 2);
3803 m_webView->close(); 3926 m_webView->close();
3804 m_webView = 0; 3927 m_webView = 0;
3805 } 3928 }
3806 3929
3807 } // namespace 3930 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | Source/web/tests/data/200-by-300.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698