| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/message_box_flags.h" | 9 #include "app/message_box_flags.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/test/automation/automation_messages.h" | 22 #include "chrome/test/automation/automation_messages.h" |
| 23 #include "chrome/test/automation/automation_proxy_uitest.h" | 23 #include "chrome/test/automation/automation_proxy_uitest.h" |
| 24 #include "chrome/test/automation/browser_proxy.h" | 24 #include "chrome/test/automation/browser_proxy.h" |
| 25 #include "chrome/test/automation/tab_proxy.h" | 25 #include "chrome/test/automation/tab_proxy.h" |
| 26 #include "chrome/test/automation/window_proxy.h" | 26 #include "chrome/test/automation/window_proxy.h" |
| 27 #include "chrome/test/ui/ui_test.h" | 27 #include "chrome/test/ui/ui_test.h" |
| 28 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
| 29 #include "net/url_request/url_request_unittest.h" | 29 #include "net/url_request/url_request_unittest.h" |
| 30 #include "views/event.h" | 30 #include "views/event.h" |
| 31 | 31 |
| 32 #if defined(OS_MACOSX) |
| 33 #define MAYBE_WindowGetViewBounds DISABLED_WindowGetViewBounds |
| 34 #else |
| 35 #define MAYBE_WindowGetViewBounds WindowGetViewBounds |
| 36 #endif |
| 37 |
| 32 class AutomationProxyTest : public UITest { | 38 class AutomationProxyTest : public UITest { |
| 33 protected: | 39 protected: |
| 34 AutomationProxyTest() { | 40 AutomationProxyTest() { |
| 35 dom_automation_enabled_ = true; | 41 dom_automation_enabled_ = true; |
| 36 launch_arguments_.AppendSwitchWithValue(switches::kLang, | 42 launch_arguments_.AppendSwitchWithValue(switches::kLang, |
| 37 L"en-US"); | 43 L"en-US"); |
| 38 } | 44 } |
| 39 }; | 45 }; |
| 40 | 46 |
| 41 TEST_F(AutomationProxyTest, GetBrowserWindowCount) { | 47 TEST_F(AutomationProxyTest, GetBrowserWindowCount) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 57 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(-1)); | 63 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(-1)); |
| 58 ASSERT_FALSE(window.get()); | 64 ASSERT_FALSE(window.get()); |
| 59 } | 65 } |
| 60 | 66 |
| 61 { | 67 { |
| 62 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(1)); | 68 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(1)); |
| 63 ASSERT_FALSE(window.get()); | 69 ASSERT_FALSE(window.get()); |
| 64 } | 70 } |
| 65 }; | 71 }; |
| 66 | 72 |
| 67 // TODO(port): This test is for Chrome Views, which we only use on Windows. | 73 // TODO(estade): port automation provider for this test to mac. |
| 68 // Maybe split this into a _win.cc file? | 74 TEST_F(AutomationProxyVisibleTest, MAYBE_WindowGetViewBounds) { |
| 69 #if defined(OS_WIN) | |
| 70 TEST_F(AutomationProxyVisibleTest, WindowGetViewBounds) { | |
| 71 { | 75 { |
| 72 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 76 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 73 ASSERT_TRUE(browser.get()); | 77 ASSERT_TRUE(browser.get()); |
| 74 scoped_refptr<WindowProxy> window(browser->GetWindow()); | 78 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
| 75 ASSERT_TRUE(window.get()); | 79 ASSERT_TRUE(window.get()); |
| 76 | 80 |
| 77 scoped_refptr<TabProxy> tab1(browser->GetTab(0)); | 81 scoped_refptr<TabProxy> tab1(browser->GetTab(0)); |
| 78 ASSERT_TRUE(tab1.get()); | 82 ASSERT_TRUE(tab1.get()); |
| 79 GURL tab1_url; | 83 GURL tab1_url; |
| 80 ASSERT_TRUE(tab1->GetCurrentURL(&tab1_url)); | 84 ASSERT_TRUE(tab1->GetCurrentURL(&tab1_url)); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 ASSERT_TRUE(tab2.get()); | 152 ASSERT_TRUE(tab2.get()); |
| 149 GURL tab2_new_url; | 153 GURL tab2_new_url; |
| 150 ASSERT_TRUE(tab2->GetCurrentURL(&tab2_new_url)); | 154 ASSERT_TRUE(tab2->GetCurrentURL(&tab2_new_url)); |
| 151 | 155 |
| 152 EXPECT_EQ(tab1_url.spec(), tab2_new_url.spec()); | 156 EXPECT_EQ(tab1_url.spec(), tab2_new_url.spec()); |
| 153 EXPECT_EQ(tab2_url.spec(), tab1_new_url.spec()); | 157 EXPECT_EQ(tab2_url.spec(), tab1_new_url.spec()); |
| 154 | 158 |
| 155 */ | 159 */ |
| 156 } | 160 } |
| 157 } | 161 } |
| 158 #endif // defined(OS_WIN) | |
| 159 | 162 |
| 160 TEST_F(AutomationProxyTest, GetTabCount) { | 163 TEST_F(AutomationProxyTest, GetTabCount) { |
| 161 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 164 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 162 ASSERT_TRUE(window.get()); | 165 ASSERT_TRUE(window.get()); |
| 163 | 166 |
| 164 int tab_count = 0; | 167 int tab_count = 0; |
| 165 ASSERT_TRUE(window->GetTabCount(&tab_count)); | 168 ASSERT_TRUE(window->GetTabCount(&tab_count)); |
| 166 ASSERT_EQ(1, tab_count); | 169 ASSERT_EQ(1, tab_count); |
| 167 } | 170 } |
| 168 | 171 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 // now, test that we can get multiple cookies: | 454 // now, test that we can get multiple cookies: |
| 452 ASSERT_TRUE(tab->SetCookie(url, "foo1=baz1")); | 455 ASSERT_TRUE(tab->SetCookie(url, "foo1=baz1")); |
| 453 ASSERT_TRUE(tab->SetCookie(url, "foo2=baz2")); | 456 ASSERT_TRUE(tab->SetCookie(url, "foo2=baz2")); |
| 454 | 457 |
| 455 ASSERT_TRUE(tab->GetCookies(url, &value_result)); | 458 ASSERT_TRUE(tab->GetCookies(url, &value_result)); |
| 456 ASSERT_FALSE(value_result.empty()); | 459 ASSERT_FALSE(value_result.empty()); |
| 457 EXPECT_TRUE(value_result.find("foo1=baz1") != std::string::npos); | 460 EXPECT_TRUE(value_result.find("foo1=baz1") != std::string::npos); |
| 458 EXPECT_TRUE(value_result.find("foo2=baz2") != std::string::npos); | 461 EXPECT_TRUE(value_result.find("foo2=baz2") != std::string::npos); |
| 459 } | 462 } |
| 460 | 463 |
| 461 // TODO(port): Determine what tests need this and port. | |
| 462 #if defined(OS_WIN) | |
| 463 TEST_F(AutomationProxyTest, GetHWND) { | |
| 464 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | |
| 465 ASSERT_TRUE(browser.get()); | |
| 466 scoped_refptr<WindowProxy> window(browser->GetWindow()); | |
| 467 ASSERT_TRUE(window.get()); | |
| 468 | |
| 469 HWND handle; | |
| 470 ASSERT_TRUE(window->GetHWND(&handle)); | |
| 471 ASSERT_TRUE(handle); | |
| 472 } | |
| 473 #endif | |
| 474 | |
| 475 TEST_F(AutomationProxyTest, NavigateToURLAsync) { | 464 TEST_F(AutomationProxyTest, NavigateToURLAsync) { |
| 476 AutomationProxy* automation_object = automation(); | 465 AutomationProxy* automation_object = automation(); |
| 477 scoped_refptr<BrowserProxy> window(automation_object->GetBrowserWindow(0)); | 466 scoped_refptr<BrowserProxy> window(automation_object->GetBrowserWindow(0)); |
| 478 ASSERT_TRUE(window.get()); | 467 ASSERT_TRUE(window.get()); |
| 479 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 468 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 480 ASSERT_TRUE(tab.get()); | 469 ASSERT_TRUE(tab.get()); |
| 481 | 470 |
| 482 FilePath filename(test_data_directory_); | 471 FilePath filename(test_data_directory_); |
| 483 filename = filename.AppendASCII("cookie1.html"); | 472 filename = filename.AppendASCII("cookie1.html"); |
| 484 GURL newurl = net::FilePathToFileURL(filename); | 473 GURL newurl = net::FilePathToFileURL(filename); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 | 1179 |
| 1191 // Allow some time for the popup to show up and close. | 1180 // Allow some time for the popup to show up and close. |
| 1192 PlatformThread::Sleep(2000); | 1181 PlatformThread::Sleep(2000); |
| 1193 | 1182 |
| 1194 std::wstring expected(L"string"); | 1183 std::wstring expected(L"string"); |
| 1195 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); | 1184 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); |
| 1196 std::wstring actual; | 1185 std::wstring actual; |
| 1197 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); | 1186 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); |
| 1198 ASSERT_EQ(expected, actual); | 1187 ASSERT_EQ(expected, actual); |
| 1199 } | 1188 } |
| OLD | NEW |