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 "base/base_paths.h" |
7 #include "base/file_util.h" | 8 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
9 #include "base/path_service.h" | 10 #include "base/path_service.h" |
10 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
11 #include "chrome/browser/extensions/extension_prefs.h" | 12 #include "chrome/browser/extensions/extension_prefs.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_system.h" | 14 #include "chrome/browser/extensions/extension_system.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 extension_service->EnableExtension(extension->id()); | 65 extension_service->EnableExtension(extension->id()); |
65 | 66 |
66 return extension; | 67 return extension; |
67 } | 68 } |
68 | 69 |
69 EnsureMediaDirectoriesExists::EnsureMediaDirectoriesExists() | 70 EnsureMediaDirectoriesExists::EnsureMediaDirectoriesExists() |
70 : num_galleries_(0) { | 71 : num_galleries_(0) { |
71 Init(); | 72 Init(); |
72 } | 73 } |
73 | 74 |
| 75 EnsureMediaDirectoriesExists::~EnsureMediaDirectoriesExists() { |
| 76 } |
| 77 |
74 void EnsureMediaDirectoriesExists::Init() { | 78 void EnsureMediaDirectoriesExists::Init() { |
75 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 79 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
76 return; | 80 return; |
77 #else | 81 #else |
| 82 |
78 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); | 83 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); |
79 | 84 |
80 const int kDirectoryKeys[] = { | 85 #if defined(OS_WIN) || defined(OS_MACOSX) |
81 chrome::DIR_USER_MUSIC, | 86 // This is to make sure the tests don't think iTunes is installed (unless |
82 chrome::DIR_USER_PICTURES, | 87 // we control it specifically). |
83 chrome::DIR_USER_VIDEOS, | 88 appdir_override_.reset(new base::ScopedPathOverride( |
84 }; | 89 base::DIR_APP_DATA, fake_dir_.path().AppendASCII("itunes"))); |
| 90 #endif |
85 | 91 |
86 const char* kDirectoryNames[] = { | 92 music_override_.reset(new base::ScopedPathOverride( |
87 "music", | 93 chrome::DIR_USER_MUSIC, fake_dir_.path().AppendASCII("music"))); |
88 "pictures", | 94 pictures_override_.reset(new base::ScopedPathOverride( |
89 "videos", | 95 chrome::DIR_USER_PICTURES, fake_dir_.path().AppendASCII("pictures"))); |
90 }; | 96 video_override_.reset(new base::ScopedPathOverride( |
91 | 97 chrome::DIR_USER_VIDEOS, fake_dir_.path().AppendASCII("videos"))); |
92 for (size_t i = 0; i < arraysize(kDirectoryKeys); ++i) { | 98 num_galleries_ = 3; |
93 PathService::OverrideAndCreateIfNeeded( | |
94 kDirectoryKeys[i], fake_dir_.path().AppendASCII(kDirectoryNames[i]), | |
95 true /*create*/); | |
96 base::FilePath path; | |
97 if (PathService::Get(kDirectoryKeys[i], &path) && | |
98 file_util::DirectoryExists(path)) { | |
99 ++num_galleries_; | |
100 } | |
101 } | |
102 ASSERT_GT(num_galleries_, 0); | |
103 #endif | 99 #endif |
104 } | 100 } |
105 | 101 |
106 } // namespace chrome | 102 } // namespace chrome |
OLD | NEW |