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

Side by Side Diff: chrome/browser/download/save_page_uitest.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_encoding_uitest.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/platform_thread.h" 7 #include "base/platform_thread.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/test_file_util.h" 9 #include "base/test_file_util.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
(...skipping 11 matching lines...) Expand all
22 #if defined(OS_WIN) 22 #if defined(OS_WIN)
23 ".htm"; 23 ".htm";
24 #else 24 #else
25 ".html"; 25 ".html";
26 #endif 26 #endif
27 27
28 class SavePageTest : public UITest { 28 class SavePageTest : public UITest {
29 protected: 29 protected:
30 SavePageTest() : UITest() {} 30 SavePageTest() : UITest() {}
31 31
32 void CheckFile(const FilePath& client_file, 32 void CheckFile(const FilePath& generated_file,
33 const FilePath& server_file) { 33 const FilePath& expected_result_file) {
34 file_util::FileInfo previous, current; 34 FilePath expected_result_filepath = UITest::GetTestFilePath(
35 bool exist = false; 35 UTF8ToWide(kTestDir), expected_result_file.ToWStringHack());
36 for (int i = 0; i < 20; ++i) { 36 ASSERT_TRUE(file_util::PathExists(expected_result_filepath));
37 if (exist) { 37 WaitForGeneratedFileAndCheck(generated_file,
38 file_util::GetFileInfo(client_file, &current); 38 expected_result_filepath,
39 if (current.size == previous.size) 39 false, // Don't care whether they are equal.
40 break; 40 false,
41 previous = current; 41 false); // Don't delete file
42 } else if (file_util::PathExists(client_file)) {
43 file_util::GetFileInfo(client_file, &previous);
44 exist = true;
45 }
46 PlatformThread::Sleep(sleep_timeout_ms());
47 }
48 EXPECT_TRUE(exist);
49 EXPECT_TRUE(file_util::DieFileDie(client_file, false));
50 } 42 }
51 43
52 virtual void SetUp() { 44 virtual void SetUp() {
53 UITest::SetUp(); 45 UITest::SetUp();
54 EXPECT_TRUE(file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), 46 EXPECT_TRUE(file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""),
55 &save_dir_)); 47 &save_dir_));
56 48
57 download_dir_ = FilePath::FromWStringHack(GetDownloadDirectory()); 49 download_dir_ = FilePath::FromWStringHack(GetDownloadDirectory());
58 } 50 }
59 51
(...skipping 27 matching lines...) Expand all
87 automation()->SavePackageShouldPromptUser(false); 79 automation()->SavePackageShouldPromptUser(false);
88 EXPECT_TRUE(browser->RunCommandAsync(IDC_SAVE_PAGE)); 80 EXPECT_TRUE(browser->RunCommandAsync(IDC_SAVE_PAGE));
89 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); 81 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get()));
90 automation()->SavePackageShouldPromptUser(true); 82 automation()->SavePackageShouldPromptUser(true);
91 83
92 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name))); 84 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)));
93 EXPECT_TRUE(file_util::DieFileDie(full_file_name, false)); 85 EXPECT_TRUE(file_util::DieFileDie(full_file_name, false));
94 EXPECT_TRUE(file_util::DieFileDie(dir, true)); 86 EXPECT_TRUE(file_util::DieFileDie(dir, true));
95 } 87 }
96 #endif 88 #endif
OLDNEW
« no previous file with comments | « chrome/browser/browser_encoding_uitest.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698