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_IMAGE_ANIMATOR_H 17 #define UI_TEST_IMAGE_ANIMATOR_H 18 19 #include "components/ui_image_animator.h" 20 #include "components/ui_label.h" 21 #include "components/ui_label_button.h" 22 #include "components/ui_scroll_view.h" 23 #include "layout/grid_layout.h" 24 #include "ui_test.h" 25 26 namespace OHOS { 27 class TestAnimatorStopListener : public UIImageAnimatorView::AnimatorStopListener { 28 public: TestAnimatorStopListener(UIViewGroup * viewGroup)29 explicit TestAnimatorStopListener(UIViewGroup* viewGroup) : viewGroup_(viewGroup) 30 { 31 viewGroup_ = viewGroup; 32 } ~TestAnimatorStopListener()33 ~TestAnimatorStopListener() {} 34 Init()35 void Init() 36 { 37 label_ = new UILabel(); 38 viewGroup_->Add(label_); 39 label_->SetPosition(24, 50, 200, 29); // 24: position x 50: position y 200: width 29: height 40 label_->SetText("OnAnimatorStop"); 41 label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE); 42 label_->SetStyle(STYLE_TEXT_COLOR, Color::Black().full); 43 label_->SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full); 44 label_->SetStyle(STYLE_BACKGROUND_OPA, 255); // 255: value 45 label_->SetVisible(false); 46 } 47 OnAnimatorStop(UIView & view)48 void OnAnimatorStop(UIView& view) override 49 { 50 label_->SetVisible(true); 51 label_->Invalidate(); 52 } 53 private: 54 UILabel* label_ = nullptr; 55 UIViewGroup* viewGroup_ = nullptr; 56 }; 57 58 class UITestImageAnimator : public UITest, public UIView::OnClickListener { 59 public: UITestImageAnimator()60 UITestImageAnimator() {} ~UITestImageAnimator()61 ~UITestImageAnimator() {} 62 void SetUp() override; 63 void TearDown() override; 64 const UIView* GetTestView() override; 65 66 void SetUpButton(UILabelButton* btn, const char* title); 67 68 bool OnClick(UIView& view, const ClickEvent& event) override; 69 70 void UIKit_ImageAnimator_Test_Start_001(); 71 void UIKit_ImageAnimator_Test_Stop_002(); 72 void UIKit_ImageAnimator_Test_Pause_003(); 73 void UIKit_ImageAnimator_Test_Resume_004(); 74 void UIKit_ImageAnimator_Test_SetImageAnimatorSrc_005(); 75 void UIKit_ImageAnimator_Test_SetTickOfUpdate_006(); 76 void UIKit_ImageAnimator_Test_SetSizeFixed_007(); 77 void UIKit_ImageAnimator_Test_SetRepeat_008(); 78 void UIKit_ImageAnimator_Test_SetReverse_009(); 79 void UIKit_ImageAnimator_Test_SetAnimatorStopListener_010(); 80 void UIKit_ImageAnimator_Test_SetRepeatTimes_011(); 81 void UIKit_ImageAnimator_Test_SetFillMode_True_Forward_012(); 82 void UIKit_ImageAnimator_Test_SetFillMode_True_Backward_013(); 83 void UIKit_ImageAnimator_Test_SetFillMode_False_Forward_014(); 84 void UIKit_ImageAnimator_Test_SetFillMode_False_Backward_015(); 85 void UIKit_ImageAnimator_Test_SetImageInfo_016(); 86 87 private: 88 void InitImageInfo(); 89 UIScrollView* container_ = nullptr; 90 GridLayout* layout_ = nullptr; 91 UIImageAnimatorView* imageAnimator_ = nullptr; 92 TestAnimatorStopListener* listener_ = nullptr; 93 94 UILabelButton* startBtn_ = nullptr; 95 UILabelButton* stopBtn_ = nullptr; 96 UILabelButton* pauseBtn_ = nullptr; 97 UILabelButton* resumeBtn_ = nullptr; 98 UILabelButton* setImageBtn_ = nullptr; 99 UILabelButton* setSpeedBtn_ = nullptr; 100 UILabelButton* fixedBtn_ = nullptr; 101 UILabelButton* repeatBtn_ = nullptr; 102 UILabelButton* noRepeatBtn_ = nullptr; 103 UILabelButton* reverseOrderBtn_ = nullptr; 104 UILabelButton* positiveOrderBtn_ = nullptr; 105 UILabelButton* listenerBtn_ = nullptr; 106 UILabelButton* repeatTimesBtn_ = nullptr; 107 UILabelButton* fillModeTrueForwardBtn_ = nullptr; 108 UILabelButton* fillModeTrueBackwardBtn_ = nullptr; 109 UILabelButton* fillModeFalseForwardBtn_ = nullptr; 110 UILabelButton* fillModeFalseBackwardBtn_ = nullptr; 111 UILabelButton* setImageInfoBtn_ = nullptr; 112 113 ImageInfo* imageInfo1_ = nullptr; 114 ImageInfo* imageInfo2_ = nullptr; 115 ImageInfo* imageInfo3_ = nullptr; 116 ImageAnimatorInfo imageAnimatorImageInfo_[3] = { 0 }; 117 }; 118 } // namespace OHOS 119 #endif // UI_TEST_IMAGE_ANIMATOR_H 120