1/*
2 * Copyright (c) 2024 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 "gtest/gtest.h"
17#include "ability_kit.h"
18#define private public
19#include "VirtualMessageImpl.h"
20
21namespace {
22    int32_t MessageSuccessCallback(const void *data)
23    {
24        return 0;
25    }
26
27    int32_t MessageFailCallback(const void *data, uint16_t dataLength, uint16_t errorCode)
28    {
29        return 0;
30    }
31
32    TEST(AblityKitTest, RegisterReceiverTest)
33    {
34        int32_t ret = OHOS::AbilityKit::RegisterReceiver("testBundleName",
35            MessageSuccessCallback, MessageFailCallback, 0, 0, 0);
36        EXPECT_FALSE(VirtualMessageImpl::GetInstance().callBacks.empty());
37        EXPECT_EQ(ret, 0);
38    }
39
40    TEST(AblityKitTest, UnregisterReceiverTest)
41    {
42        int32_t ret = OHOS::AbilityKit::UnregisterReceiver("testBundleName");
43        EXPECT_TRUE(VirtualMessageImpl::GetInstance().callBacks.empty());
44        EXPECT_EQ(ret, 0);
45    }
46
47    TEST(AblityKitTest, SendMsgToPeerAppTest)
48    {
49        int32_t ret = OHOS::AbilityKit::SendMsgToPeerApp(false, "", "", 0, 0, 0, 0, 0);
50        EXPECT_EQ(ret, 0);
51    }
52
53    TEST(AblityKitTest, DetectPhoneAppTest)
54    {
55        int32_t ret = OHOS::AbilityKit::DetectPhoneApp("", "", 0, 0, 0);
56        EXPECT_EQ(ret, 0);
57    }
58
59    TEST(AblityKitTest, DetectResourceReleaseTest)
60    {
61        int32_t ret = OHOS::AbilityKit::DetectResourceRelease();
62        EXPECT_EQ(ret, 0);
63    }
64
65    TEST(AblityKitTest, SendMsgResourceReleaseTest)
66    {
67        int32_t ret = OHOS::AbilityKit::SendMsgResourceRelease();
68        EXPECT_EQ(ret, 0);
69    }
70}