← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~ahayzen/music-app/qml-unit-test-filenames into lp:music-app

 

Andrew Hayzen has proposed merging lp:~ahayzen/music-app/qml-unit-test-filenames into lp:music-app.

Commit message:
* Add qml unit tests for different filenames with media-hub and mediascanner

Requested reviews:
  Music App Developers (music-app-dev)

For more details, see:
https://code.launchpad.net/~ahayzen/music-app/qml-unit-test-filenames/+merge/270512

* Add qml unit tests for different filenames with media-hub and mediascanner

This add a set of qml unit tests, which can be run manually to test that all the possible filenames in the ascii table can be played/found. (Plan is to add this to the manual tests list once that is in the repo).
-- 
Your team Music App Developers is requested to review the proposed merge of lp:~ahayzen/music-app/qml-unit-test-filenames into lp:music-app.
=== modified file 'app/components/Player.qml'
--- app/components/Player.qml	2015-06-28 03:06:49 +0000
+++ app/components/Player.qml	2015-09-09 11:29:54 +0000
@@ -40,6 +40,7 @@
     property int currentIndex: -1
     property int duration: 1
     readonly property bool isPlaying: player.playbackState === MediaPlayer.PlayingState
+    readonly property bool loaded: mediaPlayerLoader.status == Loader.Ready
     readonly property var playbackState: mediaPlayerLoader.status == Loader.Ready ? mediaPlayerLoader.item.playbackState : MediaPlayer.StoppedState
     property int position: 0
     property alias repeat: settings.repeat

=== modified file 'debian/changelog'
--- debian/changelog	2015-09-08 14:18:46 +0000
+++ debian/changelog	2015-09-09 11:29:54 +0000
@@ -1,3 +1,4 @@
+<<<<<<< TREE
 music-app (2.2ubuntu2) UNRELEASED; urgency=medium
 
   [ Bartosz Kosiorek ]
@@ -5,6 +6,14 @@
 
  -- Bartosz Kosiorek <gang65@xxxxxxxxxxxxxx>  Tue, 08 Sep 2015 10:08:49 +0200
 
+=======
+music-app (2.2ubuntu2) UNRELEASED; urgency=medium
+
+  * Add qml unit tests for different filenames with media-hub and mediascanner
+
+ -- Andrew Hayzen <andy@andy-Pangolin-Performance>  Tue, 08 Sep 2015 17:12:29 +0100
+
+>>>>>>> MERGE-SOURCE
 music-app (2.2ubuntu1) vivid; urgency=medium
 
   [ Victor Thompson ]

=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt	2014-01-31 20:43:59 +0000
+++ tests/CMakeLists.txt	2015-09-09 11:29:54 +0000
@@ -1,1 +1,2 @@
 add_subdirectory(autopilot)
+add_subdirectory(unit)

=== added directory 'tests/unit'
=== added file 'tests/unit/CMakeLists.txt'
--- tests/unit/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ tests/unit/CMakeLists.txt	2015-09-09 11:29:54 +0000
@@ -0,0 +1,6 @@
+# make the emulator files visible on qtcreator
+file(GLOB QML_UNIT_TEST_FILES
+     RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+     *.qml *.sh)
+
+add_custom_target(com_ubuntu_music_QMLUNITTESTFiles ALL SOURCES ${QML_UNIT_TEST_FILES})

=== added directory 'tests/unit/files'
=== added directory 'tests/unit/files/original'
=== added file 'tests/unit/files/original/1.ogg'
Binary files tests/unit/files/original/1.ogg	1970-01-01 00:00:00 +0000 and tests/unit/files/original/1.ogg	2015-09-09 11:29:54 +0000 differ
=== added file 'tests/unit/generate_files.sh'
--- tests/unit/generate_files.sh	1970-01-01 00:00:00 +0000
+++ tests/unit/generate_files.sh	2015-09-09 11:29:54 +0000
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+mkdir files/generated
+
+for i in {32..126}  # from 'Space' to '~'
+do
+    if [ $i -eq 46 ] || [ $i -eq 47 ]  # skip '.' and '/'
+    then
+        continue
+    else
+        chr=$(printf \\$(printf '%03o' $i))
+
+        echo "Creating file $chr.ogg from 1.ogg"
+        cp "files/original/1.ogg" "files/generated/$chr.ogg"
+    fi
+done

