2
* Copyright 2016 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
import "../../../qml/Components/MediaServices"
20
import Unity.Test 0.1 as UT
21
import Ubuntu.Components 1.3
22
import QtMultimedia 5.0
30
property var sourceData: {
31
// TODO do we want a video or make this fake
32
"source": "file:///home/nick/Videos/test-mpeg.ogv",
33
"screenshot": Qt.resolvedUrl("../Dash/artwork/avatar.png")
36
property var sourceData2: {
37
// TODO do we want a video or make this fake
38
"source": "file:///home/nick/Videos/test-mpeg2.ogv",
39
"screenshot": Qt.resolvedUrl("../Dash/artwork/checkers.png")
43
source: root.sourceData["source"]
46
"title" : "TEST MPEG",
47
"resolution" : { "width": 160, "height": 90 }
52
source: root.sourceData2["source"]
55
"title" : "TEST MPEG",
56
"resolution" : { "width": 90, "height": 240 }
76
sourceData: root.sourceData
80
maximumEmbeddedHeight: undefined
95
anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
99
onClicked: services.fullscreen = !services.fullscreen
101
UT.MouseTouchEmulationCheckbox {}
113
name: "VideoMediaServices"
116
property int oldControlTimerInterval: 0;
119
services.sourceData = root.sourceData
120
services.context = "video";
122
var controlHideTimer = findInvisibleChild(services, "controlHideTimer");
123
verify(controlHideTimer !== null);
124
oldControlTimerInterval = controlHideTimer.interval;
128
serviceCloseSpy.clear();
129
services.context = "";
130
services.fullscreen = false;
131
services.maximumEmbeddedHeight = undefined;
132
tryCompareFunction(function() { return services.header ? services.header.visible : false }, false);
133
tryCompareFunction(function() { return services.footer ? services.footer.visible : false }, false);
135
var controlHideTimer = findInvisibleChild(services, "controlHideTimer");
136
controlHideTimer.interval = oldControlTimerInterval;
139
function test_videoWidget() {
140
var videoPlayer = findChild(services, "videoPlayer");
141
verify(videoPlayer !== null);
143
var videoControls = findChild(services, "videoControls");
144
verify(videoControls !== null);
147
function test_tapVideoPlayerToPlayAndPause() {
148
var videoPlayer = findChild(services, "videoPlayer");
149
verify(videoPlayer !== null)
150
tap(videoPlayer, videoPlayer.width/2, videoPlayer.height/2);
152
var mediaPlayer = findInvisibleChild(services, "mediaPlayer");
153
verify(mediaPlayer !== null);
154
compare(mediaPlayer.playbackState, MediaPlayer.PlayingState, "Media player should be playing");
156
tap(videoPlayer, videoPlayer.width/2, videoPlayer.height/2);
157
compare(mediaPlayer.playbackState, MediaPlayer.PausedState, "Media player should be playing");
160
function test_fullscreenSwitch() {
161
var mediaPlayer = findInvisibleChild(services, "mediaPlayer");
162
verify(mediaPlayer !== null);
164
wait(UbuntuAnimation.BriskDuration); // animation
166
var button = findChild(services, "viewActionButton");
167
verify(button !== null);
170
compare(services.fullscreen, true, "Should have switched to fullscreen mode.");
173
function test_HeaderVisibleOnlyWhenFullscreen() {
174
services.fullscreen = false;
175
compare(services.header, null, "Header should be null when not fullscreen");
176
services.fullscreen = true;
177
tryCompareFunction(function() { return services.header !== null }, true);
180
function test_ControlsShowAndHideWhenPlayed() {
181
services.fullscreen = true;
182
var controlHideTimer = findInvisibleChild(services, "controlHideTimer");
183
controlHideTimer.interval = 100;
185
var mediaPlayer = findInvisibleChild(services, "mediaPlayer");
188
tryCompare(services.header, "visible", true);
189
tryCompare(services.footer, "visible", true);
191
tryCompare(services.header, "visible", false);
192
tryCompare(services.footer, "visible", false);
195
function test_ControlsDontTimeOutWhenPaused() {
196
services.fullscreen = true;
197
var controlHideTimer = findInvisibleChild(services, "controlHideTimer");
198
controlHideTimer.interval = 100;
200
var mediaPlayer = findInvisibleChild(services, "mediaPlayer");
205
compare(services.header.visible, true, "Header should still be visible");
206
compare(services.footer.visible, true, "Footer should still be visible");
209
function test_close() {
210
services.fullscreen = true;
211
var mediaPlayer = findInvisibleChild(services, "mediaPlayer");
214
wait(UbuntuAnimation.BriskDuration); // animation
216
var navigationButton = findChild(services, "navigationButton");
217
verify(navigationButton !== null);
219
tap(navigationButton);
220
compare(serviceCloseSpy.count, 1, "close was not called");
223
function test_maximumVideoSize() {
224
services.maximumEmbeddedHeight = root.height / 2
225
services.sourceData = root.sourceData2
226
verify(services.content !== null);
227
tryCompare(services.content, "height", root.height/2);