Chromium Code Reviews| 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 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 void UITest::PrintResultList(const std::wstring& measurement, | 748 void UITest::PrintResultList(const std::wstring& measurement, |
| 749 const std::wstring& modifier, | 749 const std::wstring& modifier, |
| 750 const std::wstring& trace, | 750 const std::wstring& trace, |
| 751 const std::wstring& values, | 751 const std::wstring& values, |
| 752 const std::wstring& units, | 752 const std::wstring& units, |
| 753 bool important) { | 753 bool important) { |
| 754 PrintResultsImpl(measurement, modifier, trace, values, | 754 PrintResultsImpl(measurement, modifier, trace, values, |
| 755 L"[", L"]", units, important); | 755 L"[", L"]", units, important); |
| 756 } | 756 } |
| 757 | 757 |
| 758 GURL UITest::GetTestUrl(const std::wstring& test_directory, | 758 std::wstring UITest::GetTestFilePath(const std::wstring& test_directory, |
| 759 const std::wstring &test_case) { | 759 const std::wstring &test_case) { |
|
Johnny(Jianning) Ding
2009/03/09 12:31:46
make the parameter of this line aligned with previ
| |
| 760 std::wstring path; | 760 std::wstring path; |
| 761 PathService::Get(chrome::DIR_TEST_DATA, &path); | 761 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 762 file_util::AppendToPath(&path, test_directory); | 762 file_util::AppendToPath(&path, test_directory); |
| 763 file_util::AppendToPath(&path, test_case); | 763 file_util::AppendToPath(&path, test_case); |
| 764 return net::FilePathToFileURL(path); | 764 return path; |
| 765 } | |
| 766 | |
| 767 // Static | |
| 768 GURL UITest::GetTestUrl(const std::wstring& test_directory, | |
| 769 const std::wstring &test_case){ | |
| 770 return net::FilePathToFileURL(GetTestFilePath(test_directory, test_case)); | |
| 765 } | 771 } |
| 766 | 772 |
| 767 void UITest::WaitForFinish(const std::string &name, | 773 void UITest::WaitForFinish(const std::string &name, |
| 768 const std::string &id, | 774 const std::string &id, |
| 769 const GURL &url, | 775 const GURL &url, |
| 770 const std::string& test_complete_cookie, | 776 const std::string& test_complete_cookie, |
| 771 const std::string& expected_cookie_value, | 777 const std::string& expected_cookie_value, |
| 772 const int wait_time) { | 778 const int wait_time) { |
| 773 const int kIntervalMilliSeconds = 50; | 779 const int kIntervalMilliSeconds = 50; |
| 774 // The webpage being tested has javascript which sets a cookie | 780 // The webpage being tested has javascript which sets a cookie |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 801 bool important) { | 807 bool important) { |
| 802 // <*>RESULT <graph_name>: <trace_name>= <value> <units> | 808 // <*>RESULT <graph_name>: <trace_name>= <value> <units> |
| 803 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units> | 809 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units> |
| 804 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units> | 810 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units> |
| 805 wprintf(L"%lsRESULT %ls%ls: %ls= %ls%ls%ls %ls\n", | 811 wprintf(L"%lsRESULT %ls%ls: %ls= %ls%ls%ls %ls\n", |
| 806 important ? L"*" : L"", measurement.c_str(), modifier.c_str(), | 812 important ? L"*" : L"", measurement.c_str(), modifier.c_str(), |
| 807 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(), | 813 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(), |
| 808 units.c_str()); | 814 units.c_str()); |
| 809 } | 815 } |
| 810 | 816 |
| 817 void UITest::WaitForGeneratedFileAndCheck(const std::wstring& generated_file, | |
| 818 const std::wstring& source_file, | |
| 819 bool need_equal, | |
| 820 bool delete_generate_file){ | |
| 821 bool exist = false; | |
| 822 // Wait the the generated file ready. | |
| 823 for (int i = 0; i < 20; ++i) { | |
| 824 if (file_util::PathExists(generated_file)) { | |
| 825 exist = true; | |
| 826 break; | |
| 827 } | |
| 828 Sleep(kWaitForActionMaxMsec / 20); | |
| 829 } | |
| 830 EXPECT_TRUE(exist); | |
| 831 | |
| 832 int64 generated_file_size = 0; | |
| 833 int64 server_file_size = 0; | |
| 834 EXPECT_TRUE(file_util::GetFileSize(generated_file, &generated_file_size)); | |
| 835 EXPECT_TRUE(file_util::GetFileSize(source_file, &server_file_size)); | |
| 836 if (need_equal) { | |
| 837 EXPECT_EQ(generated_file_size, server_file_size); | |
| 838 EXPECT_TRUE(file_util::ContentsEqual(generated_file, source_file)); | |
| 839 } else { | |
| 840 EXPECT_NE(generated_file_size, server_file_size); | |
| 841 EXPECT_FALSE(file_util::ContentsEqual(generated_file, source_file)); | |
| 842 } | |
| 843 if (delete_generate_file) | |
| 844 EXPECT_TRUE(DieFileDie(generated_file, false)); | |
| 845 } | |
| 846 | |
| 847 | |
| 811 #endif // OS_WIN | 848 #endif // OS_WIN |
| OLD | NEW |