1 /* 2 * Copyright (c) 2021, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <aidl/android/automotive/watchdog/internal/ApplicationCategoryType.h> 20 #include <aidl/android/automotive/watchdog/internal/ComponentType.h> 21 #include <aidl/android/automotive/watchdog/internal/PackageInfo.h> 22 #include <aidl/android/automotive/watchdog/internal/UidType.h> 23 #include <gmock/gmock.h> 24 25 #include <string> 26 #include <vector> 27 28 namespace android { 29 namespace automotive { 30 namespace watchdog { 31 32 aidl::android::automotive::watchdog::internal::PackageInfo constructPackageInfo( 33 const char* packageName, int32_t uid, 34 aidl::android::automotive::watchdog::internal::UidType uidType = 35 aidl::android::automotive::watchdog::internal::UidType::UNKNOWN, 36 aidl::android::automotive::watchdog::internal::ComponentType componentType = 37 aidl::android::automotive::watchdog::internal::ComponentType::UNKNOWN, 38 aidl::android::automotive::watchdog::internal::ApplicationCategoryType appCategoryType = 39 aidl::android::automotive::watchdog::internal::ApplicationCategoryType::OTHERS, 40 std::vector<std::string> sharedUidPackages = {}); 41 42 aidl::android::automotive::watchdog::internal::PackageInfo constructAppPackageInfo( 43 const char* packageName, 44 const aidl::android::automotive::watchdog::internal::ComponentType componentType, 45 const aidl::android::automotive::watchdog::internal::ApplicationCategoryType 46 appCategoryType = aidl::android::automotive::watchdog::internal:: 47 ApplicationCategoryType::OTHERS, 48 const std::vector<std::string>& sharedUidPackages = {}); 49 50 MATCHER_P(PackageIdentifierEq, expected, "") { 51 const auto& actual = arg; 52 return ::testing::Value(actual.name, ::testing::Eq(expected.name)) && 53 ::testing::Value(actual.uid, ::testing::Eq(expected.uid)); 54 } 55 56 MATCHER_P(PackageInfoEq, expected, "") { 57 const auto& actual = arg; 58 return ::testing::Value(actual.packageIdentifier, 59 PackageIdentifierEq(expected.packageIdentifier)) && 60 ::testing::Value(actual.uidType, ::testing::Eq(expected.uidType)) && 61 ::testing::Value(actual.sharedUidPackages, 62 ::testing::UnorderedElementsAreArray(expected.sharedUidPackages)) && 63 ::testing::Value(actual.componentType, ::testing::Eq(expected.componentType)) && 64 ::testing::Value(actual.appCategoryType, ::testing::Eq(expected.appCategoryType)); 65 } 66 67 } // namespace watchdog 68 } // namespace automotive 69 } // namespace android 70