1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef THERMAL_TEST_H 17 #define THERMAL_TEST_H 18 19 #include <gtest/gtest.h> 20 #include <string> 21 22 namespace OHOS { 23 namespace PowerMgr { 24 const uint32_t MAX_PATH = 256; 25 const std::string VOLUME_PATH = "/data/service/el0/thermal/config/volume"; 26 const std::string BATTERY_PATH = "/data/service/el0/thermal/sensor/battery/temp"; 27 const std::string SHELL_PATH = "/data/service/el0/thermal/sensor/shell/temp"; 28 const std::string SOC_PATH = "/data/service/el0/thermal/sensor/soc/temp"; 29 const std::string AMBIENT_PATH = "/data/service/el0/thermal/sensor/ambient/temp"; 30 const std::string PA_PATH = "/data/service/el0/thermal/sensor/pa/temp"; 31 const std::string AP_PATH = "/data/service/el0/thermal/sensor/ap/temp"; 32 const std::string CONFIG_LEVEL_PATH = "/data/service/el0/thermal/config/configLevel"; 33 const std::string LCD_PATH = "/data/service/el0/thermal/config/lcd"; 34 const std::string PROCESS_PATH = "/data/service/el0/thermal/config/process_ctrl"; 35 const std::string SHUTDOWN_PATH = "/data/service/el0/thermal/config/shut_down"; 36 const std::string CHARGER_PATH = "/data/service/el0/thermal/sensor/charger/temp"; 37 const std::string CPU_PATH = "/data/service/el0/thermal/sensor/cpu/temp"; 38 const std::string BATTERY_CAPACITY_PATH = "/data/service/el0/battery/battery/capacity"; 39 const std::string CHARGER_STATUS_PATH = "/data/service/el0/battery/ohos_charger/status"; 40 const std::string CHARGER_CURRENT_PATH = "/data/service/el0/battery/battery/current_now"; 41 const std::string VENDOR_CONFIG = "/vendor/etc/thermal_config/thermal_service_config.xml"; 42 constexpr const char* BATTERY_CHARGER_CURRENT_PATH = "/data/service/el0/thermal/cooling/battery/current"; 43 constexpr const char* SIMULATION_TEMP_DIR = "/data/service/el0/thermal/sensor/%s/temp"; 44 constexpr const char* SC_CURRENT_PATH = "/data/service/el0/thermal/config/sc_current"; 45 constexpr const char* BUCK_CURRENT_PATH = "/data/service/el0/thermal/config/buck_current"; 46 constexpr const char* SC_VOLTAGE_PATH = "/data/service/el0/thermal/config/sc_voltage"; 47 constexpr const char* BUCK_VOLTAGE_PATH = "/data/service/el0/thermal/config/buck_voltage"; 48 class ThermalTest { 49 public: 50 static int32_t WriteFile(std::string path, std::string buf); 51 static int32_t ReadFile(std::string path, std::string& buf); 52 static int32_t ConvertInt(const std::string& value); 53 static int32_t InitNode(); 54 bool IsMock(const std::string& path); 55 bool IsVendor(); 56 static std::string GetNodeValue(const std::string& path); 57 static int32_t SetNodeValue(int32_t value, const std::string& path); 58 static int32_t SetNodeString(std::string str, const std::string& path); 59 }; 60 } // namespace PowerMgr 61 } // namespace OHOS 62 #endif // THERMAL_TEST_H 63