• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #define private public
17 #define protected public
18 
19 #include <string>
20 #include <unistd.h>
21 
22 #include "iesim_service_callback_stub.h"
23 #include "ipc_types.h"
24 #include "iremote_stub.h"
25 #include "gtest/gtest.h"
26 
27 namespace OHOS {
28 namespace Telephony {
29 using namespace testing::ext;
30 constexpr int32_t DEFAULT_ERROR = -1;
31 constexpr int32_t DEFAULT_RESULT = 0;
32 class IEsimServiceCallbackStubTest : public testing::Test {
33 public:
34     static void SetUpTestCase();
35     static void TearDownTestCase();
36     void SetUp();
37     void TearDown();
38 };
39 
SetUpTestCase()40 void IEsimServiceCallbackStubTest::SetUpTestCase()
41 {
42 }
43 
TearDownTestCase()44 void IEsimServiceCallbackStubTest::TearDownTestCase()
45 {
46 }
47 
SetUp()48 void IEsimServiceCallbackStubTest::SetUp() {}
49 
TearDown()50 void IEsimServiceCallbackStubTest::TearDown() {}
51 
52 HWTEST_F(IEsimServiceCallbackStubTest, OnGetEuiccProfileInfoList, Function | MediumTest | Level1)
53 {
54     MessageParcel data;
55     std::shared_ptr<IEsimServiceCallbackStub> stub = std::make_shared<IEsimServiceCallbackStub>();
56     int endIndex = static_cast<int>(IEsimServiceCallback::EsimServiceCallback::GET_EID_RESULT);
57     for (int requestId = static_cast<int>(IEsimServiceCallback::EsimServiceCallback::GET_EUICCINFO_RESULT);
58         requestId < endIndex + 1;
59         requestId++) {
60         int32_t ret = stub->OnEsimServiceCallback(
61             static_cast<IEsimServiceCallback::EsimServiceCallback>(requestId), data);
62         EXPECT_EQ(ret, DEFAULT_RESULT);
63     }
64 }
65 
66 HWTEST_F(IEsimServiceCallbackStubTest, OnGetEuiccProfileInfoListFailed, Function | MediumTest | Level1)
67 {
68     MessageParcel data;
69     std::shared_ptr<IEsimServiceCallbackStub> stub = std::make_shared<IEsimServiceCallbackStub>();
70     constexpr uint32_t outIndex = 99;
71     int32_t ret = stub->OnEsimServiceCallback(static_cast<IEsimServiceCallback::EsimServiceCallback>(outIndex), data);
72     EXPECT_EQ(ret, DEFAULT_ERROR);
73 }
74 } // namespace Telephony
75 } // namespace OHOS