1 /* 2 * Copyright (C) 2021 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 16 #include <cstdlib> 17 #include <ctime> 18 #include <chrono> 19 #include <fstream> 20 #include "json/json.h" 21 #include <gtest/gtest.h> 22 #include "time_common.h" 23 #include "time_permission.h" 24 25 namespace { 26 using namespace testing::ext; 27 using namespace OHOS; 28 using namespace OHOS::MiscServices; 29 using namespace std::chrono; 30 31 class TimePermissionTest : public testing::Test { 32 public: 33 static void SetUpTestCase(void); 34 35 static void TearDownTestCase(void); 36 37 void SetUp(); 38 39 void TearDown(); 40 }; 41 SetUpTestCase(void)42void TimePermissionTest::SetUpTestCase(void) { 43 } 44 TearDownTestCase(void)45void TimePermissionTest::TearDownTestCase(void) { 46 } 47 SetUp(void)48void TimePermissionTest::SetUp(void) { 49 } 50 TearDown(void)51void TimePermissionTest::TearDown(void) { 52 } 53 54 /** 55 * @tc.name: CheckCallingPermission001 56 * @tc.desc: check calling permission 57 * @tc.type: FUNC 58 */ 59 HWTEST_F(TimePermissionTest, CheckCallingPermission001, TestSize.Level1) 60 { 61 std::string permissionName(""); 62 bool ret = TimePermission::CheckCallingPermission(permissionName); 63 EXPECT_EQ(false, ret); 64 65 bool ret1 = TimePermission::CheckCallingPermission("permissionName"); 66 EXPECT_EQ(true, ret1); 67 } 68 69 }