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