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 "core_service.h"
20 #include "esim_state_type.h"
21 #include "gmock/gmock.h"
22 #include "string_ex.h"
23 #include "str_convert.h"
24 #include "sim_manager.h"
25 #include "telephony_errors.h"
26 #include "telephony_log_wrapper.h"
27 #include "telephony_permission.h"
28 #include "gtest/gtest.h"
29
30 namespace OHOS {
31 namespace Telephony {
32 using namespace testing::ext;
33 class EsimCoreServiceTest : public testing::Test {
34 public:
35 static void SetUpTestCase();
36 static void TearDownTestCase();
37 void SetUp();
38 void TearDown();
39 };
40
SetUpTestCase()41 void EsimCoreServiceTest::SetUpTestCase() {}
42
TearDownTestCase()43 void EsimCoreServiceTest::TearDownTestCase() {}
44
SetUp()45 void EsimCoreServiceTest::SetUp() {}
46
TearDown()47 void EsimCoreServiceTest::TearDown() {}
48
49
50 HWTEST_F(EsimCoreServiceTest, SendApduData_0001, Function | MediumTest | Level1)
51 {
52 std::shared_ptr<CoreService> mCoreService = std::make_shared<CoreService>();
53 std::shared_ptr<TelRilManager> telRilManager = std::make_shared<TelRilManager>();
54 mCoreService->simManager_ = std::make_shared<SimManager>(telRilManager);
55 int32_t slotId = 0;
56 std::u16string aid = Str8ToStr16("aid test");
57 EsimApduData apduData;
58 ResponseEsimResult responseResult;
59 EXPECT_NE(mCoreService->SendApduData(
60 slotId, aid, apduData, responseResult), TELEPHONY_ERR_SUCCESS);
61 mCoreService->simManager_ = nullptr;
62 EXPECT_EQ(mCoreService->SendApduData(
63 slotId, aid, apduData, responseResult), TELEPHONY_ERR_ILLEGAL_USE_OF_SYSTEM_API);
64 }
65
66 } // namespace Telephony
67 } // namespace OHOS