• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025-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 <gtest/gtest.h>
17 #include "cJSON.h"
18 #include "interoperable_client_manager.h"
19 #include "call_object_manager.h"
20 #include "transmission_manager.h"
21 #include "interoperable_data_controller.h"
22 #include "ims_call.h"
23 
24 namespace OHOS {
25 namespace Telephony {
26 using namespace testing::ext;
27 
28 class InteroperableClientManagerTest : public testing::Test {
29 public:
SetUpTestCase()30     static void SetUpTestCase() {}
TearDownTestCase()31     static void TearDownTestCase() {}
SetUp()32     virtual void SetUp() {}
TearDown()33     virtual void TearDown() {}
34 };
35 
36 /**
37  * @tc.number   Telephony_InteroperableClientManagerTest_001
38  * @tc.name     test create controller call
39  * @tc.desc     Function test
40  */
41 HWTEST_F(InteroperableClientManagerTest, Telephony_InteroperableClientManagerTest_001, Function | MediumTest | Level1)
42 {
43     auto controller = std::make_shared<InteroperableClientManager>();
44     sptr<CallBase> call = nullptr;
45     std::string devId = "";
46     ASSERT_NO_THROW(controller->OnCallCreated(call, devId));
47 }
48 
49 /**
50  * @tc.number   Telephony_InteroperableClientManagerTest_002
51  * @tc.name     test destroy call
52  * @tc.desc     Function test
53  */
54 HWTEST_F(InteroperableClientManagerTest, Telephony_InteroperableClientManagerTest_002, Function | MediumTest | Level1)
55 {
56     auto controller = std::make_shared<InteroperableClientManager>();
57     ASSERT_NO_THROW(controller->OnCallDestroyed());
58 }
59 
60 /**
61  * @tc.number   Telephony_InteroperableClientManagerTest_003
62  * @tc.name     test controller connect remote
63  * @tc.desc     Function test
64  */
65 HWTEST_F(InteroperableClientManagerTest, Telephony_InteroperableClientManagerTest_003, Function | MediumTest | Level1)
66 {
67     auto controller = std::make_shared<InteroperableClientManager>();
68     std::string devId = "";
69     ASSERT_NO_THROW(controller->ConnectRemote(devId));
70     ASSERT_NO_THROW(controller->ConnectRemote(devId)); // check session is not null
71 }
72 
73 /**
74 
75  * @tc.number   Telephony_InteroperableClientManagerTest_004
76  * @tc.name     test on connected
77  * @tc.desc     Function test
78  */
79 HWTEST_F(InteroperableClientManagerTest, Telephony_InteroperableClientManagerTest_004, Function | MediumTest | Level1)
80 {
81     auto controller = std::make_shared<InteroperableClientManager>();
82     DialParaInfo info;
83     std::string accountNumber = "12345678";
84     sptr<CallBase> call = new IMSCall(info);
85     EXPECT_NO_THROW(controller->OnConnected());
86 
87     controller->phoneNum_ = accountNumber;
88     call->SetAccountNumber(accountNumber);
89     CallObjectManager::callObjectPtrList_.push_back(call);
90     EXPECT_NO_THROW(controller->OnConnected());
91 
92     call->SetCallDirection(CallDirection::CALL_DIRECTION_OUT);
93     call->SetPhoneOrWatchDial(static_cast<int32_t>(PhoneOrWatchDial::WATCH_DIAL));
94     EXPECT_NO_THROW(controller->OnConnected());
95 }
96 
97 /**
98 
99  * @tc.number   Telephony_InteroperableClientManagerTest_005
100  * @tc.name     test call created
101  * @tc.desc     Function test
102  */
103 HWTEST_F(InteroperableClientManagerTest, Telephony_InteroperableClientManagerTest_005, Function | MediumTest | Level1)
104 {
105     auto controller = std::make_shared<InteroperableClientManager>();
106     DialParaInfo info;
107     std::string networkId = "1";
108     std::string accountNumber = "123";
109     sptr<CallBase> call = new IMSCall(info);
110     call->SetAccountNumber(accountNumber);
111     call->callState_ = TelCallState::CALL_STATUS_WAITING;
112     EXPECT_NO_THROW(controller->CallCreated(call, networkId));
113 }
114 } // namespace Telephony
115 } // namespace OHOS