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

Side by Side Diff: chrome/browser/prefs/pref_functional_browsertest.cc

Issue 273233004: Fix some more tests that were writing to the user's home directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 7 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
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 =
49 BrowserContext::GetDownloadManager(browser()->profile());
50 base::FilePath download_dir =
51 (DownloadPrefs::FromDownloadManager(download_manager))->DownloadPath();
52 base::FilePath new_download_dir = download_dir.AppendASCII("my_downloads");
53 base::FilePath downloaded_pkg = 50 base::FilePath downloaded_pkg =
54 new_download_dir.AppendASCII("a_zip_file.zip"); 51 new_download_dir.path().AppendASCII("a_zip_file.zip");
55 52
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. 53 // Set pref to download in new_download_dir.
64 browser()->profile()->GetPrefs()->SetFilePath( 54 browser()->profile()->GetPrefs()->SetFilePath(
65 prefs::kDownloadDefaultDirectory, 55 prefs::kDownloadDefaultDirectory, new_download_dir.path());
66 new_download_dir);
67 56
68 // Create a downloads observer. 57 // Create a downloads observer.
69 scoped_ptr<content::DownloadTestObserver> downloads_observer( 58 scoped_ptr<content::DownloadTestObserver> downloads_observer(
70 CreateWaiter(browser(), 1)); 59 CreateWaiter(browser(), 1));
71 ui_test_utils::NavigateToURL( 60 ui_test_utils::NavigateToURL(
72 browser(), 61 browser(),
73 test_server()->GetURL("files/downloads/a_zip_file.zip")); 62 test_server()->GetURL("files/downloads/a_zip_file.zip"));
74 // Waits for the download to complete. 63 // Waits for the download to complete.
75 downloads_observer->WaitForFinished(); 64 downloads_observer->WaitForFinished();
76 EXPECT_TRUE(base::PathExists(downloaded_pkg)); 65 EXPECT_TRUE(base::PathExists(downloaded_pkg));
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeBrowsingEnabled)); 235 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeBrowsingEnabled));
247 EXPECT_FALSE(prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)); 236 EXPECT_FALSE(prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled));
248 EXPECT_FALSE(prefs->GetBoolean(prefs::kSearchSuggestEnabled)); 237 EXPECT_FALSE(prefs->GetBoolean(prefs::kSearchSuggestEnabled));
249 } 238 }
250 239
251 // Verify that we have some Local State prefs. 240 // Verify that we have some Local State prefs.
252 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestHaveLocalStatePrefs) { 241 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestHaveLocalStatePrefs) {
253 EXPECT_TRUE(g_browser_process->local_state()->GetPreferenceValues().get()); 242 EXPECT_TRUE(g_browser_process->local_state()->GetPreferenceValues().get());
254 } 243 }
255 244
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698