| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/platform_thread.h" | 7 #include "base/platform_thread.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/test/automation/tab_proxy.h" | 9 #include "chrome/test/automation/tab_proxy.h" |
| 10 #include "chrome/test/automation/browser_proxy.h" | 10 #include "chrome/test/automation/browser_proxy.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 SessionHistoryTest() : UITest() { | 24 SessionHistoryTest() : UITest() { |
| 25 FilePath path(test_data_directory_); | 25 FilePath path(test_data_directory_); |
| 26 path = path.AppendASCII("session_history"); | 26 path = path.AppendASCII("session_history"); |
| 27 | 27 |
| 28 url_prefix_ = UTF8ToWide(net::FilePathToFileURL(path).spec()); | 28 url_prefix_ = UTF8ToWide(net::FilePathToFileURL(path).spec()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual void SetUp() { | 31 virtual void SetUp() { |
| 32 UITest::SetUp(); | 32 UITest::SetUp(); |
| 33 | 33 |
| 34 window_.reset(automation()->GetBrowserWindow(0)); | 34 window_ = automation()->GetBrowserWindow(0); |
| 35 ASSERT_TRUE(window_.get()); | 35 ASSERT_TRUE(window_.get()); |
| 36 | 36 |
| 37 int active_tab_index = -1; | 37 int active_tab_index = -1; |
| 38 ASSERT_TRUE(window_->GetActiveTabIndex(&active_tab_index)); | 38 ASSERT_TRUE(window_->GetActiveTabIndex(&active_tab_index)); |
| 39 tab_.reset(window_->GetTab(active_tab_index)); | 39 tab_ = window_->GetTab(active_tab_index); |
| 40 ASSERT_TRUE(tab_.get()); | 40 ASSERT_TRUE(tab_.get()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Simulate clicking a link. Only works on the frames.html testserver page. | 43 // Simulate clicking a link. Only works on the frames.html testserver page. |
| 44 void ClickLink(std::string node_id) { | 44 void ClickLink(std::string node_id) { |
| 45 GURL url("javascript:clickLink('" + node_id + "')"); | 45 GURL url("javascript:clickLink('" + node_id + "')"); |
| 46 ASSERT_TRUE(tab_->NavigateToURL(url)); | 46 ASSERT_TRUE(tab_->NavigateToURL(url)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Simulate filling in form data. Only works on the frames.html page with | 49 // Simulate filling in form data. Only works on the frames.html page with |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 } | 91 } |
| 92 | 92 |
| 93 GURL GetTabURL() { | 93 GURL GetTabURL() { |
| 94 GURL url; | 94 GURL url; |
| 95 EXPECT_TRUE(tab_->GetCurrentURL(&url)); | 95 EXPECT_TRUE(tab_->GetCurrentURL(&url)); |
| 96 return url; | 96 return url; |
| 97 } | 97 } |
| 98 | 98 |
| 99 protected: | 99 protected: |
| 100 wstring url_prefix_; | 100 wstring url_prefix_; |
| 101 scoped_ptr<BrowserProxy> window_; | 101 scoped_refptr<BrowserProxy> window_; |
| 102 scoped_ptr<TabProxy> tab_; | 102 scoped_refptr<TabProxy> tab_; |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 TEST_F(SessionHistoryTest, BasicBackForward) { | 105 TEST_F(SessionHistoryTest, BasicBackForward) { |
| 106 scoped_refptr<HTTPTestServer> server = | 106 scoped_refptr<HTTPTestServer> server = |
| 107 HTTPTestServer::CreateServer(kDocRoot, NULL); | 107 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 108 ASSERT_TRUE(NULL != server.get()); | 108 ASSERT_TRUE(NULL != server.get()); |
| 109 | 109 |
| 110 // about:blank should be loaded first. | 110 // about:blank should be loaded first. |
| 111 ASSERT_FALSE(tab_->GoBack()); | 111 ASSERT_FALSE(tab_->GoBack()); |
| 112 EXPECT_EQ(L"", GetTabTitle()); | 112 EXPECT_EQ(L"", GetTabTitle()); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 scoped_refptr<HTTPTestServer> server = | 495 scoped_refptr<HTTPTestServer> server = |
| 496 HTTPTestServer::CreateServer(kDocRoot, NULL); | 496 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 497 ASSERT_TRUE(NULL != server.get()); | 497 ASSERT_TRUE(NULL != server.get()); |
| 498 | 498 |
| 499 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage( | 499 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage( |
| 500 "files/session_history/replace.html?no-title.html"))); | 500 "files/session_history/replace.html?no-title.html"))); |
| 501 EXPECT_EQ(L"", GetTabTitle()); | 501 EXPECT_EQ(L"", GetTabTitle()); |
| 502 } | 502 } |
| 503 | 503 |
| 504 } // namespace | 504 } // namespace |
| OLD | NEW |