OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #endif | 10 #endif |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 | 328 |
329 GURL url; | 329 GURL url; |
330 bool success = tab_proxy->GetCurrentURL(&url); | 330 bool success = tab_proxy->GetCurrentURL(&url); |
331 EXPECT_TRUE(success); | 331 EXPECT_TRUE(success); |
332 if (!success) | 332 if (!success) |
333 return GURL(); | 333 return GURL(); |
334 return url; | 334 return url; |
335 } | 335 } |
336 | 336 |
337 std::wstring UITestBase::GetActiveTabTitle(int window_index) { | 337 std::wstring UITestBase::GetActiveTabTitle(int window_index) { |
338 std::wstring title; | 338 string16 title; |
339 scoped_refptr<TabProxy> tab_proxy(GetActiveTab(window_index)); | 339 scoped_refptr<TabProxy> tab_proxy(GetActiveTab(window_index)); |
340 EXPECT_TRUE(tab_proxy.get()); | 340 EXPECT_TRUE(tab_proxy.get()); |
341 if (!tab_proxy.get()) | 341 if (!tab_proxy.get()) |
342 return title; | 342 return std::wstring(); |
343 | 343 |
344 EXPECT_TRUE(tab_proxy->GetTabTitle(&title)); | 344 EXPECT_TRUE(tab_proxy->GetTabTitle(&title)); |
345 return title; | 345 return UTF16ToWideHack(title); |
346 } | 346 } |
347 | 347 |
348 int UITestBase::GetActiveTabIndex(int window_index) { | 348 int UITestBase::GetActiveTabIndex(int window_index) { |
349 scoped_refptr<BrowserProxy> window_proxy(automation()-> | 349 scoped_refptr<BrowserProxy> window_proxy(automation()-> |
350 GetBrowserWindow(window_index)); | 350 GetBrowserWindow(window_index)); |
351 EXPECT_TRUE(window_proxy.get()); | 351 EXPECT_TRUE(window_proxy.get()); |
352 if (!window_proxy.get()) | 352 if (!window_proxy.get()) |
353 return -1; | 353 return -1; |
354 | 354 |
355 int active_tab_index = -1; | 355 int active_tab_index = -1; |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 const int kMaxIntervals = timeout_ms / kIntervalMs; | 713 const int kMaxIntervals = timeout_ms / kIntervalMs; |
714 | 714 |
715 // Wait until the test signals it has completed. | 715 // Wait until the test signals it has completed. |
716 for (int i = 0; i < kMaxIntervals; ++i) { | 716 for (int i = 0; i < kMaxIntervals; ++i) { |
717 bool browser_survived = CrashAwareSleep(kIntervalMs); | 717 bool browser_survived = CrashAwareSleep(kIntervalMs); |
718 EXPECT_TRUE(browser_survived); | 718 EXPECT_TRUE(browser_survived); |
719 if (!browser_survived) | 719 if (!browser_survived) |
720 return false; | 720 return false; |
721 | 721 |
722 bool done_value = false; | 722 bool done_value = false; |
723 bool success = tab->ExecuteAndExtractBool(frame_xpath, jscript, | 723 bool success = tab->ExecuteAndExtractBool(WideToUTF16Hack(frame_xpath), |
| 724 WideToUTF16Hack(jscript), |
724 &done_value); | 725 &done_value); |
725 EXPECT_TRUE(success); | 726 EXPECT_TRUE(success); |
726 if (!success) | 727 if (!success) |
727 return false; | 728 return false; |
728 if (done_value) | 729 if (done_value) |
729 return true; | 730 return true; |
730 } | 731 } |
731 | 732 |
732 ADD_FAILURE() << "Timeout reached in WaitUntilJavaScriptCondition"; | 733 ADD_FAILURE() << "Timeout reached in WaitUntilJavaScriptCondition"; |
733 return false; | 734 return false; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 incorrect_state_count++; | 856 incorrect_state_count++; |
856 } | 857 } |
857 | 858 |
858 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() | 859 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() |
859 << " seconds" | 860 << " seconds" |
860 << " call failed " << fail_count << " times" | 861 << " call failed " << fail_count << " times" |
861 << " state was incorrect " << incorrect_state_count << " times"; | 862 << " state was incorrect " << incorrect_state_count << " times"; |
862 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; | 863 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; |
863 return false; | 864 return false; |
864 } | 865 } |
OLD | NEW |