OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/file_util.h" | |
6 #include "base/files/scoped_temp_dir.h" | |
7 #include "base/memory/ref_counted.h" | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/message_loop/message_loop.h" | |
10 #include "base/run_loop.h" | |
11 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | |
12 #include "chrome/browser/media_galleries/fileapi/picasa/picasa_data_provider.h" | |
13 #include "chrome/browser/media_galleries/fileapi/safe_picasa_albums_indexer.h" | |
14 #include "chrome/common/media_galleries/picasa_types.h" | |
15 #include "chrome/common/media_galleries/pmp_test_helper.h" | |
16 #include "chrome/test/base/in_process_browser_test.h" | |
17 #include "content/public/test/test_browser_thread.h" | |
18 | |
19 using chrome::MediaFileSystemBackend; | |
20 | |
21 namespace picasa { | |
22 | |
23 namespace { | |
24 | |
25 void WriteTestAlbumTable(PmpTestHelper* test_helper, | |
26 base::FilePath test_folder_1_path, | |
27 base::FilePath test_folder_2_path) { | |
28 std::vector<uint32> category_vector; | |
29 category_vector.push_back(kAlbumCategoryFolder); | |
30 category_vector.push_back(kAlbumCategoryInvalid); | |
31 category_vector.push_back(kAlbumCategoryAlbum); | |
32 category_vector.push_back(kAlbumCategoryFolder); | |
33 category_vector.push_back(kAlbumCategoryAlbum); | |
34 | |
35 std::vector<double> date_vector; | |
36 date_vector.push_back(0.0); | |
37 date_vector.push_back(0.0); | |
38 date_vector.push_back(0.0); | |
39 date_vector.push_back(0.0); | |
40 date_vector.push_back(0.0); | |
41 | |
42 std::vector<std::string> filename_vector; | |
43 filename_vector.push_back(test_folder_1_path.AsUTF8Unsafe()); | |
44 filename_vector.push_back(""); | |
45 filename_vector.push_back(""); | |
46 filename_vector.push_back(test_folder_2_path.AsUTF8Unsafe()); | |
47 filename_vector.push_back(""); | |
48 | |
49 std::vector<std::string> name_vector; | |
50 name_vector.push_back(test_folder_1_path.BaseName().AsUTF8Unsafe()); | |
51 name_vector.push_back(""); | |
52 name_vector.push_back("Album 1 Name"); | |
53 name_vector.push_back(test_folder_2_path.BaseName().AsUTF8Unsafe()); | |
54 name_vector.push_back("Album 2 Name"); | |
55 | |
56 std::vector<std::string> token_vector; | |
57 token_vector.push_back(""); | |
58 token_vector.push_back(""); | |
59 token_vector.push_back(std::string(kAlbumTokenPrefix) + "uid3"); | |
60 token_vector.push_back(""); | |
61 token_vector.push_back(std::string(kAlbumTokenPrefix) + "uid5"); | |
62 | |
63 std::vector<std::string> uid_vector; | |
64 uid_vector.push_back("uid1"); | |
65 uid_vector.push_back("uid2"); | |
66 uid_vector.push_back("uid3"); | |
67 uid_vector.push_back("uid4"); | |
68 uid_vector.push_back("uid5"); | |
69 | |
70 ASSERT_TRUE(test_helper->WriteColumnFileFromVector( | |
71 "category", PMP_TYPE_UINT32, category_vector)); | |
72 ASSERT_TRUE(test_helper->WriteColumnFileFromVector( | |
73 "date", PMP_TYPE_DOUBLE64, date_vector)); | |
74 ASSERT_TRUE(test_helper->WriteColumnFileFromVector( | |
75 "filename", PMP_TYPE_STRING, filename_vector)); | |
76 ASSERT_TRUE(test_helper->WriteColumnFileFromVector( | |
77 "name", PMP_TYPE_STRING, name_vector)); | |
78 ASSERT_TRUE(test_helper->WriteColumnFileFromVector( | |
79 "token", PMP_TYPE_STRING, token_vector)); | |
80 ASSERT_TRUE(test_helper->WriteColumnFileFromVector( | |
81 "uid", PMP_TYPE_STRING, uid_vector)); | |
82 } | |
83 | |
84 void WriteAlbumsImagesIndex(const base::FilePath& test_folder_1_path, | |
85 const base::FilePath& test_folder_2_path) { | |
86 const char folder_1_test_ini[] = | |
87 "[InBoth.jpg]\n" | |
88 "albums=uid3,uid5\n" | |
89 "[InSecondAlbumOnly.jpg]\n" | |
90 "albums=uid5\n"; | |
91 ASSERT_TRUE( | |
92 file_util::WriteFile(test_folder_1_path.AppendASCII(kPicasaINIFilename), | |
93 folder_1_test_ini, | |
94 arraysize(folder_1_test_ini))); | |
95 | |
96 const char folder_2_test_ini[] = | |
97 "[InFirstAlbumOnly.jpg]\n" | |
98 "albums=uid3\n"; | |
99 ASSERT_TRUE( | |
100 file_util::WriteFile(test_folder_2_path.AppendASCII(kPicasaINIFilename), | |
101 folder_2_test_ini, | |
102 arraysize(folder_2_test_ini))); | |
103 } | |
104 | |
105 void VerifyAlbumTable(PicasaDataProvider* data_provider, | |
106 base::FilePath test_folder_1_path, | |
107 base::FilePath test_folder_2_path) { | |
108 scoped_ptr<AlbumMap> folders = data_provider->GetFolders(); | |
109 ASSERT_TRUE(folders.get()); | |
110 EXPECT_EQ(2u, folders->size()); | |
111 | |
112 AlbumMap::const_iterator folder_1 = folders->find( | |
113 test_folder_1_path.BaseName().AsUTF8Unsafe() + " 1899-12-30"); | |
114 EXPECT_NE(folders->end(), folder_1); | |
115 EXPECT_EQ(test_folder_1_path.BaseName().AsUTF8Unsafe(), | |
116 folder_1->second.name); | |
117 EXPECT_EQ(test_folder_1_path, folder_1->second.path); | |
118 EXPECT_EQ("uid1", folder_1->second.uid); | |
119 | |
120 AlbumMap::const_iterator folder_2 = folders->find( | |
121 test_folder_2_path.BaseName().AsUTF8Unsafe() + " 1899-12-30"); | |
122 EXPECT_NE(folders->end(), folder_2); | |
123 EXPECT_EQ(test_folder_2_path.BaseName().AsUTF8Unsafe(), | |
124 folder_2->second.name); | |
125 EXPECT_EQ(test_folder_2_path, folder_2->second.path); | |
126 EXPECT_EQ("uid4", folder_2->second.uid); | |
127 | |
128 scoped_ptr<AlbumMap> albums = data_provider->GetAlbums(); | |
129 ASSERT_TRUE(albums.get()); | |
130 EXPECT_EQ(2u, albums->size()); | |
131 | |
132 AlbumMap::const_iterator album_1 = albums->find("Album 1 Name 1899-12-30"); | |
133 EXPECT_NE(albums->end(), album_1); | |
134 EXPECT_EQ("Album 1 Name", album_1->second.name); | |
135 EXPECT_EQ(base::FilePath(), album_1->second.path); | |
136 EXPECT_EQ("uid3", album_1->second.uid); | |
137 | |
138 AlbumMap::const_iterator album_2 = albums->find("Album 2 Name 1899-12-30"); | |
139 EXPECT_NE(albums->end(), album_2); | |
140 EXPECT_EQ("Album 2 Name", album_2->second.name); | |
141 EXPECT_EQ(base::FilePath(), album_2->second.path); | |
142 EXPECT_EQ("uid5", album_2->second.uid); | |
143 } | |
144 | |
145 void VerifyAlbumsImagesIndex(PicasaDataProvider* data_provider, | |
146 base::FilePath test_folder_1_path, | |
147 base::FilePath test_folder_2_path) { | |
148 base::PlatformFileError error; | |
149 scoped_ptr<AlbumImages> album_1_images = | |
150 data_provider->FindAlbumImages("uid3", &error); | |
151 ASSERT_TRUE(album_1_images); | |
152 EXPECT_EQ(base::PLATFORM_FILE_OK, error); | |
153 EXPECT_EQ(2u, album_1_images->size()); | |
154 EXPECT_NE(album_1_images->end(), album_1_images->find("InBoth.jpg")); | |
155 EXPECT_EQ(test_folder_1_path.AppendASCII("InBoth.jpg"), | |
156 (*album_1_images)["InBoth.jpg"]); | |
157 EXPECT_NE(album_1_images->end(), | |
158 album_1_images->find("InFirstAlbumOnly.jpg")); | |
159 EXPECT_EQ(test_folder_2_path.AppendASCII("InFirstAlbumOnly.jpg"), | |
160 (*album_1_images)["InFirstAlbumOnly.jpg"]); | |
161 | |
162 scoped_ptr<AlbumImages> album_2_images = | |
163 data_provider->FindAlbumImages("uid5", &error); | |
164 ASSERT_TRUE(album_2_images); | |
165 EXPECT_EQ(base::PLATFORM_FILE_OK, error); | |
166 EXPECT_EQ(2u, album_2_images->size()); | |
167 EXPECT_NE(album_2_images->end(), album_2_images->find("InBoth.jpg")); | |
168 EXPECT_EQ(test_folder_1_path.AppendASCII("InBoth.jpg"), | |
169 (*album_2_images)["InBoth.jpg"]); | |
170 EXPECT_NE(album_2_images->end(), | |
171 album_2_images->find("InSecondAlbumOnly.jpg")); | |
172 EXPECT_EQ(test_folder_1_path.AppendASCII("InSecondAlbumOnly.jpg"), | |
173 (*album_2_images)["InSecondAlbumOnly.jpg"]); | |
174 } | |
175 | |
176 } // namespace | |
177 | |
178 class PicasaDataProviderTest : public InProcessBrowserTest { | |
179 public: | |
180 PicasaDataProviderTest() : test_helper_(kPicasaAlbumTableName) {} | |
181 virtual ~PicasaDataProviderTest() {} | |
182 | |
183 protected: | |
184 // Runs on the MediaTaskRunner and designed to be overridden by subclasses. | |
185 virtual void InitializeTestData() { | |
vandebo (ex-Chrome)
2013/08/23 16:42:41
It looks like no class overrides this, but doesn't
tommycli
2013/08/26 22:06:17
Done.
| |
186 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | |
187 ASSERT_TRUE(test_folder_1_.CreateUniqueTempDir()); | |
188 ASSERT_TRUE(test_folder_2_.CreateUniqueTempDir()); | |
189 ASSERT_TRUE(test_helper_.Init()); | |
190 picasa_data_provider_.reset( | |
191 new PicasaDataProvider(test_helper_.GetTempDirPath())); | |
192 } | |
193 | |
194 void RunTest() { | |
195 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
196 base::RunLoop loop; | |
197 quit_closure_ = loop.QuitClosure(); | |
198 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | |
199 FROM_HERE, | |
200 base::Bind(&PicasaDataProviderTest::StartTestOnMediaTaskRunner, | |
201 base::Unretained(this))); | |
202 loop.Run(); | |
203 } | |
204 | |
205 virtual PicasaDataProvider::DataType RequestedDataType() const = 0; | |
206 | |
207 // Start the test. The data provider is refreshed before calling StartTest | |
208 // and the result of the refresh is passed in. | |
209 virtual void VerifyRefreshResults(bool parse_success) {}; | |
210 | |
211 void TestDone() { | |
212 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | |
213 | |
214 // The data provider must be destructed on the MediaTaskRunner. This is done | |
215 // in a posted task rather than directly because TestDone is called by | |
216 // PicasaDataProvider. The callee should not destroy the caller. | |
217 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | |
218 FROM_HERE, | |
219 base::Bind(&PicasaDataProviderTest::DestructDataProviderThenQuit, | |
220 base::Unretained(this))); | |
221 } | |
222 | |
223 const base::FilePath& test_folder_1_path() { return test_folder_1_.path(); } | |
224 const base::FilePath& test_folder_2_path() { return test_folder_2_.path(); } | |
225 | |
226 PmpTestHelper* test_helper() { return &test_helper_; } | |
227 | |
228 PicasaDataProvider* data_provider() const { | |
229 return picasa_data_provider_.get(); | |
230 } | |
231 | |
232 private: | |
233 virtual void StartTestOnMediaTaskRunner() { | |
234 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | |
235 InitializeTestData(); | |
236 | |
237 data_provider()->RefreshData( | |
238 RequestedDataType(), | |
239 base::Bind(&PicasaDataProviderTest::VerifyRefreshResults, | |
240 base::Unretained(this))); | |
241 } | |
242 | |
243 void DestructDataProviderThenQuit() { | |
244 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | |
245 picasa_data_provider_.reset(); | |
246 content::BrowserThread::PostTask( | |
247 content::BrowserThread::UI, FROM_HERE, quit_closure_); | |
248 } | |
249 | |
250 base::ScopedTempDir test_folder_1_; | |
251 base::ScopedTempDir test_folder_2_; | |
252 | |
253 PmpTestHelper test_helper_; | |
254 scoped_ptr<PicasaDataProvider> picasa_data_provider_; | |
255 | |
256 base::Closure quit_closure_; | |
257 | |
258 DISALLOW_COPY_AND_ASSIGN(PicasaDataProviderTest); | |
259 }; | |
260 | |
261 class PicasaDataProviderNoDatabaseGetListTest : public PicasaDataProviderTest { | |
262 protected: | |
263 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { | |
264 return PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA; | |
265 } | |
266 virtual void VerifyRefreshResults(bool parse_success) OVERRIDE { | |
267 EXPECT_FALSE(parse_success); | |
268 TestDone(); | |
269 } | |
270 }; | |
271 | |
272 IN_PROC_BROWSER_TEST_F(PicasaDataProviderNoDatabaseGetListTest, | |
273 NoDatabaseGetList) { | |
274 RunTest(); | |
275 } | |
276 | |
277 class PicasaDataProviderNoDatabaseGetAlbumsImagesTest | |
278 : public PicasaDataProviderTest { | |
279 protected: | |
280 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { | |
281 return PicasaDataProvider::ALBUMS_IMAGES_DATA; | |
282 } | |
283 virtual void VerifyRefreshResults(bool parse_success) OVERRIDE { | |
284 EXPECT_FALSE(parse_success); | |
285 TestDone(); | |
286 } | |
287 }; | |
288 | |
289 IN_PROC_BROWSER_TEST_F(PicasaDataProviderNoDatabaseGetAlbumsImagesTest, | |
290 NoDatabaseGetAlbumsImages) { | |
291 RunTest(); | |
292 } | |
293 | |
294 class PicasaDataProviderGetListTest : public PicasaDataProviderTest { | |
295 protected: | |
296 virtual void InitializeTestData() OVERRIDE { | |
297 PicasaDataProviderTest::InitializeTestData(); | |
298 WriteTestAlbumTable( | |
299 test_helper(), test_folder_1_path(), test_folder_2_path()); | |
300 } | |
301 | |
302 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { | |
303 return PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA; | |
304 } | |
305 | |
306 virtual void VerifyRefreshResults(bool parse_success) OVERRIDE { | |
307 ASSERT_TRUE(parse_success); | |
308 VerifyAlbumTable( | |
309 data_provider(), test_folder_1_path(), test_folder_2_path()); | |
310 TestDone(); | |
311 } | |
312 }; | |
313 | |
314 IN_PROC_BROWSER_TEST_F(PicasaDataProviderGetListTest, GetListTest) { | |
315 RunTest(); | |
316 } | |
317 | |
318 class PicasaDataProviderGetAlbumsImagesTest : public PicasaDataProviderTest { | |
319 protected: | |
320 virtual void InitializeTestData() OVERRIDE { | |
321 PicasaDataProviderTest::InitializeTestData(); | |
322 WriteTestAlbumTable( | |
323 test_helper(), test_folder_1_path(), test_folder_2_path()); | |
324 WriteAlbumsImagesIndex(test_folder_1_path(), test_folder_2_path()); | |
325 } | |
326 | |
327 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { | |
328 return PicasaDataProvider::ALBUMS_IMAGES_DATA; | |
329 } | |
330 | |
331 virtual void VerifyRefreshResults(bool parse_success) OVERRIDE { | |
332 ASSERT_TRUE(parse_success); | |
333 VerifyAlbumTable( | |
334 data_provider(), test_folder_1_path(), test_folder_2_path()); | |
335 VerifyAlbumsImagesIndex( | |
336 data_provider(), test_folder_1_path(), test_folder_2_path()); | |
337 TestDone(); | |
338 } | |
339 }; | |
340 | |
341 IN_PROC_BROWSER_TEST_F(PicasaDataProviderGetAlbumsImagesTest, | |
342 GetAlbumsImagesTest) { | |
343 RunTest(); | |
344 } | |
345 | |
346 class PicasaDataProviderMultipleMixedCallbacksTest | |
347 : public PicasaDataProviderTest { | |
348 public: | |
349 PicasaDataProviderMultipleMixedCallbacksTest() | |
350 : list_callbacks_called_(0), albums_images_callbacks_called_(0) {} | |
351 | |
352 virtual void InitializeTestData() OVERRIDE { | |
353 PicasaDataProviderTest::InitializeTestData(); | |
354 WriteTestAlbumTable( | |
355 test_helper(), test_folder_1_path(), test_folder_2_path()); | |
356 WriteAlbumsImagesIndex(test_folder_1_path(), test_folder_2_path()); | |
357 } | |
358 | |
359 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { | |
360 return PicasaDataProvider::ALBUMS_IMAGES_DATA; | |
361 } | |
362 | |
363 protected: | |
364 virtual void ListCallback(int expected_list_callbacks_called, | |
365 bool parse_success) { | |
366 ASSERT_TRUE(parse_success); | |
367 ASSERT_EQ(expected_list_callbacks_called, ++list_callbacks_called_); | |
368 VerifyAlbumTable( | |
369 data_provider(), test_folder_1_path(), test_folder_2_path()); | |
370 CheckTestDone(); | |
371 } | |
372 | |
373 virtual void AlbumsImagesCallback(int expected_albums_images_callbacks_called, | |
374 bool parse_success) { | |
375 ASSERT_TRUE(parse_success); | |
376 ASSERT_EQ(expected_albums_images_callbacks_called, | |
377 ++albums_images_callbacks_called_); | |
378 VerifyAlbumsImagesIndex( | |
379 data_provider(), test_folder_1_path(), test_folder_2_path()); | |
380 CheckTestDone(); | |
381 } | |
382 | |
383 private: | |
384 void CheckTestDone() { | |
385 ASSERT_LE(list_callbacks_called_, 2); | |
386 ASSERT_LE(albums_images_callbacks_called_, 2); | |
387 if (list_callbacks_called_ == 2 && albums_images_callbacks_called_ == 2) | |
388 TestDone(); | |
389 } | |
390 | |
391 virtual void StartTestOnMediaTaskRunner() { | |
392 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | |
393 InitializeTestData(); | |
394 | |
395 data_provider()->RefreshData( | |
396 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA, | |
397 base::Bind(&PicasaDataProviderMultipleMixedCallbacksTest::ListCallback, | |
398 base::Unretained(this), | |
399 1)); | |
400 data_provider()->RefreshData( | |
401 PicasaDataProvider::ALBUMS_IMAGES_DATA, | |
402 base::Bind( | |
403 &PicasaDataProviderMultipleMixedCallbacksTest::AlbumsImagesCallback, | |
404 base::Unretained(this), | |
405 1)); | |
406 data_provider()->RefreshData( | |
407 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA, | |
408 base::Bind(&PicasaDataProviderMultipleMixedCallbacksTest::ListCallback, | |
409 base::Unretained(this), | |
410 2)); | |
411 data_provider()->RefreshData( | |
412 PicasaDataProvider::ALBUMS_IMAGES_DATA, | |
413 base::Bind( | |
414 &PicasaDataProviderMultipleMixedCallbacksTest::AlbumsImagesCallback, | |
415 base::Unretained(this), | |
416 2)); | |
417 } | |
418 | |
419 int list_callbacks_called_; | |
420 int albums_images_callbacks_called_; | |
421 }; | |
422 | |
423 IN_PROC_BROWSER_TEST_F(PicasaDataProviderMultipleMixedCallbacksTest, | |
424 MultipleMixedCallbacks) { | |
425 RunTest(); | |
426 } | |
427 | |
428 class PicasaDataProviderInvalidateSimpleTest | |
429 : public PicasaDataProviderGetListTest { | |
430 protected: | |
431 virtual void FirstListCallback(bool parse_success) { | |
432 ASSERT_FALSE(parse_success); | |
433 WriteTestAlbumTable( | |
434 test_helper(), test_folder_1_path(), test_folder_2_path()); | |
435 | |
436 // TODO(tommycli): Remove this line once database is under file watch. | |
437 data_provider()->InvalidateData(); | |
438 | |
439 // Have to post this, otherwise this will run the callback immediately. | |
440 MediaFileSystemBackend::MediaTaskRunner()->PostTask( | |
441 FROM_HERE, | |
442 base::Bind( | |
443 &PicasaDataProvider::RefreshData, | |
444 base::Unretained(data_provider()), | |
445 RequestedDataType(), | |
446 base::Bind( | |
447 &PicasaDataProviderInvalidateSimpleTest::SecondListCallback, | |
448 base::Unretained(this)))); | |
449 } | |
450 | |
451 virtual void SecondListCallback(bool parse_success) { | |
452 ASSERT_TRUE(parse_success); | |
453 VerifyAlbumTable( | |
454 data_provider(), test_folder_1_path(), test_folder_2_path()); | |
455 TestDone(); | |
456 } | |
457 | |
458 private: | |
459 virtual void StartTestOnMediaTaskRunner() { | |
460 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | |
461 | |
462 // We don't want to write the database until later. | |
463 PicasaDataProviderTest::InitializeTestData(); | |
464 | |
465 data_provider()->RefreshData( | |
466 RequestedDataType(), | |
467 base::Bind(&PicasaDataProviderInvalidateSimpleTest::FirstListCallback, | |
468 base::Unretained(this))); | |
469 } | |
470 }; | |
471 | |
472 IN_PROC_BROWSER_TEST_F(PicasaDataProviderInvalidateSimpleTest, | |
473 InvalidateSimpleTest) { | |
474 RunTest(); | |
475 } | |
476 | |
477 class PicasaDataProviderInvalidateInflightTableReaderTest | |
478 : public PicasaDataProviderGetListTest { | |
479 virtual void StartTestOnMediaTaskRunner() { | |
480 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | |
481 PicasaDataProviderGetListTest::InitializeTestData(); | |
482 | |
483 // Temporarily empty the database path to guarantee that the first utility | |
484 // process will fail to read the database. | |
485 base::FilePath database_path = data_provider()->GetDatabasePathForTesting(); | |
486 data_provider()->SetDatabasePathForTesting(base::FilePath()); | |
487 data_provider()->RefreshData( | |
488 RequestedDataType(), | |
489 base::Bind(&PicasaDataProviderInvalidateInflightTableReaderTest:: | |
490 VerifyRefreshResults, | |
491 base::Unretained(this))); | |
492 | |
493 // Now restore the database path and invalidate the inflight table reader. | |
494 data_provider()->SetDatabasePathForTesting(database_path); | |
vandebo (ex-Chrome)
2013/08/23 16:42:41
database_path = test_helper_.GetTempDirPath(), set
tommycli
2013/08/26 22:06:17
Done.
| |
495 data_provider()->InvalidateData(); | |
496 | |
497 // VerifyRefreshResults callback should receive correct results now. | |
498 } | |
499 }; | |
500 | |
501 IN_PROC_BROWSER_TEST_F(PicasaDataProviderInvalidateInflightTableReaderTest, | |
502 InvalidateInflightTableReaderTest) { | |
503 RunTest(); | |
504 } | |
505 | |
506 class PicasaDataProviderInvalidateInflightAlbumsIndexerTest | |
507 : public PicasaDataProviderGetAlbumsImagesTest { | |
508 protected: | |
509 virtual void ListCallback(bool parse_success) { | |
510 ASSERT_TRUE(parse_success); | |
511 | |
512 // Temporarily empty the album maps to guarantee that the first utility | |
513 // process will give incorrect results. | |
514 AlbumMap album_map, folder_map; | |
515 data_provider()->GetAlbumMapsForTesting(&album_map, &folder_map); | |
516 data_provider()->SetAlbumMapsForTesting(AlbumMap(), AlbumMap()); | |
517 data_provider()->RefreshData( | |
518 PicasaDataProvider::ALBUMS_IMAGES_DATA, | |
519 // Now write the INI files and invalidate the inflight albums indexer. | |
520 base::Bind(&PicasaDataProviderInvalidateInflightAlbumsIndexerTest:: | |
521 VerifyRefreshResults, | |
522 base::Unretained(this))); | |
523 | |
524 // Now restore the album maps and invalidate the inflight albums indexer. | |
525 data_provider()->SetAlbumMapsForTesting(album_map, folder_map); | |
526 data_provider()->InvalidateData(); | |
vandebo (ex-Chrome)
2013/08/23 16:42:41
Invalidate data is going start from the beginning,
tommycli
2013/08/26 22:06:17
Done.
| |
527 | |
528 // VerifyRefreshResults callback should receive correct results now. | |
529 } | |
530 | |
531 private: | |
532 virtual void StartTestOnMediaTaskRunner() { | |
533 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); | |
534 PicasaDataProviderGetAlbumsImagesTest::InitializeTestData(); | |
535 | |
536 data_provider()->RefreshData( | |
537 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA, | |
538 base::Bind(&PicasaDataProviderInvalidateInflightAlbumsIndexerTest:: | |
539 ListCallback, | |
540 base::Unretained(this))); | |
541 } | |
542 }; | |
543 | |
544 IN_PROC_BROWSER_TEST_F(PicasaDataProviderInvalidateInflightAlbumsIndexerTest, | |
545 InvalidateInflightAlbumsIndexerTest) { | |
546 RunTest(); | |
547 } | |
548 | |
549 } // namespace picasa | |
OLD | NEW |