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 #ifndef UI_WIDGET_IMAGE_H 17 #define UI_WIDGET_IMAGE_H 18 19 #include <string> 20 #include <map> 21 #include "extern_api.h" 22 23 namespace OHOS::uitest { 24 /**The informational image of a Widget on the WidgetTree.*/ 25 class WidgetImage : public ExternApi<TypeId::COMPONENT> { 26 public: 27 std::string GetAttribute(std::string_view attrName, std::string_view defaultValue) const; 28 29 void SetAttributes(const std::map<std::string, std::string> &source); 30 31 void SetSelectionDesc(std::string_view desc); 32 33 std::string GetSelectionDesc() const; 34 35 /**Return the UI page scope identifier.*/ 36 std::string GetHierarchy() const; 37 38 /**Return the hashcode of the represented widget object.*/ 39 std::string GetHashCode() const; 40 41 /** Check if this WidgetImage equals to the given one. If the hashcode are same, 42 * return true; else return true if only all the other attributes are same. */ 43 bool Compare(const WidgetImage &other) const; 44 45 void WriteIntoParcel(nlohmann::json &data) const override; 46 47 void ReadFromParcel(const nlohmann::json &data) override; 48 49 private: 50 // the attributes 51 std::map <std::string, std::string> attributes_; 52 // the description of the selection criteria of this widget. 53 std::string selectionCriteria_; 54 }; 55 } 56 57 #endif 58