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 "iremote_object.h" 18#define private public 19#define protected public 20#include "sms_send_short_message_proxy.h" 21#include "sms_delivery_short_message_proxy.h" 22#include "mock/mock_remote_object.h" 23namespace OHOS { 24namespace Telephony { 25using namespace testing::ext; 26 27class SmsServiceProxyTest : public testing::Test { 28public: 29 static void SetUpTestCase(); 30 static void TearDownTestCase(); 31 void SetUp(); 32 void TearDown(); 33}; 34void SmsServiceProxyTest::SetUpTestCase() {} 35 36void SmsServiceProxyTest::TearDownTestCase() {} 37 38void SmsServiceProxyTest::SetUp() {} 39 40void SmsServiceProxyTest::TearDown() {} 41 42/** 43 * @tc.number Telephony_SmsMmsGtest_smsServiceProxyTest_001 44 * @tc.name smsServiceProxyTest_001 45 * @tc.desc Function test 46 */ 47HWTEST_F(SmsServiceProxyTest, smsServiceProxyTest_001, Function | MediumTest | Level1) 48{ 49 sptr<IRemoteObject> sptrRemoteObject = nullptr; 50 ISendShortMessageCallback::SmsSendResult sendResult = 51 ISendShortMessageCallback::SmsSendResult::SEND_SMS_FAILURE_UNKNOWN; 52 53 SmsSendShortMessageProxy sendShortMessageProxy(sptrRemoteObject); 54 EXPECT_EQ(sendShortMessageProxy.Remote().GetRefPtr(), nullptr); 55 sendShortMessageProxy.OnSmsSendResult(sendResult); 56} 57/** 58 * @tc.number Telephony_SmsMmsGtest_smsServiceProxyTest_002 59 * @tc.name smsServiceProxyTest_001 60 * @tc.desc Function test 61 */ 62HWTEST_F(SmsServiceProxyTest, smsServiceProxyTest_002, Function | MediumTest | Level1) 63{ 64 sptr<MockRemoteObject> sptrRemoteObject = new MockRemoteObject(); 65 sptrRemoteObject->retGetObjectRefCount = 1; 66 sptrRemoteObject->retSendRequest = 0; 67 68 ISendShortMessageCallback::SmsSendResult sendResult = 69 ISendShortMessageCallback::SmsSendResult::SEND_SMS_FAILURE_UNKNOWN; 70 SmsSendShortMessageProxy sendShortMessageProxy(sptrRemoteObject); 71 EXPECT_EQ(sendShortMessageProxy.Remote().GetRefPtr(), sptrRemoteObject); 72 sendShortMessageProxy.OnSmsSendResult(sendResult); 73} 74/** 75 * @tc.number Telephony_SmsMmsGtest_smsServiceProxyTest_003 76 * @tc.name smsServiceProxyTest_001 77 * @tc.desc Function test 78 */ 79HWTEST_F(SmsServiceProxyTest, smsServiceProxyTest_003, Function | MediumTest | Level1) 80{ 81 sptr<IRemoteObject> sptrRemoteObject = nullptr; 82 std::u16string strPdu = u""; 83 SmsDeliveryShortMessageProxy sendShortMessageProxy(sptrRemoteObject); 84 EXPECT_EQ(sendShortMessageProxy.Remote().GetRefPtr(), nullptr); 85 sendShortMessageProxy.OnSmsDeliveryResult(strPdu); 86} 87/** 88 * @tc.number Telephony_SmsMmsGtest_smsServiceProxyTest_004 89 * @tc.name smsServiceProxyTest_001 90 * @tc.desc Function test 91 */ 92HWTEST_F(SmsServiceProxyTest, smsServiceProxyTest_004, Function | MediumTest | Level1) 93{ 94 sptr<MockRemoteObject> sptrRemoteObject = new MockRemoteObject(); 95 sptrRemoteObject->retGetObjectRefCount = 1; 96 sptrRemoteObject->retSendRequest = 0; 97 98 std::u16string strPdu = u""; 99 SmsDeliveryShortMessageProxy sendShortMessageProxy(sptrRemoteObject); 100 EXPECT_EQ(sendShortMessageProxy.Remote().GetRefPtr(), sptrRemoteObject); 101 sendShortMessageProxy.OnSmsDeliveryResult(strPdu); 102} 103} 104}