Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Side by Side Diff: chrome/test/ui/ui_test.cc

Issue 6187002: Remove sleep_timeout_ms and fix all the callers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | chrome/worker/worker_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 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
11 11
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 const int kCycles = 10; 306 const int kCycles = 10;
307 for (int i = 0; i < kCycles; i++) { 307 for (int i = 0; i < kCycles; i++) {
308 bool visible = false; 308 bool visible = false;
309 bool animating = true; 309 bool animating = true;
310 if (!browser->GetBookmarkBarVisibility(&visible, &animating)) 310 if (!browser->GetBookmarkBarVisibility(&visible, &animating))
311 return false; // Some error. 311 return false; // Some error.
312 if (visible == wait_for_open && !animating) 312 if (visible == wait_for_open && !animating)
313 return true; // Bookmark bar visibility change complete. 313 return true; // Bookmark bar visibility change complete.
314 314
315 // Give it a chance to catch up. 315 // Give it a chance to catch up.
316 bool browser_survived = CrashAwareSleep(sleep_timeout_ms() / kCycles); 316 bool browser_survived = CrashAwareSleep(
317 TestTimeouts::action_timeout_ms() / kCycles);
317 EXPECT_TRUE(browser_survived); 318 EXPECT_TRUE(browser_survived);
318 if (!browser_survived) 319 if (!browser_survived)
319 return false; 320 return false;
320 } 321 }
321 322
322 ADD_FAILURE() << "Timeout reached in WaitForBookmarkBarVisibilityChange"; 323 ADD_FAILURE() << "Timeout reached in WaitForBookmarkBarVisibilityChange";
323 return false; 324 return false;
324 } 325 }
325 326
326 GURL UITestBase::GetActiveTabURL(int window_index) { 327 GURL UITestBase::GetActiveTabURL(int window_index) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return 0; 381 return 0;
381 382
382 int result = 0; 383 int result = 0;
383 EXPECT_TRUE(window->GetTabCount(&result)); 384 EXPECT_TRUE(window->GetTabCount(&result));
384 385
385 return result; 386 return result;
386 } 387 }
387 388
388 void UITestBase::WaitUntilTabCount(int tab_count) { 389 void UITestBase::WaitUntilTabCount(int tab_count) {
389 const int kMaxIntervals = 10; 390 const int kMaxIntervals = 10;
390 const int kIntervalMs = sleep_timeout_ms() / kMaxIntervals; 391 const int kIntervalMs = TestTimeouts::action_timeout_ms() / kMaxIntervals;
391 392
392 for (int i = 0; i < kMaxIntervals; ++i) { 393 for (int i = 0; i < kMaxIntervals; ++i) {
393 bool browser_survived = CrashAwareSleep(kIntervalMs); 394 bool browser_survived = CrashAwareSleep(kIntervalMs);
394 EXPECT_TRUE(browser_survived); 395 EXPECT_TRUE(browser_survived);
395 if (!browser_survived) 396 if (!browser_survived)
396 return; 397 return;
397 if (GetTabCount() == tab_count) 398 if (GetTabCount() == tab_count)
398 return; 399 return;
399 } 400 }
400 401
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 std::string cookie_value = WaitUntilCookieNonEmpty(tab.get(), url, 649 std::string cookie_value = WaitUntilCookieNonEmpty(tab.get(), url,
649 cookie_name.c_str(), 650 cookie_name.c_str(),
650 wait_time); 651 wait_time);
651 EXPECT_EQ(expected_cookie_value, cookie_value); 652 EXPECT_EQ(expected_cookie_value, cookie_value);
652 } 653 }
653 654
654 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { 655 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) {
655 for (int i = 0; i < 10; i++) { 656 for (int i = 0; i < 10; i++) {
656 if (file_util::EvictFileFromSystemCache(path)) 657 if (file_util::EvictFileFromSystemCache(path))
657 return true; 658 return true;
658 base::PlatformThread::Sleep(sleep_timeout_ms() / 10); 659 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / 10);
659 } 660 }
660 return false; 661 return false;
661 } 662 }
662 663
663 void UITest::WaitForGeneratedFileAndCheck( 664 void UITest::WaitForGeneratedFileAndCheck(
664 const FilePath& generated_file, 665 const FilePath& generated_file,
665 const FilePath& original_file, 666 const FilePath& original_file,
666 bool compare_files, 667 bool compare_files,
667 bool need_equal, 668 bool need_equal,
668 bool delete_generated_file) { 669 bool delete_generated_file) {
669 // Check whether the target file has been generated. 670 // Check whether the target file has been generated.
670 base::PlatformFileInfo previous, current; 671 base::PlatformFileInfo previous, current;
671 bool exist = false; 672 bool exist = false;
672 const int kCycles = 20; 673 const int kCycles = 20;
673 for (int i = 0; i < kCycles; ++i) { 674 for (int i = 0; i < kCycles; ++i) {
674 if (exist) { 675 if (exist) {
675 file_util::GetFileInfo(generated_file, &current); 676 file_util::GetFileInfo(generated_file, &current);
676 if (current.size == previous.size) 677 if (current.size == previous.size)
677 break; 678 break;
678 previous = current; 679 previous = current;
679 } else if (file_util::PathExists(generated_file)) { 680 } else if (file_util::PathExists(generated_file)) {
680 file_util::GetFileInfo(generated_file, &previous); 681 file_util::GetFileInfo(generated_file, &previous);
681 exist = true; 682 exist = true;
682 } 683 }
683 base::PlatformThread::Sleep(sleep_timeout_ms() / kCycles); 684 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles);
684 } 685 }
685 EXPECT_TRUE(exist); 686 EXPECT_TRUE(exist);
686 687
687 if (compare_files) { 688 if (compare_files) {
688 // Check whether the generated file is equal with original file according to 689 // Check whether the generated file is equal with original file according to
689 // parameter: need_equal. 690 // parameter: need_equal.
690 int64 generated_file_size = 0; 691 int64 generated_file_size = 0;
691 int64 original_file_size = 0; 692 int64 original_file_size = 0;
692 693
693 EXPECT_TRUE(file_util::GetFileSize(generated_file, &generated_file_size)); 694 EXPECT_TRUE(file_util::GetFileSize(generated_file, &generated_file_size));
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 bool wait_for_open) { 792 bool wait_for_open) {
792 const int kCycles = 10; 793 const int kCycles = 10;
793 for (int i = 0; i < kCycles; i++) { 794 for (int i = 0; i < kCycles; i++) {
794 bool visible = false; 795 bool visible = false;
795 if (!browser->IsFindWindowFullyVisible(&visible)) 796 if (!browser->IsFindWindowFullyVisible(&visible))
796 return false; // Some error. 797 return false; // Some error.
797 if (visible == wait_for_open) 798 if (visible == wait_for_open)
798 return true; // Find window visibility change complete. 799 return true; // Find window visibility change complete.
799 800
800 // Give it a chance to catch up. 801 // Give it a chance to catch up.
801 bool browser_survived = CrashAwareSleep(sleep_timeout_ms() / kCycles); 802 bool browser_survived = CrashAwareSleep(
803 TestTimeouts::action_timeout_ms() / kCycles);
802 EXPECT_TRUE(browser_survived); 804 EXPECT_TRUE(browser_survived);
803 if (!browser_survived) 805 if (!browser_survived)
804 return false; 806 return false;
805 } 807 }
806 808
807 ADD_FAILURE() << "Timeout reached in WaitForFindWindowVisibilityChange"; 809 ADD_FAILURE() << "Timeout reached in WaitForFindWindowVisibilityChange";
808 return false; 810 return false;
809 } 811 }
810 812
811 bool UITest::WaitForDownloadShelfVisibilityChange(BrowserProxy* browser, 813 bool UITest::WaitForDownloadShelfVisibilityChange(BrowserProxy* browser,
812 bool wait_for_open) { 814 bool wait_for_open) {
813 const int kCycles = 10; 815 const int kCycles = 10;
814 int fail_count = 0; 816 int fail_count = 0;
815 int incorrect_state_count = 0; 817 int incorrect_state_count = 0;
816 base::Time start = base::Time::Now(); 818 base::Time start = base::Time::Now();
817 for (int i = 0; i < kCycles; i++) { 819 for (int i = 0; i < kCycles; i++) {
818 // Give it a chance to catch up. 820 // Give it a chance to catch up.
819 bool browser_survived = CrashAwareSleep(sleep_timeout_ms() / kCycles); 821 bool browser_survived = CrashAwareSleep(
822 TestTimeouts::action_timeout_ms() / kCycles);
820 EXPECT_TRUE(browser_survived); 823 EXPECT_TRUE(browser_survived);
821 if (!browser_survived) { 824 if (!browser_survived) {
822 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() 825 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF()
823 << " seconds" 826 << " seconds"
824 << " call failed " << fail_count << " times" 827 << " call failed " << fail_count << " times"
825 << " state was incorrect " << incorrect_state_count << " times"; 828 << " state was incorrect " << incorrect_state_count << " times";
826 ADD_FAILURE() << "Browser failed in " << __FUNCTION__; 829 ADD_FAILURE() << "Browser failed in " << __FUNCTION__;
827 return false; 830 return false;
828 } 831 }
829 832
(...skipping 12 matching lines...) Expand all
842 incorrect_state_count++; 845 incorrect_state_count++;
843 } 846 }
844 847
845 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() 848 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF()
846 << " seconds" 849 << " seconds"
847 << " call failed " << fail_count << " times" 850 << " call failed " << fail_count << " times"
848 << " state was incorrect " << incorrect_state_count << " times"; 851 << " state was incorrect " << incorrect_state_count << " times";
849 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; 852 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__;
850 return false; 853 return false;
851 } 854 }
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | chrome/worker/worker_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698