From 6ad173095e02bf7e41bff6d48b3d279254ac19a7 Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Mon, 19 Feb 2018 11:35:24 +0300 Subject: [PATCH] Review fixes --- ugc/ugc_tests/storage_tests.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ugc/ugc_tests/storage_tests.cpp b/ugc/ugc_tests/storage_tests.cpp index 9a1792c155..918acdedd3 100644 --- a/ugc/ugc_tests/storage_tests.cpp +++ b/ugc/ugc_tests/storage_tests.cpp @@ -376,3 +376,32 @@ UNIT_CLASS_TEST(StorageTest, DifferentUGCVersions) fromOld.BuildFrom(oldUGC); TEST_EQUAL(fromOld, storage.GetUGCUpdate(firstId), ()); } + +UNIT_CLASS_TEST(StorageTest, NumberOfUnsynchronized) +{ + auto & builder = MwmBuilder::Builder(); + m2::PointD const cafePoint(1.0, 1.0); + builder.Build({TestCafe(cafePoint)}); + auto const cafeId = builder.FeatureIdForCafeAtPoint(cafePoint); + auto const cafeUGC = MakeTestUGCUpdate(Time(chrono::hours(24 * 10))); + + { + Storage storage(builder.GetIndex()); + storage.Load(); + TEST_EQUAL(storage.SetUGCUpdate(cafeId, cafeUGC), Storage::SettingResult::Success, ()); + storage.SaveIndex(); + } + + Storage storage(builder.GetIndex()); + storage.Load(); + TEST_EQUAL(storage.GetNumberOfUnsynchronized(), 1, ()); + + TEST_EQUAL(storage.SetUGCUpdate(cafeId, cafeUGC), Storage::SettingResult::Success, ()); + TEST_EQUAL(storage.GetNumberOfUnsynchronized(), 1, ()); + TEST_EQUAL(storage.GetNumberOfDeletedForTesting(), 1, ()); + + storage.MarkAllAsSynchronized(); + TEST_EQUAL(storage.GetNumberOfUnsynchronized(), 0, ()); + + TEST(DeleteIndexFile(), ()); +}