1 /* 2 * Copyright (c) 2021-2022 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 "power_set_mode_test.h" 17 18 #include <iostream> 19 20 #include <datetime_ex.h> 21 #include <gtest/gtest.h> 22 #include <if_system_ability_manager.h> 23 #include <ipc_skeleton.h> 24 #include <string_ex.h> 25 26 #include "power_common.h" 27 #include "power_mgr_client.h" 28 #include "power_mgr_service.h" 29 #include "power_state_machine.h" 30 31 using namespace testing::ext; 32 using namespace OHOS::PowerMgr; 33 using namespace OHOS; 34 using namespace std; 35 36 namespace { 37 /** 38 * @tc.name: SetDeviceModeTest001 39 * @tc.desc: test SetDeviceMode in proxy 40 * @tc.type: FUNC 41 */ 42 HWTEST_F (PowerSetModeTest, SetModeTest001, TestSize.Level0) 43 { 44 sleep(SLEEP_WAIT_TIME_S); 45 GTEST_LOG_(INFO) << "SetModeTest001: SetMode start."; 46 auto& powerMgrClient = PowerMgrClient::GetInstance(); 47 48 PowerMode mode1 = PowerMode::POWER_SAVE_MODE; 49 if (true) { 50 powerMgrClient.SetDeviceMode(mode1); 51 } 52 sleep(SLEEP_WAIT_TIME_S); 53 PowerMode mode2 = PowerMode::PERFORMANCE_MODE; 54 if (true) { 55 powerMgrClient.SetDeviceMode(mode2); 56 } 57 sleep(SLEEP_WAIT_TIME_S); 58 PowerMode mode3 = PowerMode::EXTREME_POWER_SAVE_MODE; 59 if (true) { 60 powerMgrClient.SetDeviceMode(mode3); 61 } 62 63 GTEST_LOG_(INFO) << "SetModeTest001: SetMode end."; 64 } 65 }