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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 11 #include "base/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" |
17 #include "chrome/common/extensions/extension_manifest_constants.h" | 18 #include "chrome/common/extensions/extension_manifest_constants.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 : num_galleries_(0) { | 71 : num_galleries_(0) { |
71 Init(); | 72 Init(); |
72 } | 73 } |
73 | 74 |
74 void EnsureMediaDirectoriesExists::Init() { | 75 void EnsureMediaDirectoriesExists::Init() { |
75 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 76 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
76 return; | 77 return; |
77 #else | 78 #else |
78 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); | 79 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); |
79 | 80 |
| 81 #if defined(OS_WIN) |
| 82 DCHECK_EQ(0U, fake_dir_.path().value().find(FILE_PATH_LITERAL("C:"))) |
| 83 << "TestVolumeMountWatcherWin requries fake_dir to be on C: " |
| 84 << "(note the capital). You have: " << fake_dir_.path().AsUTF8Unsafe() |
| 85 << ". Check your TMP enviornment variable."; |
| 86 #endif |
| 87 |
80 const int kDirectoryKeys[] = { | 88 const int kDirectoryKeys[] = { |
81 chrome::DIR_USER_MUSIC, | 89 chrome::DIR_USER_MUSIC, |
82 chrome::DIR_USER_PICTURES, | 90 chrome::DIR_USER_PICTURES, |
83 chrome::DIR_USER_VIDEOS, | 91 chrome::DIR_USER_VIDEOS, |
84 }; | 92 }; |
85 | 93 |
86 const char* kDirectoryNames[] = { | 94 const char* kDirectoryNames[] = { |
87 "music", | 95 "music", |
88 "pictures", | 96 "pictures", |
89 "videos", | 97 "videos", |
90 }; | 98 }; |
91 | 99 |
92 for (size_t i = 0; i < arraysize(kDirectoryKeys); ++i) { | 100 for (size_t i = 0; i < arraysize(kDirectoryKeys); ++i) { |
93 PathService::OverrideAndCreateIfNeeded( | 101 PathService::OverrideAndCreateIfNeeded( |
94 kDirectoryKeys[i], fake_dir_.path().AppendASCII(kDirectoryNames[i]), | 102 kDirectoryKeys[i], fake_dir_.path().AppendASCII(kDirectoryNames[i]), |
95 true /*create*/); | 103 true /*create*/); |
96 base::FilePath path; | 104 base::FilePath path; |
97 if (PathService::Get(kDirectoryKeys[i], &path) && | 105 if (PathService::Get(kDirectoryKeys[i], &path) && |
98 file_util::DirectoryExists(path)) { | 106 file_util::DirectoryExists(path)) { |
99 ++num_galleries_; | 107 ++num_galleries_; |
100 } | 108 } |
101 } | 109 } |
102 ASSERT_GT(num_galleries_, 0); | 110 ASSERT_GT(num_galleries_, 0); |
103 #endif | 111 #endif |
104 } | 112 } |
105 | 113 |
106 } // namespace chrome | 114 } // namespace chrome |
OLD | NEW |