Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/download/download_prefs.h" | 9 #include "chrome/browser/download/download_prefs.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable.h" | 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 new content::DownloadTestObserverTerminal( | 37 new content::DownloadTestObserverTerminal( |
| 38 download_manager, | 38 download_manager, |
| 39 num_downloads, | 39 num_downloads, |
| 40 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); | 40 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); |
| 41 return make_scoped_ptr(downloads_observer); | 41 return make_scoped_ptr(downloads_observer); |
| 42 } | 42 } |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestDownloadDirPref) { | 45 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestDownloadDirPref) { |
| 46 ASSERT_TRUE(test_server()->Start()); | 46 ASSERT_TRUE(test_server()->Start()); |
| 47 base::ScopedTempDir new_download_dir; | |
| 48 ASSERT_TRUE(new_download_dir.CreateUniqueTempDir()); | |
| 47 | 49 |
| 48 DownloadManager* download_manager = | 50 DownloadManager* download_manager = |
| 49 BrowserContext::GetDownloadManager(browser()->profile()); | 51 BrowserContext::GetDownloadManager(browser()->profile()); |
| 50 base::FilePath download_dir = | 52 base::FilePath download_dir = |
|
Bernhard Bauer
2014/05/10 15:35:56
Is this still required?
asanka
2014/05/10 18:52:55
Removed. Thanks!
| |
| 51 (DownloadPrefs::FromDownloadManager(download_manager))->DownloadPath(); | 53 (DownloadPrefs::FromDownloadManager(download_manager))->DownloadPath(); |
| 52 base::FilePath new_download_dir = download_dir.AppendASCII("my_downloads"); | |
| 53 base::FilePath downloaded_pkg = | 54 base::FilePath downloaded_pkg = |
| 54 new_download_dir.AppendASCII("a_zip_file.zip"); | 55 new_download_dir.path().AppendASCII("a_zip_file.zip"); |
| 55 | 56 |
| 56 // If the directory exists, delete it. | |
| 57 if (base::PathExists(new_download_dir)) { | |
| 58 base::DeleteFile(new_download_dir, true); | |
| 59 } | |
| 60 | |
| 61 // Create the new downloads directory. | |
| 62 base::CreateDirectory(new_download_dir); | |
| 63 // Set pref to download in new_download_dir. | 57 // Set pref to download in new_download_dir. |
| 64 browser()->profile()->GetPrefs()->SetFilePath( | 58 browser()->profile()->GetPrefs()->SetFilePath( |
| 65 prefs::kDownloadDefaultDirectory, | 59 prefs::kDownloadDefaultDirectory, new_download_dir.path()); |
| 66 new_download_dir); | |
| 67 | 60 |
| 68 // Create a downloads observer. | 61 // Create a downloads observer. |
| 69 scoped_ptr<content::DownloadTestObserver> downloads_observer( | 62 scoped_ptr<content::DownloadTestObserver> downloads_observer( |
| 70 CreateWaiter(browser(), 1)); | 63 CreateWaiter(browser(), 1)); |
| 71 ui_test_utils::NavigateToURL( | 64 ui_test_utils::NavigateToURL( |
| 72 browser(), | 65 browser(), |
| 73 test_server()->GetURL("files/downloads/a_zip_file.zip")); | 66 test_server()->GetURL("files/downloads/a_zip_file.zip")); |
| 74 // Waits for the download to complete. | 67 // Waits for the download to complete. |
| 75 downloads_observer->WaitForFinished(); | 68 downloads_observer->WaitForFinished(); |
| 76 EXPECT_TRUE(base::PathExists(downloaded_pkg)); | 69 EXPECT_TRUE(base::PathExists(downloaded_pkg)); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeBrowsingEnabled)); | 239 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeBrowsingEnabled)); |
| 247 EXPECT_FALSE(prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)); | 240 EXPECT_FALSE(prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)); |
| 248 EXPECT_FALSE(prefs->GetBoolean(prefs::kSearchSuggestEnabled)); | 241 EXPECT_FALSE(prefs->GetBoolean(prefs::kSearchSuggestEnabled)); |
| 249 } | 242 } |
| 250 | 243 |
| 251 // Verify that we have some Local State prefs. | 244 // Verify that we have some Local State prefs. |
| 252 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestHaveLocalStatePrefs) { | 245 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestHaveLocalStatePrefs) { |
| 253 EXPECT_TRUE(g_browser_process->local_state()->GetPreferenceValues().get()); | 246 EXPECT_TRUE(g_browser_process->local_state()->GetPreferenceValues().get()); |
| 254 } | 247 } |
| 255 | 248 |
| OLD | NEW |