1 /*
2  * Copyright 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 #ifndef CPP_WATCHDOG_SERVER_TESTS_OVERUSECONFIGURATIONTESTUTILS_H_
18 #define CPP_WATCHDOG_SERVER_TESTS_OVERUSECONFIGURATIONTESTUTILS_H_
19 
20 #include <aidl/android/automotive/watchdog/PerStateBytes.h>
21 #include <aidl/android/automotive/watchdog/internal/ApplicationCategoryType.h>
22 #include <aidl/android/automotive/watchdog/internal/ComponentType.h>
23 #include <aidl/android/automotive/watchdog/internal/IoOveruseAlertThreshold.h>
24 #include <aidl/android/automotive/watchdog/internal/IoOveruseConfiguration.h>
25 #include <aidl/android/automotive/watchdog/internal/PackageMetadata.h>
26 #include <aidl/android/automotive/watchdog/internal/PerStateIoOveruseThreshold.h>
27 #include <aidl/android/automotive/watchdog/internal/ResourceOveruseConfiguration.h>
28 #include <gmock/gmock.h>
29 
30 #include <string>
31 #include <vector>
32 
33 namespace android {
34 namespace automotive {
35 namespace watchdog {
36 
37 aidl::android::automotive::watchdog::internal::ResourceOveruseConfiguration
38 constructResourceOveruseConfig(
39         const aidl::android::automotive::watchdog::internal::ComponentType type,
40         const std::vector<std::string>&& safeToKill,
41         const std::vector<std::string>&& vendorPrefixes,
42         const std::vector<aidl::android::automotive::watchdog::internal::PackageMetadata>
43                 packageMetadata,
44         const aidl::android::automotive::watchdog::internal::IoOveruseConfiguration&
45                 ioOveruseConfiguration);
46 
47 aidl::android::automotive::watchdog::internal::IoOveruseConfiguration constructIoOveruseConfig(
48         aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold componentLevel,
49         const std::vector<
50                 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold>&
51                 packageSpecific,
52         const std::vector<
53                 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold>&
54                 categorySpecific,
55         const std::vector<aidl::android::automotive::watchdog::internal::IoOveruseAlertThreshold>&
56                 systemWide);
57 
58 aidl::android::automotive::watchdog::PerStateBytes toPerStateBytes(const int64_t fgBytes,
59                                                                    const int64_t bgBytes,
60                                                                    const int64_t garageModeBytes);
61 
62 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold
63 toPerStateIoOveruseThreshold(
64         const std::string& name,
65         const aidl::android::automotive::watchdog::PerStateBytes& perStateBytes);
66 
67 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold
68 toPerStateIoOveruseThreshold(const std::string& name, const int64_t fgBytes, const int64_t bgBytes,
69                              const int64_t garageModeBytes);
70 
71 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold
72 toPerStateIoOveruseThreshold(
73         const aidl::android::automotive::watchdog::internal::ComponentType type,
74         const aidl::android::automotive::watchdog::PerStateBytes& perStateBytes);
75 
76 aidl::android::automotive::watchdog::internal::PerStateIoOveruseThreshold
77 toPerStateIoOveruseThreshold(
78         const aidl::android::automotive::watchdog::internal::ComponentType type,
79         const int64_t fgBytes, const int64_t bgBytes, const int64_t garageModeBytes);
80 
81 aidl::android::automotive::watchdog::internal::PackageMetadata toPackageMetadata(
82         std::string packageName,
83         aidl::android::automotive::watchdog::internal::ApplicationCategoryType type);
84 
85 aidl::android::automotive::watchdog::internal::IoOveruseAlertThreshold toIoOveruseAlertThreshold(
86         const int64_t durationInSeconds, const int64_t writtenBytesPerSecond);
87 
88 testing::Matcher<const aidl::android::automotive::watchdog::internal::ResourceOveruseConfiguration&>
89 ResourceOveruseConfigurationMatcher(
90         const aidl::android::automotive::watchdog::internal::ResourceOveruseConfiguration& config);
91 
92 }  // namespace watchdog
93 }  // namespace automotive
94 }  // namespace android
95 
96 #endif  //  CPP_WATCHDOG_SERVER_TESTS_OVERUSECONFIGURATIONTESTUTILS_H_
97