From e88a10c8e072b38788ea1a3caefae7732a29943f Mon Sep 17 00:00:00 2001 From: Xiang Wang Date: Tue, 12 Sep 2023 17:29:38 -0700 Subject: [PATCH] Add VTS to check temperature and thresholds are set for SKIN type The test will only run if the product or board first API level is >= 35. Bug: b/288119641 Bug: b/302018405 Test: atest VtsHalThermalTargetTest Change-Id: I0954e23ea674cdc5f92842f7f72a66334deb386c --- thermal/aidl/vts/VtsHalThermalTargetTest.cpp | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp index 4b0eb655b5..ecb64a706e 100644 --- a/thermal/aidl/vts/VtsHalThermalTargetTest.cpp +++ b/thermal/aidl/vts/VtsHalThermalTargetTest.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #define LOG_TAG "thermal_aidl_hal_test" @@ -227,6 +228,49 @@ TEST_P(ThermalAidlTest, TemperatureThresholdTest) { } } +// Test Thermal->getTemperatureThresholdsWithType(SKIN). +// @VsrTest = GMS-VSR-3.2.5-001 +// @VsrTest = VSR-3.2.5-001 +// @VsrTest = GMS-VSR-3.2.5-002 +// @VsrTest = VSR-3.2.5-002 +TEST_P(ThermalAidlTest, SkinTemperatureThresholdsTest) { + auto apiLevel = ::android::base::GetIntProperty("ro.vendor.api_level", 0); + if (apiLevel < 35) { + GTEST_SKIP() << "Skipping test as the vendor level is below 35: " << apiLevel; + } + std::vector temperatures; + ::ndk::ScopedAStatus status = + mThermal->getTemperaturesWithType(TemperatureType::SKIN, &temperatures); + ASSERT_TRUE(status.isOk()) << "getTemperaturesWithType(SKIN) failed"; + ASSERT_FALSE(temperatures.empty()) << "getTemperaturesWithType(SKIN) returns empty"; + ASSERT_EQ(1, temperatures.size()) + << "getTemperaturesWithType(SKIN) returns multiple temperatures"; + + std::vector thresholds; + status = mThermal->getTemperatureThresholdsWithType(TemperatureType::SKIN, &thresholds); + ASSERT_TRUE(status.isOk()) << "getTemperatureThresholdsWithType(SKIN) failed"; + ASSERT_FALSE(thresholds.empty()) << "getTemperatureThresholdsWithType(SKIN) returns empty"; + ASSERT_EQ(1, thresholds.size()) + << "getTemperatureThresholdsWithType(SKIN) returns multiple thresholds"; + auto temperature = temperatures[0]; + auto threshold = thresholds[0]; + ASSERT_EQ(temperature.name, threshold.name); + auto severities = ::ndk::enum_range(); + auto cardinality = std::distance(severities.begin(), severities.end()); + ASSERT_NE(NAN, temperature.value); + ASSERT_EQ(cardinality, threshold.hotThrottlingThresholds.size()); + float lastThreshold = threshold.hotThrottlingThresholds[1]; + // skip NONE, and check that the rest should be set and non-decreasing + for (auto i = 2; i < cardinality; i++) { + float t = threshold.hotThrottlingThresholds[i]; + ASSERT_NE(NAN, t); + ASSERT_TRUE(t >= lastThreshold) << "Temperature thresholds should be non-decreasing " + << "but got " << t << " for status " << i << " and " + << lastThreshold << " for status " << i - 1; + lastThreshold = t; + } +} + // Test Thermal->getCoolingDevices(). TEST_P(ThermalAidlTest, CoolingDeviceTest) { std::vector ret;