OLD | NEW |
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 "chrome/browser/media_galleries/media_galleries_test_util.h" | 5 #include "chrome/browser/media_galleries/media_galleries_test_util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Each pointer must be reset an extra time so as to destroy the existing | 103 // Each pointer must be reset an extra time so as to destroy the existing |
104 // override prior to creating a new one. This is because the PathService, | 104 // override prior to creating a new one. This is because the PathService, |
105 // which supports these overrides, only allows one override to exist per path | 105 // which supports these overrides, only allows one override to exist per path |
106 // in its internal bookkeeping; attempting to add a second override invokes | 106 // in its internal bookkeeping; attempting to add a second override invokes |
107 // a CHECK crash. | 107 // a CHECK crash. |
108 music_override_.reset(); | 108 music_override_.reset(); |
109 std::string music_path_string("music"); | 109 std::string music_path_string("music"); |
110 music_path_string.append(base::IntToString(times_overrides_changed_)); | 110 music_path_string.append(base::IntToString(times_overrides_changed_)); |
111 music_override_.reset(new base::ScopedPathOverride( | 111 music_override_.reset(new base::ScopedPathOverride( |
112 chrome::DIR_USER_MUSIC, | 112 chrome::DIR_USER_MUSIC, |
113 fake_dir_.path().AppendASCII(music_path_string))); | 113 fake_dir_.GetPath().AppendASCII(music_path_string))); |
114 | 114 |
115 pictures_override_.reset(); | 115 pictures_override_.reset(); |
116 std::string pictures_path_string("pictures"); | 116 std::string pictures_path_string("pictures"); |
117 pictures_path_string.append(base::IntToString(times_overrides_changed_)); | 117 pictures_path_string.append(base::IntToString(times_overrides_changed_)); |
118 pictures_override_.reset(new base::ScopedPathOverride( | 118 pictures_override_.reset(new base::ScopedPathOverride( |
119 chrome::DIR_USER_PICTURES, | 119 chrome::DIR_USER_PICTURES, |
120 fake_dir_.path().AppendASCII(pictures_path_string))); | 120 fake_dir_.GetPath().AppendASCII(pictures_path_string))); |
121 | 121 |
122 video_override_.reset(); | 122 video_override_.reset(); |
123 std::string videos_path_string("videos"); | 123 std::string videos_path_string("videos"); |
124 videos_path_string.append(base::IntToString(times_overrides_changed_)); | 124 videos_path_string.append(base::IntToString(times_overrides_changed_)); |
125 video_override_.reset(new base::ScopedPathOverride( | 125 video_override_.reset(new base::ScopedPathOverride( |
126 chrome::DIR_USER_VIDEOS, | 126 chrome::DIR_USER_VIDEOS, |
127 fake_dir_.path().AppendASCII(videos_path_string))); | 127 fake_dir_.GetPath().AppendASCII(videos_path_string))); |
128 | 128 |
129 times_overrides_changed_++; | 129 times_overrides_changed_++; |
130 | 130 |
131 num_galleries_ = 3; | 131 num_galleries_ = 3; |
132 } | 132 } |
133 | 133 |
134 base::FilePath EnsureMediaDirectoriesExists::GetFakeAppDataPath() const { | 134 base::FilePath EnsureMediaDirectoriesExists::GetFakeAppDataPath() const { |
135 DCHECK(fake_dir_.IsValid()); | 135 DCHECK(fake_dir_.IsValid()); |
136 return fake_dir_.path().AppendASCII("appdata"); | 136 return fake_dir_.GetPath().AppendASCII("appdata"); |
137 } | 137 } |
138 | 138 |
139 #if defined(OS_WIN) | 139 #if defined(OS_WIN) |
140 base::FilePath EnsureMediaDirectoriesExists::GetFakeLocalAppDataPath() const { | 140 base::FilePath EnsureMediaDirectoriesExists::GetFakeLocalAppDataPath() const { |
141 DCHECK(fake_dir_.IsValid()); | 141 DCHECK(fake_dir_.IsValid()); |
142 return fake_dir_.path().AppendASCII("localappdata"); | 142 return fake_dir_.GetPath().AppendASCII("localappdata"); |
143 } | 143 } |
144 | 144 |
145 void EnsureMediaDirectoriesExists::SetCustomPicasaAppDataPath( | 145 void EnsureMediaDirectoriesExists::SetCustomPicasaAppDataPath( |
146 const base::FilePath& path) { | 146 const base::FilePath& path) { |
147 base::win::RegKey key(HKEY_CURRENT_USER, picasa::kPicasaRegistryPath, | 147 base::win::RegKey key(HKEY_CURRENT_USER, picasa::kPicasaRegistryPath, |
148 KEY_SET_VALUE); | 148 KEY_SET_VALUE); |
149 key.WriteValue(picasa::kPicasaRegistryAppDataPathKey, path.value().c_str()); | 149 key.WriteValue(picasa::kPicasaRegistryAppDataPathKey, path.value().c_str()); |
150 } | 150 } |
151 #endif // OS_WIN | 151 #endif // OS_WIN |
152 | 152 |
153 #if defined(OS_MACOSX) | 153 #if defined(OS_MACOSX) |
154 void EnsureMediaDirectoriesExists::SetCustomPicasaAppDataPath( | 154 void EnsureMediaDirectoriesExists::SetCustomPicasaAppDataPath( |
155 const base::FilePath& path) { | 155 const base::FilePath& path) { |
156 mac_preferences_->AddTestItem( | 156 mac_preferences_->AddTestItem( |
157 base::mac::NSToCFCast(picasa::kPicasaAppDataPathMacPreferencesKey), | 157 base::mac::NSToCFCast(picasa::kPicasaAppDataPathMacPreferencesKey), |
158 base::SysUTF8ToNSString(path.value()), | 158 base::SysUTF8ToNSString(path.value()), |
159 false); | 159 false); |
160 } | 160 } |
161 #endif // OS_MACOSX | 161 #endif // OS_MACOSX |
162 | 162 |
163 #if defined(OS_WIN) || defined(OS_MACOSX) | 163 #if defined(OS_WIN) || defined(OS_MACOSX) |
164 base::FilePath | 164 base::FilePath |
165 EnsureMediaDirectoriesExists::GetFakePicasaFoldersRootPath() const { | 165 EnsureMediaDirectoriesExists::GetFakePicasaFoldersRootPath() const { |
166 DCHECK(fake_dir_.IsValid()); | 166 DCHECK(fake_dir_.IsValid()); |
167 return fake_dir_.path().AppendASCII("picasa_folders"); | 167 return fake_dir_.GetPath().AppendASCII("picasa_folders"); |
168 } | 168 } |
169 #endif // OS_WIN || OS_MACOSX | 169 #endif // OS_WIN || OS_MACOSX |
170 | 170 |
171 #if defined(OS_MACOSX) | 171 #if defined(OS_MACOSX) |
172 base::FilePath EnsureMediaDirectoriesExists::GetFakeITunesRootPath() const { | 172 base::FilePath EnsureMediaDirectoriesExists::GetFakeITunesRootPath() const { |
173 DCHECK(fake_dir_.IsValid()); | 173 DCHECK(fake_dir_.IsValid()); |
174 return fake_dir_.path().AppendASCII("itunes"); | 174 return fake_dir_.GetPath().AppendASCII("itunes"); |
175 } | 175 } |
176 #endif // OS_MACOSX | 176 #endif // OS_MACOSX |
177 | 177 |
178 void EnsureMediaDirectoriesExists::Init() { | 178 void EnsureMediaDirectoriesExists::Init() { |
179 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 179 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
180 return; | 180 return; |
181 #else | 181 #else |
182 | 182 |
183 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); | 183 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); |
184 | 184 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 base::FilePath MakeMediaGalleriesTestingPath(const std::string& dir) { | 219 base::FilePath MakeMediaGalleriesTestingPath(const std::string& dir) { |
220 #if defined(OS_WIN) | 220 #if defined(OS_WIN) |
221 return base::FilePath(FILE_PATH_LITERAL("C:\\")).AppendASCII(dir); | 221 return base::FilePath(FILE_PATH_LITERAL("C:\\")).AppendASCII(dir); |
222 #elif defined(OS_POSIX) | 222 #elif defined(OS_POSIX) |
223 return base::FilePath(FILE_PATH_LITERAL("/")).Append(dir); | 223 return base::FilePath(FILE_PATH_LITERAL("/")).Append(dir); |
224 #else | 224 #else |
225 NOTREACHED(); | 225 NOTREACHED(); |
226 #endif | 226 #endif |
227 } | 227 } |
OLD | NEW |