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

Unified Diff: content/browser/browser_plugin/browser_plugin_host_browsertest.cc

Issue 11360106: Browser Plugin: Implement AutoSize (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nits + added tests Created 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_host_browsertest.cc
diff --git a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
index 053a97f8f27b6b1633afa299971ff8b5ecef802c..abf44c47ba020758dc9e3e0b0632cc075e199d17 100644
--- a/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
+++ b/content/browser/browser_plugin/browser_plugin_host_browsertest.cc
@@ -74,6 +74,13 @@ const char kHTMLForGuestAcceptDrag[] =
" ondrop=\"dropped();\">"
"</textarea>"
"</body></html>";
+const char kHTMLForGuestWithSize[] =
+ "data:text/html,"
+ "<html>"
+ "<body style=\"margin: 0px;\">"
+ "<img style=\"width: 100%; height: 400px;\"/>"
+ "</body>"
+ "</html>";
std::string GetHTMLForGuestWithTitle(const std::string& title) {
return StringPrintf(kHTMLForGuestWithTitle, title.c_str());
@@ -1106,4 +1113,42 @@ IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusPreservation) {
}
}
+// This test verifies that if a browser plugin is in autosize mode before
+// navigation then the guest starts auto-sized.
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeBeforeNavigation) {
+ const char* kEmbedderURL = "files/browser_plugin_embedder.html";
+ const std::string embedder_code =
+ "document.getElementById('plugin').minWidth = 300;"
+ "document.getElementById('plugin').minHeight = 200;"
+ "document.getElementById('plugin').maxWidth = 600;"
+ "document.getElementById('plugin').maxHeight = 400;"
+ "document.getElementById('plugin').autoSize = true;";
+ StartBrowserPluginTest(
+ kEmbedderURL, kHTMLForGuestWithSize, true, embedder_code);
+ // Verify that the guest has been auto-sized.
+ test_guest()->WaitForViewSize(gfx::Size(300, 400));
+}
+
+// This test verifies that enabling autosize resizes the guest and triggers
+// a 'sizechanged' event.
+IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeAfterNavigation) {
+ const char* kEmbedderURL = "files/browser_plugin_embedder.html";
+ StartBrowserPluginTest(
+ kEmbedderURL, kHTMLForGuestWithSize, true, "");
+ RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
+ test_embedder()->web_contents()->GetRenderViewHost());
+
+ const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)");
+ content::TitleWatcher title_watcher(test_embedder()->web_contents(),
+ expected_title);
+ ExecuteSyncJSFunction(rvh, ASCIIToUTF16(
+ "document.getElementById('plugin').minWidth = 300;"
+ "document.getElementById('plugin').minHeight = 200;"
+ "document.getElementById('plugin').maxWidth = 600;"
+ "document.getElementById('plugin').maxHeight = 400;"
+ "document.getElementById('plugin').autoSize = true;"));
lazyboy 2012/11/07 07:39:09 Also how about adding tests that doesn't specify a
Fady Samuel 2012/11/07 20:21:12 Added a couple of subtests.
+ string16 actual_title = title_watcher.WaitAndGetTitle();
+ EXPECT_EQ(expected_title, actual_title);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698