| 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/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/test/automation/tab_proxy.h" | 10 #include "chrome/test/automation/tab_proxy.h" |
| 11 #include "chrome/test/automation/browser_proxy.h" | 11 #include "chrome/test/automation/browser_proxy.h" |
| 12 #include "chrome/test/ui/ui_test.h" | 12 #include "chrome/test/ui/ui_test.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 15 #include "net/url_request/url_request_unittest.h" | 15 #include "net/url_request/url_request_unittest.h" |
| 16 | 16 |
| 17 using std::wstring; | |
| 18 | |
| 19 namespace { | 17 namespace { |
| 20 | 18 |
| 21 const wchar_t kDocRoot[] = L"chrome/test/data"; | 19 const wchar_t kDocRoot[] = L"chrome/test/data"; |
| 22 | 20 |
| 23 class SessionHistoryTest : public UITest { | 21 class SessionHistoryTest : public UITest { |
| 24 protected: | 22 protected: |
| 25 SessionHistoryTest() : UITest() { | 23 SessionHistoryTest() : UITest() { |
| 26 dom_automation_enabled_ = true; | 24 dom_automation_enabled_ = true; |
| 27 } | 25 } |
| 28 | 26 |
| 29 virtual void SetUp() { | 27 virtual void SetUp() { |
| 30 UITest::SetUp(); | 28 UITest::SetUp(); |
| 31 | 29 |
| 32 window_ = automation()->GetBrowserWindow(0); | 30 window_ = automation()->GetBrowserWindow(0); |
| 33 ASSERT_TRUE(window_.get()); | 31 ASSERT_TRUE(window_.get()); |
| 34 | 32 |
| 35 int active_tab_index = -1; | 33 tab_ = window_->GetActiveTab(); |
| 36 ASSERT_TRUE(window_->GetActiveTabIndex(&active_tab_index)); | |
| 37 tab_ = window_->GetTab(active_tab_index); | |
| 38 ASSERT_TRUE(tab_.get()); | 34 ASSERT_TRUE(tab_.get()); |
| 39 } | 35 } |
| 40 | 36 |
| 41 // Simulate clicking a link. Only works on the frames.html testserver page. | 37 // Simulate clicking a link. Only works on the frames.html testserver page. |
| 42 void ClickLink(std::string node_id) { | 38 void ClickLink(std::string node_id) { |
| 43 GURL url("javascript:clickLink('" + node_id + "')"); | 39 GURL url("javascript:clickLink('" + node_id + "')"); |
| 44 ASSERT_TRUE(tab_->NavigateToURL(url)); | 40 ASSERT_TRUE(tab_->NavigateToURL(url)); |
| 45 } | 41 } |
| 46 | 42 |
| 47 // Simulate filling in form data. Only works on the frames.html page with | 43 // Simulate filling in form data. Only works on the frames.html page with |
| (...skipping 12 matching lines...) Expand all Loading... |
| 60 GURL url("javascript:submitForm('" + node_id + "')"); | 56 GURL url("javascript:submitForm('" + node_id + "')"); |
| 61 ASSERT_TRUE(tab_->NavigateToURL(url)); | 57 ASSERT_TRUE(tab_->NavigateToURL(url)); |
| 62 } | 58 } |
| 63 | 59 |
| 64 // Navigate session history using history.go(distance). | 60 // Navigate session history using history.go(distance). |
| 65 void JavascriptGo(std::string distance) { | 61 void JavascriptGo(std::string distance) { |
| 66 GURL url("javascript:history.go('" + distance + "')"); | 62 GURL url("javascript:history.go('" + distance + "')"); |
| 67 ASSERT_TRUE(tab_->NavigateToURL(url)); | 63 ASSERT_TRUE(tab_->NavigateToURL(url)); |
| 68 } | 64 } |
| 69 | 65 |
| 70 wstring GetTabTitle() { | 66 std::wstring GetTabTitle() { |
| 71 wstring title; | 67 std::wstring title; |
| 72 EXPECT_TRUE(tab_->GetTabTitle(&title)); | 68 EXPECT_TRUE(tab_->GetTabTitle(&title)); |
| 73 return title; | 69 return title; |
| 74 } | 70 } |
| 75 | 71 |
| 76 GURL GetTabURL() { | 72 GURL GetTabURL() { |
| 77 GURL url; | 73 GURL url; |
| 78 EXPECT_TRUE(tab_->GetCurrentURL(&url)); | 74 EXPECT_TRUE(tab_->GetCurrentURL(&url)); |
| 79 return url; | 75 return url; |
| 80 } | 76 } |
| 81 | 77 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 ASSERT_TRUE(tab_->GoBack()); | 546 ASSERT_TRUE(tab_->GoBack()); |
| 551 | 547 |
| 552 // Ensure history.length is properly truncated. | 548 // Ensure history.length is properly truncated. |
| 553 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title2.html"))); | 549 ASSERT_TRUE(tab_->NavigateToURL(server->TestServerPage("files/title2.html"))); |
| 554 ASSERT_TRUE(tab_->ExecuteAndExtractInt( | 550 ASSERT_TRUE(tab_->ExecuteAndExtractInt( |
| 555 L"", L"domAutomationController.send(history.length)", &length)); | 551 L"", L"domAutomationController.send(history.length)", &length)); |
| 556 EXPECT_EQ(2, length); | 552 EXPECT_EQ(2, length); |
| 557 } | 553 } |
| 558 | 554 |
| 559 } // namespace | 555 } // namespace |
| OLD | NEW |