diff --git a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp index 2a7ed22968b449f7a15fae136b1a8e27630a017d..e344596de3d37b023b7692f20982f1b10080014d 100644 --- a/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp +++ b/frameworks/libs/distributeddb/test/unittest/common/syncer/distributeddb_mock_sync_module_test.cpp @@ -386,16 +386,17 @@ void TimeSync001() EXPECT_CALL(*communicator, SendMessage(_, _, _, _)).WillRepeatedly(Return(DB_ERROR)); const int loopCount = 100; const int timeDriverMs = 200; + std::shared_ptr timeSync = std::make_shared(); for (int i = 0; i < loopCount; ++i) { - MockTimeSync timeSync; - EXPECT_EQ(timeSync.Initialize(communicator, metadata, storage, "DEVICES_A", ""), E_OK); - EXPECT_CALL(timeSync, SyncStart).WillRepeatedly(Return(E_OK)); - timeSync.ModifyTimer(timeDriverMs); + EXPECT_EQ(timeSync->Initialize(communicator, metadata, storage, "DEVICES_A", ""), E_OK); + EXPECT_CALL(*timeSync, SyncStart(_, _, _)).WillRepeatedly(Return(E_OK)); + timeSync->ModifyTimer(timeDriverMs); std::this_thread::sleep_for(std::chrono::milliseconds(timeDriverMs)); - timeSync.Close(); + timeSync->Close(); } std::this_thread::sleep_for(std::chrono::seconds(1)); metadata = nullptr; + timeSync = nullptr; delete storage; delete communicator; }