• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "rdb_service_proxy.h"
17 
18 #include <gtest/gtest.h>
19 
20 #include "rdb_manager_impl.h"
21 #include "rdb_service.h"
22 #include "rdb_types.h"
23 
24 using namespace testing::ext;
25 using namespace OHOS::DistributedRdb;
26 namespace Test {
27 class RdbServiceProxyTest : public testing::Test {
28 public:
SetUpTestCase(void)29     static void SetUpTestCase(void){};
TearDownTestCase(void)30     static void TearDownTestCase(void){};
SetUp(void)31     void SetUp(void){};
TearDown(void)32     void TearDown(void){};
33 };
34 
35 /**
36  * @tc.name: OnRemoteDeadSyncComplete
37  * @tc.desc: OnRemoteDeadSyncComplete callback is executed
38  * @tc.type: FUNC
39  */
40 HWTEST_F(RdbServiceProxyTest, OnRemoteDeadSyncComplete, TestSize.Level1)
41 {
42     RdbSyncerParam param;
43     param.bundleName_ = "com.example.test";
44     param.storeName_ = "test.db";
45     auto [status, service] = RdbManagerImpl::GetInstance().GetRdbService(param);
46     ASSERT_NE(service, nullptr);
47 
__anon5a9be97d0102(const Details &details) 48     auto callback = [](const Details &details) {
49         ASSERT_NE(details.size(), 0);
50         EXPECT_TRUE(details.begin()->first.empty());
51         EXPECT_EQ(details.begin()->second.progress, Progress::SYNC_FINISH);
52         EXPECT_EQ(details.begin()->second.code, ProgressCode::UNKNOWN_ERROR);
53     };
54 
55     RdbService::Option option;
56     option.seqNum = 1;
57     auto proxy = std::static_pointer_cast<RdbServiceProxy>(service);
58     ASSERT_NE(proxy, nullptr);
59     proxy->syncCallbacks_.Insert(option.seqNum, callback);
60     proxy->OnRemoteDeadSyncComplete();
61 }
62 } // namespace Test