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

Side by Side Diff: base/json/json_value_serializer_unittest.cc

Issue 18584011: Rename base::Delete to base::DeleteFile (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
« no previous file with comments | « base/files/scoped_temp_dir_unittest.cc ('k') | base/memory/shared_memory_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 6
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_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 const base::FilePath written_file_path = 417 const base::FilePath written_file_path =
418 temp_dir_.path().Append(FILE_PATH_LITERAL("test_output.js")); 418 temp_dir_.path().Append(FILE_PATH_LITERAL("test_output.js"));
419 419
420 ASSERT_FALSE(PathExists(written_file_path)); 420 ASSERT_FALSE(PathExists(written_file_path));
421 JSONFileValueSerializer serializer(written_file_path); 421 JSONFileValueSerializer serializer(written_file_path);
422 ASSERT_TRUE(serializer.Serialize(*root)); 422 ASSERT_TRUE(serializer.Serialize(*root));
423 ASSERT_TRUE(PathExists(written_file_path)); 423 ASSERT_TRUE(PathExists(written_file_path));
424 424
425 // Now compare file contents. 425 // Now compare file contents.
426 EXPECT_TRUE(TextContentsEqual(original_file_path, written_file_path)); 426 EXPECT_TRUE(TextContentsEqual(original_file_path, written_file_path));
427 EXPECT_TRUE(base::Delete(written_file_path, false)); 427 EXPECT_TRUE(base::DeleteFile(written_file_path, false));
428 } 428 }
429 429
430 TEST_F(JSONFileValueSerializerTest, RoundtripNested) { 430 TEST_F(JSONFileValueSerializerTest, RoundtripNested) {
431 base::FilePath original_file_path; 431 base::FilePath original_file_path;
432 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &original_file_path)); 432 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &original_file_path));
433 original_file_path = original_file_path.Append( 433 original_file_path = original_file_path.Append(
434 FILE_PATH_LITERAL("serializer_nested_test.json")); 434 FILE_PATH_LITERAL("serializer_nested_test.json"));
435 435
436 ASSERT_TRUE(PathExists(original_file_path)); 436 ASSERT_TRUE(PathExists(original_file_path));
437 437
438 JSONFileValueSerializer deserializer(original_file_path); 438 JSONFileValueSerializer deserializer(original_file_path);
439 scoped_ptr<Value> root; 439 scoped_ptr<Value> root;
440 root.reset(deserializer.Deserialize(NULL, NULL)); 440 root.reset(deserializer.Deserialize(NULL, NULL));
441 ASSERT_TRUE(root.get()); 441 ASSERT_TRUE(root.get());
442 442
443 // Now try writing. 443 // Now try writing.
444 base::FilePath written_file_path = temp_dir_.path().Append( 444 base::FilePath written_file_path = temp_dir_.path().Append(
445 FILE_PATH_LITERAL("test_output.json")); 445 FILE_PATH_LITERAL("test_output.json"));
446 446
447 ASSERT_FALSE(PathExists(written_file_path)); 447 ASSERT_FALSE(PathExists(written_file_path));
448 JSONFileValueSerializer serializer(written_file_path); 448 JSONFileValueSerializer serializer(written_file_path);
449 ASSERT_TRUE(serializer.Serialize(*root)); 449 ASSERT_TRUE(serializer.Serialize(*root));
450 ASSERT_TRUE(PathExists(written_file_path)); 450 ASSERT_TRUE(PathExists(written_file_path));
451 451
452 // Now compare file contents. 452 // Now compare file contents.
453 EXPECT_TRUE(TextContentsEqual(original_file_path, written_file_path)); 453 EXPECT_TRUE(TextContentsEqual(original_file_path, written_file_path));
454 EXPECT_TRUE(base::Delete(written_file_path, false)); 454 EXPECT_TRUE(base::DeleteFile(written_file_path, false));
455 } 455 }
456 456
457 TEST_F(JSONFileValueSerializerTest, NoWhitespace) { 457 TEST_F(JSONFileValueSerializerTest, NoWhitespace) {
458 base::FilePath source_file_path; 458 base::FilePath source_file_path;
459 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &source_file_path)); 459 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &source_file_path));
460 source_file_path = source_file_path.Append( 460 source_file_path = source_file_path.Append(
461 FILE_PATH_LITERAL("serializer_test_nowhitespace.json")); 461 FILE_PATH_LITERAL("serializer_test_nowhitespace.json"));
462 ASSERT_TRUE(PathExists(source_file_path)); 462 ASSERT_TRUE(PathExists(source_file_path));
463 JSONFileValueSerializer serializer(source_file_path); 463 JSONFileValueSerializer serializer(source_file_path);
464 scoped_ptr<Value> root; 464 scoped_ptr<Value> root;
465 root.reset(serializer.Deserialize(NULL, NULL)); 465 root.reset(serializer.Deserialize(NULL, NULL));
466 ASSERT_TRUE(root.get()); 466 ASSERT_TRUE(root.get());
467 } 467 }
468 468
469 } // namespace 469 } // namespace
470 470
471 } // namespace base 471 } // namespace base
OLDNEW
« no previous file with comments | « base/files/scoped_temp_dir_unittest.cc ('k') | base/memory/shared_memory_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698