Index: chrome/browser/media_gallery/media_galleries_test_util.cc |
diff --git a/chrome/browser/media_gallery/media_galleries_test_util.cc b/chrome/browser/media_gallery/media_galleries_test_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ef2823712df6a7b8be9618a48323fde37a8f234f |
--- /dev/null |
+++ b/chrome/browser/media_gallery/media_galleries_test_util.cc |
@@ -0,0 +1,50 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/media_gallery/media_galleries_test_util.h" |
+ |
+#include "chrome/common/chrome_paths.h" |
Lei Zhang
2012/11/09 09:14:53
alphabetical order
vandebo (ex-Chrome)
2012/11/13 06:50:18
Done.
|
+#include "base/file_path.h" |
+#include "base/file_util.h" |
+#include "base/path_service.h" |
+#include "base/stringprintf.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+EnsureMediaDirectoriesExists::EnsureMediaDirectoriesExists() |
+ : num_galleries_(0) { |
+ Init(); |
+} |
+ |
+void EnsureMediaDirectoriesExists::Init() { |
+#if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
+ return; |
+#else |
+ ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); |
+ |
+ const int kDirectoryKeys[] = { |
+ chrome::DIR_USER_MUSIC, |
+ chrome::DIR_USER_PICTURES, |
+ chrome::DIR_USER_VIDEOS, |
+ }; |
+ |
+ const char* kDirectoryNames[] = { |
+ "music", |
+ "pictures", |
+ "videos", |
+ }; |
+ |
+ for (size_t i = 0; i < arraysize(kDirectoryKeys); ++i) { |
+ PathService::OverrideAndCreateIfNeeded( |
+ kDirectoryKeys[i], |
+ fake_dir_.path().Append(FILE_PATH_LITERAL(kDirectoryNames[i])), |
Lei Zhang
2012/11/09 09:14:53
Just AppendASCII() ?
vandebo (ex-Chrome)
2012/11/13 06:50:18
Done.
|
+ true /*create*/); |
+ FilePath path; |
+ if (PathService::Get(kDirectoryKeys[i], &path) && |
+ file_util::DirectoryExists(path)) { |
+ ++num_galleries_; |
+ } |
+ } |
+ ASSERT_GT(num_galleries_, 0); |
+#endif |
+} |