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 <errno.h> | 5 #include <errno.h> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 | 546 |
547 FilePath nonexisting_file(FILE_PATH_LITERAL("gdata/Dummy file.txt")); | 547 FilePath nonexisting_file(FILE_PATH_LITERAL("gdata/Dummy file.txt")); |
548 FilePath file_in_root(FILE_PATH_LITERAL("gdata/File 1.txt")); | 548 FilePath file_in_root(FILE_PATH_LITERAL("gdata/File 1.txt")); |
549 FilePath dir_in_root(FILE_PATH_LITERAL("gdata/Directory 1")); | 549 FilePath dir_in_root(FILE_PATH_LITERAL("gdata/Directory 1")); |
550 FilePath file_in_subdir( | 550 FilePath file_in_subdir( |
551 FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt")); | 551 FILE_PATH_LITERAL("gdata/Directory 1/SubDirectory File 1.txt")); |
552 | 552 |
553 GDataFileBase* file = NULL; | 553 GDataFileBase* file = NULL; |
554 EXPECT_TRUE((file = FindFile(file_in_root)) != NULL); | 554 EXPECT_TRUE((file = FindFile(file_in_root)) != NULL); |
555 EXPECT_TRUE(file->AsGDataFile() != NULL); | 555 EXPECT_TRUE(file->AsGDataFile() != NULL); |
556 std::string file_in_root_resource = file->AsGDataFile()->resource(); | 556 std::string file_in_root_resource = file->AsGDataFile()->resource_id(); |
557 EXPECT_EQ(file, FindFileByResource(file_in_root_resource)); | 557 EXPECT_EQ(file, FindFileByResource(file_in_root_resource)); |
558 | 558 |
559 EXPECT_TRUE(FindFile(dir_in_root) != NULL); | 559 EXPECT_TRUE(FindFile(dir_in_root) != NULL); |
560 | 560 |
561 EXPECT_TRUE((file = FindFile(file_in_subdir)) != NULL); | 561 EXPECT_TRUE((file = FindFile(file_in_subdir)) != NULL); |
562 EXPECT_TRUE(file->AsGDataFile() != NULL); | 562 EXPECT_TRUE(file->AsGDataFile() != NULL); |
563 std::string file_in_subdir_resource = file->AsGDataFile()->resource(); | 563 std::string file_in_subdir_resource = file->AsGDataFile()->resource_id(); |
564 EXPECT_EQ(file, FindFileByResource(file_in_subdir_resource)); | 564 EXPECT_EQ(file, FindFileByResource(file_in_subdir_resource)); |
565 | 565 |
566 // Remove first file in root. | 566 // Remove first file in root. |
567 EXPECT_TRUE(RemoveFile(file_in_root)); | 567 EXPECT_TRUE(RemoveFile(file_in_root)); |
568 EXPECT_TRUE(FindFile(file_in_root) == NULL); | 568 EXPECT_TRUE(FindFile(file_in_root) == NULL); |
569 EXPECT_EQ(NULL, FindFileByResource(file_in_root_resource)); | 569 EXPECT_EQ(NULL, FindFileByResource(file_in_root_resource)); |
570 EXPECT_TRUE(FindFile(dir_in_root) != NULL); | 570 EXPECT_TRUE(FindFile(dir_in_root) != NULL); |
571 EXPECT_TRUE((file = FindFile(file_in_subdir)) != NULL); | 571 EXPECT_TRUE((file = FindFile(file_in_subdir)) != NULL); |
572 EXPECT_EQ(file, FindFileByResource(file_in_subdir_resource)); | 572 EXPECT_EQ(file, FindFileByResource(file_in_subdir_resource)); |
573 | 573 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 file = file_info->AsGDataFile(); | 754 file = file_info->AsGDataFile(); |
755 ASSERT_TRUE(file != NULL); | 755 ASSERT_TRUE(file != NULL); |
756 } | 756 } |
757 | 757 |
758 // A file that exists in GData but not in cache. | 758 // A file that exists in GData but not in cache. |
759 FilePath cache_file_path = file_system_->GetFromCacheForPath(gdata_file_path); | 759 FilePath cache_file_path = file_system_->GetFromCacheForPath(gdata_file_path); |
760 EXPECT_TRUE(cache_file_path.empty()); | 760 EXPECT_TRUE(cache_file_path.empty()); |
761 | 761 |
762 // Store a file corresponding to resource and md5 of "gdata/File 1.txt" to | 762 // Store a file corresponding to resource and md5 of "gdata/File 1.txt" to |
763 // cache. | 763 // cache. |
764 TestStoreToCache(file->resource(), file->file_md5(), | 764 TestStoreToCache(file->resource_id(), file->file_md5(), |
765 GetTestFilePath("root_feed.json")); | 765 GetTestFilePath("root_feed.json")); |
766 | 766 |
767 // Now the file should exist in cache. | 767 // Now the file should exist in cache. |
768 cache_file_path = file_system_->GetFromCacheForPath(gdata_file_path); | 768 cache_file_path = file_system_->GetFromCacheForPath(gdata_file_path); |
769 EXPECT_EQ(file_system_->GetCacheFilePath(file->resource(), file->file_md5()), | 769 EXPECT_EQ(file_system_->GetCacheFilePath(file->resource_id(), |
| 770 file->file_md5()), |
770 cache_file_path); | 771 cache_file_path); |
771 | 772 |
772 // A file that doesn't exist in gdata. | 773 // A file that doesn't exist in gdata. |
773 cache_file_path = file_system_->GetFromCacheForPath( | 774 cache_file_path = file_system_->GetFromCacheForPath( |
774 FilePath(FILE_PATH_LITERAL("gdata/Nonexistent.txt"))); | 775 FilePath(FILE_PATH_LITERAL("gdata/Nonexistent.txt"))); |
775 EXPECT_TRUE(cache_file_path.empty()); | 776 EXPECT_TRUE(cache_file_path.empty()); |
776 } | 777 } |
777 | 778 |
778 // Create a directory through the document service | 779 // Create a directory through the document service |
779 TEST_F(GDataFileSystemTest, CreateDirectoryWithService) { | 780 TEST_F(GDataFileSystemTest, CreateDirectoryWithService) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 | 820 |
820 virtual void SetUp() OVERRIDE { | 821 virtual void SetUp() OVERRIDE { |
821 profile_.reset(new TestingProfile); | 822 profile_.reset(new TestingProfile); |
822 // TODO(kuan): Create some cache files to trigger scanning of cache dir, | 823 // TODO(kuan): Create some cache files to trigger scanning of cache dir, |
823 // and write tests to check the cache map. | 824 // and write tests to check the cache map. |
824 Init(profile_.get()); | 825 Init(profile_.get()); |
825 } | 826 } |
826 }; | 827 }; |
827 | 828 |
828 } // namespace gdata | 829 } // namespace gdata |
OLD | NEW |