1 /*
2  * Copyright (C) 2023 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 #include <android-base/file.h>
18 #include <gtest/gtest.h>
19 #include <jsonpb/json_schema_test.h>
20 
21 #include "thermal_info_config_test.h"
22 
23 using namespace ::android::jsonpb;
24 using ::android::base::GetExecutableDirectory;
25 
26 namespace devices {
27 namespace shusky {
28 
29 template <typename T>
MakeTestParam(const std::string & path)30 JsonSchemaTestConfigFactory MakeTestParam(const std::string &path) {
31   return android::jsonpb::MakeTestParam<T>(GetExecutableDirectory() + path);
32 }
33 
34 // Make test suite for thermal info config schema.
35 INSTANTIATE_TEST_SUITE_P(
36     ThermalSuite, ThermalInfoConfigTest,
37     ::testing::Values(
38         MakeTestParam<ThermalConfig>("/thermal_info_config_husky.json"),
39         MakeTestParam<ThermalConfig>("/thermal_info_config_shiba.json"),
40         MakeTestParam<ThermalConfig>("/thermal_info_config_charge_husky.json"),
41         MakeTestParam<ThermalConfig>("/thermal_info_config_charge_shiba.json"),
42         MakeTestParam<ThermalConfig>("/thermal_info_config_ripcurrent.json"),
43         MakeTestParam<ThermalConfig>(
44             "/thermal_info_config_charge_ripcurrent.json")));
45 
46 // Ignores a formatting check (b/c 0.0 != 0 textually)
47 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(JsonSchemaTest);
48 
main(int argc,char ** argv)49 int main(int argc, char **argv) {
50   ::testing::InitGoogleTest(&argc, argv);
51   return RUN_ALL_TESTS();
52 }
53 
54 } // namespace shusky
55 } // namespace devices
56