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

Side by Side Diff: content/browser/session_history_browsertest.cc

Issue 10539134: TabContentsWrapper -> TabContents, part 57. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: last use Created 8 years, 6 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
OLDNEW
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/string_util.h" 5 #include "base/string_util.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/test/base/in_process_browser_test.h" 8 #include "chrome/test/base/in_process_browser_test.h"
9 #include "chrome/test/base/ui_test_utils.h" 9 #include "chrome/test/base/ui_test_utils.h"
10 #include "content/public/browser/notification_service.h" 10 #include "content/public/browser/notification_service.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 ui_test_utils::NavigateToURL(browser(), url); 47 ui_test_utils::NavigateToURL(browser(), url);
48 } 48 }
49 49
50 // Navigate session history using history.go(distance). 50 // Navigate session history using history.go(distance).
51 void JavascriptGo(std::string distance) { 51 void JavascriptGo(std::string distance) {
52 GURL url("javascript:history.go('" + distance + "')"); 52 GURL url("javascript:history.go('" + distance + "')");
53 ui_test_utils::NavigateToURL(browser(), url); 53 ui_test_utils::NavigateToURL(browser(), url);
54 } 54 }
55 55
56 std::string GetTabTitle() { 56 std::string GetTabTitle() {
57 return UTF16ToASCII(browser()->GetSelectedWebContents()->GetTitle()); 57 return UTF16ToASCII(browser()->GetActiveWebContents()->GetTitle());
58 } 58 }
59 59
60 GURL GetTabURL() { 60 GURL GetTabURL() {
61 return browser()->GetSelectedWebContents()->GetURL(); 61 return browser()->GetActiveWebContents()->GetURL();
62 } 62 }
63 63
64 GURL GetURL(const std::string file) { 64 GURL GetURL(const std::string file) {
65 return test_server()->GetURL(std::string("files/session_history/") + file); 65 return test_server()->GetURL(std::string("files/session_history/") + file);
66 } 66 }
67 67
68 void NavigateAndCheckTitle(const char* filename, 68 void NavigateAndCheckTitle(const char* filename,
69 const std::string& expected_title) { 69 const std::string& expected_title) {
70 string16 expected_title16(ASCIIToUTF16(expected_title)); 70 string16 expected_title16(ASCIIToUTF16(expected_title));
71 ui_test_utils::TitleWatcher title_watcher( 71 ui_test_utils::TitleWatcher title_watcher(
72 browser()->GetSelectedWebContents(), expected_title16); 72 browser()->GetActiveWebContents(), expected_title16);
73 ui_test_utils::NavigateToURL(browser(), GetURL(filename)); 73 ui_test_utils::NavigateToURL(browser(), GetURL(filename));
74 ASSERT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); 74 ASSERT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
75 } 75 }
76 76
77 void GoBack() { 77 void GoBack() {
78 ui_test_utils::WindowedNotificationObserver load_stop_observer( 78 ui_test_utils::WindowedNotificationObserver load_stop_observer(
79 content::NOTIFICATION_LOAD_STOP, 79 content::NOTIFICATION_LOAD_STOP,
80 content::NotificationService::AllSources()); 80 content::NotificationService::AllSources());
81 browser()->GoBack(CURRENT_TAB); 81 browser()->GoBack(CURRENT_TAB);
82 load_stop_observer.Wait(); 82 load_stop_observer.Wait();
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 EXPECT_EQ("foo", GetTabTitle()); 427 EXPECT_EQ("foo", GetTabTitle());
428 428
429 GoBack(); 429 GoBack();
430 EXPECT_EQ("Default Title", GetTabTitle()); 430 EXPECT_EQ("Default Title", GetTabTitle());
431 } 431 }
432 432
433 // http://code.google.com/p/chromium/issues/detail?id=56267 433 // http://code.google.com/p/chromium/issues/detail?id=56267
434 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, HistoryLength) { 434 IN_PROC_BROWSER_TEST_F(SessionHistoryTest, HistoryLength) {
435 int length; 435 int length;
436 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( 436 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt(
437 browser()->GetSelectedWebContents()->GetRenderViewHost(), 437 browser()->GetActiveWebContents()->GetRenderViewHost(),
438 L"", L"domAutomationController.send(history.length)", &length)); 438 L"", L"domAutomationController.send(history.length)", &length));
439 EXPECT_EQ(1, length); 439 EXPECT_EQ(1, length);
440 440
441 ui_test_utils::NavigateToURL(browser(), GetURL("title1.html")); 441 ui_test_utils::NavigateToURL(browser(), GetURL("title1.html"));
442 442
443 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( 443 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt(
444 browser()->GetSelectedWebContents()->GetRenderViewHost(), 444 browser()->GetActiveWebContents()->GetRenderViewHost(),
445 L"", L"domAutomationController.send(history.length)", &length)); 445 L"", L"domAutomationController.send(history.length)", &length));
446 EXPECT_EQ(2, length); 446 EXPECT_EQ(2, length);
447 447
448 // Now test that history.length is updated when the navigation is committed. 448 // Now test that history.length is updated when the navigation is committed.
449 ui_test_utils::NavigateToURL(browser(), GetURL("record_length.html")); 449 ui_test_utils::NavigateToURL(browser(), GetURL("record_length.html"));
450 450
451 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( 451 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt(
452 browser()->GetSelectedWebContents()->GetRenderViewHost(), 452 browser()->GetActiveWebContents()->GetRenderViewHost(),
453 L"", L"domAutomationController.send(history.length)", &length)); 453 L"", L"domAutomationController.send(history.length)", &length));
454 EXPECT_EQ(3, length); 454 EXPECT_EQ(3, length);
455 455
456 GoBack(); 456 GoBack();
457 GoBack(); 457 GoBack();
458 458
459 // Ensure history.length is properly truncated. 459 // Ensure history.length is properly truncated.
460 ui_test_utils::NavigateToURL(browser(), GetURL("title2.html")); 460 ui_test_utils::NavigateToURL(browser(), GetURL("title2.html"));
461 461
462 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( 462 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt(
463 browser()->GetSelectedWebContents()->GetRenderViewHost(), 463 browser()->GetActiveWebContents()->GetRenderViewHost(),
464 L"", L"domAutomationController.send(history.length)", &length)); 464 L"", L"domAutomationController.send(history.length)", &length));
465 EXPECT_EQ(2, length); 465 EXPECT_EQ(2, length);
466 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698