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 #define private public
16 #define protected public
17
18 #include "gtest/gtest.h"
19 #include "sim_state_manager.h"
20 #include "sim_state_manager.h"
21 #include "sim_sms_controller.h"
22 #include "tel_ril_manager.h"
23
24 namespace OHOS {
25 namespace Telephony {
26 using namespace testing::ext;
27
28 class SimSmsControllerTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 void SetUp();
33 void TearDown();
34 };
35
TearDownTestCase()36 void SimSmsControllerTest::TearDownTestCase() {}
37
SetUp()38 void SimSmsControllerTest::SetUp() {}
39
TearDown()40 void SimSmsControllerTest::TearDown() {}
41
SetUpTestCase()42 void SimSmsControllerTest::SetUpTestCase() {}
43
44 HWTEST_F(SimSmsControllerTest, Telephony_Sim_ProcessEvent_001, Function | MediumTest | Level1)
45 {
46 auto telRilManager_ = std::make_shared<TelRilManager>();
47 auto stateManager_ = std::make_shared<SimStateManager>(telRilManager_);
48 auto simSmsController = std::make_shared<SimSmsController>(stateManager_);
49 AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(SIM_SMS_GET_COMPLETED, 1);
50 simSmsController->ProcessEvent(event);
51 EXPECT_EQ(simSmsController->loadDone_, true);
52 }
53
54 HWTEST_F(SimSmsControllerTest, Telephony_Sim_ProcessEvent_002, Function | MediumTest | Level1)
55 {
56 auto telRilManager_ = std::make_shared<TelRilManager>();
57 auto stateManager_ = std::make_shared<SimStateManager>(telRilManager_);
58 auto simSmsController = std::make_shared<SimSmsController>(stateManager_);
59 AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(SIM_SMS_UPDATE_COMPLETED, 1);
60 simSmsController->ProcessEvent(event);
61 EXPECT_EQ(simSmsController->responseReady_, true);
62 }
63
64 HWTEST_F(SimSmsControllerTest, Telephony_Sim_ProcessEvent_003, Function | MediumTest | Level1)
65 {
66 auto telRilManager_ = std::make_shared<TelRilManager>();
67 auto stateManager_ = std::make_shared<SimStateManager>(telRilManager_);
68 auto simSmsController = std::make_shared<SimSmsController>(stateManager_);
69 AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(SIM_SMS_WRITE_COMPLETED, 1);
70 simSmsController->ProcessEvent(event);
71 EXPECT_EQ(simSmsController->responseReady_, true);
72 }
73
74 HWTEST_F(SimSmsControllerTest, Telephony_Sim_ProcessEvent_004, Function | MediumTest | Level1)
75 {
76 auto telRilManager_ = std::make_shared<TelRilManager>();
77 auto stateManager_ = std::make_shared<SimStateManager>(telRilManager_);
78 auto simSmsController = std::make_shared<SimSmsController>(stateManager_);
79 AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(SIM_SMS_DELETE_COMPLETED, 1);
80 simSmsController->ProcessEvent(event);
81 EXPECT_EQ(simSmsController->responseReady_, true);
82 }
83
84 HWTEST_F(SimSmsControllerTest, Telephony_Sim_SetRilAndFileManager_001, Function | MediumTest | Level1)
85 {
86 auto telRilManager_ = std::make_shared<TelRilManager>();
87 auto stateManager_ = std::make_shared<SimStateManager>(telRilManager_);
88 auto simSmsController = std::make_shared<SimSmsController>(stateManager_);
89 AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(SIM_SMS_DELETE_COMPLETED, 1);
90 simSmsController->SetRilAndFileManager(nullptr, nullptr);
91 EXPECT_EQ(simSmsController->fileManager_, nullptr);
92 }
93
94 }
95 }