Chromium Code Reviews| Index: components/reading_list/ios/reading_list_store_unittest.mm |
| diff --git a/components/reading_list/ios/reading_list_store_unittest.mm b/components/reading_list/ios/reading_list_store_unittest.mm |
| index d3ac94fc3730d33dea0664ee348b7cd69f843555..ade97da9ce2cf7d3a0e28c73794375b9d5cbc1f2 100644 |
| --- a/components/reading_list/ios/reading_list_store_unittest.mm |
| +++ b/components/reading_list/ios/reading_list_store_unittest.mm |
| @@ -255,13 +255,13 @@ TEST_F(ReadingListStoreTest, ApplySyncChangesOneMerge) { |
| TEST_F(ReadingListStoreTest, ApplySyncChangesOneIgnored) { |
| // Read entry but with unread URL as it must update the other one. |
| ReadingListEntry old_entry(GURL("http://unread.example.com/"), |
| - "unread title"); |
| + "old unread title"); |
| old_entry.SetRead(true); |
| base::test::ios::SpinRunLoopWithMinDelay( |
| base::TimeDelta::FromMilliseconds(10)); |
| syncer::EntityDataMap remote_input; |
| - model_->AddEntry(GURL("http://unread.example.com/"), "unread title"); |
| + model_->AddEntry(GURL("http://unread.example.com/"), "new unread title"); |
| AssertCounts(0, 0, 0, 0, 0); |
| std::unique_ptr<sync_pb::ReadingListSpecifics> specifics = |
| @@ -275,8 +275,10 @@ TEST_F(ReadingListStoreTest, ApplySyncChangesOneIgnored) { |
| "http://unread.example.com/", data.PassToPtr())); |
| syncer::SyncError error = reading_list_store_->ApplySyncChanges( |
|
gambard
2016/12/07 10:28:49
Do you need the |error| variable?
|
| reading_list_store_->CreateMetadataChangeList(), add_changes); |
| - AssertCounts(1, 0, 0, 0, 0); |
| - EXPECT_EQ(sync_merged_.size(), 0u); |
| + AssertCounts(1, 0, 0, 0, 1); |
| + EXPECT_EQ(sync_merged_.size(), 1u); |
| + EXPECT_EQ(model_->GetEntryByURL(GURL("http://unread.example.com/"))->Title(), |
| + "new unread title"); |
| } |
| TEST_F(ReadingListStoreTest, ApplySyncChangesOneRemove) { |
| @@ -289,3 +291,68 @@ TEST_F(ReadingListStoreTest, ApplySyncChangesOneRemove) { |
| EXPECT_EQ(sync_removed_.size(), 1u); |
| EXPECT_EQ(sync_removed_.count("http://read.example.com/"), 1u); |
| } |
| + |
| +TEST_F(ReadingListStoreTest, CompareEntriesForSync) { |
| + sync_pb::ReadingListSpecifics entryA; |
| + sync_pb::ReadingListSpecifics entryB; |
| + entryA.set_url("http://foo.bar"); |
| + entryB.set_url("http://foo.bar"); |
| + entryA.set_title("Foo Bar"); |
| + entryB.set_title("Foo Bar"); |
| + entryA.set_status(sync_pb::ReadingListSpecifics::UNREAD); |
| + entryB.set_status(sync_pb::ReadingListSpecifics::UNREAD); |
| + entryA.set_creation_time_us(10); |
| + entryB.set_creation_time_us(10); |
| + entryA.set_update_time_us(100); |
| + entryB.set_update_time_us(100); |
| + // Equal entries can be submitted. |
| + EXPECT_TRUE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_TRUE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + |
| + // Try to update each field. |
| + entryA.set_url("http://foo.foo"); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_update_time_us(110); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_TRUE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_url("http://foo.bar"); |
| + entryA.set_update_time_us(100); |
| + |
| + entryA.set_title("foo bar"); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_update_time_us(110); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_TRUE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_title("Foo Bar"); |
| + entryA.set_update_time_us(100); |
| + |
| + entryA.set_creation_time_us(15); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_update_time_us(110); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_TRUE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_creation_time_us(10); |
| + entryA.set_update_time_us(100); |
| + |
| + entryA.set_status(sync_pb::ReadingListSpecifics::READ); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_update_time_us(110); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_TRUE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_status(sync_pb::ReadingListSpecifics::UNREAD); |
| + entryA.set_update_time_us(100); |
| + |
| + entryA.set_status(sync_pb::ReadingListSpecifics::UNSEEN); |
| + // Special case UNSEEN -> SEEN status |
| + EXPECT_TRUE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_update_time_us(110); |
| + EXPECT_FALSE(ReadingListStore::CompareEntriesForSync(entryA, entryB)); |
| + EXPECT_TRUE(ReadingListStore::CompareEntriesForSync(entryB, entryA)); |
| + entryA.set_status(sync_pb::ReadingListSpecifics::UNREAD); |
| + entryA.set_update_time_us(100); |
| +} |