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

Unified Diff: chrome/browser/download/notification/download_notification_browsertest.cc

Issue 2317993003: //chrome/browser and //components A-E: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Rebase Created 4 years, 3 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
Index: chrome/browser/download/notification/download_notification_browsertest.cc
diff --git a/chrome/browser/download/notification/download_notification_browsertest.cc b/chrome/browser/download/notification/download_notification_browsertest.cc
index 85bb01ba4a8739439066e127211eec51870756fc..66927c395da7956965cf3fb8c2d1d4be28383498 100644
--- a/chrome/browser/download/notification/download_notification_browsertest.cc
+++ b/chrome/browser/download/notification/download_notification_browsertest.cc
@@ -285,31 +285,23 @@ class DownloadNotificationTestBase : public InProcessBrowserTest {
GetMessageCenter()->DisableTimersForTest();
- // Set up the temporary download folder.
- ASSERT_TRUE(CreateAndSetDownloadsDirectory(browser()));
+ ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir());
+ ASSERT_TRUE(SetDownloadsDirectory(browser()));
}
protected:
- // Must be called after browser creation. Creates a temporary
- // directory for downloads that is auto-deleted on destruction.
- // Returning false indicates a failure of the function, and should be asserted
- // in the caller.
- bool CreateAndSetDownloadsDirectory(Browser* browser) {
+ // Must be called after browser creation. Assumes that |downloads_directory_|
vabr (Chromium) 2016/09/12 08:23:12 To get rid of the need to check whether the direct
+ // is created and sets its path to be used for downloads by |browser|.
+ // Returning false indicates a failure of the function, and should be
+ // asserted in the caller.
+ bool SetDownloadsDirectory(Browser* browser) {
if (!browser)
return false;
- if (!downloads_directory_.path().empty())
- return true; // already created
-
- if (!downloads_directory_.CreateUniqueTempDir())
- return false;
-
browser->profile()->GetPrefs()->SetFilePath(
- prefs::kDownloadDefaultDirectory,
- downloads_directory_.path());
+ prefs::kDownloadDefaultDirectory, downloads_directory_.GetPath());
browser->profile()->GetPrefs()->SetFilePath(
- prefs::kSaveFileDefaultDirectory,
- downloads_directory_.path());
+ prefs::kSaveFileDefaultDirectory, downloads_directory_.GetPath());
return true;
}
@@ -354,7 +346,7 @@ class DownloadNotificationTest : public DownloadNotificationTestBase {
incognito_browser_ = CreateIncognitoBrowser();
Profile* incognito_profile = incognito_browser_->profile();
- ASSERT_TRUE(CreateAndSetDownloadsDirectory(incognito_browser_));
+ ASSERT_TRUE(SetDownloadsDirectory(incognito_browser_));
std::unique_ptr<TestChromeDownloadManagerDelegate> incognito_test_delegate;
incognito_test_delegate.reset(
« no previous file with comments | « chrome/browser/download/download_target_determiner_unittest.cc ('k') | chrome/browser/download/save_page_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698