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

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_apitest.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 (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
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(), xml_contents.size()));
364 xml_contents.size()));
365 } 364 }
366 #endif // defined(OS_MACOSX) 365 #endif // defined(OS_MACOSX)
367 366
368 base::FilePath GetCommonDataDir() const { 367 base::FilePath GetCommonDataDir() const {
369 return test_data_dir_.AppendASCII("api_test") 368 return test_data_dir_.AppendASCII("api_test")
370 .AppendASCII("media_galleries") 369 .AppendASCII("media_galleries")
371 .AppendASCII("common"); 370 .AppendASCII("common");
372 } 371 }
373 372
374 int num_galleries() const { 373 int num_galleries() const {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 ASSERT_TRUE(ExtensionFunctionDispatcher::OverrideFunction( 550 ASSERT_TRUE(ExtensionFunctionDispatcher::OverrideFunction(
552 "mediaGalleries.addScanResults", 551 "mediaGalleries.addScanResults",
553 &TestMediaGalleriesAddScanResultsFunction::Factory)); 552 &TestMediaGalleriesAddScanResultsFunction::Factory));
554 553
555 // Add some files and directories to the scan root for testing. Only the 554 // Add some files and directories to the scan root for testing. Only the
556 // "f" directory should be found. 555 // "f" directory should be found.
557 std::string dummy_data; 556 std::string dummy_data;
558 dummy_data.resize(1); 557 dummy_data.resize(1);
559 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("a/b"))); 558 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("a/b")));
560 ASSERT_EQ(static_cast<int>(dummy_data.size()), 559 ASSERT_EQ(static_cast<int>(dummy_data.size()),
561 file_util::WriteFile(scan_root.path().AppendASCII("a/b/c.jpg"), 560 base::WriteFile(scan_root.path().AppendASCII("a/b/c.jpg"),
562 dummy_data.c_str(), dummy_data.size())); 561 dummy_data.c_str(), dummy_data.size()));
563 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("a/d"))); 562 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. 563 dummy_data.resize(201 * 1024); // 200k is the min size for the folder finder.
565 ASSERT_EQ(static_cast<int>(dummy_data.size()), 564 ASSERT_EQ(static_cast<int>(dummy_data.size()),
566 file_util::WriteFile(scan_root.path().AppendASCII("a/d/e.txt"), 565 base::WriteFile(scan_root.path().AppendASCII("a/d/e.txt"),
567 dummy_data.c_str(), dummy_data.size())); 566 dummy_data.c_str(), dummy_data.size()));
568 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("f"))); 567 ASSERT_TRUE(base::CreateDirectory(scan_root.path().AppendASCII("f")));
569 ASSERT_EQ(static_cast<int>(dummy_data.size()), 568 ASSERT_EQ(static_cast<int>(dummy_data.size()),
570 file_util::WriteFile(scan_root.path().AppendASCII("f/g.jpg"), 569 base::WriteFile(scan_root.path().AppendASCII("f/g.jpg"),
571 dummy_data.c_str(), dummy_data.size())); 570 dummy_data.c_str(), dummy_data.size()));
572 571
573 ASSERT_TRUE(RunMediaGalleriesTest("scan")) << message_; 572 ASSERT_TRUE(RunMediaGalleriesTest("scan")) << message_;
574 } 573 }
575 574
576 IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, GetMetadata) { 575 IN_PROC_BROWSER_TEST_F(MediaGalleriesPlatformAppBrowserTest, GetMetadata) {
577 RemoveAllGalleries(); 576 RemoveAllGalleries();
578 MakeSingleFakeGallery(); 577 MakeSingleFakeGallery();
579 578
580 AddFileToSingleFakeGallery(media::GetTestDataFilePath("90rotation.mp4")); 579 AddFileToSingleFakeGallery(media::GetTestDataFilePath("90rotation.mp4"));
581 AddFileToSingleFakeGallery(media::GetTestDataFilePath("id3_png_test.mp3")); 580 AddFileToSingleFakeGallery(media::GetTestDataFilePath("id3_png_test.mp3"));
582 581
583 base::ListValue custom_args; 582 base::ListValue custom_args;
584 #if defined(USE_PROPRIETARY_CODECS) 583 #if defined(USE_PROPRIETARY_CODECS)
585 custom_args.AppendBoolean(true); 584 custom_args.AppendBoolean(true);
586 #else 585 #else
587 custom_args.AppendBoolean(false); 586 custom_args.AppendBoolean(false);
588 #endif 587 #endif
589 ASSERT_TRUE(RunMediaGalleriesTestWithArg("media_metadata", custom_args)) 588 ASSERT_TRUE(RunMediaGalleriesTestWithArg("media_metadata", custom_args))
590 << message_; 589 << message_;
591 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698