1e5d0e473Sopenharmony_ci/*
2e5d0e473Sopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd.
3e5d0e473Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e5d0e473Sopenharmony_ci * you may not use this file except in compliance with the License.
5e5d0e473Sopenharmony_ci * You may obtain a copy of the License at
6e5d0e473Sopenharmony_ci *
7e5d0e473Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e5d0e473Sopenharmony_ci *
9e5d0e473Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e5d0e473Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e5d0e473Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e5d0e473Sopenharmony_ci * See the License for the specific language governing permissions and
13e5d0e473Sopenharmony_ci * limitations under the License.
14e5d0e473Sopenharmony_ci */
15e5d0e473Sopenharmony_ci
16e5d0e473Sopenharmony_ci#include "gtest/gtest.h"
17e5d0e473Sopenharmony_ci#include "iremote_object.h"
18e5d0e473Sopenharmony_ci#define private public
19e5d0e473Sopenharmony_ci#define protected public
20e5d0e473Sopenharmony_ci#include "sms_send_short_message_proxy.h"
21e5d0e473Sopenharmony_ci#include "sms_delivery_short_message_proxy.h"
22e5d0e473Sopenharmony_ci#include "mock/mock_remote_object.h"
23e5d0e473Sopenharmony_cinamespace OHOS {
24e5d0e473Sopenharmony_cinamespace Telephony {
25e5d0e473Sopenharmony_ciusing namespace testing::ext;
26e5d0e473Sopenharmony_ci
27e5d0e473Sopenharmony_ciclass SmsServiceProxyTest : public testing::Test {
28e5d0e473Sopenharmony_cipublic:
29e5d0e473Sopenharmony_ci    static void SetUpTestCase();
30e5d0e473Sopenharmony_ci    static void TearDownTestCase();
31e5d0e473Sopenharmony_ci    void SetUp();
32e5d0e473Sopenharmony_ci    void TearDown();
33e5d0e473Sopenharmony_ci};
34e5d0e473Sopenharmony_civoid SmsServiceProxyTest::SetUpTestCase() {}
35e5d0e473Sopenharmony_ci
36e5d0e473Sopenharmony_civoid SmsServiceProxyTest::TearDownTestCase() {}
37e5d0e473Sopenharmony_ci
38e5d0e473Sopenharmony_civoid SmsServiceProxyTest::SetUp() {}
39e5d0e473Sopenharmony_ci
40e5d0e473Sopenharmony_civoid SmsServiceProxyTest::TearDown() {}
41e5d0e473Sopenharmony_ci
42e5d0e473Sopenharmony_ci/**
43e5d0e473Sopenharmony_ci * @tc.number   Telephony_SmsMmsGtest_smsServiceProxyTest_001
44e5d0e473Sopenharmony_ci * @tc.name     smsServiceProxyTest_001
45e5d0e473Sopenharmony_ci * @tc.desc     Function test
46e5d0e473Sopenharmony_ci */
47e5d0e473Sopenharmony_ciHWTEST_F(SmsServiceProxyTest, smsServiceProxyTest_001, Function | MediumTest | Level1)
48e5d0e473Sopenharmony_ci{
49e5d0e473Sopenharmony_ci    sptr<IRemoteObject> sptrRemoteObject = nullptr;
50e5d0e473Sopenharmony_ci    ISendShortMessageCallback::SmsSendResult sendResult =
51e5d0e473Sopenharmony_ci        ISendShortMessageCallback::SmsSendResult::SEND_SMS_FAILURE_UNKNOWN;
52e5d0e473Sopenharmony_ci
53e5d0e473Sopenharmony_ci    SmsSendShortMessageProxy sendShortMessageProxy(sptrRemoteObject);
54e5d0e473Sopenharmony_ci    EXPECT_EQ(sendShortMessageProxy.Remote().GetRefPtr(), nullptr);
55e5d0e473Sopenharmony_ci    sendShortMessageProxy.OnSmsSendResult(sendResult);
56e5d0e473Sopenharmony_ci}
57e5d0e473Sopenharmony_ci/**
58e5d0e473Sopenharmony_ci * @tc.number   Telephony_SmsMmsGtest_smsServiceProxyTest_002
59e5d0e473Sopenharmony_ci * @tc.name     smsServiceProxyTest_001
60e5d0e473Sopenharmony_ci * @tc.desc     Function test
61e5d0e473Sopenharmony_ci */
62e5d0e473Sopenharmony_ciHWTEST_F(SmsServiceProxyTest, smsServiceProxyTest_002, Function | MediumTest | Level1)
63e5d0e473Sopenharmony_ci{
64e5d0e473Sopenharmony_ci    sptr<MockRemoteObject> sptrRemoteObject = new MockRemoteObject();
65e5d0e473Sopenharmony_ci    sptrRemoteObject->retGetObjectRefCount = 1;
66e5d0e473Sopenharmony_ci    sptrRemoteObject->retSendRequest = 0;
67e5d0e473Sopenharmony_ci
68e5d0e473Sopenharmony_ci    ISendShortMessageCallback::SmsSendResult sendResult =
69e5d0e473Sopenharmony_ci        ISendShortMessageCallback::SmsSendResult::SEND_SMS_FAILURE_UNKNOWN;
70e5d0e473Sopenharmony_ci    SmsSendShortMessageProxy sendShortMessageProxy(sptrRemoteObject);
71e5d0e473Sopenharmony_ci    EXPECT_EQ(sendShortMessageProxy.Remote().GetRefPtr(), sptrRemoteObject);
72e5d0e473Sopenharmony_ci    sendShortMessageProxy.OnSmsSendResult(sendResult);
73e5d0e473Sopenharmony_ci}
74e5d0e473Sopenharmony_ci/**
75e5d0e473Sopenharmony_ci * @tc.number   Telephony_SmsMmsGtest_smsServiceProxyTest_003
76e5d0e473Sopenharmony_ci * @tc.name     smsServiceProxyTest_001
77e5d0e473Sopenharmony_ci * @tc.desc     Function test
78e5d0e473Sopenharmony_ci */
79e5d0e473Sopenharmony_ciHWTEST_F(SmsServiceProxyTest, smsServiceProxyTest_003, Function | MediumTest | Level1)
80e5d0e473Sopenharmony_ci{
81e5d0e473Sopenharmony_ci    sptr<IRemoteObject> sptrRemoteObject = nullptr;
82e5d0e473Sopenharmony_ci    std::u16string strPdu = u"";
83e5d0e473Sopenharmony_ci    SmsDeliveryShortMessageProxy sendShortMessageProxy(sptrRemoteObject);
84e5d0e473Sopenharmony_ci    EXPECT_EQ(sendShortMessageProxy.Remote().GetRefPtr(), nullptr);
85e5d0e473Sopenharmony_ci    sendShortMessageProxy.OnSmsDeliveryResult(strPdu);
86e5d0e473Sopenharmony_ci}
87e5d0e473Sopenharmony_ci/**
88e5d0e473Sopenharmony_ci * @tc.number   Telephony_SmsMmsGtest_smsServiceProxyTest_004
89e5d0e473Sopenharmony_ci * @tc.name     smsServiceProxyTest_001
90e5d0e473Sopenharmony_ci * @tc.desc     Function test
91e5d0e473Sopenharmony_ci */
92e5d0e473Sopenharmony_ciHWTEST_F(SmsServiceProxyTest, smsServiceProxyTest_004, Function | MediumTest | Level1)
93e5d0e473Sopenharmony_ci{
94e5d0e473Sopenharmony_ci    sptr<MockRemoteObject> sptrRemoteObject = new MockRemoteObject();
95e5d0e473Sopenharmony_ci    sptrRemoteObject->retGetObjectRefCount = 1;
96e5d0e473Sopenharmony_ci    sptrRemoteObject->retSendRequest = 0;
97e5d0e473Sopenharmony_ci
98e5d0e473Sopenharmony_ci    std::u16string strPdu = u"";
99e5d0e473Sopenharmony_ci    SmsDeliveryShortMessageProxy sendShortMessageProxy(sptrRemoteObject);
100e5d0e473Sopenharmony_ci    EXPECT_EQ(sendShortMessageProxy.Remote().GetRefPtr(), sptrRemoteObject);
101e5d0e473Sopenharmony_ci    sendShortMessageProxy.OnSmsDeliveryResult(strPdu);
102e5d0e473Sopenharmony_ci}
103e5d0e473Sopenharmony_ci}
104e5d0e473Sopenharmony_ci}