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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host_browsertest.cc

Issue 281833003: BrowserPluginHostTest: Rewrite 3 focus related tests and 1 visibility test to browser_tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase @tott, fix conflict Created 6 years, 7 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 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/memory/singleton.h" 5 #include "base/memory/singleton.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 10 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return test_guest_manager_; 223 return test_guest_manager_;
224 } 224 }
225 225
226 private: 226 private:
227 TestBrowserPluginEmbedder* test_embedder_; 227 TestBrowserPluginEmbedder* test_embedder_;
228 TestBrowserPluginGuest* test_guest_; 228 TestBrowserPluginGuest* test_guest_;
229 TestGuestManager* test_guest_manager_; 229 TestGuestManager* test_guest_manager_;
230 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostTest); 230 DISALLOW_COPY_AND_ASSIGN(BrowserPluginHostTest);
231 }; 231 };
232 232
233 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, AdvanceFocus) {
234 const char kEmbedderURL[] = "/browser_plugin_focus.html";
235 const char* kGuestURL = "/browser_plugin_focus_child.html";
236 StartBrowserPluginTest(kEmbedderURL, kGuestURL, false, std::string());
237
238 SimulateMouseClick(test_embedder()->web_contents(), 0,
239 blink::WebMouseEvent::ButtonLeft);
240 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents());
241 // Wait until we focus into the guest.
242 test_guest()->WaitForFocus();
243
244 // TODO(fsamuel): A third Tab key press should not be necessary.
245 // The browser plugin will take keyboard focus but it will not
246 // focus an initial element. The initial element is dependent
247 // upon tab direction which WebKit does not propagate to the plugin.
248 // See http://crbug.com/147644.
249 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents());
250 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents());
251 BrowserPluginHostTest::SimulateTabKeyPress(test_embedder()->web_contents());
252 test_guest()->WaitForAdvanceFocus();
253 }
254
255 // This test opens a page in http and then opens another page in https, forcing 233 // This test opens a page in http and then opens another page in https, forcing
256 // a RenderViewHost swap in the web_contents. We verify that the embedder in the 234 // a RenderViewHost swap in the web_contents. We verify that the embedder in the
257 // web_contents gets cleared properly. 235 // web_contents gets cleared properly.
258 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderChangedAfterSwap) { 236 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, EmbedderChangedAfterSwap) {
259 net::SpawnedTestServer https_server( 237 net::SpawnedTestServer https_server(
260 net::SpawnedTestServer::TYPE_HTTPS, 238 net::SpawnedTestServer::TYPE_HTTPS,
261 net::SpawnedTestServer::kLocalhost, 239 net::SpawnedTestServer::kLocalhost,
262 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); 240 base::FilePath(FILE_PATH_LITERAL("content/test/data")));
263 ASSERT_TRUE(https_server.Start()); 241 ASSERT_TRUE(https_server.Start());
264 242
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 rvh->DragTargetDragEnter(drop_data, gfx::Point(start_x, start_y), 394 rvh->DragTargetDragEnter(drop_data, gfx::Point(start_x, start_y),
417 gfx::Point(start_x, start_y), blink::WebDragOperationEvery, 0); 395 gfx::Point(start_x, start_y), blink::WebDragOperationEvery, 0);
418 rvh->DragTargetDragOver(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), 396 rvh->DragTargetDragOver(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y),
419 blink::WebDragOperationEvery, 0); 397 blink::WebDragOperationEvery, 0);
420 rvh->DragTargetDrop(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), 0); 398 rvh->DragTargetDrop(gfx::Point(end_x, end_y), gfx::Point(end_x, end_y), 0);
421 399
422 base::string16 actual_title = title_watcher.WaitAndGetTitle(); 400 base::string16 actual_title = title_watcher.WaitAndGetTitle();
423 EXPECT_EQ(expected_title, actual_title); 401 EXPECT_EQ(expected_title, actual_title);
424 } 402 }
425 403
426 // This test verifies that if a browser plugin is hidden before navigation,
427 // the guest starts off hidden.
428 // This test is flaky under ThreadSanitizer, see http://crbug.com/370240
429 #if !defined(THREAD_SANITIZER)
430 #define MAYBE_HiddenBeforeNavigation HiddenBeforeNavigation
431 #else
432 #define MAYBE_HiddenBeforeNavigation DISABLED_HiddenBeforeNavigation
433 #endif
434 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, MAYBE_HiddenBeforeNavigation) {
435 const char* kEmbedderURL = "/browser_plugin_embedder.html";
436 const std::string embedder_code =
437 "document.getElementById('plugin').style.visibility = 'hidden'";
438 StartBrowserPluginTest(
439 kEmbedderURL, kHTMLForGuest, true, embedder_code);
440 EXPECT_FALSE(test_guest()->visible());
441 }
442
443 // This test verifies that if a browser plugin is focused before navigation then
444 // the guest starts off focused.
445 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusBeforeNavigation) {
446 const char* kEmbedderURL = "/browser_plugin_embedder.html";
447 const std::string embedder_code =
448 "document.getElementById('plugin').focus();";
449 StartBrowserPluginTest(
450 kEmbedderURL, kHTMLForGuest, true, embedder_code);
451 RenderFrameHost* guest_rfh = test_guest()->web_contents()->GetMainFrame();
452 // Verify that the guest is focused.
453 scoped_ptr<base::Value> value =
454 content::ExecuteScriptAndGetValue(guest_rfh, "document.hasFocus()");
455 bool result = false;
456 ASSERT_TRUE(value->GetAsBoolean(&result));
457 EXPECT_TRUE(result);
458 }
459
460 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, FocusTracksEmbedder) {
461 const char* kEmbedderURL = "/browser_plugin_embedder.html";
462 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string());
463 // Blur the embedder.
464 test_embedder()->web_contents()->GetRenderViewHost()->Blur();
465 // Ensure that the guest is also blurred.
466 test_guest()->WaitForBlur();
467 }
468
469 // This test verifies that if IME is enabled in the embedder, it is also enabled 404 // This test verifies that if IME is enabled in the embedder, it is also enabled
470 // in the guest. 405 // in the guest.
471 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, VerifyInputMethodActive) { 406 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, VerifyInputMethodActive) {
472 const char* kEmbedderURL = "/browser_plugin_embedder.html"; 407 const char* kEmbedderURL = "/browser_plugin_embedder.html";
473 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string()); 408 StartBrowserPluginTest(kEmbedderURL, kHTMLForGuest, true, std::string());
474 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( 409 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
475 test_guest()->web_contents()->GetRenderViewHost()); 410 test_guest()->web_contents()->GetRenderViewHost());
476 EXPECT_TRUE(rvh->input_method_active()); 411 EXPECT_TRUE(rvh->input_method_active());
477 } 412 }
478 413
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 scoped_ptr<base::Value> value = 564 scoped_ptr<base::Value> value =
630 content::ExecuteScriptAndGetValue( 565 content::ExecuteScriptAndGetValue(
631 guest_rfh, "document.getElementById('input1').value"); 566 guest_rfh, "document.getElementById('input1').value");
632 std::string actual_value; 567 std::string actual_value;
633 ASSERT_TRUE(value->GetAsString(&actual_value)); 568 ASSERT_TRUE(value->GetAsString(&actual_value));
634 EXPECT_EQ(base::UTF16ToUTF8(expected_value), actual_value); 569 EXPECT_EQ(base::UTF16ToUTF8(expected_value), actual_value);
635 } 570 }
636 } 571 }
637 572
638 } // namespace content 573 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/browser_plugin/test_browser_plugin_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698