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

Side by Side Diff: chrome/browser/media_gallery/media_galleries_test_util.cc

Issue 11535008: Implement mediaGalleriesPrivate api to notify extensions about gallery changed events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_gallery/media_galleries_test_util.h" 5 #include "chrome/browser/media_gallery/media_galleries_test_util.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 extension_service->EnableExtension(extension->id()); 62 extension_service->EnableExtension(extension->id());
63 63
64 return extension; 64 return extension;
65 } 65 }
66 66
67 EnsureMediaDirectoriesExists::EnsureMediaDirectoriesExists() 67 EnsureMediaDirectoriesExists::EnsureMediaDirectoriesExists()
68 : num_galleries_(0) { 68 : num_galleries_(0) {
69 Init(); 69 Init();
70 } 70 }
71 71
72 bool EnsureMediaDirectoriesExists::AddNewFileInGallery(
73 int gallery_directory_key) {
74 if ((gallery_directory_key != chrome::DIR_USER_MUSIC) &&
75 (gallery_directory_key != chrome::DIR_USER_PICTURES) &&
76 (gallery_directory_key != chrome::DIR_USER_VIDEOS))
77 return false;
78
79 FilePath gallery_dir;
80 PathService::Get(gallery_directory_key, &gallery_dir);
81 FilePath gallery_file =
82 gallery_dir.Append(FILE_PATH_LITERAL("test1.txt"));
83 std::string content("new content");
84 int write_size = file_util::WriteFile(gallery_file, content.c_str(),
85 content.length());
86 return (write_size == static_cast<int>(content.length()));
87 }
88
72 void EnsureMediaDirectoriesExists::Init() { 89 void EnsureMediaDirectoriesExists::Init() {
73 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) 90 #if defined(OS_CHROMEOS) || defined(OS_ANDROID)
74 return; 91 return;
75 #else 92 #else
76 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); 93 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir());
77 94
78 const int kDirectoryKeys[] = { 95 const int kDirectoryKeys[] = {
79 chrome::DIR_USER_MUSIC, 96 chrome::DIR_USER_MUSIC,
80 chrome::DIR_USER_PICTURES, 97 chrome::DIR_USER_PICTURES,
81 chrome::DIR_USER_VIDEOS, 98 chrome::DIR_USER_VIDEOS,
(...skipping 13 matching lines...) Expand all
95 if (PathService::Get(kDirectoryKeys[i], &path) && 112 if (PathService::Get(kDirectoryKeys[i], &path) &&
96 file_util::DirectoryExists(path)) { 113 file_util::DirectoryExists(path)) {
97 ++num_galleries_; 114 ++num_galleries_;
98 } 115 }
99 } 116 }
100 ASSERT_GT(num_galleries_, 0); 117 ASSERT_GT(num_galleries_, 0);
101 #endif 118 #endif
102 } 119 }
103 120
104 } // namespace chrome 121 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698