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 #ifndef WIDGET_OPERATOR_H 17 #define WIDGET_OPERATOR_H 18 19 #include "ui_driver.h" 20 21 namespace OHOS::uitest { 22 class WidgetOperator { 23 public: 24 WidgetOperator(UiDriver &driver, const Widget &widget, const UiOpArgs &options); 25 26 /**Perform generic-click widget.*/ 27 void GenericClick(TouchOp op, ApiCallErr &error) const; 28 29 /**Inject the given text to the widget.*/ 30 void InputText(std::string_view text, ApiCallErr &error) const; 31 32 /**Scroll widget to the end (top or bottom).*/ 33 void ScrollToEnd(bool toTop, ApiCallErr &error) const; 34 35 /**Drag widget to another one.*/ 36 void DragIntoWidget(const Widget &another, ApiCallErr &error) const; 37 38 /**Pinch widget to the target scale*/ 39 void PinchWidget(float_t scale, ApiCallErr &error) const; 40 41 /**Scroll on the widget to find the target widget matching the selector.*/ 42 std::unique_ptr<Widget> ScrollFindWidget(const WidgetSelector &selector, ApiCallErr &error) const; 43 44 private: 45 void TurnPage(bool toTop, int &oriDistance, ApiCallErr &error) const; 46 UiDriver &driver_; 47 const Widget &widget_; 48 const UiOpArgs &options_; 49 }; 50 } // namespace OHOS::uitest 51 52 #endif