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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 #endif // OS_MACOSX | 128 #endif // OS_MACOSX |
129 | 129 |
130 #if defined(OS_WIN) || defined(OS_MACOSX) | 130 #if defined(OS_WIN) || defined(OS_MACOSX) |
131 base::FilePath | 131 base::FilePath |
132 EnsureMediaDirectoriesExists::GetFakePicasaFoldersRootPath() const { | 132 EnsureMediaDirectoriesExists::GetFakePicasaFoldersRootPath() const { |
133 DCHECK(fake_dir_.IsValid()); | 133 DCHECK(fake_dir_.IsValid()); |
134 return fake_dir_.path().AppendASCII("picasa_folders"); | 134 return fake_dir_.path().AppendASCII("picasa_folders"); |
135 } | 135 } |
136 #endif // OS_WIN || OS_MACOSX | 136 #endif // OS_WIN || OS_MACOSX |
137 | 137 |
138 #if defined(OS_MACOSX) | |
139 base::FilePath EnsureMediaDirectoriesExists::GetFakeIPhotoRootPath() const { | |
140 DCHECK(fake_dir_.IsValid()); | |
141 return fake_dir_.path().AppendASCII("iphoto"); | |
142 } | |
143 #endif // OS_MACOSX | |
144 | |
138 void EnsureMediaDirectoriesExists::Init() { | 145 void EnsureMediaDirectoriesExists::Init() { |
139 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 146 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
140 return; | 147 return; |
141 #else | 148 #else |
142 | 149 |
143 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); | 150 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); |
144 | 151 |
145 #if defined(OS_WIN) || defined(OS_MACOSX) | 152 #if defined(OS_WIN) || defined(OS_MACOSX) |
146 // This is to control whether or not tests think iTunes (on Windows) and | 153 // This is to control whether or not tests think iTunes (on Windows) and |
147 // Picasa are installed. | 154 // Picasa are installed. |
148 app_data_override_.reset(new base::ScopedPathOverride( | 155 app_data_override_.reset(new base::ScopedPathOverride( |
149 base::DIR_APP_DATA, GetFakeAppDataPath())); | 156 base::DIR_APP_DATA, GetFakeAppDataPath())); |
150 #endif // OS_WIN || OS_MACOSX | 157 #endif // OS_WIN || OS_MACOSX |
151 | 158 |
152 #if defined(OS_WIN) | 159 #if defined(OS_WIN) |
153 // Picasa on Windows is by default in the DIR_LOCAL_APP_DATA directory. | 160 // Picasa on Windows is by default in the DIR_LOCAL_APP_DATA directory. |
154 local_app_data_override_.reset(new base::ScopedPathOverride( | 161 local_app_data_override_.reset(new base::ScopedPathOverride( |
155 base::DIR_LOCAL_APP_DATA, GetFakeLocalAppDataPath())); | 162 base::DIR_LOCAL_APP_DATA, GetFakeLocalAppDataPath())); |
156 // Picasa also looks in the registry for an alternate path. | 163 // Picasa also looks in the registry for an alternate path. |
157 registry_override_.OverrideRegistry(HKEY_CURRENT_USER, L"hkcu_picasa"); | 164 registry_override_.OverrideRegistry(HKEY_CURRENT_USER, L"hkcu_picasa"); |
158 #endif // OS_WIN | 165 #endif // OS_WIN |
159 | 166 |
160 #if defined(OS_MACOSX) | 167 #if defined(OS_MACOSX) |
161 mac_preferences_.reset(new MockPreferences); | 168 mac_preferences_.reset(new MockPreferences); |
162 iapps::SetMacPreferencesForTesting(mac_preferences_.get()); | 169 |
163 picasa::SetMacPreferencesForTesting(mac_preferences_.get()); | 170 // Note that these overrides set a string value, which isn't the right |
vandebo (ex-Chrome)
2014/01/06 18:45:03
Can you use NSArrayFromFilePath to fix this?
Greg Billock
2014/01/07 16:50:55
Fixed this up a bit.
| |
171 // type (expected to be an array), so overriding them to work requires | |
172 // converting the path to an array. | |
164 | 173 |
165 // iTunes override. | 174 // iTunes override. |
166 mac_preferences_->AddTestItem( | 175 mac_preferences_->AddTestItem( |
167 base::mac::NSToCFCast(iapps::kITunesRecentDatabasePathsKey), | 176 base::mac::NSToCFCast(iapps::kITunesRecentDatabasePathsKey), |
168 base::SysUTF8ToNSString(fake_dir_.path().AppendASCII("itunes").value()), | 177 base::SysUTF8ToNSString(fake_dir_.path().AppendASCII("itunes").value()), |
169 false); | 178 false); |
170 | 179 |
171 // iPhoto override. | 180 // iPhoto override. |
172 mac_preferences_->AddTestItem( | 181 mac_preferences_->AddTestItem( |
173 base::mac::NSToCFCast(iapps::kIPhotoRecentDatabasesKey), | 182 base::mac::NSToCFCast(iapps::kIPhotoRecentDatabasesKey), |
174 base::SysUTF8ToNSString(fake_dir_.path().AppendASCII("iphoto").value()), | 183 base::SysUTF8ToNSString(fake_dir_.path().AppendASCII("iphoto").value()), |
175 false); | 184 false); |
185 | |
186 iapps::SetMacPreferencesForTesting(mac_preferences_.get()); | |
187 picasa::SetMacPreferencesForTesting(mac_preferences_.get()); | |
176 #endif // OS_MACOSX | 188 #endif // OS_MACOSX |
177 | 189 |
178 music_override_.reset(new base::ScopedPathOverride( | 190 music_override_.reset(new base::ScopedPathOverride( |
179 chrome::DIR_USER_MUSIC, fake_dir_.path().AppendASCII("music"))); | 191 chrome::DIR_USER_MUSIC, fake_dir_.path().AppendASCII("music"))); |
180 pictures_override_.reset(new base::ScopedPathOverride( | 192 pictures_override_.reset(new base::ScopedPathOverride( |
181 chrome::DIR_USER_PICTURES, fake_dir_.path().AppendASCII("pictures"))); | 193 chrome::DIR_USER_PICTURES, fake_dir_.path().AppendASCII("pictures"))); |
182 video_override_.reset(new base::ScopedPathOverride( | 194 video_override_.reset(new base::ScopedPathOverride( |
183 chrome::DIR_USER_VIDEOS, fake_dir_.path().AppendASCII("videos"))); | 195 chrome::DIR_USER_VIDEOS, fake_dir_.path().AppendASCII("videos"))); |
184 num_galleries_ = 3; | 196 num_galleries_ = 3; |
185 #endif // OS_CHROMEOS || OS_ANDROID | 197 #endif // OS_CHROMEOS || OS_ANDROID |
186 } | 198 } |
OLD | NEW |