1/* 2 * Copyright (C) 2022 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 "standardize_utils.h" 20#include "mmi_code_utils.h" 21#include "module_service_utils.h" 22 23namespace OHOS { 24namespace Telephony { 25using namespace testing::ext; 26class StandardizeUtilsTest : public testing::Test { 27public: 28 static void SetUpTestCase(); 29 static void TearDownTestCase(); 30 void SetUp(); 31 void TearDown(); 32}; 33void StandardizeUtilsTest::SetUpTestCase() {} 34 35void StandardizeUtilsTest::TearDownTestCase() {} 36 37void StandardizeUtilsTest::SetUp() {} 38 39void StandardizeUtilsTest::TearDown() {} 40 41 42/** 43 * @tc.number Telephony_StandardizeUtilsTest_0001 44 * @tc.name Test CellularCallConnectionCS 45 * @tc.desc Function test 46 */ 47HWTEST_F(StandardizeUtilsTest, StandardizeUtilsTest_0001, Function | MediumTest | Level1) 48{ 49 StandardizeUtils standardizeUtils; 50 std::string phoneString; 51 EXPECT_EQ(standardizeUtils.RemoveSeparatorsPhoneNumber(phoneString), ""); 52 53 phoneString = "1234567890*#+N,;!@$%^&*()_-={}[]|:<>?"; 54 EXPECT_NE(standardizeUtils.RemoveSeparatorsPhoneNumber(phoneString), "1234567890*#+N,;"); 55 56 std::string networkAddress; 57 std::string postDial; 58 standardizeUtils.ExtractAddressAndPostDial(phoneString, networkAddress, postDial); 59 EXPECT_EQ(networkAddress, "1234567890*#+N"); 60 EXPECT_EQ(postDial, ",;!@$%^&*()_-={}[]|:<>?"); 61 62 int32_t intValue1 = 145; 63 int32_t intValue2 = 133; 64 phoneString = "1234567890*#+N,;!@$%^&*()_-={}[]|:<>?"; 65 EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue1), "+1234567890*#+N,;!@$%^&*()_-={}[]|:<>?"); 66 EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue2), "1234567890*#+N,;!@$%^&*()_-={}[]|:<>?"); 67 68 phoneString = "+1234567890*#+N,;!@$%^&*()_-={}[]|:<>?"; 69 EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue1), "+1234567890*#+N,;!@$%^&*()_-={}[]|:<>?"); 70 EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue2), "+1234567890*#+N,;!@$%^&*()_-={}[]|:<>?"); 71 72 phoneString = "12345678908"; 73 EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue1), "+12345678908"); 74 EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue2), "12345678908"); 75 76 phoneString = "+12345678908"; 77 EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue1), "+12345678908"); 78 EXPECT_EQ(standardizeUtils.FormatNumberAndToa(phoneString, intValue2), "+12345678908"); 79} 80 81/** 82 * @tc.number Telephony_MMICodeUtilsTest_0001 83 * @tc.name Test MMICodeUtils 84 * @tc.desc Function test 85 */ 86HWTEST_F(StandardizeUtilsTest, MMICodeUtilsTest_0001, Function | MediumTest | Level1) 87{ 88 MMICodeUtils mmiCodeUtils; 89 std::string analyseString; 90 bool isNeedUseIms = true; 91 mmiCodeUtils.IsNeedExecuteMmi(analyseString, isNeedUseIms); 92 93 int32_t slotId = 0; 94 EXPECT_FALSE(mmiCodeUtils.ExecuteMmiCode(slotId)); 95 96 mmiCodeUtils.mmiData_.serviceCode = "03"; 97 mmiCodeUtils.ExecuteMmiCode(slotId); 98 EXPECT_TRUE(mmiCodeUtils.ExecuteMmiCode(slotId)); 99} 100 101/** 102 * @tc.number Telephony_ModuleServiceUtilsTest_0001 103 * @tc.name Test ModuleServiceUtils 104 * @tc.desc Function test 105 */ 106HWTEST_F(StandardizeUtilsTest, ModuleServiceUtilsTest_0001, Function | MediumTest | Level1) 107{ 108 ModuleServiceUtils moduleServiceUtils; 109 int32_t slotId = 0; 110 EXPECT_FALSE(moduleServiceUtils.GetImsUtSupportState(slotId)); 111 112 auto ptr = moduleServiceUtils.GetImsServiceRemoteObject(); 113 EXPECT_EQ(ptr, nullptr); 114} 115} // namespace Telephony 116} // namespace OHOS