Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7091)

Unified Diff: chrome/browser/media_gallery/media_galleries_test_util.cc

Issue 11027051: MediaFileSystemRegistry unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
+}

Powered by Google App Engine
This is Rietveld 408576698