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

Unified Diff: chrome/test/ui/ui_test.cc

Issue 165393: Add a UI test for "Encoding" menu. Please see crbug.com/5515 for more details... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ui/ui_test.cc
===================================================================
--- chrome/test/ui/ui_test.cc (revision 23177)
+++ chrome/test/ui/ui_test.cc (working copy)
@@ -860,15 +860,22 @@
return result;
}
-GURL UITest::GetTestUrl(const std::wstring& test_directory,
- const std::wstring &test_case) {
+// Static
+FilePath UITest::GetTestFilePath(const std::wstring& test_directory,
+ const std::wstring& test_case) {
FilePath path;
PathService::Get(chrome::DIR_TEST_DATA, &path);
path = path.Append(FilePath::FromWStringHack(test_directory));
path = path.Append(FilePath::FromWStringHack(test_case));
- return net::FilePathToFileURL(path);
+ return path;
}
+// Static
+GURL UITest::GetTestUrl(const std::wstring& test_directory,
+ const std::wstring &test_case) {
+ return net::FilePathToFileURL(GetTestFilePath(test_directory, test_case));
+}
+
void UITest::WaitForFinish(const std::string &name,
const std::string &id,
const GURL &url,
@@ -981,4 +988,44 @@
return source_history_file;
}
+void UITest::WaitForGeneratedFileAndCheck(const FilePath& generated_file,
+ const FilePath& original_file,
+ bool compare_files,
+ bool need_equal,
+ bool delete_generated_file) {
+ // Check whether the target file has been generated.
+ file_util::FileInfo previous, current;
+ bool exist = false;
+ for (int i = 0; i < 20; ++i) {
+ if (exist) {
+ file_util::GetFileInfo(generated_file, &current);
+ if (current.size == previous.size)
+ break;
+ previous = current;
+ } else if (file_util::PathExists(generated_file)) {
+ file_util::GetFileInfo(generated_file, &previous);
+ exist = true;
+ }
+ PlatformThread::Sleep(sleep_timeout_ms());
+ }
+ EXPECT_TRUE(exist);
+ if (compare_files) {
+ // Check whether the generated file is equal with original file according to
+ // parameter: need_equal.
+ int64 generated_file_size = 0;
+ int64 original_file_size = 0;
+ EXPECT_TRUE(file_util::GetFileSize(generated_file, &generated_file_size));
+ EXPECT_TRUE(file_util::GetFileSize(original_file, &original_file_size));
+ if (need_equal) {
+ EXPECT_EQ(generated_file_size, original_file_size);
+ EXPECT_TRUE(file_util::ContentsEqual(generated_file, original_file));
+ } else {
+ EXPECT_NE(generated_file_size, original_file_size);
+ EXPECT_FALSE(file_util::ContentsEqual(generated_file, original_file));
+ }
+ }
+ if (delete_generated_file)
+ EXPECT_TRUE(file_util::DieFileDie(generated_file, false));
+}
+
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698