| 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 // Returns a map from metahandle -> expected time (as a Time object). | 281 // Returns a map from metahandle -> expected time (as a Time object). |
| 282 std::map<int64, base::Time> GetExpectedMetaTimes() { | 282 std::map<int64, base::Time> GetExpectedMetaTimes() { |
| 283 std::map<int64, base::Time> expected_meta_times; | 283 std::map<int64, base::Time> expected_meta_times; |
| 284 const std::map<int64, int64>& expected_meta_proto_times = | 284 const std::map<int64, int64>& expected_meta_proto_times = |
| 285 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS); | 285 GetExpectedMetaProtoTimes(INCLUDE_DELETED_ITEMS); |
| 286 for (std::map<int64, int64>::const_iterator it = | 286 for (std::map<int64, int64>::const_iterator it = |
| 287 expected_meta_proto_times.begin(); | 287 expected_meta_proto_times.begin(); |
| 288 it != expected_meta_proto_times.end(); ++it) { | 288 it != expected_meta_proto_times.end(); ++it) { |
| 289 expected_meta_times[it->first] = | 289 expected_meta_times[it->first] = |
| 290 csync::ProtoTimeToTime(it->second); | 290 syncer::ProtoTimeToTime(it->second); |
| 291 } | 291 } |
| 292 return expected_meta_times; | 292 return expected_meta_times; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Extracts a map from metahandle -> time (in proto format) from the | 295 // Extracts a map from metahandle -> time (in proto format) from the |
| 296 // given database. | 296 // given database. |
| 297 std::map<int64, int64> GetMetaProtoTimes(sql::Connection *db) { | 297 std::map<int64, int64> GetMetaProtoTimes(sql::Connection *db) { |
| 298 sql::Statement s(db->GetCachedStatement( | 298 sql::Statement s(db->GetCachedStatement( |
| 299 SQL_FROM_HERE, | 299 SQL_FROM_HERE, |
| 300 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime " | 300 "SELECT metahandle, mtime, server_mtime, ctime, server_ctime " |
| (...skipping 19 matching lines...) Expand all Loading... |
| 320 const char* t2_expr, | 320 const char* t2_expr, |
| 321 const base::Time& t1, | 321 const base::Time& t1, |
| 322 const base::Time& t2) { | 322 const base::Time& t2) { |
| 323 if (t1 == t2) | 323 if (t1 == t2) |
| 324 return ::testing::AssertionSuccess(); | 324 return ::testing::AssertionSuccess(); |
| 325 | 325 |
| 326 return ::testing::AssertionFailure() | 326 return ::testing::AssertionFailure() |
| 327 << t1_expr << " and " << t2_expr | 327 << t1_expr << " and " << t2_expr |
| 328 << " (internal values: " << t1.ToInternalValue() | 328 << " (internal values: " << t1.ToInternalValue() |
| 329 << " and " << t2.ToInternalValue() | 329 << " and " << t2.ToInternalValue() |
| 330 << ") (proto time: " << csync::TimeToProtoTime(t1) | 330 << ") (proto time: " << syncer::TimeToProtoTime(t1) |
| 331 << " and " << csync::TimeToProtoTime(t2) | 331 << " and " << syncer::TimeToProtoTime(t2) |
| 332 << ") do not match"; | 332 << ") do not match"; |
| 333 } | 333 } |
| 334 | 334 |
| 335 // 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 |
| 336 // given time. | 336 // given time. |
| 337 void ExpectTime(const EntryKernel& entry_kernel, | 337 void ExpectTime(const EntryKernel& entry_kernel, |
| 338 const base::Time& expected_time) { | 338 const base::Time& expected_time) { |
| 339 EXPECT_PRED_FORMAT2(AssertTimesMatch, | 339 EXPECT_PRED_FORMAT2(AssertTimesMatch, |
| 340 expected_time, entry_kernel.ref(CTIME)); | 340 expected_time, entry_kernel.ref(CTIME)); |
| 341 EXPECT_PRED_FORMAT2(AssertTimesMatch, | 341 EXPECT_PRED_FORMAT2(AssertTimesMatch, |
| (...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2152 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID(); | 2152 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID(); |
| 2153 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); | 2153 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); |
| 2154 EXPECT_EQ(24U, guid1.size()); | 2154 EXPECT_EQ(24U, guid1.size()); |
| 2155 EXPECT_EQ(24U, guid2.size()); | 2155 EXPECT_EQ(24U, guid2.size()); |
| 2156 // 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 |
| 2157 // dies of heat death. | 2157 // dies of heat death. |
| 2158 EXPECT_NE(guid1, guid2); | 2158 EXPECT_NE(guid1, guid2); |
| 2159 } | 2159 } |
| 2160 | 2160 |
| 2161 } // namespace syncable | 2161 } // namespace syncable |
| OLD | NEW |