=== added file 'tests/unit/setup_run_on_device.sh'
--- tests/unit/setup_run_on_device.sh	1970-01-01 00:00:00 +0000
+++ tests/unit/setup_run_on_device.sh	2015-09-09 11:29:54 +0000
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Copy music app to device
+adb push ../../. /tmp/music-app-unit-test
+
+# Generate files
+./generate_files.sh
+
+# Copy files to device
+adb push files/generated /home/phablet/Music/QMLTest
+
+# TODO: make writeable ?
+
+# Install requirements
+adb shell sudo apt-get install ubuntu-app-test qtdeclarative5-dev-tools qml-module-qttest -y
+
+adb shell "sudo apt-get install ubuntu-app-test qtdeclarative5-dev-tools qml-module-qttest -y"
+
+# Run qmltestrunner
+adb shell "cd /tmp/music-app-unit-test/tests/unit && ubuntu-app-test qmltestrunner -silent -eventdelay 500"
+
+# Clean up
+adb shell "rm -rf /home/phablet/Music/QMLTest"
+adb shell "rm -rf /tmp/music-app-unit-test"
+rm -rf files/generated

=== added file 'tests/unit/tst_filenames.qml'
--- tests/unit/tst_filenames.qml	1970-01-01 00:00:00 +0000
+++ tests/unit/tst_filenames.qml	2015-09-09 11:29:54 +0000
@@ -0,0 +1,116 @@
+
+import QtTest 1.0
+import QtQuick 2.4
+import Ubuntu.Components 1.2
+import Ubuntu.MediaScanner 0.1
+import Ubuntu.Test 1.0
+
+import "../../app/components"
+
+MainView {
+    // Wrapper function around decodeURIComponent() to prevent exceptions
+    // from bubbling up to the app.
+    function decodeFileURI(filename)
+    {
+        var newFilename = "";
+        try {
+            newFilename = decodeURIComponent(filename);
+        } catch (e) {
+            newFilename = filename;
+            console.log("Unicode decoding error:", filename, e.message)
+        }
+
+        return newFilename;
+    }
+
+    Item {
+        id: trackQueue
+
+        property ListModel model: ListModel {
+
+        }
+    }
+
+    /* Mediahub */
+    Player {
+        id: player
+    }
+
+    /* Mediascanner */
+    SongsModel {
+        id: songsModel
+        store: MediaStore {
+            id: musicStore
+        }
+    }
+
+    /* UnitTests */
+    UbuntuTestCase {
+        property var filepaths: [
+
+        ]
+
+        function init() {
+            // Wait for the async MediaPlayer to load
+            tryCompare(player, "loaded", true, 250, "Player has not loaded");
+        }
+
+        function init_data() {
+            return filepaths;
+        }
+
+        function initTestCase() {
+            // Build up filenames to test
+            var blacklist = [46, 47];  // '.', '/'
+
+            for (var i=32; i < 127; i++) {
+                if (blacklist.indexOf(i) > -1) {
+                    continue;
+                } else {
+                    var chr = String.fromCharCode(i);
+                    filepaths.push({ filepath: "/home/phablet/Music/QMLTest/" + chr + ".ogg", tag: chr });
+                }
+            }
+        }
+
+        function test_mediascanner(data) {
+            var filepath = decodeFileURI(data.filepath);
+            var msResult = musicStore.lookup(filepath);
+
+            // Check lookup from ms2 returned something
+            verify(msResult !== null, "Mediascanner2 could not find track - " + filepath);
+
+            compare(msResult.title, "Test Sound", "Mediascanner title is not the same - " + filepath);
+            compare(msResult.album, "Test Album", "Mediascanner album is not the same - " + filepath);
+            compare(msResult.author, "Test Artist", "Mediascanner author is not the same - " + filepath);
+            compare(msResult.art, "image://albumart/artist=Test%20Artist&album=Test%20Album", "Mediascanner art is not the same - " + filepath);
+        }
+
+        function test_media_hub(data) {
+            if (data.tag === "#") {  // manually skip otherwise media-hub crashes
+                // FIXME: MediaHub won't play '#' due to http://pad.lv/1449790
+                // expectFail("#", "MediaHub won't play '#' due to http://pad.lv/1449790";)
+
+                /*
+                  // FIXME: Not sure why this doesn't work, it should only skip this data row but it skips the test
+                if (data.tag === "#") {
+                    skip("MediaHub won't play '#' due to http://pad.lv/1449790";)
+                }
+                */
+            } else {
+                var filepath = data.filepath;
+
+                player.setSource(filepath);
+                player.play();
+
+                wait(1100);  // Wait for the track to reach > 1s
+
+                // Check that track is playing and the position has changed
+                compare(player.isPlaying, true, "MediaHub is not playing the track - " + filepath);
+                verify(player.position > 0, "MediaHub position has not changed - " + filepath + " - " + player.position);
+
+                player.pause();
+            }
+        }
+    }
+}


Follow ups