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

Side by Side Diff: chrome/browser/download/save_page_uitest.cc

Issue 160480: Convert parts of SavePage UI tests to more reliable browser tests. (Closed)
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
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 virtual void TearDown() { 78 virtual void TearDown() {
79 UITest::TearDown(); 79 UITest::TearDown();
80 file_util::DieFileDie(save_dir_, true); 80 file_util::DieFileDie(save_dir_, true);
81 } 81 }
82 82
83 FilePath save_dir_; 83 FilePath save_dir_;
84 FilePath download_dir_; 84 FilePath download_dir_;
85 }; 85 };
86 86
87 // Flaky on Linux: http://code.google.com/p/chromium/issues/detail?id=14746
88 TEST_F(SavePageTest, SaveHTMLOnly) {
89 std::string file_name("a.htm");
90 FilePath full_file_name = save_dir_.AppendASCII(file_name);
91 FilePath dir = save_dir_.AppendASCII("a_files");
92
93 GURL url = URLRequestMockHTTPJob::GetMockUrl(
94 UTF8ToWide(std::string(kTestDir) + "/" + file_name));
95 scoped_refptr<TabProxy> tab(GetActiveTab());
96 ASSERT_TRUE(tab.get());
97 ASSERT_TRUE(tab->NavigateToURL(url));
98 WaitUntilTabCount(1);
99
100 EXPECT_TRUE(tab->SavePage(full_file_name.ToWStringHack(), dir.ToWStringHack(),
101 SavePackage::SAVE_AS_ONLY_HTML));
102 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
103 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get()));
104
105 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)),
106 true);
107 EXPECT_FALSE(file_util::PathExists(dir));
108 }
109
110 // Flaky on Linux: http://code.google.com/p/chromium/issues/detail?id=14746
111 TEST_F(SavePageTest, SaveCompleteHTML) {
112 std::string file_name = "b.htm";
113 FilePath full_file_name = save_dir_.AppendASCII(file_name);
114 FilePath dir = save_dir_.AppendASCII("b_files");
115
116 GURL url = URLRequestMockHTTPJob::GetMockUrl(
117 UTF8ToWide(std::string(kTestDir) + "/" + file_name));
118 scoped_refptr<TabProxy> tab(GetActiveTab());
119 ASSERT_TRUE(tab.get());
120 ASSERT_TRUE(tab->NavigateToURL(url));
121 WaitUntilTabCount(1);
122
123 EXPECT_TRUE(tab->SavePage(full_file_name.ToWStringHack(), dir.ToWStringHack(),
124 SavePackage::SAVE_AS_COMPLETE_HTML));
125 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
126 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get()));
127
128 CheckFile(dir.AppendASCII("1.png"), FilePath(FILE_PATH_LITERAL("1.png")),
129 true);
130 CheckFile(dir.AppendASCII("1.css"), FilePath(FILE_PATH_LITERAL("1.css")),
131 true);
132 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)),
133 false);
134 EXPECT_TRUE(file_util::DieFileDie(dir, true));
135 }
136
137 TEST_F(SavePageTest, NoSave) { 87 TEST_F(SavePageTest, NoSave) {
138 std::string file_name = "c.htm"; 88 std::string file_name = "c.htm";
139 FilePath full_file_name = save_dir_.AppendASCII(file_name); 89 FilePath full_file_name = save_dir_.AppendASCII(file_name);
140 FilePath dir = save_dir_.AppendASCII("c_files"); 90 FilePath dir = save_dir_.AppendASCII("c_files");
141 91
142 scoped_refptr<TabProxy> tab(GetActiveTab()); 92 scoped_refptr<TabProxy> tab(GetActiveTab());
143 ASSERT_TRUE(tab.get()); 93 ASSERT_TRUE(tab.get());
144 ASSERT_TRUE(tab->NavigateToURL(GURL("about:blank"))); 94 ASSERT_TRUE(tab->NavigateToURL(GURL("about:blank")));
145 WaitUntilTabCount(1); 95 WaitUntilTabCount(1);
146 96
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 EXPECT_TRUE(browser->RunCommandAsync(IDC_SAVE_PAGE)); 154 EXPECT_TRUE(browser->RunCommandAsync(IDC_SAVE_PAGE));
205 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get())); 155 EXPECT_TRUE(WaitForDownloadShelfVisible(browser.get()));
206 automation()->SavePackageShouldPromptUser(true); 156 automation()->SavePackageShouldPromptUser(true);
207 157
208 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)), 158 CheckFile(full_file_name, FilePath::FromWStringHack(UTF8ToWide(file_name)),
209 false); 159 false);
210 EXPECT_TRUE(file_util::DieFileDie(full_file_name, false)); 160 EXPECT_TRUE(file_util::DieFileDie(full_file_name, false));
211 EXPECT_TRUE(file_util::DieFileDie(dir, true)); 161 EXPECT_TRUE(file_util::DieFileDie(dir, true));
212 } 162 }
213 #endif 163 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698