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/memory/singleton.h" | 5 #include "base/memory/singleton.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 9 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" | 10 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
523 // Navigate to P3 and verify that the navigation occurred. | 523 // Navigate to P3 and verify that the navigation occurred. |
524 { | 524 { |
525 const string16 expected_title = ASCIIToUTF16("P3"); | 525 const string16 expected_title = ASCIIToUTF16("P3"); |
526 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 526 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
527 expected_title); | 527 expected_title); |
528 | 528 |
529 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( | 529 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16( |
530 StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P3").c_str()))); | 530 StringPrintf("SetSrc('%s');", GetHTMLForGuestWithTitle("P3").c_str()))); |
531 | 531 |
532 string16 actual_title = title_watcher.WaitAndGetTitle(); | 532 string16 actual_title = title_watcher.WaitAndGetTitle(); |
533 EXPECT_EQ(expected_title, actual_title); | 533 EXPECT_EQ(expected_title, actual_title); |
Charlie Reis
2012/10/10 06:06:53
Probably worth checking that canGoForward is false
| |
534 } | 534 } |
535 | 535 |
536 // Go back and verify that we're back at P2. | 536 // Go back and verify that we're back at P2. |
537 { | 537 { |
538 const string16 expected_title = ASCIIToUTF16("P2"); | 538 const string16 expected_title = ASCIIToUTF16("P2"); |
539 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 539 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
540 expected_title); | 540 expected_title); |
541 | 541 |
542 base::Value* value = | |
543 rvh->ExecuteJavascriptAndGetValue(string16(), | |
544 ASCIIToUTF16("CanGoBack()")); | |
545 bool result = false; | |
546 ASSERT_TRUE(value->GetAsBoolean(&result)); | |
547 EXPECT_TRUE(result); | |
Charlie Reis
2012/10/10 06:06:53
I think it would be clearer to move this check aft
Fady Samuel
2012/10/10 17:36:44
Done.
| |
542 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Back();")); | 548 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Back();")); |
543 | 549 |
544 string16 actual_title = title_watcher.WaitAndGetTitle(); | 550 string16 actual_title = title_watcher.WaitAndGetTitle(); |
545 EXPECT_EQ(expected_title, actual_title); | 551 EXPECT_EQ(expected_title, actual_title); |
546 } | 552 } |
547 | 553 |
548 // Go forward and verify that we're back at P3. | 554 // Go forward and verify that we're back at P3. |
549 { | 555 { |
550 const string16 expected_title = ASCIIToUTF16("P3"); | 556 const string16 expected_title = ASCIIToUTF16("P3"); |
551 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 557 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
552 expected_title); | 558 expected_title); |
553 | 559 |
560 base::Value* value = | |
561 rvh->ExecuteJavascriptAndGetValue(string16(), | |
562 ASCIIToUTF16("CanGoForward()")); | |
563 bool result = false; | |
564 ASSERT_TRUE(value->GetAsBoolean(&result)); | |
565 EXPECT_TRUE(result); | |
554 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Forward();")); | 566 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Forward();")); |
555 | 567 |
556 string16 actual_title = title_watcher.WaitAndGetTitle(); | 568 string16 actual_title = title_watcher.WaitAndGetTitle(); |
557 EXPECT_EQ(expected_title, actual_title); | 569 EXPECT_EQ(expected_title, actual_title); |
558 } | 570 } |
559 | 571 |
560 // Go back two entries and verify that we're back at P1. | 572 // Go back two entries and verify that we're back at P1. |
561 { | 573 { |
562 const string16 expected_title = ASCIIToUTF16("P1"); | 574 const string16 expected_title = ASCIIToUTF16("P1"); |
563 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 575 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
564 expected_title); | 576 expected_title); |
565 | 577 |
578 base::Value* value = | |
579 rvh->ExecuteJavascriptAndGetValue(string16(), | |
580 ASCIIToUTF16("CanGoBack()")); | |
581 bool result = false; | |
582 ASSERT_TRUE(value->GetAsBoolean(&result)); | |
583 EXPECT_TRUE(result); | |
Charlie Reis
2012/10/10 06:06:53
Again, we should be testing cases when CanGoBack r
Fady Samuel
2012/10/10 17:36:44
Done.
| |
566 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Go(-2);")); | 584 rvh->ExecuteJavascriptAndGetValue(string16(), ASCIIToUTF16("Go(-2);")); |
567 | 585 |
568 string16 actual_title = title_watcher.WaitAndGetTitle(); | 586 string16 actual_title = title_watcher.WaitAndGetTitle(); |
569 EXPECT_EQ(expected_title, actual_title); | 587 EXPECT_EQ(expected_title, actual_title); |
570 } | 588 } |
571 } | 589 } |
572 | 590 |
573 // This tests verifies that reloading the embedder does not crash the browser | 591 // This tests verifies that reloading the embedder does not crash the browser |
574 // and that the guest is reset. | 592 // and that the guest is reset. |
575 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { | 593 IN_PROC_BROWSER_TEST_F(BrowserPluginHostTest, ReloadEmbedder) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
696 EXPECT_TRUE(v->GetAsString(&result)); | 714 EXPECT_TRUE(v->GetAsString(&result)); |
697 EXPECT_EQ(redirect_url.spec().c_str(), result); | 715 EXPECT_EQ(redirect_url.spec().c_str(), result); |
698 | 716 |
699 v = rvh->ExecuteJavascriptAndGetValue( | 717 v = rvh->ExecuteJavascriptAndGetValue( |
700 string16(), ASCIIToUTF16("redirectNewUrl")); | 718 string16(), ASCIIToUTF16("redirectNewUrl")); |
701 EXPECT_TRUE(v->GetAsString(&result)); | 719 EXPECT_TRUE(v->GetAsString(&result)); |
702 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); | 720 EXPECT_EQ(test_server()->GetURL("files/title1.html").spec().c_str(), result); |
703 } | 721 } |
704 | 722 |
705 } // namespace content | 723 } // namespace content |
OLD | NEW |