1 /* 2 * Copyright (C) 2016 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 <gtest/gtest.h> 18 19 #include "vhal_v2_0/VehiclePropConfigIndex.h" 20 21 #include "VehicleHalTestUtils.h" 22 23 namespace android { 24 namespace hardware { 25 namespace automotive { 26 namespace vehicle { 27 namespace V2_0 { 28 29 namespace { 30 31 class PropConfigTest : public ::testing::Test { 32 protected: 33 void SetUp() override { 34 configs.assign(std::begin(kVehicleProperties), 35 std::end(kVehicleProperties)); 36 } 37 38 void TearDown() override {} 39 40 public: 41 std::vector<VehiclePropConfig> configs; 42 }; 43 44 TEST_F(PropConfigTest, hasConfig) { 45 VehiclePropConfigIndex index(configs); 46 47 ASSERT_TRUE(index.hasConfig(toInt(VehicleProperty::HVAC_FAN_SPEED))); 48 ASSERT_TRUE(index.hasConfig(toInt(VehicleProperty::INFO_MAKE))); 49 ASSERT_TRUE(index.hasConfig(toInt(VehicleProperty::INFO_FUEL_CAPACITY))); 50 51 ASSERT_FALSE(index.hasConfig(toInt(VehicleProperty::INVALID))); 52 } 53 54 TEST_F(PropConfigTest, getAllConfig) { 55 VehiclePropConfigIndex index(configs); 56 57 std::vector<VehiclePropConfig> actualConfigs = index.getAllConfigs(); 58 ASSERT_EQ(configs.size(), actualConfigs.size()); 59 60 for (size_t i = 0; i < actualConfigs.size(); i++) { 61 ASSERT_EQ(toString(configs[i]), toString(actualConfigs[i])); 62 } 63 } 64 65 TEST_F(PropConfigTest, getConfigs) { 66 VehiclePropConfigIndex index(configs); 67 auto actualConfig = index.getConfig(toInt(VehicleProperty::HVAC_FAN_SPEED)); 68 ASSERT_EQ(toString(configs[1]), toString(actualConfig)); 69 } 70 71 } // namespace anonymous 72 73 } // namespace V2_0 74 } // namespace vehicle 75 } // namespace automotive 76 } // namespace hardware 77 } // namespace android 78