OLD | NEW |
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/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 public: | 31 public: |
32 TestIPhotoDataProvider(const base::FilePath& xml_library_path, | 32 TestIPhotoDataProvider(const base::FilePath& xml_library_path, |
33 const base::Closure& callback) | 33 const base::Closure& callback) |
34 : IPhotoDataProvider(xml_library_path), | 34 : IPhotoDataProvider(xml_library_path), |
35 callback_(callback) { | 35 callback_(callback) { |
36 } | 36 } |
37 virtual ~TestIPhotoDataProvider() {} | 37 virtual ~TestIPhotoDataProvider() {} |
38 | 38 |
39 private: | 39 private: |
40 virtual void OnLibraryChanged(const base::FilePath& path, | 40 virtual void OnLibraryChanged(const base::FilePath& path, |
41 bool error) OVERRIDE { | 41 bool error) override { |
42 IPhotoDataProvider::OnLibraryChanged(path, error); | 42 IPhotoDataProvider::OnLibraryChanged(path, error); |
43 callback_.Run(); | 43 callback_.Run(); |
44 } | 44 } |
45 | 45 |
46 base::Closure callback_; | 46 base::Closure callback_; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(TestIPhotoDataProvider); | 48 DISALLOW_COPY_AND_ASSIGN(TestIPhotoDataProvider); |
49 }; | 49 }; |
50 | 50 |
51 class IPhotoDataProviderTest : public InProcessBrowserTest { | 51 class IPhotoDataProviderTest : public InProcessBrowserTest { |
52 public: | 52 public: |
53 IPhotoDataProviderTest() {} | 53 IPhotoDataProviderTest() {} |
54 virtual ~IPhotoDataProviderTest() {} | 54 virtual ~IPhotoDataProviderTest() {} |
55 | 55 |
56 protected: | 56 protected: |
57 virtual void SetUp() OVERRIDE { | 57 virtual void SetUp() override { |
58 ASSERT_TRUE(library_dir_.CreateUniqueTempDir()); | 58 ASSERT_TRUE(library_dir_.CreateUniqueTempDir()); |
59 WriteLibraryInternal(); | 59 WriteLibraryInternal(); |
60 // The ImportedMediaGalleryRegistry is created on which ever thread calls | 60 // The ImportedMediaGalleryRegistry is created on which ever thread calls |
61 // GetInstance() first. It shouldn't matter what thread creates, however | 61 // GetInstance() first. It shouldn't matter what thread creates, however |
62 // in practice it is always created on the UI thread, so this calls | 62 // in practice it is always created on the UI thread, so this calls |
63 // GetInstance here to mirror those real conditions. | 63 // GetInstance here to mirror those real conditions. |
64 ImportedMediaGalleryRegistry::GetInstance(); | 64 ImportedMediaGalleryRegistry::GetInstance(); |
65 InProcessBrowserTest::SetUp(); | 65 InProcessBrowserTest::SetUp(); |
66 } | 66 } |
67 | 67 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 base::Closure quit_closure_; | 151 base::Closure quit_closure_; |
152 | 152 |
153 DISALLOW_COPY_AND_ASSIGN(IPhotoDataProviderTest); | 153 DISALLOW_COPY_AND_ASSIGN(IPhotoDataProviderTest); |
154 }; | 154 }; |
155 | 155 |
156 class IPhotoDataProviderBasicTest : public IPhotoDataProviderTest { | 156 class IPhotoDataProviderBasicTest : public IPhotoDataProviderTest { |
157 public: | 157 public: |
158 IPhotoDataProviderBasicTest() {} | 158 IPhotoDataProviderBasicTest() {} |
159 virtual ~IPhotoDataProviderBasicTest() {} | 159 virtual ~IPhotoDataProviderBasicTest() {} |
160 | 160 |
161 virtual std::string GetLibraryString() OVERRIDE { | 161 virtual std::string GetLibraryString() override { |
162 return "<plist><dict>\n" | 162 return "<plist><dict>\n" |
163 "<key>List of Albums</key>\n" | 163 "<key>List of Albums</key>\n" |
164 "<array>" | 164 "<array>" |
165 " <dict>\n" | 165 " <dict>\n" |
166 " <key>AlbumId</key>" | 166 " <key>AlbumId</key>" |
167 " <integer>14</integer>" | 167 " <integer>14</integer>" |
168 " <key>AlbumName</key>" | 168 " <key>AlbumName</key>" |
169 " <string>Album1</string>" | 169 " <string>Album1</string>" |
170 " <key>KeyList</key>" | 170 " <key>KeyList</key>" |
171 " <array>" | 171 " <array>" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 " <string>/vol/dupe/path2.jpg</string>" | 261 " <string>/vol/dupe/path2.jpg</string>" |
262 " <key>ThumbPath</key>" | 262 " <key>ThumbPath</key>" |
263 " <string>/vol/dupe/thumb2.jpg</string>" | 263 " <string>/vol/dupe/thumb2.jpg</string>" |
264 " <key>OriginalPath</key>" \ | 264 " <key>OriginalPath</key>" \ |
265 " <string>/original/vol/another2.jpg</string>" \ | 265 " <string>/original/vol/another2.jpg</string>" \ |
266 " </dict>\n" | 266 " </dict>\n" |
267 "</dict>\n" | 267 "</dict>\n" |
268 "</dict></plist>\n"; | 268 "</dict></plist>\n"; |
269 } | 269 } |
270 | 270 |
271 virtual void StartTest(bool parse_success) OVERRIDE { | 271 virtual void StartTest(bool parse_success) override { |
272 EXPECT_TRUE(parse_success); | 272 EXPECT_TRUE(parse_success); |
273 | 273 |
274 std::vector<std::string> names = data_provider()->GetAlbumNames(); | 274 std::vector<std::string> names = data_provider()->GetAlbumNames(); |
275 EXPECT_EQ(3U, names.size()); | 275 EXPECT_EQ(3U, names.size()); |
276 EXPECT_EQ("Album1", names[0]); | 276 EXPECT_EQ("Album1", names[0]); |
277 | 277 |
278 EXPECT_EQ(FilePath("/vol/path1.jpg").value(), | 278 EXPECT_EQ(FilePath("/vol/path1.jpg").value(), |
279 data_provider()->GetPhotoLocationInAlbum( | 279 data_provider()->GetPhotoLocationInAlbum( |
280 "Album1", "path1.jpg").value()); | 280 "Album1", "path1.jpg").value()); |
281 EXPECT_EQ(FilePath("/vol/path3.jpg").value(), | 281 EXPECT_EQ(FilePath("/vol/path3.jpg").value(), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 DISALLOW_COPY_AND_ASSIGN(IPhotoDataProviderBasicTest); | 339 DISALLOW_COPY_AND_ASSIGN(IPhotoDataProviderBasicTest); |
340 }; | 340 }; |
341 | 341 |
342 class IPhotoDataProviderRefreshTest : public IPhotoDataProviderTest { | 342 class IPhotoDataProviderRefreshTest : public IPhotoDataProviderTest { |
343 public: | 343 public: |
344 IPhotoDataProviderRefreshTest() {} | 344 IPhotoDataProviderRefreshTest() {} |
345 virtual ~IPhotoDataProviderRefreshTest() {} | 345 virtual ~IPhotoDataProviderRefreshTest() {} |
346 | 346 |
347 std::string another_album; | 347 std::string another_album; |
348 | 348 |
349 virtual std::string GetLibraryString() OVERRIDE { | 349 virtual std::string GetLibraryString() override { |
350 return "<plist><dict>\n" | 350 return "<plist><dict>\n" |
351 "<key>List of Albums</key>\n" | 351 "<key>List of Albums</key>\n" |
352 "<array>" | 352 "<array>" |
353 " <dict>" | 353 " <dict>" |
354 " <key>AlbumId</key>" | 354 " <key>AlbumId</key>" |
355 " <integer>14</integer>" | 355 " <integer>14</integer>" |
356 " <key>AlbumName</key>" | 356 " <key>AlbumName</key>" |
357 " <string>Album1</string>" | 357 " <string>Album1</string>" |
358 " <key>KeyList</key>" | 358 " <key>KeyList</key>" |
359 " <array>" | 359 " <array>" |
(...skipping 14 matching lines...) Expand all Loading... |
374 " <string>guid1</string>" | 374 " <string>guid1</string>" |
375 " <key>ImagePath</key>" | 375 " <key>ImagePath</key>" |
376 " <string>/vol/path1.jpg</string>" | 376 " <string>/vol/path1.jpg</string>" |
377 " <key>ThumbPath</key>" | 377 " <key>ThumbPath</key>" |
378 " <string>/vol/thumb1.jpg</string>" | 378 " <string>/vol/thumb1.jpg</string>" |
379 " </dict>\n" | 379 " </dict>\n" |
380 "</dict>\n" | 380 "</dict>\n" |
381 "</dict></plist>\n"; | 381 "</dict></plist>\n"; |
382 } | 382 } |
383 | 383 |
384 virtual void StartTest(bool parse_success) OVERRIDE { | 384 virtual void StartTest(bool parse_success) override { |
385 EXPECT_TRUE(parse_success); | 385 EXPECT_TRUE(parse_success); |
386 | 386 |
387 EXPECT_EQ(FilePath("/vol/path1.jpg"), | 387 EXPECT_EQ(FilePath("/vol/path1.jpg"), |
388 data_provider()->GetPhotoLocationInAlbum("Album1", "path1.jpg")); | 388 data_provider()->GetPhotoLocationInAlbum("Album1", "path1.jpg")); |
389 std::vector<std::string> names = data_provider()->GetAlbumNames(); | 389 std::vector<std::string> names = data_provider()->GetAlbumNames(); |
390 EXPECT_EQ(1U, names.size()); | 390 EXPECT_EQ(1U, names.size()); |
391 EXPECT_EQ("Album1", names[0]); | 391 EXPECT_EQ("Album1", names[0]); |
392 | 392 |
393 another_album = | 393 another_album = |
394 " <dict>" | 394 " <dict>" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 436 |
437 private: | 437 private: |
438 DISALLOW_COPY_AND_ASSIGN(IPhotoDataProviderRefreshTest); | 438 DISALLOW_COPY_AND_ASSIGN(IPhotoDataProviderRefreshTest); |
439 }; | 439 }; |
440 | 440 |
441 class IPhotoDataProviderInvalidTest : public IPhotoDataProviderTest { | 441 class IPhotoDataProviderInvalidTest : public IPhotoDataProviderTest { |
442 public: | 442 public: |
443 IPhotoDataProviderInvalidTest() {} | 443 IPhotoDataProviderInvalidTest() {} |
444 virtual ~IPhotoDataProviderInvalidTest() {} | 444 virtual ~IPhotoDataProviderInvalidTest() {} |
445 | 445 |
446 virtual void StartTest(bool parse_success) OVERRIDE { | 446 virtual void StartTest(bool parse_success) override { |
447 EXPECT_TRUE(parse_success); | 447 EXPECT_TRUE(parse_success); |
448 | 448 |
449 SetLibraryChangeCallback( | 449 SetLibraryChangeCallback( |
450 base::Bind(&IPhotoDataProvider::RefreshData, | 450 base::Bind(&IPhotoDataProvider::RefreshData, |
451 base::Unretained(data_provider()), | 451 base::Unretained(data_provider()), |
452 base::Bind(&IPhotoDataProviderInvalidTest::CheckInvalid, | 452 base::Bind(&IPhotoDataProviderInvalidTest::CheckInvalid, |
453 base::Unretained(this)))); | 453 base::Unretained(this)))); |
454 EXPECT_EQ(1L, base::WriteFile(XmlFile(), " ", 1)); | 454 EXPECT_EQ(1L, base::WriteFile(XmlFile(), " ", 1)); |
455 } | 455 } |
456 | 456 |
(...skipping 12 matching lines...) Expand all Loading... |
469 | 469 |
470 IN_PROC_BROWSER_TEST_F(IPhotoDataProviderRefreshTest, RefreshTest) { | 470 IN_PROC_BROWSER_TEST_F(IPhotoDataProviderRefreshTest, RefreshTest) { |
471 RunTest(); | 471 RunTest(); |
472 } | 472 } |
473 | 473 |
474 IN_PROC_BROWSER_TEST_F(IPhotoDataProviderInvalidTest, InvalidTest) { | 474 IN_PROC_BROWSER_TEST_F(IPhotoDataProviderInvalidTest, InvalidTest) { |
475 RunTest(); | 475 RunTest(); |
476 } | 476 } |
477 | 477 |
478 } // namespace iphoto | 478 } // namespace iphoto |
OLD | NEW |