• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define private public
17 #define protected public
18 
19 #include <string>
20 #include <unistd.h>
21 
22 #include "core_service_client.h"
23 #include "esim_state_type.h"
24 #include "if_system_ability_manager_mock.h"
25 #include "iservice_registry.h"
26 #include "securec.h"
27 #include "str_convert.h"
28 #include "string_ex.h"
29 #include "telephony_errors.h"
30 #include "telephony_log_wrapper.h"
31 #include "gtest/gtest.h"
32 
33 namespace OHOS {
34 namespace Telephony {
35 using namespace testing::ext;
36 class EsimCoreServiceClientBranchTest : public testing::Test {
37 public:
38     static void SetUpTestCase();
39     static void TearDownTestCase();
40     void SetUp();
41     void TearDown();
42 
43     static inline std::shared_ptr<ISystemAbilityManagerMock> samgr = std::make_shared<ISystemAbilityManagerMock>();
44 };
45 
SetUpTestCase()46 void EsimCoreServiceClientBranchTest::SetUpTestCase()
47 {
48     SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = sptr<ISystemAbilityManager>(samgr.get());
49 }
50 
TearDownTestCase()51 void EsimCoreServiceClientBranchTest::TearDownTestCase()
52 {
53     samgr = nullptr;
54     SystemAbilityManagerClient::GetInstance().systemAbilityManager_ = nullptr;
55 }
56 
SetUp()57 void EsimCoreServiceClientBranchTest::SetUp() {}
58 
TearDown()59 void EsimCoreServiceClientBranchTest::TearDown() {}
60 
61 HWTEST_F(EsimCoreServiceClientBranchTest, SendApduData_0100, Function | MediumTest | Level1)
62 {
63     int32_t slotId = 0;
64     std::u16string aid = Str8ToStr16("aid test");
65     EsimApduData apduData;
66     ResponseEsimResult responseResult;
67     EXPECT_CALL(*samgr, CheckSystemAbility(testing::_)).WillOnce(testing::Return(nullptr));
68     int32_t result = CoreServiceClient::GetInstance().SendApduData(slotId, aid, apduData, responseResult);
69     EXPECT_EQ(result, TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL);
70 }
71 
72 } // namespace Telephony
73 } // namespace OHOS