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 16d95e75fdSopenharmony_ci#define private public 17d95e75fdSopenharmony_ci#define protected public 18d95e75fdSopenharmony_ci 19d95e75fdSopenharmony_ci#include "gtest/gtest.h" 20d95e75fdSopenharmony_ci#include "telephony_errors.h" 21d95e75fdSopenharmony_ci#include "emergency_utils.h" 22d95e75fdSopenharmony_ci 23d95e75fdSopenharmony_cinamespace OHOS { 24d95e75fdSopenharmony_cinamespace Telephony { 25d95e75fdSopenharmony_ciusing namespace testing::ext; 26d95e75fdSopenharmony_ciclass EmergencyUtilsTest : 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 EmergencyUtilsTest::SetUpTestCase() {} 34d95e75fdSopenharmony_ci 35d95e75fdSopenharmony_civoid EmergencyUtilsTest::TearDownTestCase() {} 36d95e75fdSopenharmony_ci 37d95e75fdSopenharmony_civoid EmergencyUtilsTest::SetUp() {} 38d95e75fdSopenharmony_ci 39d95e75fdSopenharmony_civoid EmergencyUtilsTest::TearDown() {} 40d95e75fdSopenharmony_ci 41d95e75fdSopenharmony_ci/** 42d95e75fdSopenharmony_ci * @tc.number Telephony_EmergencyUtilsTest_0001 43d95e75fdSopenharmony_ci * @tc.name Test EmergencyUtilsTest 44d95e75fdSopenharmony_ci * @tc.desc Function test 45d95e75fdSopenharmony_ci */ 46d95e75fdSopenharmony_ciHWTEST_F(EmergencyUtilsTest, EmergencyUtilsTest_0001, Function | MediumTest | Level1) 47d95e75fdSopenharmony_ci{ 48d95e75fdSopenharmony_ci EmergencyUtils emergencyUtils; 49d95e75fdSopenharmony_ci int32_t slotId = 0; 50d95e75fdSopenharmony_ci std::string phoneNum; 51d95e75fdSopenharmony_ci bool enabled = false; 52d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCall(slotId, phoneNum, enabled), TELEPHONY_ERR_ARGUMENT_INVALID); 53d95e75fdSopenharmony_ci 54d95e75fdSopenharmony_ci phoneNum = "+911"; 55d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCall(slotId, phoneNum, enabled), TELEPHONY_ERR_ARGUMENT_INVALID); 56d95e75fdSopenharmony_ci 57d95e75fdSopenharmony_ci phoneNum = "911@123456778901"; 58d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCall(slotId, phoneNum, enabled), TELEPHONY_ERR_ARGUMENT_INVALID); 59d95e75fdSopenharmony_ci 60d95e75fdSopenharmony_ci phoneNum = "911%40123456778901"; 61d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCall(slotId, phoneNum, enabled), TELEPHONY_ERR_ARGUMENT_INVALID); 62d95e75fdSopenharmony_ci} 63d95e75fdSopenharmony_ci 64d95e75fdSopenharmony_ci/** 65d95e75fdSopenharmony_ci * @tc.number Telephony_EmergencyUtilsTest_0002 66d95e75fdSopenharmony_ci * @tc.name Test EmergencyUtilsTest 67d95e75fdSopenharmony_ci * @tc.desc Function test 68d95e75fdSopenharmony_ci */ 69d95e75fdSopenharmony_ciHWTEST_F(EmergencyUtilsTest, EmergencyUtilsTest_0002, Function | MediumTest | Level1) 70d95e75fdSopenharmony_ci{ 71d95e75fdSopenharmony_ci EmergencyUtils emergencyUtils; 72d95e75fdSopenharmony_ci int32_t slotId = 0; 73d95e75fdSopenharmony_ci bool enabled = false; 74d95e75fdSopenharmony_ci 75d95e75fdSopenharmony_ci std::string formatString = "57694898180"; 76d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 77d95e75fdSopenharmony_ci 78d95e75fdSopenharmony_ci formatString = "110"; 79d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 80d95e75fdSopenharmony_ci 81d95e75fdSopenharmony_ci formatString = "120"; 82d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 83d95e75fdSopenharmony_ci 84d95e75fdSopenharmony_ci formatString = "119"; 85d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 86d95e75fdSopenharmony_ci 87d95e75fdSopenharmony_ci formatString = "122"; 88d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 89d95e75fdSopenharmony_ci 90d95e75fdSopenharmony_ci formatString = "112"; 91d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 92d95e75fdSopenharmony_ci 93d95e75fdSopenharmony_ci formatString = "000"; 94d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 95d95e75fdSopenharmony_ci 96d95e75fdSopenharmony_ci formatString = "911"; 97d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 98d95e75fdSopenharmony_ci 99d95e75fdSopenharmony_ci formatString = "08"; 100d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 101d95e75fdSopenharmony_ci 102d95e75fdSopenharmony_ci formatString = "118"; 103d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 104d95e75fdSopenharmony_ci 105d95e75fdSopenharmony_ci formatString = "999"; 106d95e75fdSopenharmony_ci EXPECT_EQ(emergencyUtils.IsEmergencyCallProcessing(slotId, formatString, enabled), TELEPHONY_SUCCESS); 107d95e75fdSopenharmony_ci} 108d95e75fdSopenharmony_ci} // namespace Telephony 109d95e75fdSopenharmony_ci} // namespace OHOS