| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Returns a map from metahandle -> expected time (as a Time object). | 282 // Returns a map from metahandle -> expected time (as a Time object). |
| 283 std::map<int64, base::Time> GetExpectedMetaTimes() { | 283 std::map<int64, base::Time> GetExpectedMetaTimes() { |
| 284 std::map<int64, base::Time> expected_meta_times; | 284 std::map<int64, base::Time> expected_meta_times; |
| 285 const std::map<int64, int64>& expected_meta_proto_times = | 285 const std::map<int64, int64>& expected_meta_proto_times = |
| 286 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS); | 286 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS); |
| 287 for (std::map<int64, int64>::const_iterator it = | 287 for (std::map<int64, int64>::const_iterator it = |
| 288 expected_meta_proto_times.begin(); | 288 expected_meta_proto_times.begin(); |
| 289 it != expected_meta_proto_times.end(); ++it) { | 289 it != expected_meta_proto_times.end(); ++it) { |
| 290 expected_meta_times[it->first] = | 290 expected_meta_times[it->first] = ProtoTimeToTime(it->second); |
| 291 syncer::ProtoTimeToTime(it->second); | |
| 292 } | 291 } |
| 293 return expected_meta_times; | 292 return expected_meta_times; |
| 294 } | 293 } |
| 295 | 294 |
| 296 // Extracts a map from metahandle -> time (in proto format) from the | 295 // Extracts a map from metahandle -> time (in proto format) from the |
| 297 // given database. | 296 // given database. |
| 298 std::map<int64, int64> GetMetaProtoTimes(sql::Connection *db) { | 297 std::map<int64, int64> GetMetaProtoTimes(sql::Connection *db) { |
| 299 sql::Statement s(db->GetCachedStatement( | 298 sql::Statement s(db->GetCachedStatement( |
| 300 SQL_FROM_HERE, | 299 SQL_FROM_HERE, |
| 301 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime " | 300 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime " |
| (...skipping 19 matching lines...) Expand all Loading... |
| 321 const char* t2_expr, | 320 const char* t2_expr, |
| 322 const base::Time& t1, | 321 const base::Time& t1, |
| 323 const base::Time& t2) { | 322 const base::Time& t2) { |
| 324 if (t1 == t2) | 323 if (t1 == t2) |
| 325 return ::testing::AssertionSuccess(); | 324 return ::testing::AssertionSuccess(); |
| 326 | 325 |
| 327 return ::testing::AssertionFailure() | 326 return ::testing::AssertionFailure() |
| 328 << t1_expr << " and " << t2_expr | 327 << t1_expr << " and " << t2_expr |
| 329 << " (internal values: " << t1.ToInternalValue() | 328 << " (internal values: " << t1.ToInternalValue() |
| 330 << " and " << t2.ToInternalValue() | 329 << " and " << t2.ToInternalValue() |
| 331 << ") (proto time: " << syncer::TimeToProtoTime(t1) | 330 << ") (proto time: " << TimeToProtoTime(t1) |
| 332 << " and " << syncer::TimeToProtoTime(t2) | 331 << " and " << TimeToProtoTime(t2) |
| 333 << ") do not match"; | 332 << ") do not match"; |
| 334 } | 333 } |
| 335 | 334 |
| 336 // Expect that all time fields of the given entry kernel will be the | 335 // Expect that all time fields of the given entry kernel will be the |
| 337 // given time. | 336 // given time. |
| 338 void ExpectTime(const EntryKernel& entry_kernel, | 337 void ExpectTime(const EntryKernel& entry_kernel, |
| 339 const base::Time& expected_time) { | 338 const base::Time& expected_time) { |
| 340 EXPECT_PRED_FORMAT2(AssertTimesMatch, | 339 EXPECT_PRED_FORMAT2(AssertTimesMatch, |
| 341 expected_time, entry_kernel.ref(CTIME)); | 340 expected_time, entry_kernel.ref(CTIME)); |
| 342 EXPECT_PRED_FORMAT2(AssertTimesMatch, | 341 EXPECT_PRED_FORMAT2(AssertTimesMatch, |
| (...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 ASSERT_FALSE(connection.DoesColumnExist("share_info", | 1944 ASSERT_FALSE(connection.DoesColumnExist("share_info", |
| 1946 "autofill_entries_added_during_migration")); | 1945 "autofill_entries_added_during_migration")); |
| 1947 ASSERT_FALSE(connection.DoesColumnExist("share_info", | 1946 ASSERT_FALSE(connection.DoesColumnExist("share_info", |
| 1948 "autofill_profiles_added_during_migration")); | 1947 "autofill_profiles_added_during_migration")); |
| 1949 | 1948 |
| 1950 // Column added in version 78. | 1949 // Column added in version 78. |
| 1951 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics")); | 1950 ASSERT_TRUE(connection.DoesColumnExist("metas", "base_server_specifics")); |
| 1952 | 1951 |
| 1953 // Check download_progress state (v75 migration) | 1952 // Check download_progress state (v75 migration) |
| 1954 ASSERT_EQ(694, | 1953 ASSERT_EQ(694, |
| 1955 dir_info.kernel_info.download_progress[syncer::BOOKMARKS] | 1954 dir_info.kernel_info.download_progress[BOOKMARKS] |
| 1956 .timestamp_token_for_migration()); | 1955 .timestamp_token_for_migration()); |
| 1957 ASSERT_FALSE( | 1956 ASSERT_FALSE( |
| 1958 dir_info.kernel_info.download_progress[syncer::BOOKMARKS] | 1957 dir_info.kernel_info.download_progress[BOOKMARKS] |
| 1959 .has_token()); | 1958 .has_token()); |
| 1960 ASSERT_EQ(32904, | 1959 ASSERT_EQ(32904, |
| 1961 dir_info.kernel_info.download_progress[syncer::BOOKMARKS] | 1960 dir_info.kernel_info.download_progress[BOOKMARKS] |
| 1962 .data_type_id()); | 1961 .data_type_id()); |
| 1963 ASSERT_FALSE( | 1962 ASSERT_FALSE( |
| 1964 dir_info.kernel_info.download_progress[syncer::THEMES] | 1963 dir_info.kernel_info.download_progress[THEMES] |
| 1965 .has_timestamp_token_for_migration()); | 1964 .has_timestamp_token_for_migration()); |
| 1966 ASSERT_TRUE( | 1965 ASSERT_TRUE( |
| 1967 dir_info.kernel_info.download_progress[syncer::THEMES] | 1966 dir_info.kernel_info.download_progress[THEMES] |
| 1968 .has_token()); | 1967 .has_token()); |
| 1969 ASSERT_TRUE( | 1968 ASSERT_TRUE( |
| 1970 dir_info.kernel_info.download_progress[syncer::THEMES] | 1969 dir_info.kernel_info.download_progress[THEMES] |
| 1971 .token().empty()); | 1970 .token().empty()); |
| 1972 ASSERT_EQ(41210, | 1971 ASSERT_EQ(41210, |
| 1973 dir_info.kernel_info.download_progress[syncer::THEMES] | 1972 dir_info.kernel_info.download_progress[THEMES] |
| 1974 .data_type_id()); | 1973 .data_type_id()); |
| 1975 | 1974 |
| 1976 // Check metas | 1975 // Check metas |
| 1977 EXPECT_EQ(GetExpectedMetaProtoTimes(DONT_INCLUDE_DELETED_ITEMS), | 1976 EXPECT_EQ(GetExpectedMetaProtoTimes(DONT_INCLUDE_DELETED_ITEMS), |
| 1978 GetMetaProtoTimes(&connection)); | 1977 GetMetaProtoTimes(&connection)); |
| 1979 ExpectTimes(index, GetExpectedMetaTimes()); | 1978 ExpectTimes(index, GetExpectedMetaTimes()); |
| 1980 | 1979 |
| 1981 MetahandlesIndex::iterator it = index.begin(); | 1980 MetahandlesIndex::iterator it = index.begin(); |
| 1982 ASSERT_TRUE(it != index.end()); | 1981 ASSERT_TRUE(it != index.end()); |
| 1983 ASSERT_EQ(1, (*it)->ref(META_HANDLE)); | 1982 ASSERT_EQ(1, (*it)->ref(META_HANDLE)); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); | 2153 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); |
| 2155 EXPECT_EQ(24U, guid1.size()); | 2154 EXPECT_EQ(24U, guid1.size()); |
| 2156 EXPECT_EQ(24U, guid2.size()); | 2155 EXPECT_EQ(24U, guid2.size()); |
| 2157 // In theory this test can fail, but it won't before the universe | 2156 // In theory this test can fail, but it won't before the universe |
| 2158 // dies of heat death. | 2157 // dies of heat death. |
| 2159 EXPECT_NE(guid1, guid2); | 2158 EXPECT_NE(guid1, guid2); |
| 2160 } | 2159 } |
| 2161 | 2160 |
| 2162 } // namespace syncable | 2161 } // namespace syncable |
| 2163 } // namespace syncer | 2162 } // namespace syncer |
| OLD | NEW |