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