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_VIDEO_H
17 #define UI_TEST_VIDEO_H
18 
19 #include "components/ui_label_button.h"
20 #include "components/ui_scroll_view.h"
21 #include "components/ui_video.h"
22 #include "ui_test.h"
23 
24 #ifndef VERSION_LITE
25 namespace OHOS {
26 class UITestVideo : public UITest, public UIView::OnClickListener {
27 public:
UITestVideo()28     UITestVideo() {}
~UITestVideo()29     ~UITestVideo() {}
30     void SetUp() override;
31     void TearDown() override;
32     const UIView* GetTestView() override;
33     bool OnClick(UIView &view, const ClickEvent& event) override;
34     bool OnClick1(UIView &view, const ClickEvent& event);
35     bool OnClick2(UIView &view, const ClickEvent& event);
36     void DealClickLoopButton() const;
37     void InitTestButtons();
38     void SetupTestButton(UILabelButton* button, const char* text);
39     void DeleteTestButtons();
40     void UIKitUIVideoTestSetVideo001();
41 
42     class TestVideoListener : public UIVideo::VideoPlayerListener {
43     public:
TestVideoListener()44         TestVideoListener() {}
~TestVideoListener()45         ~TestVideoListener() {}
46 
OnPlaybackComplete()47         void OnPlaybackComplete() override
48         {
49             if (infoLabel_ != nullptr) {
50                 infoLabel_->SetText("OnPlaybackComplete");
51             }
52         }
53 
OnError(int32_t errorType,int32_t errorCode)54         void OnError(int32_t errorType, int32_t errorCode) override
55         {
56             if (infoLabel_ != nullptr) {
57                 infoLabel_->SetText("OnError");
58             }
59         }
60 
OnInfo(int type,int extra)61         void OnInfo(int type, int extra) override
62         {
63             if (infoLabel_ != nullptr) {
64                 infoLabel_->SetText("OnInfo");
65             }
66         }
67 
OnVideoSizeChanged(int width,int height)68         void OnVideoSizeChanged(int width, int height) override
69         {
70             if (infoLabel_ != nullptr) {
71                 infoLabel_->SetText("OnVideoSizeChanged");
72             }
73         }
74 
OnRewindToComplete()75         void OnRewindToComplete() override
76         {
77             if (infoLabel_ != nullptr) {
78                 infoLabel_->SetText("OnRewindToComplete");
79             }
80         }
81 
OnPlaybackPause()82         void OnPlaybackPause() override
83         {
84             if (infoLabel_ != nullptr) {
85                 infoLabel_->SetText("OnPlaybackPause");
86             }
87         }
88 
OnPlaybackPlay()89         void OnPlaybackPlay() override
90         {
91             if (infoLabel_ != nullptr) {
92                 infoLabel_->SetText("OnPlaybackPlay");
93             }
94         }
95 
OnPlaybackStop()96         void OnPlaybackStop() override
97         {
98             if (infoLabel_ != nullptr) {
99                 infoLabel_->SetText("OnPlaybackStop");
100             }
101         }
102 
SetInfoLabel(UILabel * label)103         void SetInfoLabel(UILabel* label)
104         {
105             infoLabel_ = label;
106         }
107 
108     private:
109         UILabel* infoLabel_ = nullptr;
110     };
111 
112 private:
113     UIScrollView* container_ = nullptr;
114     UIVideo* video_ = nullptr;
115     UILabel* infoLabel_ = nullptr;
116     UILabelButton* loopButton_ = nullptr;
117     UILabelButton* volButtonAdd_ = nullptr;
118     UILabelButton* volButtonSub_ = nullptr;
119     UILabelButton* rewindButtonAdd_ = nullptr;
120     UILabelButton* rewindButtonSub_ = nullptr;
121     UILabelButton* pauseButton_ = nullptr;
122     UILabelButton* playButton_ = nullptr;
123     UILabelButton* stopButton_ = nullptr;
124     UILabelButton* resetButton_ = nullptr;
125     UILabelButton* totleTimeButton_ = nullptr;
126     TestVideoListener* testVideoListener_ = nullptr;
127 };
128 } // namespace OHOS
129 #endif // VERSION_LITE
130 #endif // UI_TEST_VIDEO_H
131