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 16 #include "common_event_permission_manager.h" 17 18 #include <algorithm> 19 #include <string> 20 #include <unordered_map> 21 #include <vector> 22 23 namespace { 24 bool g_mockGetEventPermissionRet = true; 25 } 26 27 namespace OHOS { 28 namespace EventFwk { MockGetEventPermission(bool mockRet)29void MockGetEventPermission(bool mockRet) 30 { 31 g_mockGetEventPermissionRet = mockRet; 32 } GetEventPermission(const std::string & event)33Permission CommonEventPermissionManager::GetEventPermission(const std::string &event) 34 { 35 Permission per; 36 if (true == g_mockGetEventPermissionRet) { 37 std::string eventName = "aa"; 38 per.names.emplace_back(eventName); 39 eventMap_.insert(std::make_pair(eventName, per)); 40 return eventMap_.find(eventName)->second; 41 } 42 return per; 43 } 44 } // namespace EventFwk 45 } // namespace OHOS 46