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

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

Issue 10980002: Mac Web Intents Part 1: Show extension download progress (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added test Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return false; 194 return false;
195 } 195 }
196 196
197 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu); 197 DISALLOW_COPY_AND_ASSIGN(TestRenderViewContextMenu);
198 }; 198 };
199 199
200 bool WasAutoOpened(DownloadItem* item) { 200 bool WasAutoOpened(DownloadItem* item) {
201 return item->GetAutoOpened(); 201 return item->GetAutoOpened();
202 } 202 }
203 203
204 // Called when a download starts. Marks the download as hidden.
205 void SetHiddenDownloadCallback(scoped_refptr<DownloadManager> download_manager,
206 content::DownloadId id,
207 net::Error error) {
208 DownloadItem* item = download_manager->GetDownload(id.local());
209 item->SetIsHiddenDownload(true);
210 }
211
204 } // namespace 212 } // namespace
205 213
206 // While an object of this class exists, it will mock out download 214 // While an object of this class exists, it will mock out download
207 // opening for all downloads created on the specified download manager. 215 // opening for all downloads created on the specified download manager.
208 class MockDownloadOpeningObserver : public DownloadManager::Observer { 216 class MockDownloadOpeningObserver : public DownloadManager::Observer {
209 public: 217 public:
210 explicit MockDownloadOpeningObserver(DownloadManager* manager) 218 explicit MockDownloadOpeningObserver(DownloadManager* manager)
211 : download_manager_(manager) { 219 : download_manager_(manager) {
212 download_manager_->AddObserver(this); 220 download_manager_->AddObserver(this);
213 } 221 }
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 GetDownloads(browser(), &download_items); 2243 GetDownloads(browser(), &download_items);
2236 ASSERT_EQ(1u, download_items.size()); 2244 ASSERT_EQ(1u, download_items.size());
2237 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), 2245 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"),
2238 download_items[0]->GetOriginalUrl()); 2246 download_items[0]->GetOriginalUrl());
2239 2247
2240 // Check that the file contains the expected referrer. 2248 // Check that the file contains the expected referrer.
2241 FilePath file(download_items[0]->GetFullPath()); 2249 FilePath file(download_items[0]->GetFullPath());
2242 std::string expected_contents = test_server()->GetURL("").spec(); 2250 std::string expected_contents = test_server()->GetURL("").spec();
2243 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); 2251 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length()));
2244 } 2252 }
2253
2254 IN_PROC_BROWSER_TEST_F(DownloadTest, HiddenDownload) {
2255 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
2256 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
2257
2258 scoped_refptr<DownloadManager> download_manager =
2259 DownloadManagerForBrowser(browser());
2260 scoped_ptr<content::DownloadTestObserver> observer(
2261 new content::DownloadTestObserverTerminal(
2262 download_manager,
2263 1,
2264 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
2265 content::DownloadSaveInfo save_info;
2266 save_info.prompt_for_save_location = false;
2267
2268 // Download and set ShouldShowInDownloadsUI to false.
asanka 2012/10/02 21:08:37 Nit: Comment out of date.
sail 2012/10/02 21:48:26 Done.
2269 WebContents* web_contents = chrome::GetActiveWebContents(browser());
2270 scoped_ptr<DownloadUrlParameters> params(
2271 DownloadUrlParameters::FromWebContents(web_contents, url, save_info));
2272 params->set_callback(
2273 base::Bind(&SetHiddenDownloadCallback, download_manager));
2274 download_manager->DownloadUrl(params.Pass());
2275 observer->WaitForFinished();
2276
2277 // Verify that download shelf is not shown.
2278 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
2279 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698