Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/test/test_timeouts.h" | 8 #include "base/test/test_timeouts.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 10 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 67 "data:text/html,<html><body>" | 67 "data:text/html,<html><body>" |
| 68 "<script>" | 68 "<script>" |
| 69 "function dropped() {" | 69 "function dropped() {" |
| 70 " document.title = \"DROPPED\";" | 70 " document.title = \"DROPPED\";" |
| 71 "}" | 71 "}" |
| 72 "</script>" | 72 "</script>" |
| 73 "<textarea id=\"text\" style=\"width:100%; height: 100%\"" | 73 "<textarea id=\"text\" style=\"width:100%; height: 100%\"" |
| 74 " ondrop=\"dropped();\">" | 74 " ondrop=\"dropped();\">" |
| 75 "</textarea>" | 75 "</textarea>" |
| 76 "</body></html>"; | 76 "</body></html>"; |
| 77 const char kHTMLForGuestWithSize[] = | |
| 78 "data:text/html," | |
| 79 "<html>" | |
| 80 "<body style=\"margin: 0px;\">" | |
| 81 "<img style=\"width: 100%; height: 400px;\"/>" | |
| 82 "</body>" | |
| 83 "</html>"; | |
| 77 | 84 |
| 78 std::string GetHTMLForGuestWithTitle(const std::string& title) { | 85 std::string GetHTMLForGuestWithTitle(const std::string& title) { |
| 79 return StringPrintf(kHTMLForGuestWithTitle, title.c_str()); | 86 return StringPrintf(kHTMLForGuestWithTitle, title.c_str()); |
| 80 } | 87 } |
| 81 | 88 |
| 82 } // namespace | 89 } // namespace |
| 83 | 90 |
| 84 namespace content { | 91 namespace content { |
| 85 | 92 |
| 86 // Test factory for creating test instances of BrowserPluginEmbedder and | 93 // Test factory for creating test instances of BrowserPluginEmbedder and |
| (...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1099 // Verify that the guest is focused. | 1106 // Verify that the guest is focused. |
| 1100 scoped_ptr<base::Value> value( | 1107 scoped_ptr<base::Value> value( |
| 1101 guest_rvh->ExecuteJavascriptAndGetValue(string16(), | 1108 guest_rvh->ExecuteJavascriptAndGetValue(string16(), |
| 1102 ASCIIToUTF16("document.hasFocus()"))); | 1109 ASCIIToUTF16("document.hasFocus()"))); |
| 1103 bool result = false; | 1110 bool result = false; |
| 1104 ASSERT_TRUE(value->GetAsBoolean(&result)); | 1111 ASSERT_TRUE(value->GetAsBoolean(&result)); |
| 1105 EXPECT_TRUE(result); | 1112 EXPECT_TRUE(result); |
| 1106 } | 1113 } |
| 1107 } | 1114 } |
| 1108 | 1115 |
| 1116 // This test verifies that if a browser plugin is in autosize mode before | |
| 1117 // navigation then the guest starts auto-sized. | |
| 1118 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeBeforeNavigation) { | |
| 1119 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | |
| 1120 const std::string embedder_code = | |
| 1121 "document.getElementById('plugin').minWidth = 300;" | |
| 1122 "document.getElementById('plugin').minHeight = 200;" | |
| 1123 "document.getElementById('plugin').maxWidth = 600;" | |
| 1124 "document.getElementById('plugin').maxHeight = 400;" | |
| 1125 "document.getElementById('plugin').autoSize = true;"; | |
| 1126 StartBrowserPluginTest( | |
| 1127 kEmbedderURL, kHTMLForGuestWithSize, true, embedder_code); | |
| 1128 // Verify that the guest has been auto-sized. | |
| 1129 test_guest()->WaitForViewSize(gfx::Size(300, 400)); | |
| 1130 } | |
| 1131 | |
| 1132 // This test verifies that enabling autosize resizes the guest and triggers | |
| 1133 // a 'sizechanged' event. | |
| 1134 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AutoSizeAfterNavigation) { | |
| 1135 const char* kEmbedderURL = "files/browser_plugin_embedder.html"; | |
| 1136 StartBrowserPluginTest( | |
| 1137 kEmbedderURL, kHTMLForGuestWithSize, true, ""); | |
| 1138 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | |
| 1139 test_embedder()->web_contents()->GetRenderViewHost()); | |
| 1140 | |
| 1141 const string16 expected_title = ASCIIToUTF16("AutoSize(300, 400)"); | |
| 1142 content::TitleWatcher title_watcher(test_embedder()->web_contents(), | |
| 1143 expected_title); | |
| 1144 ExecuteSyncJSFunction(rvh, ASCIIToUTF16( | |
| 1145 "document.getElementById('plugin').minWidth = 300;" | |
| 1146 "document.getElementById('plugin').minHeight = 200;" | |
| 1147 "document.getElementById('plugin').maxWidth = 600;" | |
| 1148 "document.getElementById('plugin').maxHeight = 400;" | |
| 1149 "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.
| |
| 1150 string16 actual_title = title_watcher.WaitAndGetTitle(); | |
| 1151 EXPECT_EQ(expected_title, actual_title); | |
| 1152 } | |
| 1153 | |
| 1109 } // namespace content | 1154 } // namespace content |
| OLD | NEW |