| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| 11 #include "chrome/browser/view_ids.h" | 11 #include "chrome/browser/view_ids.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 ASSERT_FALSE(is_timeout); | 288 ASSERT_FALSE(is_timeout); |
| 289 | 289 |
| 290 std::wstring title; | 290 std::wstring title; |
| 291 ASSERT_TRUE(tab->GetTabTitle(&title)); | 291 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 292 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); | 292 ASSERT_STREQ(L"Title Of Awesomeness", title.c_str()); |
| 293 | 293 |
| 294 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), | 294 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), |
| 295 1, &is_timeout); | 295 1, &is_timeout); |
| 296 ASSERT_TRUE(is_timeout); | 296 ASSERT_TRUE(is_timeout); |
| 297 | 297 |
| 298 Sleep(10); | 298 PlatformThread::Sleep(10); |
| 299 } | 299 } |
| 300 | 300 |
| 301 // This test is disabled. See bug 794412. | 301 // This test is disabled. See bug 794412. |
| 302 TEST_F(AutomationProxyTest, DISABLED_NavigateToURLWithTimeout2) { | 302 TEST_F(AutomationProxyTest, DISABLED_NavigateToURLWithTimeout2) { |
| 303 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 303 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 304 ASSERT_TRUE(window.get()); | 304 ASSERT_TRUE(window.get()); |
| 305 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 305 scoped_ptr<TabProxy> tab(window->GetTab(0)); |
| 306 tab.reset(window->GetTab(0)); | 306 tab.reset(window->GetTab(0)); |
| 307 ASSERT_TRUE(tab.get()); | 307 ASSERT_TRUE(tab.get()); |
| 308 | 308 |
| 309 std::wstring filename1(test_data_directory_); | 309 std::wstring filename1(test_data_directory_); |
| 310 file_util::AppendToPath(&filename1, L"title1.html"); | 310 file_util::AppendToPath(&filename1, L"title1.html"); |
| 311 | 311 |
| 312 bool is_timeout; | 312 bool is_timeout; |
| 313 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename1), | 313 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename1), |
| 314 1, &is_timeout); | 314 1, &is_timeout); |
| 315 ASSERT_TRUE(is_timeout); | 315 ASSERT_TRUE(is_timeout); |
| 316 | 316 |
| 317 std::wstring filename2(test_data_directory_); | 317 std::wstring filename2(test_data_directory_); |
| 318 file_util::AppendToPath(&filename2, L"title2.html"); | 318 file_util::AppendToPath(&filename2, L"title2.html"); |
| 319 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), | 319 tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), |
| 320 10000, &is_timeout); | 320 10000, &is_timeout); |
| 321 ASSERT_FALSE(is_timeout); | 321 ASSERT_FALSE(is_timeout); |
| 322 | 322 |
| 323 Sleep(10); | 323 PlatformThread::Sleep(10); |
| 324 } | 324 } |
| 325 | 325 |
| 326 TEST_F(AutomationProxyTest, GoBackForward) { | 326 TEST_F(AutomationProxyTest, GoBackForward) { |
| 327 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 327 scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 328 ASSERT_TRUE(window.get()); | 328 ASSERT_TRUE(window.get()); |
| 329 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 329 scoped_ptr<TabProxy> tab(window->GetTab(0)); |
| 330 ASSERT_TRUE(tab.get()); | 330 ASSERT_TRUE(tab.get()); |
| 331 | 331 |
| 332 std::wstring title; | 332 std::wstring title; |
| 333 ASSERT_TRUE(tab->GetTabTitle(&title)); | 333 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB)); | 493 ASSERT_TRUE(window->ApplyAccelerator(IDC_NEW_TAB)); |
| 494 ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1, | 494 ASSERT_TRUE(window->WaitForTabCountToBecome(tab_count + 1, |
| 495 action_timeout_ms())); | 495 action_timeout_ms())); |
| 496 ASSERT_TRUE(window->GetTabCount(&tab_count)); | 496 ASSERT_TRUE(window->GetTabCount(&tab_count)); |
| 497 scoped_ptr<TabProxy> tab(window->GetTab(tab_count - 1)); | 497 scoped_ptr<TabProxy> tab(window->GetTab(tab_count - 1)); |
| 498 ASSERT_TRUE(tab.get()); | 498 ASSERT_TRUE(tab.get()); |
| 499 | 499 |
| 500 std::wstring title; | 500 std::wstring title; |
| 501 int i; | 501 int i; |
| 502 for (i = 0; i < 10; ++i) { | 502 for (i = 0; i < 10; ++i) { |
| 503 Sleep(sleep_timeout_ms()); | 503 PlatformThread::Sleep(sleep_timeout_ms()); |
| 504 ASSERT_TRUE(tab->GetTabTitle(&title)); | 504 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 505 if (title == L"Destinations" || title == L"New Tab") | 505 if (title == L"Destinations" || title == L"New Tab") |
| 506 break; | 506 break; |
| 507 } | 507 } |
| 508 // If we got to 10, the new tab failed to open. | 508 // If we got to 10, the new tab failed to open. |
| 509 ASSERT_NE(10, i); | 509 ASSERT_NE(10, i); |
| 510 } | 510 } |
| 511 | 511 |
| 512 class AutomationProxyTest4 : public UITest { | 512 class AutomationProxyTest4 : public UITest { |
| 513 protected: | 513 protected: |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 #if 0 | 631 #if 0 |
| 632 // Open a new Destinations tab to execute script inside. | 632 // Open a new Destinations tab to execute script inside. |
| 633 window->ApplyAccelerator(IDC_NEWTAB); | 633 window->ApplyAccelerator(IDC_NEWTAB); |
| 634 tab.reset(window->GetTab(1)); | 634 tab.reset(window->GetTab(1)); |
| 635 ASSERT_TRUE(tab.get()); | 635 ASSERT_TRUE(tab.get()); |
| 636 ASSERT_TRUE(window->ActivateTab(1)); | 636 ASSERT_TRUE(window->ActivateTab(1)); |
| 637 | 637 |
| 638 std::wstring title; | 638 std::wstring title; |
| 639 int i; | 639 int i; |
| 640 for (i = 0; i < 10; ++i) { | 640 for (i = 0; i < 10; ++i) { |
| 641 Sleep(sleep_timeout_ms()); | 641 PlatformThread::Sleep(sleep_timeout_ms()); |
| 642 ASSERT_TRUE(tab->GetTabTitle(&title)); | 642 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| 643 if (title == L"Destinations") | 643 if (title == L"Destinations") |
| 644 break; | 644 break; |
| 645 } | 645 } |
| 646 // If we got to 10, the new tab failed to open. | 646 // If we got to 10, the new tab failed to open. |
| 647 ASSERT_NE(10, i); | 647 ASSERT_NE(10, i); |
| 648 ASSERT_FALSE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual)); | 648 ASSERT_FALSE(tab->ExecuteAndExtractString(xpath1, jscript1, &actual)); |
| 649 #endif | 649 #endif |
| 650 } | 650 } |
| 651 | 651 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 834 |
| 835 const std::string& target() const { | 835 const std::string& target() const { |
| 836 return target_; | 836 return target_; |
| 837 } | 837 } |
| 838 | 838 |
| 839 // Waits for the DidNavigate event to be processed on the current thread. | 839 // Waits for the DidNavigate event to be processed on the current thread. |
| 840 // Returns true if the event arrived, false if there was a timeout. | 840 // Returns true if the event arrived, false if there was a timeout. |
| 841 bool WaitForNavigationComplete(int max_time_to_wait_ms) { | 841 bool WaitForNavigationComplete(int max_time_to_wait_ms) { |
| 842 base::TimeTicks start(base::TimeTicks::Now()); | 842 base::TimeTicks start(base::TimeTicks::Now()); |
| 843 while (!navigate_complete_) { | 843 while (!navigate_complete_) { |
| 844 Sleep(50); | 844 PlatformThread::Sleep(50); |
| 845 MessageLoop::current()->RunAllPending(); | 845 MessageLoop::current()->RunAllPending(); |
| 846 base::TimeTicks end(base::TimeTicks::Now()); | 846 base::TimeTicks end(base::TimeTicks::Now()); |
| 847 base::TimeDelta delta = end - start; | 847 base::TimeDelta delta = end - start; |
| 848 if (static_cast<int>(delta.InMilliseconds()) > max_time_to_wait_ms) | 848 if (static_cast<int>(delta.InMilliseconds()) > max_time_to_wait_ms) |
| 849 return false; | 849 return false; |
| 850 } | 850 } |
| 851 return true; | 851 return true; |
| 852 } | 852 } |
| 853 | 853 |
| 854 protected: | 854 protected: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 TEST_F(ExternalTabTestType, CreateExternalTab) { | 887 TEST_F(ExternalTabTestType, CreateExternalTab) { |
| 888 HWND external_tab_container = NULL; | 888 HWND external_tab_container = NULL; |
| 889 scoped_ptr<TabProxy> tab(automation()->CreateExternalTab(NULL, gfx::Rect(), | 889 scoped_ptr<TabProxy> tab(automation()->CreateExternalTab(NULL, gfx::Rect(), |
| 890 WS_POPUP, &external_tab_container)); | 890 WS_POPUP, &external_tab_container)); |
| 891 EXPECT_TRUE(tab != NULL); | 891 EXPECT_TRUE(tab != NULL); |
| 892 EXPECT_NE(FALSE, ::IsWindow(external_tab_container)); | 892 EXPECT_NE(FALSE, ::IsWindow(external_tab_container)); |
| 893 if (tab != NULL) { | 893 if (tab != NULL) { |
| 894 tab->NavigateInExternalTab(GURL(L"http://www.google.com")); | 894 tab->NavigateInExternalTab(GURL(L"http://www.google.com")); |
| 895 EXPECT_EQ(true, ExternalTabHandler(external_tab_container, 1000)); | 895 EXPECT_EQ(true, ExternalTabHandler(external_tab_container, 1000)); |
| 896 // Since the tab goes away lazily, wait a bit | 896 // Since the tab goes away lazily, wait a bit |
| 897 Sleep(1000); | 897 PlatformThread::Sleep(1000); |
| 898 EXPECT_FALSE(tab->is_valid()); | 898 EXPECT_FALSE(tab->is_valid()); |
| 899 } | 899 } |
| 900 } | 900 } |
| 901 | 901 |
| 902 TEST_F(ExternalTabTestType, ExternalTabPostMessage) { | 902 TEST_F(ExternalTabTestType, ExternalTabPostMessage) { |
| 903 AutomationProxyForExternalTab* proxy = | 903 AutomationProxyForExternalTab* proxy = |
| 904 static_cast<AutomationProxyForExternalTab*>(automation()); | 904 static_cast<AutomationProxyForExternalTab*>(automation()); |
| 905 | 905 |
| 906 HWND external_tab_container = NULL; | 906 HWND external_tab_container = NULL; |
| 907 scoped_ptr<TabProxy> tab(proxy->CreateExternalTab(NULL, gfx::Rect(), | 907 scoped_ptr<TabProxy> tab(proxy->CreateExternalTab(NULL, gfx::Rect(), |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 | 1100 |
| 1101 scoped_ptr<TabProxy> tab(window->GetTab(0)); | 1101 scoped_ptr<TabProxy> tab(window->GetTab(0)); |
| 1102 ASSERT_TRUE(tab.get()); | 1102 ASSERT_TRUE(tab.get()); |
| 1103 | 1103 |
| 1104 std::wstring filename(test_data_directory_); | 1104 std::wstring filename(test_data_directory_); |
| 1105 file_util::AppendToPath(&filename, L"dom_automation_test_with_popup.html"); | 1105 file_util::AppendToPath(&filename, L"dom_automation_test_with_popup.html"); |
| 1106 | 1106 |
| 1107 tab->NavigateToURL(net::FilePathToFileURL(filename)); | 1107 tab->NavigateToURL(net::FilePathToFileURL(filename)); |
| 1108 | 1108 |
| 1109 // Allow some time for the popup to show up and close. | 1109 // Allow some time for the popup to show up and close. |
| 1110 Sleep(2000); | 1110 PlatformThread::Sleep(2000); |
| 1111 | 1111 |
| 1112 std::wstring expected(L"string"); | 1112 std::wstring expected(L"string"); |
| 1113 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); | 1113 std::wstring jscript = CreateJSString(L"\"" + expected + L"\""); |
| 1114 std::wstring actual; | 1114 std::wstring actual; |
| 1115 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); | 1115 ASSERT_TRUE(tab->ExecuteAndExtractString(L"", jscript, &actual)); |
| 1116 ASSERT_STREQ(expected.c_str(), actual.c_str()); | 1116 ASSERT_STREQ(expected.c_str(), actual.c_str()); |
| 1117 } | 1117 } |
| OLD | NEW |