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

Side by Side Diff: chrome/browser/media_galleries/fileapi/itunes_data_provider_browsertest.cc

Issue 23727009: Cleanup: Remove chrome namespace for storage monitor and media galleries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 7 years, 3 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/format_macros.h" 12 #include "base/format_macros.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/run_loop.h" 16 #include "base/run_loop.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h" 18 #include "chrome/browser/media_galleries/fileapi/itunes_data_provider.h"
19 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" 19 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
20 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h" 20 #include "chrome/browser/media_galleries/imported_media_gallery_registry.h"
21 #include "chrome/test/base/in_process_browser_test.h" 21 #include "chrome/test/base/in_process_browser_test.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24
25 using chrome::MediaFileSystemBackend;
26
27 namespace itunes { 25 namespace itunes {
28 26
29 namespace { 27 namespace {
30 28
31 struct LibraryEntry { 29 struct LibraryEntry {
32 LibraryEntry(const std::string& artist, const std::string& album, 30 LibraryEntry(const std::string& artist, const std::string& album,
33 const base::FilePath& location) 31 const base::FilePath& location)
34 : artist(artist), 32 : artist(artist),
35 album(album), 33 album(album),
36 location(location) { 34 location(location) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 virtual ~ITunesDataProviderTest() {} 67 virtual ~ITunesDataProviderTest() {}
70 68
71 protected: 69 protected:
72 virtual void SetUp() OVERRIDE { 70 virtual void SetUp() OVERRIDE {
73 ASSERT_TRUE(library_dir_.CreateUniqueTempDir()); 71 ASSERT_TRUE(library_dir_.CreateUniqueTempDir());
74 WriteLibraryInternal(SetUpLibrary()); 72 WriteLibraryInternal(SetUpLibrary());
75 // The ImportedMediaGalleryRegistry is created on which ever thread calls 73 // The ImportedMediaGalleryRegistry is created on which ever thread calls
76 // GetInstance() first. It shouldn't matter what thread creates, however 74 // GetInstance() first. It shouldn't matter what thread creates, however
77 // in practice it is always created on the UI thread, so this calls 75 // in practice it is always created on the UI thread, so this calls
78 // GetInstance here to mirror those real conditions. 76 // GetInstance here to mirror those real conditions.
79 chrome::ImportedMediaGalleryRegistry::GetInstance(); 77 ImportedMediaGalleryRegistry::GetInstance();
80 InProcessBrowserTest::SetUp(); 78 InProcessBrowserTest::SetUp();
81 } 79 }
82 80
83 void RunTest() { 81 void RunTest() {
84 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 82 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
85 base::RunLoop loop; 83 base::RunLoop loop;
86 quit_closure_ = loop.QuitClosure(); 84 quit_closure_ = loop.QuitClosure();
87 MediaFileSystemBackend::MediaTaskRunner()->PostTask( 85 MediaFileSystemBackend::MediaTaskRunner()->PostTask(
88 FROM_HERE, 86 FROM_HERE,
89 base::Bind(&ITunesDataProviderTest::StartTestOnMediaTaskRunner, 87 base::Bind(&ITunesDataProviderTest::StartTestOnMediaTaskRunner,
90 base::Unretained(this))); 88 base::Unretained(this)));
91 loop.Run(); 89 loop.Run();
92 } 90 }
93 91
94 void WriteLibrary(const std::vector<LibraryEntry>& entries, 92 void WriteLibrary(const std::vector<LibraryEntry>& entries,
95 const base::Closure& callback) { 93 const base::Closure& callback) {
96 SetLibraryChangeCallback(callback); 94 SetLibraryChangeCallback(callback);
97 WriteLibraryInternal(entries); 95 WriteLibraryInternal(entries);
98 } 96 }
99 97
100 void SetLibraryChangeCallback(const base::Closure& callback) { 98 void SetLibraryChangeCallback(const base::Closure& callback) {
101 EXPECT_TRUE(library_changed_callback_.is_null()); 99 EXPECT_TRUE(library_changed_callback_.is_null());
102 library_changed_callback_ = callback; 100 library_changed_callback_ = callback;
103 } 101 }
104 102
105 ITunesDataProvider* data_provider() const { 103 ITunesDataProvider* data_provider() const {
106 return chrome::ImportedMediaGalleryRegistry::ITunesDataProvider(); 104 return ImportedMediaGalleryRegistry::ITunesDataProvider();
107 } 105 }
108 106
109 const base::FilePath& library_dir() const { 107 const base::FilePath& library_dir() const {
110 return library_dir_.path(); 108 return library_dir_.path();
111 } 109 }
112 110
113 base::FilePath XmlFile() const { 111 base::FilePath XmlFile() const {
114 return library_dir_.path().AppendASCII("library.xml"); 112 return library_dir_.path().AppendASCII("library.xml");
115 } 113 }
116 114
(...skipping 18 matching lines...) Expand all
135 virtual std::vector<LibraryEntry> SetUpLibrary() { 133 virtual std::vector<LibraryEntry> SetUpLibrary() {
136 return std::vector<LibraryEntry>(); 134 return std::vector<LibraryEntry>();
137 } 135 }
138 136
139 // Start the test. The data provider is refreshed before calling StartTest 137 // Start the test. The data provider is refreshed before calling StartTest
140 // and the result of the refresh is passed in. 138 // and the result of the refresh is passed in.
141 virtual void StartTest(bool parse_success) = 0; 139 virtual void StartTest(bool parse_success) = 0;
142 140
143 void TestDone() { 141 void TestDone() {
144 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); 142 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread());
145 chrome::ImportedMediaGalleryRegistry* imported_registry = 143 ImportedMediaGalleryRegistry* imported_registry =
146 chrome::ImportedMediaGalleryRegistry::GetInstance(); 144 ImportedMediaGalleryRegistry::GetInstance();
147 imported_registry->itunes_data_provider_.reset(); 145 imported_registry->itunes_data_provider_.reset();
148 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 146 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
149 quit_closure_); 147 quit_closure_);
150 } 148 }
151 149
152 private: 150 private:
153 void StartTestOnMediaTaskRunner() { 151 void StartTestOnMediaTaskRunner() {
154 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); 152 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread());
155 chrome::ImportedMediaGalleryRegistry* imported_registry = 153 ImportedMediaGalleryRegistry* imported_registry =
156 chrome::ImportedMediaGalleryRegistry::GetInstance(); 154 ImportedMediaGalleryRegistry::GetInstance();
157 imported_registry->itunes_data_provider_.reset( 155 imported_registry->itunes_data_provider_.reset(
158 new TestITunesDataProvider( 156 new TestITunesDataProvider(
159 XmlFile(), 157 XmlFile(),
160 base::Bind(&ITunesDataProviderTest::OnLibraryChanged, 158 base::Bind(&ITunesDataProviderTest::OnLibraryChanged,
161 base::Unretained(this)))); 159 base::Unretained(this))));
162 data_provider()->RefreshData(base::Bind(&ITunesDataProviderTest::StartTest, 160 data_provider()->RefreshData(base::Bind(&ITunesDataProviderTest::StartTest,
163 base::Unretained(this))); 161 base::Unretained(this)));
164 }; 162 };
165 163
166 void OnLibraryChanged() { 164 void OnLibraryChanged() {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 452
455 IN_PROC_BROWSER_TEST_F(ITunesDataProviderUniqueNameTest, UniqueNameTest) { 453 IN_PROC_BROWSER_TEST_F(ITunesDataProviderUniqueNameTest, UniqueNameTest) {
456 RunTest(); 454 RunTest();
457 } 455 }
458 456
459 IN_PROC_BROWSER_TEST_F(ITunesDataProviderEscapeTest, EscapeTest) { 457 IN_PROC_BROWSER_TEST_F(ITunesDataProviderEscapeTest, EscapeTest) {
460 RunTest(); 458 RunTest();
461 } 459 }
462 460
463 } // namespace itunes 461 } // namespace itunes
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698