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_H 17 #define UI_TEST_IMAGE_H 18 19 #include "components/ui_scroll_view.h" 20 #include "imgdecode/cache_manager.h" 21 #include "ui_test.h" 22 #include "components/ui_image_view.h" 23 24 #ifndef VERSION_LITE 25 #include "components/ui_label_button.h" 26 #include "test_resource_config.h" 27 #endif 28 29 namespace OHOS { 30 #if defined(ENABLE_GIF) && (ENABLE_GIF == 1) 31 class UITestImage : public UITest, public OHOS::UIView::OnClickListener { 32 #else 33 class UITestImage : public UITest { 34 #endif 35 36 public: UITestImage()37 UITestImage() {} ~UITestImage()38 ~UITestImage() {} 39 void SetUp() override; 40 void TearDown() override; 41 const UIView* GetTestView() override; 42 void UIKitUIImageTestSetImage001(); 43 void UIKitUIImageTestSetImage002(); 44 void UIKitUIImageTestSetImage004(); 45 #if defined(ENABLE_DEFAULT_CHECKBOX_IMAGE) && (ENABLE_DEFAULT_CHECKBOX_IMAGE == 1) 46 void UIKitUIImageTestSetImage005(); 47 #endif 48 void UIKitUIImageTestSetImage006(); 49 void UIKitUIImageTestSetImage007(); 50 void UIKitUIImageTestSetImage008(); 51 void UIKitUIImageTestSetImage009(); 52 void UIKitUIImageTestSetImage010(); 53 void UIKitUIImageTestSetImage011(); 54 void UIKitUIImageTestSetImage012(); 55 void UIKitUIImageTestSetImage013(); 56 void UIKitUIImageTestSetImage014(); 57 #if defined(ENABLE_GIF) && (ENABLE_GIF == 1) 58 void UIKitUIImageTestSetImage015(); 59 void UIKitUIImageTestSetImage016(); 60 #endif 61 void UIKitUIImageTestUncompress001(); 62 void UIKitUIImageTestResize001(); 63 64 private: 65 const char* GetCharByImageSrcType(ImageSrcType srcType) const; 66 #if defined(ENABLE_GIF) && (ENABLE_GIF == 1) 67 bool OnClick(UIView &view, const ClickEvent& event) override; 68 void SetUpButton(UILabelButton* btn, const char* title); 69 #endif 70 UIScrollView* container_ = nullptr; 71 #if defined(ENABLE_GIF) && (ENABLE_GIF == 1) 72 UIImageView* gifImageView_ = nullptr; 73 UILabelButton* gifToGif_ = nullptr; 74 UILabelButton* gifToJpeg_ = nullptr; 75 UILabelButton* gifToPng_ = nullptr; 76 UILabelButton* gifToBin01_ = nullptr; 77 UILabelButton* gifToBin02_ = nullptr; 78 UILabelButton* gifToBin03_ = nullptr; 79 UILabelButton* gifToBin04_ = nullptr; 80 #endif 81 82 private: 83 UILabel* AddLable(int16_t x, int16_t y, const char* data); 84 UIImageView* AddImageView(const Rect rect, const char* src, bool autoEnable, UIImageView::ImageResizeMode mode); GetRect(int16_t x,int16_t y,int16_t w,int16_t h)85 Rect GetRect(int16_t x, int16_t y, int16_t w, int16_t h) const 86 { 87 return Rect(x, y, x + w, y + h); 88 } 89 }; 90 } // namespace OHOS 91 #endif // UI_TEST_IMAGE_H 92