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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/sync_file_system/drive_backend/drive_backend_test_util.h" 6 7 #include <set> 8 9 #include "chrome/browser/drive/drive_api_util.h" 10 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.h" 11 #include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h" 12 #include "google_apis/drive/drive_api_parser.h" 13 #include "google_apis/drive/drive_entry_kinds.h" 14 #include "google_apis/drive/gdata_wapi_parser.h" 15 #include "testing/gtest/include/gtest/gtest.h" 16 17 namespace sync_file_system { 18 namespace drive_backend { 19 namespace test_util { 20 21 void ExpectEquivalentServiceMetadata(const ServiceMetadata& left, 22 const ServiceMetadata& right) { 23 EXPECT_EQ(left.largest_change_id(), right.largest_change_id()); 24 EXPECT_EQ(left.sync_root_tracker_id(), right.sync_root_tracker_id()); 25 EXPECT_EQ(left.next_tracker_id(), right.next_tracker_id()); 26 } 27 28 void ExpectEquivalentDetails(const FileDetails& left, 29 const FileDetails& right) { 30 std::set<std::string> parents; 31 for (int i = 0; i < left.parent_folder_ids_size(); ++i) 32 EXPECT_TRUE(parents.insert(left.parent_folder_ids(i)).second); 33 34 for (int i = 0; i < right.parent_folder_ids_size(); ++i) 35 EXPECT_EQ(1u, parents.erase(left.parent_folder_ids(i))); 36 EXPECT_TRUE(parents.empty()); 37 38 EXPECT_EQ(left.title(), right.title()); 39 EXPECT_EQ(left.file_kind(), right.file_kind()); 40 EXPECT_EQ(left.md5(), right.md5()); 41 EXPECT_EQ(left.etag(), right.etag()); 42 EXPECT_EQ(left.creation_time(), right.creation_time()); 43 EXPECT_EQ(left.modification_time(), right.modification_time()); 44 EXPECT_EQ(left.missing(), right.missing()); 45 EXPECT_EQ(left.change_id(), right.change_id()); 46 } 47 48 void ExpectEquivalentMetadata(const FileMetadata& left, 49 const FileMetadata& right) { 50 EXPECT_EQ(left.file_id(), right.file_id()); 51 ExpectEquivalentDetails(left.details(), right.details()); 52 } 53 54 void ExpectEquivalentTrackers(const FileTracker& left, 55 const FileTracker& right) { 56 EXPECT_EQ(left.tracker_id(), right.tracker_id()); 57 EXPECT_EQ(left.parent_tracker_id(), right.parent_tracker_id()); 58 EXPECT_EQ(left.file_id(), right.file_id()); 59 EXPECT_EQ(left.app_id(), right.app_id()); 60 EXPECT_EQ(left.tracker_kind(), right.tracker_kind()); 61 ExpectEquivalentDetails(left.synced_details(), right.synced_details()); 62 EXPECT_EQ(left.dirty(), right.dirty()); 63 EXPECT_EQ(left.active(), right.active()); 64 EXPECT_EQ(left.needs_folder_listing(), right.needs_folder_listing()); 65 } 66 67 } // namespace test_util 68 } // namespace drive_backend 69 } // namespace sync_file_system 70