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

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

Issue 870933002: Make it possible to set the display mode from the WebView API (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Using enum now Created 5 years, 11 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') | public/platform/WebDisplayMode.h » ('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) 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "core/page/Page.h" 47 #include "core/page/Page.h"
48 #include "core/paint/LayerPainter.h" 48 #include "core/paint/LayerPainter.h"
49 #include "core/rendering/RenderLayer.h" 49 #include "core/rendering/RenderLayer.h"
50 #include "core/rendering/RenderView.h" 50 #include "core/rendering/RenderView.h"
51 #include "core/testing/URLTestHelpers.h" 51 #include "core/testing/URLTestHelpers.h"
52 #include "platform/KeyboardCodes.h" 52 #include "platform/KeyboardCodes.h"
53 #include "platform/geometry/IntSize.h" 53 #include "platform/geometry/IntSize.h"
54 #include "platform/graphics/Color.h" 54 #include "platform/graphics/Color.h"
55 #include "public/platform/Platform.h" 55 #include "public/platform/Platform.h"
56 #include "public/platform/WebClipboard.h" 56 #include "public/platform/WebClipboard.h"
57 #include "public/platform/WebDisplayMode.h"
57 #include "public/platform/WebDragData.h" 58 #include "public/platform/WebDragData.h"
58 #include "public/platform/WebSize.h" 59 #include "public/platform/WebSize.h"
59 #include "public/platform/WebThread.h" 60 #include "public/platform/WebThread.h"
60 #include "public/platform/WebUnitTestSupport.h" 61 #include "public/platform/WebUnitTestSupport.h"
61 #include "public/web/WebAutofillClient.h" 62 #include "public/web/WebAutofillClient.h"
62 #include "public/web/WebContentDetectionResult.h" 63 #include "public/web/WebContentDetectionResult.h"
63 #include "public/web/WebDateTimeChooserCompletion.h" 64 #include "public/web/WebDateTimeChooserCompletion.h"
64 #include "public/web/WebDocument.h" 65 #include "public/web/WebDocument.h"
65 #include "public/web/WebDragOperation.h" 66 #include "public/web/WebDragOperation.h"
66 #include "public/web/WebElement.h" 67 #include "public/web/WebElement.h"
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 private: 1695 private:
1695 int m_count; 1696 int m_count;
1696 }; 1697 };
1697 1698
1698 WebFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* parent, const WebString& frameName, WebSandboxFlags sandboxFlags) 1699 WebFrame* CreateChildCounterFrameClient::createChildFrame(WebLocalFrame* parent, const WebString& frameName, WebSandboxFlags sandboxFlags)
1699 { 1700 {
1700 ++m_count; 1701 ++m_count;
1701 return TestWebFrameClient::createChildFrame(parent, frameName, sandboxFlags) ; 1702 return TestWebFrameClient::createChildFrame(parent, frameName, sandboxFlags) ;
1702 } 1703 }
1703 1704
1705 TEST_F(WebViewTest, ChangeDisplayMode)
1706 {
1707 WebView* webView = m_webViewHelper.initializeAndLoad("about:blank", true);
1708
1709 WebScriptSource source("document.querySelector('body').innerHTML = window.ma tchMedia('(display-mode: minimal-ui)').matches");
1710
1711 webView->mainFrame()->executeScript(source);
1712 std::string content = webView->mainFrame()->contentAsText(5).utf8();
1713 EXPECT_EQ("false", content);
1714
1715 webView->setDisplayMode(WebDisplayModeMinimalUi);
1716 webView->mainFrame()->executeScript(source);
1717 content = webView->mainFrame()->contentAsText(5).utf8();
1718 EXPECT_EQ("true", content);
1719 }
1720
1704 TEST_F(WebViewTest, AddFrameInCloseUnload) 1721 TEST_F(WebViewTest, AddFrameInCloseUnload)
1705 { 1722 {
1706 CreateChildCounterFrameClient frameClient; 1723 CreateChildCounterFrameClient frameClient;
1707 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("add_frame_in_unload.html")); 1724 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c _str()), WebString::fromUTF8("add_frame_in_unload.html"));
1708 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", tr ue, &frameClient); 1725 m_webViewHelper.initializeAndLoad(m_baseURL + "add_frame_in_unload.html", tr ue, &frameClient);
1709 m_webViewHelper.reset(); 1726 m_webViewHelper.reset();
1710 EXPECT_EQ(0, frameClient.count()); 1727 EXPECT_EQ(0, frameClient.count());
1711 } 1728 }
1712 1729
1713 TEST_F(WebViewTest, AddFrameInCloseURLUnload) 1730 TEST_F(WebViewTest, AddFrameInCloseURLUnload)
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 // Test without any preventDefault. 2332 // Test without any preventDefault.
2316 client.reset(); 2333 client.reset();
2317 frame->executeScript(WebScriptSource("setTest('none');")); 2334 frame->executeScript(WebScriptSource("setTest('none');"));
2318 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target"))); 2335 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr omUTF8("target")));
2319 EXPECT_TRUE(client.getWasCalled()); 2336 EXPECT_TRUE(client.getWasCalled());
2320 2337
2321 m_webViewHelper.reset(); // Remove dependency on locally scoped client. 2338 m_webViewHelper.reset(); // Remove dependency on locally scoped client.
2322 } 2339 }
2323 2340
2324 } // namespace 2341 } // namespace
OLDNEW
« no previous file with comments | « Source/web/WebViewImpl.cpp ('k') | public/platform/WebDisplayMode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698