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 <string>
19 #include <unistd.h>
20 #include "core_manager_inner.h"
21 #include "core_service.h"
22 #include "core_service_client.h"
23 #include "enum_convert.h"
24 #include "operator_config_cache.h"
25 #include "operator_file_parser.h"
26 #include "sim_state_type.h"
27 #include "str_convert.h"
28 #include "string_ex.h"
29 #include "tel_profile_util.h"
30 #include "telephony_ext_wrapper.h"
31 #include "gtest/gtest.h"
32 #include "sim_constant.h"
33 #include "usim_dialling_numbers_service.h"
34
35 namespace OHOS {
36 namespace Telephony {
37 using namespace testing::ext;
38 using namespace testing;
39
40 class UsimDiallingNumbersServiceTest : public testing::Test {
41 public:
42 static void SetUpTestCase();
43 static void TearDownTestCase();
44 void SetUp();
45 void TearDown();
46 };
47
48
SetUpTestCase()49 void UsimDiallingNumbersServiceTest::SetUpTestCase() {}
50
TearDownTestCase()51 void UsimDiallingNumbersServiceTest::TearDownTestCase() {}
52
SetUp()53 void UsimDiallingNumbersServiceTest::SetUp() {}
54
TearDown()55 void UsimDiallingNumbersServiceTest::TearDown() {}
56
57 HWTEST_F(UsimDiallingNumbersServiceTest, ProcessEventTest001, Function | MediumTest | Level1)
58 {
59 auto usimDiallingNumbersService = std::make_shared<UsimDiallingNumbersService>();
60 usimDiallingNumbersService->InitFuncMap();
61 int32_t invalidEventId = 0xFF3807;
62 auto event1 = AppExecFwk::InnerEvent::Get(MSG_USIM_PBR_LOAD_DONE);
63 auto event2 = AppExecFwk::InnerEvent::Get(invalidEventId);
64 usimDiallingNumbersService->ProcessEvent(event1);
65 usimDiallingNumbersService->ProcessEvent(event2);
66 EXPECT_FALSE(usimDiallingNumbersService->memberFuncMap_.empty());
67 }
68
69 HWTEST_F(UsimDiallingNumbersServiceTest, LoadPbrFilesTest001, Function | MediumTest | Level1)
70 {
71 int32_t slotId = 0;
72 auto usimDiallingNumbersService = std::make_shared<UsimDiallingNumbersService>();
73 usimDiallingNumbersService->InitFuncMap();
74 std::shared_ptr<IccFileController> file = std::make_shared<SimFileController>(slotId);
75 std::shared_ptr<IccDiallingNumbersHandler> handler = std::make_shared<IccDiallingNumbersHandler>(file);
76 usimDiallingNumbersService->SetFileControllerAndDiallingNumberHandler(file, handler);
77 usimDiallingNumbersService->LoadPbrFiles();
78 EXPECT_NE(usimDiallingNumbersService->fileController_, nullptr);
79 }
80
81 }
82 }
83