OLD | NEW |
1 // Copyright (c) 2006-2009 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 "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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 | 539 |
540 // Suppress spammy failures that seem to be occurring when running | 540 // Suppress spammy failures that seem to be occurring when running |
541 // the UI tests in single-process mode. | 541 // the UI tests in single-process mode. |
542 // TODO(jhughes): figure out why this is necessary at all, and fix it | 542 // TODO(jhughes): figure out why this is necessary at all, and fix it |
543 if (!in_process_renderer_) | 543 if (!in_process_renderer_) |
544 AssertAppNotRunning(L"Unable to quit all browser processes."); | 544 AssertAppNotRunning(L"Unable to quit all browser processes."); |
545 } | 545 } |
546 | 546 |
547 scoped_refptr<TabProxy> UITest::GetActiveTab(int window_index) { | 547 scoped_refptr<TabProxy> UITest::GetActiveTab(int window_index) { |
548 EXPECT_GE(window_index, 0); | 548 EXPECT_GE(window_index, 0); |
549 int window_count; | 549 int window_count = -1; |
550 // Use EXPECT rather than ASSERT here because ASSERT_* returns void. | 550 // We have to use EXPECT rather than ASSERT here because ASSERT_* only works |
| 551 // in functions that return void. |
551 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 552 EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 553 if (window_count == -1) |
| 554 return NULL; |
552 EXPECT_GT(window_count, window_index); | 555 EXPECT_GT(window_count, window_index); |
553 scoped_refptr<BrowserProxy> window_proxy(automation()-> | 556 scoped_refptr<BrowserProxy> window_proxy(automation()-> |
554 GetBrowserWindow(window_index)); | 557 GetBrowserWindow(window_index)); |
555 if (!window_proxy.get()) | 558 if (!window_proxy.get()) |
556 return NULL; | 559 return NULL; |
557 | 560 |
558 int active_tab_index = -1; | 561 int active_tab_index = -1; |
559 EXPECT_TRUE(window_proxy->GetActiveTabIndex(&active_tab_index)); | 562 EXPECT_TRUE(window_proxy->GetActiveTabIndex(&active_tab_index)); |
560 if (active_tab_index == -1) | 563 if (active_tab_index == -1) |
561 return NULL; | 564 return NULL; |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 // a concatenation of the test name and the test id. This allows | 891 // a concatenation of the test name and the test id. This allows |
889 // us to run multiple tests within a single webpage and test | 892 // us to run multiple tests within a single webpage and test |
890 // that they all c | 893 // that they all c |
891 std::string cookie_name = name; | 894 std::string cookie_name = name; |
892 cookie_name.append("."); | 895 cookie_name.append("."); |
893 cookie_name.append(id); | 896 cookie_name.append(id); |
894 cookie_name.append("."); | 897 cookie_name.append("."); |
895 cookie_name.append(test_complete_cookie); | 898 cookie_name.append(test_complete_cookie); |
896 | 899 |
897 scoped_refptr<TabProxy> tab(GetActiveTab()); | 900 scoped_refptr<TabProxy> tab(GetActiveTab()); |
898 | 901 EXPECT_TRUE(tab.get()); |
899 bool test_result = WaitUntilCookieValue(tab.get(), url, | 902 if (tab.get()) { |
900 cookie_name.c_str(), | 903 bool test_result = WaitUntilCookieValue(tab.get(), url, |
901 kIntervalMilliSeconds, wait_time, | 904 cookie_name.c_str(), |
902 expected_cookie_value.c_str()); | 905 kIntervalMilliSeconds, wait_time, |
903 EXPECT_EQ(true, test_result); | 906 expected_cookie_value.c_str()); |
| 907 EXPECT_EQ(true, test_result); |
| 908 } |
904 } | 909 } |
905 | 910 |
906 void UITest::PrintResult(const std::string& measurement, | 911 void UITest::PrintResult(const std::string& measurement, |
907 const std::string& modifier, | 912 const std::string& modifier, |
908 const std::string& trace, | 913 const std::string& trace, |
909 size_t value, | 914 size_t value, |
910 const std::string& units, | 915 const std::string& units, |
911 bool important) { | 916 bool important) { |
912 PrintResultsImpl(measurement, modifier, trace, UintToString(value), | 917 PrintResultsImpl(measurement, modifier, trace, UintToString(value), |
913 "", "", units, important); | 918 "", "", units, important); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 } | 966 } |
962 | 967 |
963 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { | 968 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { |
964 for (int i = 0; i < 10; i++) { | 969 for (int i = 0; i < 10; i++) { |
965 if (file_util::EvictFileFromSystemCache(path)) | 970 if (file_util::EvictFileFromSystemCache(path)) |
966 return true; | 971 return true; |
967 PlatformThread::Sleep(sleep_timeout_ms() / 10); | 972 PlatformThread::Sleep(sleep_timeout_ms() / 10); |
968 } | 973 } |
969 return false; | 974 return false; |
970 } | 975 } |
OLD | NEW |