| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 scoped_refptr<BrowserProxy> window = | 606 scoped_refptr<BrowserProxy> window = |
| 607 automation()->GetBrowserWindow(window_index); | 607 automation()->GetBrowserWindow(window_index); |
| 608 ASSERT_TRUE(window.get()); | 608 ASSERT_TRUE(window.get()); |
| 609 scoped_refptr<TabProxy> tab_proxy(window->GetTab(tab_index)); | 609 scoped_refptr<TabProxy> tab_proxy(window->GetTab(tab_index)); |
| 610 ASSERT_TRUE(tab_proxy.get()); | 610 ASSERT_TRUE(tab_proxy.get()); |
| 611 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, | 611 EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| 612 tab_proxy->NavigateToURLBlockUntilNavigationsComplete( | 612 tab_proxy->NavigateToURLBlockUntilNavigationsComplete( |
| 613 url, number_of_navigations)) << url.spec(); | 613 url, number_of_navigations)) << url.spec(); |
| 614 } | 614 } |
| 615 | 615 |
| 616 bool UITestBase::WaitForDownloadShelfVisible(BrowserProxy* browser) { | |
| 617 return WaitForDownloadShelfVisibilityChange(browser, true); | |
| 618 } | |
| 619 | |
| 620 bool UITestBase::WaitForDownloadShelfInvisible(BrowserProxy* browser) { | |
| 621 return WaitForDownloadShelfVisibilityChange(browser, false); | |
| 622 } | |
| 623 | |
| 624 bool UITestBase::WaitForDownloadShelfVisibilityChange(BrowserProxy* browser, | |
| 625 bool wait_for_open) { | |
| 626 const int kCycles = 10; | |
| 627 for (int i = 0; i < kCycles; i++) { | |
| 628 // Give it a chance to catch up. | |
| 629 PlatformThread::Sleep(sleep_timeout_ms() / kCycles); | |
| 630 | |
| 631 bool visible = !wait_for_open; | |
| 632 if (!browser->IsShelfVisible(&visible)) | |
| 633 continue; | |
| 634 if (visible == wait_for_open) | |
| 635 return true; // Got the download shelf. | |
| 636 } | |
| 637 return false; | |
| 638 } | |
| 639 | |
| 640 bool UITestBase::WaitForFindWindowVisibilityChange(BrowserProxy* browser, | 616 bool UITestBase::WaitForFindWindowVisibilityChange(BrowserProxy* browser, |
| 641 bool wait_for_open) { | 617 bool wait_for_open) { |
| 642 const int kCycles = 10; | 618 const int kCycles = 10; |
| 643 for (int i = 0; i < kCycles; i++) { | 619 for (int i = 0; i < kCycles; i++) { |
| 644 bool visible = false; | 620 bool visible = false; |
| 645 if (!browser->IsFindWindowFullyVisible(&visible)) | 621 if (!browser->IsFindWindowFullyVisible(&visible)) |
| 646 return false; // Some error. | 622 return false; // Some error. |
| 647 if (visible == wait_for_open) | 623 if (visible == wait_for_open) |
| 648 return true; // Find window visibility change complete. | 624 return true; // Find window visibility change complete. |
| 649 | 625 |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1535 set_ui_test_name(ASCIIToWide(test_name)); | 1511 set_ui_test_name(ASCIIToWide(test_name)); |
| 1536 } | 1512 } |
| 1537 UITestBase::SetUp(); | 1513 UITestBase::SetUp(); |
| 1538 PlatformTest::SetUp(); | 1514 PlatformTest::SetUp(); |
| 1539 } | 1515 } |
| 1540 | 1516 |
| 1541 void UITest::TearDown() { | 1517 void UITest::TearDown() { |
| 1542 UITestBase::TearDown(); | 1518 UITestBase::TearDown(); |
| 1543 PlatformTest::TearDown(); | 1519 PlatformTest::TearDown(); |
| 1544 } | 1520 } |
| OLD | NEW |