| 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/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/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
| 12 #include "content/public/browser/notification_service.h" | 12 #include "content/public/browser/notification_service.h" |
| 13 #include "content/public/browser/notification_types.h" | 13 #include "content/public/browser/notification_types.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
| 16 #include "content/public/test/browser_test_utils.h" |
| 16 #include "net/test/test_server.h" | 17 #include "net/test/test_server.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 class SessionHistoryTest : public InProcessBrowserTest { | 20 class SessionHistoryTest : public InProcessBrowserTest { |
| 20 protected: | 21 protected: |
| 21 SessionHistoryTest() {} | 22 SessionHistoryTest() {} |
| 22 | 23 |
| 23 virtual void SetUpOnMainThread() { | 24 virtual void SetUpOnMainThread() { |
| 24 ASSERT_TRUE(test_server()->Start()); | 25 ASSERT_TRUE(test_server()->Start()); |
| 25 } | 26 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 return chrome::GetActiveWebContents(browser())->GetURL(); | 62 return chrome::GetActiveWebContents(browser())->GetURL(); |
| 62 } | 63 } |
| 63 | 64 |
| 64 GURL GetURL(const std::string file) { | 65 GURL GetURL(const std::string file) { |
| 65 return test_server()->GetURL(std::string("files/session_history/") + file); | 66 return test_server()->GetURL(std::string("files/session_history/") + file); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void NavigateAndCheckTitle(const char* filename, | 69 void NavigateAndCheckTitle(const char* filename, |
| 69 const std::string& expected_title) { | 70 const std::string& expected_title) { |
| 70 string16 expected_title16(ASCIIToUTF16(expected_title)); | 71 string16 expected_title16(ASCIIToUTF16(expected_title)); |
| 71 ui_test_utils::TitleWatcher title_watcher( | 72 content::TitleWatcher title_watcher( |
| 72 chrome::GetActiveWebContents(browser()), expected_title16); | 73 chrome::GetActiveWebContents(browser()), expected_title16); |
| 73 ui_test_utils::NavigateToURL(browser(), GetURL(filename)); | 74 ui_test_utils::NavigateToURL(browser(), GetURL(filename)); |
| 74 ASSERT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 75 ASSERT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
| 75 } | 76 } |
| 76 | 77 |
| 77 void GoBack() { | 78 void GoBack() { |
| 78 content::WindowedNotificationObserver load_stop_observer( | 79 content::WindowedNotificationObserver load_stop_observer( |
| 79 content::NOTIFICATION_LOAD_STOP, | 80 content::NOTIFICATION_LOAD_STOP, |
| 80 content::NotificationService::AllSources()); | 81 content::NotificationService::AllSources()); |
| 81 chrome::GoBack(browser(), CURRENT_TAB); | 82 chrome::GoBack(browser(), CURRENT_TAB); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 GoBack(); | 458 GoBack(); |
| 458 | 459 |
| 459 // Ensure history.length is properly truncated. | 460 // Ensure history.length is properly truncated. |
| 460 ui_test_utils::NavigateToURL(browser(), GetURL("title2.html")); | 461 ui_test_utils::NavigateToURL(browser(), GetURL("title2.html")); |
| 461 | 462 |
| 462 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( | 463 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractInt( |
| 463 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), | 464 chrome::GetActiveWebContents(browser())->GetRenderViewHost(), |
| 464 L"", L"domAutomationController.send(history.length)", &length)); | 465 L"", L"domAutomationController.send(history.length)", &length)); |
| 465 EXPECT_EQ(2, length); | 466 EXPECT_EQ(2, length); |
| 466 } | 467 } |
| OLD | NEW |