1d95e75fdSopenharmony_ci/*
2d95e75fdSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd.
3d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License.
5d95e75fdSopenharmony_ci * You may obtain a copy of the License at
6d95e75fdSopenharmony_ci *
7d95e75fdSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8d95e75fdSopenharmony_ci *
9d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and
13d95e75fdSopenharmony_ci * limitations under the License.
14d95e75fdSopenharmony_ci */
15d95e75fdSopenharmony_ci#define private public
16d95e75fdSopenharmony_ci#define protected public
17d95e75fdSopenharmony_ci
18d95e75fdSopenharmony_ci#include "gtest/gtest.h"
19d95e75fdSopenharmony_ci#include "standardize_utils.h"
20d95e75fdSopenharmony_ci#include "mmi_code_utils.h"
21d95e75fdSopenharmony_ci#include "module_service_utils.h"
22d95e75fdSopenharmony_ci
23d95e75fdSopenharmony_cinamespace OHOS {
24d95e75fdSopenharmony_cinamespace Telephony {
25d95e75fdSopenharmony_ciusing namespace testing::ext;
26d95e75fdSopenharmony_ciclass StandardizeUtilsTest : public testing::Test {
27d95e75fdSopenharmony_cipublic:
28d95e75fdSopenharmony_ci    static void SetUpTestCase();
29d95e75fdSopenharmony_ci    static void TearDownTestCase();
30d95e75fdSopenharmony_ci    void SetUp();
31d95e75fdSopenharmony_ci    void TearDown();
32d95e75fdSopenharmony_ci};
33d95e75fdSopenharmony_civoid StandardizeUtilsTest::SetUpTestCase() {}
34d95e75fdSopenharmony_ci
35d95e75fdSopenharmony_civoid StandardizeUtilsTest::TearDownTestCase() {}
36d95e75fdSopenharmony_ci
37d95e75fdSopenharmony_civoid StandardizeUtilsTest::SetUp() {}
38d95e75fdSopenharmony_ci
39d95e75fdSopenharmony_civoid StandardizeUtilsTest::TearDown() {}
40d95e75fdSopenharmony_ci
41d95e75fdSopenharmony_ci
42d95e75fdSopenharmony_ci/**
43d95e75fdSopenharmony_ci * @tc.number   Telephony_StandardizeUtilsTest_0001
44d95e75fdSopenharmony_ci * @tc.name     Test CellularCallConnectionCS
45d95e75fdSopenharmony_ci * @tc.desc     Function test
46d95e75fdSopenharmony_ci */
47d95e75fdSopenharmony_ciHWTEST_F(StandardizeUtilsTest, StandardizeUtilsTest_0001, Function | MediumTest | Level1)
48d95e75fdSopenharmony_ci{
49d95e75fdSopenharmony_ci    StandardizeUtils standardizeUtils;
50d95e75fdSopenharmony_ci    std::string phoneString;
51d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.RemoveSeparatorsPhoneNumber(phoneString), "");
52d95e75fdSopenharmony_ci
53d95e75fdSopenharmony_ci    phoneString = "1234567890*#+N,;!@$%^&*()_-={}[]|:<>?";
54d95e75fdSopenharmony_ci    EXPECT_NE(standardizeUtils.RemoveSeparatorsPhoneNumber(phoneString), "1234567890*#+N,;");
55d95e75fdSopenharmony_ci
56d95e75fdSopenharmony_ci    std::string networkAddress;
57d95e75fdSopenharmony_ci    std::string postDial;
58d95e75fdSopenharmony_ci    standardizeUtils.ExtractAddressAndPostDial(phoneString, networkAddress, postDial);
59d95e75fdSopenharmony_ci    EXPECT_EQ(networkAddress, "1234567890*#+N");
60d95e75fdSopenharmony_ci    EXPECT_EQ(postDial, ",;!@$%^&*()_-={}[]|:<>?");
61d95e75fdSopenharmony_ci
62d95e75fdSopenharmony_ci    int32_t intValue1 = 145;
63d95e75fdSopenharmony_ci    int32_t intValue2 = 133;
64d95e75fdSopenharmony_ci    phoneString = "1234567890*#+N,;!@$%^&*()_-={}[]|:<>?";
65d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue1), "+1234567890*#+N,;!@$%^&*()_-={}[]|:<>?");
66d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue2), "1234567890*#+N,;!@$%^&*()_-={}[]|:<>?");
67d95e75fdSopenharmony_ci
68d95e75fdSopenharmony_ci    phoneString = "+1234567890*#+N,;!@$%^&*()_-={}[]|:<>?";
69d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue1), "+1234567890*#+N,;!@$%^&*()_-={}[]|:<>?");
70d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue2), "+1234567890*#+N,;!@$%^&*()_-={}[]|:<>?");
71d95e75fdSopenharmony_ci
72d95e75fdSopenharmony_ci    phoneString = "12345678908";
73d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue1), "+12345678908");
74d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue2), "12345678908");
75d95e75fdSopenharmony_ci
76d95e75fdSopenharmony_ci    phoneString = "+12345678908";
77d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue1), "+12345678908");
78d95e75fdSopenharmony_ci    EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue2), "+12345678908");
79d95e75fdSopenharmony_ci}
80d95e75fdSopenharmony_ci
81d95e75fdSopenharmony_ci/**
82d95e75fdSopenharmony_ci * @tc.number   Telephony_MMICodeUtilsTest_0001
83d95e75fdSopenharmony_ci * @tc.name     Test MMICodeUtils
84d95e75fdSopenharmony_ci * @tc.desc     Function test
85d95e75fdSopenharmony_ci */
86d95e75fdSopenharmony_ciHWTEST_F(StandardizeUtilsTest, MMICodeUtilsTest_0001, Function | MediumTest | Level1)
87d95e75fdSopenharmony_ci{
88d95e75fdSopenharmony_ci    MMICodeUtils mmiCodeUtils;
89d95e75fdSopenharmony_ci    std::string analyseString;
90d95e75fdSopenharmony_ci    bool isNeedUseIms = true;
91d95e75fdSopenharmony_ci    mmiCodeUtils.IsNeedExecuteMmi(analyseString, isNeedUseIms);
92d95e75fdSopenharmony_ci
93d95e75fdSopenharmony_ci    int32_t slotId = 0;
94d95e75fdSopenharmony_ci    EXPECT_FALSE(mmiCodeUtils.ExecuteMmiCode(slotId));
95d95e75fdSopenharmony_ci
96d95e75fdSopenharmony_ci    mmiCodeUtils.mmiData_.serviceCode = "03";
97d95e75fdSopenharmony_ci    mmiCodeUtils.ExecuteMmiCode(slotId);
98d95e75fdSopenharmony_ci    EXPECT_TRUE(mmiCodeUtils.ExecuteMmiCode(slotId));
99d95e75fdSopenharmony_ci}
100d95e75fdSopenharmony_ci
101d95e75fdSopenharmony_ci/**
102d95e75fdSopenharmony_ci * @tc.number   Telephony_ModuleServiceUtilsTest_0001
103d95e75fdSopenharmony_ci * @tc.name     Test ModuleServiceUtils
104d95e75fdSopenharmony_ci * @tc.desc     Function test
105d95e75fdSopenharmony_ci */
106d95e75fdSopenharmony_ciHWTEST_F(StandardizeUtilsTest, ModuleServiceUtilsTest_0001, Function | MediumTest | Level1)
107d95e75fdSopenharmony_ci{
108d95e75fdSopenharmony_ci    ModuleServiceUtils moduleServiceUtils;
109d95e75fdSopenharmony_ci    int32_t slotId = 0;
110d95e75fdSopenharmony_ci    EXPECT_FALSE(moduleServiceUtils.GetImsUtSupportState(slotId));
111d95e75fdSopenharmony_ci
112d95e75fdSopenharmony_ci    auto ptr = moduleServiceUtils.GetImsServiceRemoteObject();
113d95e75fdSopenharmony_ci    EXPECT_EQ(ptr, nullptr);
114d95e75fdSopenharmony_ci}
115d95e75fdSopenharmony_ci} // namespace Telephony
116d95e75fdSopenharmony_ci} // namespace OHOS