• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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_get_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_log.h"
28 #include "power_mgr_client.h"
29 #include "power_mgr_service.h"
30 #include "power_state_machine.h"
31 
32 using namespace testing::ext;
33 using namespace OHOS::PowerMgr;
34 using namespace OHOS;
35 using namespace std;
36 
37 namespace {
38 /**
39  * @tc.name: GetDeviceModeTest001
40  * @tc.desc: test GetDeviceMode in proxy
41  * @tc.type: FUNC
42  */
43 HWTEST_F (PowerGetModeTest, GetDeviceModeTest001, TestSize.Level1)
44 {
45     GTEST_LOG_(INFO) << "GetDeviceModeTest001: GetDeviceMode start.";
46     POWER_HILOGI(LABEL_TEST, "GetDeviceModeTest001 function start!");
47     PowerMode modeFirst;
48     PowerMode modeSecond = PowerMode::NORMAL_MODE;
49     sleep(SLEEP_WAIT_TIME_S);
50     auto& powerMgrClient = PowerMgrClient::GetInstance();
51 
52     modeFirst = powerMgrClient.GetDeviceMode();
53     powerMgrClient.SetDeviceMode(modeSecond);
54     EXPECT_EQ(modeSecond, powerMgrClient.GetDeviceMode());
55     powerMgrClient.SetDeviceMode(modeFirst);
56     POWER_HILOGI(LABEL_TEST, "GetDeviceModeTest001 function end!");
57     GTEST_LOG_(INFO) << "GetDeviceModeTest001: GetDeviceMode end.";
58 }
59 }