• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include "thermal_application_test.h"
17 #include "thermal_log.h"
18 
19 #ifdef THERMAL_GTEST
20 #define private   public
21 #define protected public
22 #endif
23 #include "thermal_sensor_provision.h"
24 #include "thermal_kernel_service.h"
25 
26 using namespace testing::ext;
27 using namespace OHOS::PowerMgr;
28 using namespace OHOS;
29 using namespace std;
30 
31 namespace {
32 constexpr int32_t MAX_BUFF_SIZE = 128;
33 constexpr int32_t NUM_ZERO = 0;
34 }
35 
36 namespace {
37 /**
38 * @tc.name: ThermalApplicationTest001
39 * @tc.desc: utils test
40 * @tc.type: FUNC
41 * @tc.require: issueIBYAS8
42 */
43 HWTEST_F(ThermalApplicationTest, ThermalApplicationTest001, TestSize.Level0)
44 {
45     THERMAL_HILOGI(LABEL_TEST, "ThermalApplicationTest001 function start!");
46     auto &g_service = ThermalKernelService::GetInstance();
47     g_service.OnStart();
48     std::shared_ptr<ThermalSensorProvision> provision_ = std::make_shared<ThermalSensorProvision>();
49     EXPECT_EQ(false, provision_->InitProvision());
50     char bufType[MAX_BUFF_SIZE] = {0};
51     const char* typePath1 = "/sys/class/thermal";
52     int32_t ret = provision_->ReadThermalSysfsToBuff(typePath1, bufType, sizeof(bufType));
53     EXPECT_NE(ret, NUM_ZERO);
54     const char* typePath2 = "";
55     ret = provision_->ReadThermalSysfsToBuff(typePath2, bufType, sizeof(bufType));
56     EXPECT_NE(ret, NUM_ZERO);
57     THERMAL_HILOGI(LABEL_TEST, "ThermalApplicationTest001 function end!");
58 }
59 
60 } // namespace
61