on xenial help sign in
Fix Movie preview aspect ratio.
3f08adbYing-Chun Liu
Dash/Movie/MoviePreview.qml+2−3
@@ -34,7 +34,7 @@ DashPreview {
34 header: Rectangle {
34 header: Rectangle {
35 anchors.left: parent.left
35 anchors.left: parent.left
36 anchors.right: parent.right
36 anchors.right: parent.right
37− height: units.gu(16)
37+ height: width * 9 / 16
38 color: "black"
38 color: "black"
39
39
40 Video {
40 Video {
@@ -62,8 +62,7 @@ DashPreview {
62 if (root.playable) {
62 if (root.playable) {
63 if (video.playbackState == MediaPlayer.PlayingState) {
63 if (video.playbackState == MediaPlayer.PlayingState) {
64 video.pause();
64 video.pause();
65− } else if (video.playbackState
65+ } else if (video.playbackState == MediaPlayer.PausedState) {
66− == MediaPlayer.PausedState) {
67 video.play();
66 video.play();
68 } else {
67 } else {
69 video.play();
68 video.play();
tests/qmltests/Dash/Movie/tst_MoviePreview.qml+26−37
@@ -24,42 +24,18 @@ Item {
24 width: units.gu(60)
24 width: units.gu(60)
25 height: units.gu(80)
25 height: units.gu(80)
26
26
27− property var calls
27+ property var calls: []
28+ property int counter: 0
28
29
29− function get_actions() {
30+ function get_actions_data() {
30− var a1 = new Object();
31+ return [
31− a1.id = 123;
32− a1.displayName = "Play";
33− a1.iconHint = "image://theme/search";
32+ { id: 123, displayName: "Play", iconHint: "image://theme/search" },
34− var a2 = new Object();
35− a2.id = 456;
36− a2.displayName = "Buy";
37− a2.iconHint = "image://theme/search";
33+ { id: 456, displayName: "Buy", iconHint: "image://theme/search" },
38− var a3 = new Object();
39− a3.id = 789;
40− a3.displayName = "Delete";
34+ { id: 789, displayName: "Delete", iconHint: "image//theme/search" }
41− a3.iconHint = "image://theme/search";
35+ ]
42−
43− return [a1, a2, a3];
44− }
45−
46− function get_data() {
47− var objData = new Object();
48− objData.rendererName = "preview-movie";
49− objData.title = "Unity Movie";
50− objData.subtitle = "Subtitle";
51− objData.description = "This is the description";
52− objData.image = "image://theme/syncing";
53− objData.actions = get_actions();
54− objData.year = "2013"
55− objData.rating = 3
56− objData.numRatings = 1
57− objData.execute = prueba;
58−
59− return objData;
60 }
36 }
61
37
62− function prueba(id, data){
38+ function fake_callback(id, data){
63 root.calls[root.calls.length] = id;
39 root.calls[root.calls.length] = id;
64 }
40 }
65
41
@@ -68,17 +44,30 @@ Item {
68 id: moviePreview
44 id: moviePreview
69 anchors.fill: parent
45 anchors.fill: parent
70
46
71− previewData: get_data()
47+ previewData: QtObject {
48+ property string rendererName: "preview-movie"
49+ property string title: "Unity Movie"
50+ property string subtitle: "Subtitle"
51+ property string description: "This is the description"
52+ property string image: "image://theme/syncing"
53+ property var actions: get_actions_data()
54+ property string year: "2013"
55+ property int rating: 3
56+ property int numRatings: 1
57+ property var execute: fake_callback
58+ }
72 }
59 }
73
60
74 UT.UnityTestCase {
61 UT.UnityTestCase {
75 name: "MoviePreviewTest"
62 name: "MoviePreviewTest"
76 when: windowShown
63 when: windowShown
77
64
78− function test_actions() {
65+ function init() {
79 root.calls = new Array();
66 root.calls = new Array();
67+ }
68+
69+ function test_numofbuttons() {
80 var buttons = findChild(moviePreview, "gridButtons");
70 var buttons = findChild(moviePreview, "gridButtons");
81− wait(10000);
82 compare(buttons.count, 3);
71 compare(buttons.count, 3);
83
72
84 for(var i = 0; i < buttons.count; i++) {
73 for(var i = 0; i < buttons.count; i++) {
@@ -86,7 +75,7 @@ Item {
86 buttons.currentItem.clicked();
75 buttons.currentItem.clicked();
87 }
76 }
88
77
89− var actions = get_actions();
78+ var actions = get_actions_data();
90 for(var i = 0; i < actions.length; i++) {
79 for(var i = 0; i < actions.length; i++) {
91 compare(root.calls[i], actions[i].id);
80 compare(root.calls[i], actions[i].id);
92 }
81 }