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

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

Issue 6973052: When the download folder does not exist, change the download folder to a user's "Downloads" (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add ChooseSavableDirectory() and ScopedDefaultDownloadDirectory Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 #include <set> 6 #include <set>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 download_manager_->AddObserver(this); 220 download_manager_->AddObserver(this);
221 } 221 }
222 222
223 ~SelectFileObserver() { 223 ~SelectFileObserver() {
224 download_manager_->RemoveObserver(this); 224 download_manager_->RemoveObserver(this);
225 } 225 }
226 226
227 // Downloadmanager::Observer functions. 227 // Downloadmanager::Observer functions.
228 virtual void ModelChanged() {} 228 virtual void ModelChanged() {}
229 virtual void ManagerGoingDown() {} 229 virtual void ManagerGoingDown() {}
230 virtual void SelectFileDialogDisplayed(int32 id) { 230 virtual void SelectFileDialogDisplayed(int32 id,
231 const FilePath& suggested_path) {
231 file_dialog_ids_.insert(id); 232 file_dialog_ids_.insert(id);
232 } 233 }
233 234
234 bool ShowedFileDialogForId(int32 id) { 235 bool ShowedFileDialogForId(int32 id) {
235 return file_dialog_ids_.find(id) != file_dialog_ids_.end(); 236 return file_dialog_ids_.find(id) != file_dialog_ids_.end();
236 } 237 }
237 238
238 private: 239 private:
239 std::set<int32> file_dialog_ids_; 240 std::set<int32> file_dialog_ids_;
240 scoped_refptr<DownloadManager> download_manager_; 241 scoped_refptr<DownloadManager> download_manager_;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 EXPECT_FALSE(observer->was_opened()); 582 EXPECT_FALSE(observer->was_opened());
582 EXPECT_EQ(DownloadItem::COMPLETE, download->state()); 583 EXPECT_EQ(DownloadItem::COMPLETE, download->state());
583 584
584 EXPECT_TRUE(file_util::PathExists(new_path)); 585 EXPECT_TRUE(file_util::PathExists(new_path));
585 EXPECT_FALSE(file_util::PathExists(cr_path)); 586 EXPECT_FALSE(file_util::PathExists(cr_path));
586 EXPECT_FALSE(file_util::PathExists(unique_new_path)); 587 EXPECT_FALSE(file_util::PathExists(unique_new_path));
587 std::string file_contents; 588 std::string file_contents;
588 EXPECT_TRUE(file_util::ReadFileToString(new_path, &file_contents)); 589 EXPECT_TRUE(file_util::ReadFileToString(new_path, &file_contents));
589 EXPECT_EQ(std::string(kTestData), file_contents); 590 EXPECT_EQ(std::string(kTestData), file_contents);
590 } 591 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698