| 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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 // the UI tests in single-process mode. | 451 // the UI tests in single-process mode. |
| 452 // TODO(jhughes): figure out why this is necessary at all, and fix it | 452 // TODO(jhughes): figure out why this is necessary at all, and fix it |
| 453 if (!in_process_renderer_) | 453 if (!in_process_renderer_) |
| 454 AssertAppNotRunning(L"Unable to quit all browser processes."); | 454 AssertAppNotRunning(L"Unable to quit all browser processes."); |
| 455 #else | 455 #else |
| 456 // TODO(port): depends on chrome_process_util. | 456 // TODO(port): depends on chrome_process_util. |
| 457 NOTIMPLEMENTED(); | 457 NOTIMPLEMENTED(); |
| 458 #endif | 458 #endif |
| 459 } | 459 } |
| 460 | 460 |
| 461 TabProxy* UITest::GetActiveTab() { | 461 TabProxy* UITest::GetActiveTab(int window_index) { |
| 462 scoped_ptr<BrowserProxy> window_proxy(automation()->GetBrowserWindow(0)); | 462 EXPECT_GE(window_index, 0); |
| 463 int window_count; |
| 464 // Use EXPECT rather than ASSERT here because ASSERT_* returns void. |
| 465 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 466 EXPECT_GT(window_count, window_index); |
| 467 scoped_ptr<BrowserProxy> window_proxy(automation()-> |
| 468 GetBrowserWindow(window_index)); |
| 463 if (!window_proxy.get()) | 469 if (!window_proxy.get()) |
| 464 return NULL; | 470 return NULL; |
| 465 | 471 |
| 466 int active_tab_index = -1; | 472 int active_tab_index = -1; |
| 467 EXPECT_TRUE(window_proxy->GetActiveTabIndex(&active_tab_index)); | 473 EXPECT_TRUE(window_proxy->GetActiveTabIndex(&active_tab_index)); |
| 468 if (active_tab_index == -1) | 474 if (active_tab_index == -1) |
| 469 return NULL; | 475 return NULL; |
| 470 | 476 |
| 471 return window_proxy->GetTab(active_tab_index); | 477 return window_proxy->GetTab(active_tab_index); |
| 472 } | 478 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (visible == wait_for_open && !animating) | 544 if (visible == wait_for_open && !animating) |
| 539 return true; // Bookmark bar visibility change complete. | 545 return true; // Bookmark bar visibility change complete. |
| 540 | 546 |
| 541 // Give it a chance to catch up. | 547 // Give it a chance to catch up. |
| 542 Sleep(sleep_timeout_ms() / kCycles); | 548 Sleep(sleep_timeout_ms() / kCycles); |
| 543 } | 549 } |
| 544 return false; | 550 return false; |
| 545 } | 551 } |
| 546 #endif // defined(OS_WIN) | 552 #endif // defined(OS_WIN) |
| 547 | 553 |
| 548 GURL UITest::GetActiveTabURL() { | 554 GURL UITest::GetActiveTabURL(int window_index) { |
| 549 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); | 555 scoped_ptr<TabProxy> tab_proxy(GetActiveTab(window_index)); |
| 550 if (!tab_proxy.get()) | 556 if (!tab_proxy.get()) |
| 551 return GURL(); | 557 return GURL(); |
| 552 | 558 |
| 553 GURL url; | 559 GURL url; |
| 554 if (!tab_proxy->GetCurrentURL(&url)) | 560 if (!tab_proxy->GetCurrentURL(&url)) |
| 555 return GURL(); | 561 return GURL(); |
| 556 return url; | 562 return url; |
| 557 } | 563 } |
| 558 | 564 |
| 559 std::wstring UITest::GetActiveTabTitle() { | 565 std::wstring UITest::GetActiveTabTitle(int window_index) { |
| 560 std::wstring title; | 566 std::wstring title; |
| 561 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); | 567 scoped_ptr<TabProxy> tab_proxy(GetActiveTab(window_index)); |
| 562 if (!tab_proxy.get()) | 568 if (!tab_proxy.get()) |
| 563 return title; | 569 return title; |
| 564 | 570 |
| 565 EXPECT_TRUE(tab_proxy->GetTabTitle(&title)); | 571 EXPECT_TRUE(tab_proxy->GetTabTitle(&title)); |
| 566 return title; | 572 return title; |
| 567 } | 573 } |
| 568 | 574 |
| 569 int UITest::GetActiveTabIndex() { | 575 int UITest::GetActiveTabIndex(int window_index) { |
| 570 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); | 576 scoped_ptr<TabProxy> tab_proxy(GetActiveTab(window_index)); |
| 571 if (!tab_proxy.get()) | 577 if (!tab_proxy.get()) |
| 572 return -1; | 578 return -1; |
| 573 | 579 |
| 574 int index; | 580 int index; |
| 575 EXPECT_TRUE(tab_proxy->GetTabIndex(&index)); | 581 EXPECT_TRUE(tab_proxy->GetTabIndex(&index)); |
| 576 return index; | 582 return index; |
| 577 } | 583 } |
| 578 | 584 |
| 579 bool UITest::IsBrowserRunning() { | 585 bool UITest::IsBrowserRunning() { |
| 580 return CrashAwareSleep(0); | 586 return CrashAwareSleep(0); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 } | 862 } |
| 857 | 863 |
| 858 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { | 864 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { |
| 859 for (int i = 0; i < 10; i++) { | 865 for (int i = 0; i < 10; i++) { |
| 860 if (file_util::EvictFileFromSystemCache(path)) | 866 if (file_util::EvictFileFromSystemCache(path)) |
| 861 return true; | 867 return true; |
| 862 PlatformThread::Sleep(1000); | 868 PlatformThread::Sleep(1000); |
| 863 } | 869 } |
| 864 return false; | 870 return false; |
| 865 } | 871 } |
| OLD | NEW |