Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 iphoto_data_root.AppendASCII("InFirstAlbumOnly.jpg"); | 352 iphoto_data_root.AppendASCII("InFirstAlbumOnly.jpg"); |
| 353 base::FilePath in_both_jpg = iphoto_data_root.AppendASCII("InBoth.jpg"); | 353 base::FilePath in_both_jpg = iphoto_data_root.AppendASCII("InBoth.jpg"); |
| 354 ASSERT_TRUE(base::CopyFile(test_jpg_path, first_only_jpg)); | 354 ASSERT_TRUE(base::CopyFile(test_jpg_path, first_only_jpg)); |
| 355 ASSERT_TRUE(base::CopyFile(test_jpg_path, in_both_jpg)); | 355 ASSERT_TRUE(base::CopyFile(test_jpg_path, in_both_jpg)); |
| 356 ReplaceFirstSubstringAfterOffset( | 356 ReplaceFirstSubstringAfterOffset( |
| 357 &xml_contents, 0, std::string("$path1"), first_only_jpg.value()); | 357 &xml_contents, 0, std::string("$path1"), first_only_jpg.value()); |
| 358 ReplaceFirstSubstringAfterOffset( | 358 ReplaceFirstSubstringAfterOffset( |
| 359 &xml_contents, 0, std::string("$path2"), in_both_jpg.value()); | 359 &xml_contents, 0, std::string("$path2"), in_both_jpg.value()); |
| 360 | 360 |
| 361 base::FilePath album_xml = iphoto_data_root.AppendASCII("AlbumData.xml"); | 361 base::FilePath album_xml = iphoto_data_root.AppendASCII("AlbumData.xml"); |
| 362 ASSERT_NE(-1, file_util::WriteFile(album_xml, | 362 ASSERT_NE(-1, base::WriteFile(album_xml, |
| 363 xml_contents.c_str(), | 363 xml_contents.c_str(), |
|
viettrungluu
2014/02/28 21:47:24
nit: fix indentation
| |
| 364 xml_contents.size())); | 364 xml_contents.size())); |
| 365 } | 365 } |
| 366 #endif // defined(OS_MACOSX) | 366 #endif // defined(OS_MACOSX) |
| 367 | 367 |
| 368 base::FilePath GetCommonDataDir() const { | 368 base::FilePath GetCommonDataDir() const { |
| 369 return test_data_dir_.AppendASCII("api_test") | 369 return test_data_dir_.AppendASCII("api_test") |
| 370 .AppendASCII("media_galleries") | 370 .AppendASCII("media_galleries") |
| 371 .AppendASCII("common"); | 371 .AppendASCII("common"); |
| 372 } | 372 } |
| 373 | 373 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 ASSERT_TRUE(ExtensionFunctionDispatcher::OverrideFunction( | 551 ASSERT_TRUE(ExtensionFunctionDispatcher::OverrideFunction( |
| 552 "mediaGalleries.addScanResults", | 552 "mediaGalleries.addScanResults", |
| 553 &TestMediaGalleriesAddScanResultsFunction::Factory)); | 553 &TestMediaGalleriesAddScanResultsFunction::Factory)); |
| 554 | 554 |
| 555 // Add some files and directories to the scan root for testing. Only the | 555 // Add some files and directories to the scan root for testing. Only the |
| 556 // "f" directory should be found. | 556 // "f" directory should be found. |
| 557 std::string dummy_data; | 557 std::string dummy_data; |
| 558 dummy_data.resize(1); | 558 dummy_data.resize(1); |
| 559 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("a/b"))); | 559 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("a/b"))); |
| 560 ASSERT_EQ(static_cast<int>(dummy_data.size()), | 560 ASSERT_EQ(static_cast<int>(dummy_data.size()), |
| 561 file_util::WriteFile(scan_root.path().AppendASCII("a/b/c.jpg"), | 561 base::WriteFile(scan_root.path().AppendASCII("a/b/c.jpg"), |
| 562 dummy_data.c_str(), dummy_data.size())); | 562 dummy_data.c_str(), dummy_data.size())); |
|
viettrungluu
2014/02/28 21:47:24
"
| |
| 563 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("a/d"))); | 563 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("a/d"))); |
| 564 dummy_data.resize(201 * 1024); // 200k is the min size for the folder finder. | 564 dummy_data.resize(201 * 1024); // 200k is the min size for the folder finder. |
| 565 ASSERT_EQ(static_cast<int>(dummy_data.size()), | 565 ASSERT_EQ(static_cast<int>(dummy_data.size()), |
| 566 file_util::WriteFile(scan_root.path().AppendASCII("a/d/e.txt"), | 566 base::WriteFile(scan_root.path().AppendASCII("a/d/e.txt"), |
| 567 dummy_data.c_str(), dummy_data.size())); | 567 dummy_data.c_str(), dummy_data.size())); |
|
viettrungluu
2014/02/28 21:47:24
"
| |
| 568 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("f"))); | 568 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("f"))); |
| 569 ASSERT_EQ(static_cast<int>(dummy_data.size()), | 569 ASSERT_EQ(static_cast<int>(dummy_data.size()), |
| 570 file_util::WriteFile(scan_root.path().AppendASCII("f/g.jpg"), | 570 base::WriteFile(scan_root.path().AppendASCII("f/g.jpg"), |
| 571 dummy_data.c_str(), dummy_data.size())); | 571 dummy_data.c_str(), dummy_data.size())); |
|
viettrungluu
2014/02/28 21:47:24
"
| |
| 572 | 572 |
| 573 ASSERT_TRUE(RunMediaGalleriesTest("scan")) << message_; | 573 ASSERT_TRUE(RunMediaGalleriesTest("scan")) << message_; |
| 574 } | 574 } |
| 575 | 575 |
| 576 IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, GetMetadata) { | 576 IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, GetMetadata) { |
| 577 RemoveAllGalleries(); | 577 RemoveAllGalleries(); |
| 578 MakeSingleFakeGallery(); | 578 MakeSingleFakeGallery(); |
| 579 | 579 |
| 580 AddFileToSingleFakeGallery(media::GetTestDataFilePath("90rotation.mp4")); | 580 AddFileToSingleFakeGallery(media::GetTestDataFilePath("90rotation.mp4")); |
| 581 AddFileToSingleFakeGallery(media::GetTestDataFilePath("id3_png_test.mp3")); | 581 AddFileToSingleFakeGallery(media::GetTestDataFilePath("id3_png_test.mp3")); |
| 582 | 582 |
| 583 base::ListValue custom_args; | 583 base::ListValue custom_args; |
| 584 #if defined(USE_PROPRIETARY_CODECS) | 584 #if defined(USE_PROPRIETARY_CODECS) |
| 585 custom_args.AppendBoolean(true); | 585 custom_args.AppendBoolean(true); |
| 586 #else | 586 #else |
| 587 custom_args.AppendBoolean(false); | 587 custom_args.AppendBoolean(false); |
| 588 #endif | 588 #endif |
| 589 ASSERT_TRUE(RunMediaGalleriesTestWithArg("media_metadata", custom_args)) | 589 ASSERT_TRUE(RunMediaGalleriesTestWithArg("media_metadata", custom_args)) |
| 590 << message_; | 590 << message_; |
| 591 } | 591 } |
| OLD | NEW |