[gnote] Add test for note modification conflict



commit 2310f36b29ad9b25000adffa3d0ae6fa1e980ca1
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Oct 21 17:33:16 2018 +0300

    Add test for note modification conflict

 src/test/unit/syncmanagerutests.cpp | 39 +++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
---
diff --git a/src/test/unit/syncmanagerutests.cpp b/src/test/unit/syncmanagerutests.cpp
index b54b35d2..a9e2c598 100644
--- a/src/test/unit/syncmanagerutests.cpp
+++ b/src/test/unit/syncmanagerutests.cpp
@@ -289,5 +289,44 @@ SUITE(SyncManagerTests)
     CHECK(find_note(files, "note3"));
     CHECK(!find_note(files, "note2"));
   }
+
+  TEST_FIXTURE(Fixture, note_modification_conflict)
+  {
+    // first sync
+    test::SyncClient::Ptr sync_client1 = 
dynamic_pointer_cast<test::SyncClient>(sync_manager1->get_client(manifest1));
+    gnote::sync::SilentUI::Ptr sync_ui1 = gnote::sync::SilentUI::create(*manager1);
+    sync_manager1->perform_synchronization(sync_ui1);
+
+    // sync from existing
+    test::SyncClient::Ptr sync_client2 = 
dynamic_pointer_cast<test::SyncClient>(sync_manager2->get_client(manifest2));
+    gnote::sync::SilentUI::Ptr sync_ui2 = gnote::sync::SilentUI::create(*manager2);
+    sync_manager2->perform_synchronization(sync_ui2);
+
+    // update note and sync again
+    auto note = std::dynamic_pointer_cast<test::Note>(manager1->find("note2"));
+    note->set_xml_content(make_note_content("note4", "updated content"));
+    note->set_change_type(gnote::CONTENT_CHANGED);
+    note->save();
+    sync_client1->reparse();
+    sync_manager1->perform_synchronization(sync_ui1);
+
+    // update other clinet and sync
+    note = std::dynamic_pointer_cast<test::Note>(manager2->find("note2"));
+    note->set_xml_content(make_note_content("note5", "content updated"));
+    note->set_change_type(gnote::CONTENT_CHANGED);
+    note->save();
+    sync_client2->reparse();
+    sync_manager2->perform_synchronization(sync_ui1);
+
+    // sync client1 again
+    sync_manager1->perform_synchronization(sync_ui1);
+    std::list<Glib::ustring> files;
+    sharp::directory_get_files_with_ext(notesdir2, ".note", files);
+    REQUIRE CHECK_EQUAL(4, files.size()); // 3 downloaded notes + template
+    CHECK(find_note(files, "note1"));
+    CHECK(find_note(files, "note3"));
+    CHECK(!find_note(files, "note2"));
+    CHECK(find_note(files, "note4"));
+  }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]