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

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

Issue 23459006: [Android WebView] Fix WideViewport use case after r157293 (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added a test for useWideViewport=false + <meta name='viewport' content='height=1000'> 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
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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 m_webView->settings()->setUseWideViewport(false); 574 m_webView->settings()->setUseWideViewport(false);
575 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true); 575 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true);
576 m_webView->resize(WebSize(viewportWidth, viewportHeight)); 576 m_webView->resize(WebSize(viewportWidth, viewportHeight));
577 577
578 // The page sets viewport width to 3000, but with UseWideViewport == false i s must be ignored. 578 // The page sets viewport width to 3000, but with UseWideViewport == false i s must be ignored.
579 // While the initial scale specified by the page must be accounted. 579 // While the initial scale specified by the page must be accounted.
580 EXPECT_EQ(viewportWidth / 2, webViewImpl()->mainFrameImpl()->frameView()->co ntentsSize().width()); 580 EXPECT_EQ(viewportWidth / 2, webViewImpl()->mainFrameImpl()->frameView()->co ntentsSize().width());
581 EXPECT_EQ(viewportHeight / 2, webViewImpl()->mainFrameImpl()->frameView()->c ontentsSize().height()); 581 EXPECT_EQ(viewportHeight / 2, webViewImpl()->mainFrameImpl()->frameView()->c ontentsSize().height());
582 } 582 }
583 583
584 TEST_F(WebFrameTest, WideViewportSetsTo980WithoutViewportTag)
585 {
586 registerMockedHttpURLLoad("no_viewport_tag.html");
587
588 FixedLayoutTestWebViewClient client;
589 client.m_screenInfo.deviceScaleFactor = 1;
590 int viewportWidth = 640;
591 int viewportHeight = 480;
592
593 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "no_viewport_ tag.html", true, 0, &client);
594 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true);
595 m_webView->enableFixedLayoutMode(true);
596 m_webView->settings()->setUseWideViewport(true);
597 m_webView->settings()->setViewportEnabled(true);
598 m_webView->resize(WebSize(viewportWidth, viewportHeight));
599
600 EXPECT_EQ(980, webViewImpl()->mainFrameImpl()->frameView()->contentsSize().w idth());
601 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewImpl()->mainFrameIm pl()->frameView()->contentsSize().height());
602 }
603
604 TEST_F(WebFrameTest, NoWideViewportAndHeightInMeta)
605 {
606 registerMockedHttpURLLoad("viewport-height-1000.html");
607
608 FixedLayoutTestWebViewClient client;
609 client.m_screenInfo.deviceScaleFactor = 1;
610 int viewportWidth = 640;
611 int viewportHeight = 480;
612
613 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-hei ght-1000.html", true, 0, &client);
614 m_webView->settings()->setSupportDeprecatedTargetDensityDPI(true);
615 m_webView->enableFixedLayoutMode(true);
616 m_webView->settings()->setUseWideViewport(false);
617 m_webView->settings()->setViewportEnabled(true);
618 m_webView->resize(WebSize(viewportWidth, viewportHeight));
619
620 EXPECT_EQ(viewportWidth, webViewImpl()->mainFrameImpl()->frameView()->conten tsSize().width());
621 }
622
584 TEST_F(WebFrameTest, WideViewportSetsTo980WithAutoWidth) 623 TEST_F(WebFrameTest, WideViewportSetsTo980WithAutoWidth)
585 { 624 {
586 registerMockedHttpURLLoad("viewport-2x-initial-scale.html"); 625 registerMockedHttpURLLoad("viewport-2x-initial-scale.html");
587 626
588 FixedLayoutTestWebViewClient client; 627 FixedLayoutTestWebViewClient client;
589 client.m_screenInfo.deviceScaleFactor = 1; 628 client.m_screenInfo.deviceScaleFactor = 1;
590 int viewportWidth = 640; 629 int viewportWidth = 640;
591 int viewportHeight = 480; 630 int viewportHeight = 480;
592 631
593 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-2x- initial-scale.html", true, 0, &client); 632 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "viewport-2x- initial-scale.html", true, 0, &client);
(...skipping 3160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3754 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h tml", true, 0, &client); 3793 m_webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL + "push_state.h tml", true, 0, &client);
3755 runPendingTasks(); 3794 runPendingTasks();
3756 3795
3757 EXPECT_EQ(client.startLoadingCount(), 2); 3796 EXPECT_EQ(client.startLoadingCount(), 2);
3758 EXPECT_EQ(client.stopLoadingCount(), 2); 3797 EXPECT_EQ(client.stopLoadingCount(), 2);
3759 m_webView->close(); 3798 m_webView->close();
3760 m_webView = 0; 3799 m_webView = 0;
3761 } 3800 }
3762 3801
3763 } // namespace 3802 } // namespace
OLDNEW
« no previous file with comments | « Source/core/page/PageScaleConstraintsSet.cpp ('k') | Source/web/tests/data/viewport-height-1000.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698