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 "chrome/browser/sync_file_system/drive_backend/metadata_database.h" | 5 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 app_root_folders)); | 962 app_root_folders)); |
963 | 963 |
964 ResetTrackerID(&sync_root.tracker); | 964 ResetTrackerID(&sync_root.tracker); |
965 ResetTrackerID(&app_root.tracker); | 965 ResetTrackerID(&app_root.tracker); |
966 app_root.tracker.set_parent_tracker_id(sync_root.tracker.tracker_id()); | 966 app_root.tracker.set_parent_tracker_id(sync_root.tracker.tracker_id()); |
967 | 967 |
968 VerifyTrackedFiles(tracked_files, arraysize(tracked_files)); | 968 VerifyTrackedFiles(tracked_files, arraysize(tracked_files)); |
969 VerifyReloadConsistency(); | 969 VerifyReloadConsistency(); |
970 } | 970 } |
971 | 971 |
| 972 TEST_F(MetadataDatabaseTest, DumpFiles) { |
| 973 TrackedFile sync_root(CreateTrackedSyncRoot()); |
| 974 TrackedFile app_root(CreateTrackedAppRoot(sync_root, "app_id")); |
| 975 app_root.tracker.set_app_id(app_root.metadata.details().title()); |
| 976 |
| 977 TrackedFile folder_0(CreateTrackedFolder(app_root, "folder_0")); |
| 978 TrackedFile file_0(CreateTrackedFile(folder_0, "file_0")); |
| 979 |
| 980 const TrackedFile* tracked_files[] = { |
| 981 &sync_root, &app_root, &folder_0, &file_0 |
| 982 }; |
| 983 |
| 984 SetUpDatabaseByTrackedFiles(tracked_files, arraysize(tracked_files)); |
| 985 EXPECT_EQ(SYNC_STATUS_OK, InitializeMetadataDatabase()); |
| 986 VerifyTrackedFiles(tracked_files, arraysize(tracked_files)); |
| 987 |
| 988 scoped_ptr<base::ListValue> files = |
| 989 metadata_database()->DumpFiles(app_root.tracker.app_id()); |
| 990 ASSERT_EQ(2u, files->GetSize()); |
| 991 |
| 992 base::DictionaryValue* file = NULL; |
| 993 std::string str; |
| 994 |
| 995 ASSERT_TRUE(files->GetDictionary(0, &file)); |
| 996 EXPECT_TRUE(file->GetString("title", &str) && str == "folder_0"); |
| 997 EXPECT_TRUE(file->GetString("type", &str) && str == "folder"); |
| 998 EXPECT_TRUE(file->HasKey("details")); |
| 999 |
| 1000 ASSERT_TRUE(files->GetDictionary(1, &file)); |
| 1001 EXPECT_TRUE(file->GetString("title", &str) && str == "file_0"); |
| 1002 EXPECT_TRUE(file->GetString("type", &str) && str == "file"); |
| 1003 EXPECT_TRUE(file->HasKey("details")); |
| 1004 } |
| 1005 |
972 } // namespace drive_backend | 1006 } // namespace drive_backend |
973 } // namespace sync_file_system | 1007 } // namespace sync_file_system |
OLD | NEW |