1 /* 2 * Copyright (c) 2020-2021 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_TEST_CHART_POLYLINE_H 17 #define UI_TEST_CHART_POLYLINE_H 18 19 #include "components/ui_chart.h" 20 #include "components/ui_label.h" 21 #include "components/ui_label_button.h" 22 #include "components/ui_scroll_view.h" 23 #include "ui_test.h" 24 25 namespace OHOS { 26 constexpr char* UI_TEST_POLYLINE_ADD_DATA = "add_data"; 27 constexpr char* UI_TEST_POLYLINE_DELETE_DATA = "delete_data"; 28 constexpr char* UI_TEST_POLYLINE_CLEAR_DATA = "clear_data"; 29 constexpr char* UI_TEST_POLYLINE_HIGHESET_POINT = "highest_point"; 30 constexpr char* UI_TEST_POLYLINE_LOWEST_POINT = "lowest_point"; 31 constexpr char* UI_TEST_POLYLINE_NEW_POINT = "new_point"; 32 constexpr char* UI_TEST_POLYLINE_FLIP = "flip"; 33 constexpr char* UI_TEST_POLYLINE_FILL_BOTTOM = "fill_bottom"; 34 35 constexpr char* UI_TEST_POLYLINE_ADD_POINT = "add_point"; 36 constexpr char* UI_TEST_POLYLINE_SMOOTHING = "smoothing"; 37 constexpr char* UI_TEST_POLYLINE_HIDE_POINT = "hide_point"; 38 39 class UITestChartPolyline : public UITest, public UIView::OnClickListener { 40 public: UITestChartPolyline()41 UITestChartPolyline() {} ~UITestChartPolyline()42 ~UITestChartPolyline() {} 43 void SetUp() override; 44 void TearDown() override; 45 const UIView* GetTestView() override; 46 47 void SetUpButton(UILabelButton* btn, const char* title, const char* id); 48 49 bool OnClick(UIView& view, const ClickEvent& event) override; 50 bool ClickExpand(UIView& view, UIChartDataSerial::PointStyle pointStyle); 51 52 void UIKitChartPolylineTestAddDataSerial001(); 53 void UIKitChartPolylineTestEnableReverse002(); 54 void UIKitChartPolylineTestSetGradientBottom003(); 55 void UIKitChartPolylineTestAddPoints004(); 56 57 private: 58 void SetLastPos(UIView* view); 59 void InnerDeleteChildren(UIView* view) const; 60 static constexpr uint8_t DATA_NUM = 3; 61 UIScrollView* container_ = nullptr; 62 UIChartPolyline* chart_ = nullptr; 63 UIChartDataSerial *dataSerial_[DATA_NUM] = {0}; 64 uint8_t curDataIndex_ = 0; 65 66 UIChartPolyline* ECGChart_ = nullptr; 67 UIChartDataSerial* ECGDataSerial_ = nullptr; 68 Animator* ECGAnimator_ = nullptr; 69 70 UILabelButton* addDataSerialBtn_ = nullptr; 71 UILabelButton* deleteDataSerialBtn_ = nullptr; 72 UILabelButton* clearDataSerialBtn_ = nullptr; 73 UILabelButton* reverseBtn_ = nullptr; 74 UILabelButton* topPointBtn_ = nullptr; 75 UILabelButton* bottomPointBtn_ = nullptr; 76 UILabelButton* headPointBtn_ = nullptr; 77 UILabelButton* gradientBottomBtn_ = nullptr; 78 79 UILabelButton* addPointsBtn_ = nullptr; 80 UILabelButton* smoothBtn_ = nullptr; 81 UILabelButton* hidePointsBtn_ = nullptr; 82 83 int16_t lastX_ = 0; 84 int16_t lastY_ = 0; 85 }; 86 } // namespace OHOS 87 #endif // UI_TEST_CHART_POLYLINE_H 88