| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/engine/syncer_util.h" | 5 #include "components/sync/engine_impl/syncer_util.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "sync/internal_api/public/base/unique_position.h" | 12 #include "components/sync/base/unique_position.h" |
| 13 #include "sync/internal_api/public/test/test_entry_factory.h" | 13 #include "components/sync/core/test/test_entry_factory.h" |
| 14 #include "sync/protocol/sync.pb.h" | 14 #include "components/sync/protocol/sync.pb.h" |
| 15 #include "sync/syncable/mutable_entry.h" | 15 #include "components/sync/syncable/mutable_entry.h" |
| 16 #include "sync/syncable/syncable_write_transaction.h" | 16 #include "components/sync/syncable/syncable_write_transaction.h" |
| 17 #include "sync/test/engine/test_directory_setter_upper.h" | 17 #include "components/sync/test/engine/test_directory_setter_upper.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace syncer { | 20 namespace syncer { |
| 21 | 21 |
| 22 class GetUpdatePositionTest : public ::testing::Test { | 22 class GetUpdatePositionTest : public ::testing::Test { |
| 23 public: | 23 public: |
| 24 void SetUp() override { | 24 void SetUp() override { |
| 25 dir_maker_.SetUp(); | 25 dir_maker_.SetUp(); |
| 26 entry_factory_.reset(new TestEntryFactory(directory())); | 26 entry_factory_.reset(new TestEntryFactory(directory())); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void TearDown() override { dir_maker_.TearDown(); } | 29 void TearDown() override { dir_maker_.TearDown(); } |
| 30 | 30 |
| 31 syncable::Directory* directory() { | 31 syncable::Directory* directory() { return dir_maker_.directory(); } |
| 32 return dir_maker_.directory(); | |
| 33 } | |
| 34 | 32 |
| 35 TestEntryFactory* entry_factory() { | 33 TestEntryFactory* entry_factory() { return entry_factory_.get(); } |
| 36 return entry_factory_.get(); | |
| 37 } | |
| 38 | 34 |
| 39 GetUpdatePositionTest() { | 35 GetUpdatePositionTest() { |
| 40 InitUpdate(); | 36 InitUpdate(); |
| 41 | 37 |
| 42 // Init test_position to some valid position value, but don't assign | 38 // Init test_position to some valid position value, but don't assign |
| 43 // it to the update just yet. | 39 // it to the update just yet. |
| 44 std::string pos_suffix = UniquePosition::RandomSuffix(); | 40 std::string pos_suffix = UniquePosition::RandomSuffix(); |
| 45 test_position = UniquePosition::InitialPosition(pos_suffix); | 41 test_position = UniquePosition::InitialPosition(pos_suffix); |
| 46 } | 42 } |
| 47 | 43 |
| 48 void InitUpdate() { | 44 void InitUpdate() { |
| 49 update.set_id_string("I"); | 45 update.set_id_string("I"); |
| 50 update.set_parent_id_string("P"); | 46 update.set_parent_id_string("P"); |
| 51 update.set_version(10); | 47 update.set_version(10); |
| 52 update.set_mtime(100); | 48 update.set_mtime(100); |
| 53 update.set_ctime(100); | 49 update.set_ctime(100); |
| 54 update.set_deleted(false); | 50 update.set_deleted(false); |
| 55 update.mutable_specifics()->mutable_bookmark()->set_title("Chrome"); | 51 update.mutable_specifics()->mutable_bookmark()->set_title("Chrome"); |
| 56 update.mutable_specifics()->mutable_bookmark()-> | 52 update.mutable_specifics()->mutable_bookmark()->set_url( |
| 57 set_url("https://www.chrome.com"); | 53 "https://www.chrome.com"); |
| 58 } | 54 } |
| 59 | 55 |
| 60 void InitSuffixIngredients() { | 56 void InitSuffixIngredients() { |
| 61 update.set_originator_cache_guid("CacheGUID"); | 57 update.set_originator_cache_guid("CacheGUID"); |
| 62 update.set_originator_client_item_id("OrigID"); | 58 update.set_originator_client_item_id("OrigID"); |
| 63 } | 59 } |
| 64 | 60 |
| 65 void InitProtoPosition() { | 61 void InitProtoPosition() { |
| 66 test_position.ToProto(update.mutable_unique_position()); | 62 test_position.ToProto(update.mutable_unique_position()); |
| 67 } | 63 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 EXPECT_FALSE(UniquePosition::IsValidSuffix(target.GetUniqueBookmarkTag())); | 221 EXPECT_FALSE(UniquePosition::IsValidSuffix(target.GetUniqueBookmarkTag())); |
| 226 EXPECT_FALSE(target.GetServerUniquePosition().IsValid()); | 222 EXPECT_FALSE(target.GetServerUniquePosition().IsValid()); |
| 227 UpdateServerFieldsFromUpdate(&target, invalid_update, "name"); | 223 UpdateServerFieldsFromUpdate(&target, invalid_update, "name"); |
| 228 | 224 |
| 229 // After update, target has valid bookmark tag and unique position. | 225 // After update, target has valid bookmark tag and unique position. |
| 230 EXPECT_TRUE(UniquePosition::IsValidSuffix(target.GetUniqueBookmarkTag())); | 226 EXPECT_TRUE(UniquePosition::IsValidSuffix(target.GetUniqueBookmarkTag())); |
| 231 EXPECT_TRUE(target.GetServerUniquePosition().IsValid()); | 227 EXPECT_TRUE(target.GetServerUniquePosition().IsValid()); |
| 232 } | 228 } |
| 233 | 229 |
| 234 } // namespace syncer | 230 } // namespace syncer |
| OLD | NEW |