1 /* 2 * Copyright (c) 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 "rotate_input.h" 17 18 #include "input_manager.h" 19 #include "screen.h" 20 #include "screen_manager.h" 21 #include "wukong_define.h" 22 #include "report.h" 23 namespace OHOS { 24 namespace WuKong { 25 const int ONE = 1; 26 const int TWO = 2; 27 const int THREE = 3; 28 const int FOUR = 4; RotateInput()29RotateInput::RotateInput() : InputAction() 30 { 31 std::shared_ptr<MultimodeInputMsg> multimodeInputMsg = std::make_shared<MultimodeInputMsg>(); 32 multimodeInputMsg->inputType_ = INPUTTYPE_ROTATEINPUT; 33 inputedMsgObject_ = multimodeInputMsg; 34 } 35 ~RotateInput()36RotateInput::~RotateInput() 37 { 38 } 39 OrderInput(const std::shared_ptr<SpcialTestObject> & specialTestObject)40ErrCode RotateInput::OrderInput(const std::shared_ptr<SpcialTestObject>& specialTestObject) 41 { 42 ErrCode result = OHOS::ERR_OK; 43 std::vector<sptr<Rosen::Screen>> screens; 44 Rosen::ScreenManager::GetInstance().GetAllScreens(screens); 45 46 uint32_t orientation = static_cast<uint32_t>((rand() % FOUR) + ONE); 47 switch (orientation) { 48 case ONE: 49 INFO_LOG("Rotate orientation is VERTICAL"); 50 break; 51 case TWO: 52 INFO_LOG("Rotate orientation is HORIZONTAL"); 53 break; 54 case THREE: 55 INFO_LOG("Rotate orientation is REVERSE_VERTICAL"); 56 break; 57 case FOUR: 58 INFO_LOG("Rotate orientation is REVERSE_HORIZONTAL"); 59 break; 60 61 default: 62 break; 63 } 64 screens[0]->SetOrientation(static_cast<Rosen::Orientation>(orientation)); 65 Report::GetInstance()->SyncInputInfo(inputedMsgObject_); 66 return result; 67 } 68 RandomInput()69ErrCode RotateInput::RandomInput() 70 { 71 ErrCode result = OHOS::ERR_OK; 72 std::vector<sptr<Rosen::Screen>> screens; 73 Rosen::ScreenManager::GetInstance().GetAllScreens(screens); 74 75 uint32_t orientation = static_cast<uint32_t>((rand() % FOUR) + ONE); 76 switch (orientation) { 77 case ONE: 78 INFO_LOG("Rotate orientation is VERTICAL"); 79 break; 80 case TWO: 81 INFO_LOG("Rotate orientation is HORIZONTAL"); 82 break; 83 case THREE: 84 INFO_LOG("Rotate orientation is REVERSE_VERTICAL"); 85 break; 86 case FOUR: 87 INFO_LOG("Rotate orientation is REVERSE_HORIZONTAL"); 88 break; 89 90 default: 91 break; 92 } 93 screens[0]->SetOrientation(static_cast<Rosen::Orientation>(orientation)); 94 Report::GetInstance()->SyncInputInfo(inputedMsgObject_); 95 return result; 96 } 97 GetInputInfo()98ErrCode RotateInput::GetInputInfo() 99 { 100 return OHOS::ERR_OK; 101 } 102 } // namespace WuKong 103 } // namespace OHOS 104