Merge lp:~ahayzen/music-app/add-url-dispatcher-tests into lp:music-app/trusty

Proposed by Andrew Hayzen
Status: Work in progress
Proposed branch: lp:~ahayzen/music-app/add-url-dispatcher-tests
Merge into: lp:music-app/trusty
Diff against target: 280 lines (+124/-31)
7 files modified
click/manifest.json.in (+7/-1)
debian/control (+2/-0)
music-app.qml (+24/-26)
tests/autopilot/music_app/__init__.py (+6/-1)
tests/autopilot/music_app/tests/__init__.py (+3/-3)
tests/autopilot/music_app/tests/test_music.py (+60/-0)
tests/autopilot/music_app/url_dispatcher.py (+22/-0)
To merge this branch: bzr merge lp:~ahayzen/music-app/add-url-dispatcher-tests
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Leo Arias (community) code review of the autopilot code Approve
Andrew Hayzen Abstain
Review via email: mp+233840@code.launchpad.net

Commit message

* Add tests for url-dispatcher
* Fix for depends and allow autopkg support
* Fix for recent item added even with a bad url

Description of the change

* Add tests for url-dispatcher
* Fix for depends and allow autopkg support
* Fix for recent item added even with a bad url

TESTING:
This should be tested on device in the following way...

Install the new click package:
$ bzr branch lp:~andrew-hayzen/music-app/add-url-dispatcher-tests /tmp/add-dispatcher-tests
$ cd /tmp/add-dispatcher-tests
$ click-buddy --dir . --provision

To just run the changed tests:
$ ADT_AUTOPILOT_MODULE="-v music_app.tests.test_music.TestMainWindow.test_url_dispatcher_album_play" adt-run /tmp/add-dispatcher-tests --click com.ubuntu.music --- ssh -s adb
$ ADT_AUTOPILOT_MODULE="-v music_app.tests.test_music.TestMainWindow.test_url_dispatcher_music_play" adt-run /tmp/add-dispatcher-tests --click com.ubuntu.music --- ssh -s adb

To run all tests:
$ adt-run /tmp/add-dispatcher-tests --click com.ubuntu.music --- ssh -s adb

Note you need a newer adt if you are on trusty see instructions for install of autopkgtest here [0]

0 - http://www.theorangenotebook.com/2014/09/autopilot-test-runners.html

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
620. By Andrew Hayzen

* Move dispatcher to helper

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
621. By Andrew Hayzen

* Merge of trunk

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
622. By Andrew Hayzen

* Fix for use of old artistName

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
623. By Andrew Hayzen

* Fix for unicode errors
* Jenkins debug

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
624. By Andrew Hayzen

* Ensure url-dispatcher has started before calling it

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
625. By Andrew Hayzen

* Pep8 fix

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
626. By Andrew Hayzen

* Only run tests when in click environment

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

Some inline comments.

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

#blocked as you cannot test due to bug 1370800

I've started resolving the comments, but we really need to fix ^^ bug first, otherwise you can't test if these works.

627. By Andrew Hayzen

* Various fixes for url-dispatcher

628. By Andrew Hayzen

* Merge of trunk

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
629. By Andrew Hayzen

* Fixes for pep8

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
630. By Andrew Hayzen

* Remove code comments

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

Some pita comments inline. This is pretty good, thanks Andrew.

631. By Andrew Hayzen

* Various fixes

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

I would like to land this after this [0] has landed so blocking myself for a bit.

0 - https://code.launchpad.net/~andrew-hayzen/music-app/ap-mocking-fixes/+merge/235821

review: Needs Fixing
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
632. By Andrew Hayzen

* Merge of trunk

Revision history for this message
Andrew Hayzen (ahayzen) wrote :

Unblocking myself as the other mp has landed.

review: Abstain
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

ahayzen_: as you added the decorator to the url dispatcher call, you don't need
235 + logger.debug("Calling URL Dispatcher - " + path)
elopio, ah yes good spot ;)
ahayzen_: and last pita comment, pep8 recommends to capitalize all the letter of an abbreviation.
so URLDispatcher instead of UrlDispatcher.
elopio, ah yes ok i'll do that
ahayzen_: I'm really happy with your python code. I don't know much about the QML code, so it would be safer if you get somebody to review that part.

review: Approve (code review of the autopilot code)
633. By Andrew Hayzen

* Removal of extra debugging
* Rename UrlDispatcher to URLDispatcher

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

What's up with this mp?

Revision history for this message
Victor Thompson (vthompson) wrote :

In my opinion we could do either of the following:

1. Finish review and merge this into trunk, then merge the change into the remix branch. Benefit being that the 2 added tests get some usage early on, negative being that this is extra work if something isn't quite right.
2. Create a new MP for this once remix is trunk. Benefit being we can still focus on our redesign without possible distraction.

#2 might be the safest, but #1 might be preferable if we want these tests in as early as possible.

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

I'd vote to go with the second; heads down on remix. Thanks.

Revision history for this message
Victor Thompson (vthompson) wrote :

I'll put this as a WIP as it will probably be resubmitted.

Unmerged revisions

633. By Andrew Hayzen

* Removal of extra debugging
* Rename UrlDispatcher to URLDispatcher

632. By Andrew Hayzen

* Merge of trunk

631. By Andrew Hayzen

* Various fixes

630. By Andrew Hayzen

* Remove code comments

629. By Andrew Hayzen

* Fixes for pep8

628. By Andrew Hayzen

* Merge of trunk

627. By Andrew Hayzen

* Various fixes for url-dispatcher

626. By Andrew Hayzen

* Only run tests when in click environment

625. By Andrew Hayzen

* Pep8 fix

624. By Andrew Hayzen

* Ensure url-dispatcher has started before calling it

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'click/manifest.json.in'
--- click/manifest.json.in 2014-09-08 08:08:13 +0000
+++ click/manifest.json.in 2014-09-25 16:56:36 +0000
@@ -20,6 +20,12 @@
20 "vcs-bzr-revno": "@BZR_REVNO@"20 "vcs-bzr-revno": "@BZR_REVNO@"
21 },21 },
22 "x-test": {22 "x-test": {
23 "autopilot": "@AUTOPILOT_DIR@"23 "autopilot": {
24 "autopilot_module": "@AUTOPILOT_DIR@",
25 "depends": [
26 "python3-fixtures",
27 "url-dispatcher-tools"
28 ]
29 }
24 }30 }
25}31}
2632
=== modified file 'debian/control'
--- debian/control 2014-09-08 13:24:22 +0000
+++ debian/control 2014-09-25 16:56:36 +0000
@@ -39,7 +39,9 @@
39Depends: libautopilot-qt (>= 1.4),39Depends: libautopilot-qt (>= 1.4),
40 libqt5test5,40 libqt5test5,
41 music-app (= ${source:Version}),41 music-app (= ${source:Version}),
42 python3-fixtures,
42 ubuntu-ui-toolkit-autopilot,43 ubuntu-ui-toolkit-autopilot,
44 url-dispatcher-tools,
43 ${misc:Depends},45 ${misc:Depends},
44Description: Autopilot tests for Music App46Description: Autopilot tests for Music App
45 This package contains the autopilot tests for the Music App47 This package contains the autopilot tests for the Music App
4648
=== modified file 'music-app.qml'
--- music-app.qml 2014-09-23 15:59:28 +0000
+++ music-app.qml 2014-09-25 16:56:36 +0000
@@ -204,22 +204,17 @@
204 target: UriHandler204 target: UriHandler
205205
206 function processAlbum(uri) {206 function processAlbum(uri) {
207 selectedAlbum = true;
208 var split = uri.split("/");207 var split = uri.split("/");
209208
210 if (split.length < 2) {209 if (split.length < 2) {
211 console.debug("Unknown artist-album " + uri + ", skipping")210 console.debug("Unknown artist-album " + uri + ", skipping")
212 return;211 } else {
212 selectedAlbum = true;
213
214 // Filter by artist and album
215 songsAlbumArtistModel.artist = decodeURIComponent(split[0]);
216 songsAlbumArtistModel.album = decodeURIComponent(split[1]);
213 }217 }
214
215 // Filter by artist and album
216 songsAlbumArtistModel.artist = decodeURIComponent(split[0]);
217 songsAlbumArtistModel.album = decodeURIComponent(split[1]);
218
219 // Add album to recent list
220 Library.addRecent(songsAlbumArtistModel.album, songsAlbumArtistModel.artist, songsAlbumArtistModel.art, songsAlbumArtistModel.album, "album")
221 mainView.hasRecent = true
222 recentModel.filterRecent()
223 }218 }
224219
225 function processFile(uri, play) {220 function processFile(uri, play) {
@@ -230,20 +225,19 @@
230225
231 if (!track) {226 if (!track) {
232 console.debug("Unknown file " + uri + ", skipping")227 console.debug("Unknown file " + uri + ", skipping")
233 return;228 } else {
234 }229 if (play) {
235230 // clear play queue
236 if (play) {231 trackQueue.model.clear()
237 // clear play queue232 }
238 trackQueue.model.clear()233
239 }234 // enqueue
240235 trackQueue.append(makeDict(track));
241 // enqueue236
242 trackQueue.append(makeDict(track));237 // play first URI
243238 if (play) {
244 // play first URI239 trackQueueClick(trackQueue.model.count - 1);
245 if (play) {240 }
246 trackQueueClick(trackQueue.model.count - 1);
247 }241 }
248 }242 }
249243
@@ -257,7 +251,6 @@
257 else if (uri.indexOf("music://") === 0) {251 else if (uri.indexOf("music://") === 0) {
258 uriHandler.processFile(uri.substring(8), play);252 uriHandler.processFile(uri.substring(8), play);
259 }253 }
260
261 else {254 else {
262 console.debug("Unsupported URI " + uri + ", skipping")255 console.debug("Unsupported URI " + uri + ", skipping")
263 }256 }
@@ -735,6 +728,11 @@
735 // Play album it tracks exist728 // Play album it tracks exist
736 if (rowCount > 0 && selectedAlbum) {729 if (rowCount > 0 && selectedAlbum) {
737 trackClicked(songsAlbumArtistModel, 0, true, true);730 trackClicked(songsAlbumArtistModel, 0, true, true);
731
732 // Add album to recent list
733 Library.addRecent(songsAlbumArtistModel.album, songsAlbumArtistModel.artist, null, songsAlbumArtistModel.album, "album")
734 mainView.hasRecent = true
735 recentModel.filterRecent()
738 } else if (selectedAlbum) {736 } else if (selectedAlbum) {
739 console.debug("Unknown artist-album " + artist + "/" + album + ", skipping")737 console.debug("Unknown artist-album " + artist + "/" + album + ", skipping")
740 }738 }
741739
=== modified file 'tests/autopilot/music_app/__init__.py'
--- tests/autopilot/music_app/__init__.py 2014-09-05 22:20:29 +0000
+++ tests/autopilot/music_app/__init__.py 2014-09-25 16:56:36 +0000
@@ -6,6 +6,7 @@
6# by the Free Software Foundation.6# by the Free Software Foundation.
77
8"""music-app tests and emulators - top level package."""8"""music-app tests and emulators - top level package."""
9from music_app.url_dispatcher import URLDispatcher
9from ubuntuuitoolkit import MainView, UbuntuUIToolkitCustomProxyObjectBase10from ubuntuuitoolkit import MainView, UbuntuUIToolkitCustomProxyObjectBase
1011
1112
@@ -32,7 +33,7 @@
32 return func_wrapper33 return func_wrapper
3334
3435
35class MusicApp(object):36class MusicApp():
36 """Autopilot helper object for the Music application."""37 """Autopilot helper object for the Music application."""
3738
38 def __init__(self, app_proxy):39 def __init__(self, app_proxy):
@@ -40,6 +41,10 @@
40 self.main_view = self.app.wait_select_single(MainView)41 self.main_view = self.app.wait_select_single(MainView)
41 self.player = self.app.select_single(Player, objectName='player')42 self.player = self.app.select_single(Player, objectName='player')
4243
44 def call_url_dispatcher(self, protocol, path):
45 dispatcher = URLDispatcher()
46 dispatcher.call_dispatcher(protocol, path)
47
43 def get_add_to_playlist_page(self):48 def get_add_to_playlist_page(self):
44 return self.app.wait_select_single(Page11,49 return self.app.wait_select_single(Page11,
45 objectName="addToPlaylistPage")50 objectName="addToPlaylistPage")
4651
=== modified file 'tests/autopilot/music_app/tests/__init__.py'
--- tests/autopilot/music_app/tests/__init__.py 2014-09-25 00:39:47 +0000
+++ tests/autopilot/music_app/tests/__init__.py 2014-09-25 16:56:36 +0000
@@ -62,10 +62,10 @@
6262
63 def setUp(self):63 def setUp(self):
64 super(BaseTestCaseWithPatchedHome, self).setUp()64 super(BaseTestCaseWithPatchedHome, self).setUp()
65 _, test_type = self.get_launcher_method_and_type()65 launcher_method, self.test_type = self.get_launcher_method_and_type()
66 self.home_dir = self._patch_home(test_type)66 self.home_dir = self._patch_home(self.test_type)
6767
68 self._create_music_library(test_type)68 self._create_music_library(self.test_type)
6969
70 @autopilot_logging.log_action(logger.info)70 @autopilot_logging.log_action(logger.info)
71 def launch_test_local(self):71 def launch_test_local(self):
7272
=== modified file 'tests/autopilot/music_app/tests/test_music.py'
--- tests/autopilot/music_app/tests/test_music.py 2014-09-23 20:45:41 +0000
+++ tests/autopilot/music_app/tests/test_music.py 2014-09-25 16:56:36 +0000
@@ -11,6 +11,7 @@
1111
12import logging12import logging
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
14import os
14from testtools.matchers import Equals, GreaterThan, LessThan, NotEquals15from testtools.matchers import Equals, GreaterThan, LessThan, NotEquals
1516
1617
@@ -47,6 +48,9 @@
47 }48 }
48 ]49 ]
4950
51 def is_click(self):
52 return self.test_type == "click"
53
50 @property54 @property
51 def player(self):55 def player(self):
52 return self.app.player56 return self.app.player
@@ -627,6 +631,62 @@
627 Eventually(Equals(self.tracks[-1]["title"])))631 Eventually(Equals(self.tracks[-1]["title"])))
628 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))632 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
629633
634 def test_launch_album_from_url_dispatcher_must_play_it(self):
635 """Test that the album:// url plays the correct album/artist"""
636
637 # Url dispatcher only works in a click-based env for now
638 if not self.is_click():
639 self.skipTest("URL dispatcher works only for installed click "
640 "packages.")
641
642 # create path for album://
643 album_artist = os.path.join(os.path.sep, self.tracks[1]["artist"],
644 self.tracks[1]["album"])
645
646 # Run url-dispatcher call
647 self.app.call_url_dispatcher("album://", album_artist)
648
649 self.player.isPlaying.wait_for(True) # ensure track is playing
650
651 # Check that the album and artist are correct
652 self.assertThat(self.player.currentMetaArtist,
653 Eventually(Equals(self.tracks[1]["artist"])))
654 self.assertThat(self.player.currentMetaAlbum,
655 Eventually(Equals(self.tracks[1]["album"])))
656
657 # Check now playing page is shown
658 now_playing_page = self.app.get_now_playing_page()
659 now_playing_page.visible.wait_for(True)
660
661 # Check that the play queue count is correct
662 self.assertThat(now_playing_page.get_count(), Eventually(Equals(1)))
663
664 def test_launch_music_from_url_dispatcher_must_play_it(self):
665 """Test that the music:// url plays the correct file"""
666
667 # Url dispatcher only works in a click-based env for now
668 if not self.is_click():
669 self.skipTest("URL dispatcher works only for installed click "
670 "packages.")
671
672 path = os.path.join(self.home_dir, "Music", self.tracks[0]["source"])
673
674 # Run url-dispatcher call
675 self.app.call_url_dispatcher("music://", path)
676
677 self.player.isPlaying.wait_for(True) # ensure track is playing
678
679 # Check that the source of the file is correct
680 self.assertThat(self.player.source,
681 Eventually(Equals("file://" + path)))
682
683 # Check now playing page is shown
684 now_playing_page = self.app.get_now_playing_page()
685 now_playing_page.visible.wait_for(True)
686
687 # Check that the play queue count is correct
688 self.assertThat(now_playing_page.get_count(), Eventually(Equals(1)))
689
630 def test_pressing_prev_after_5_seconds(self):690 def test_pressing_prev_after_5_seconds(self):
631 """Pressing previous after 5s jumps to the start of current song"""691 """Pressing previous after 5s jumps to the start of current song"""
632692
633693
=== added file 'tests/autopilot/music_app/url_dispatcher.py'
--- tests/autopilot/music_app/url_dispatcher.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/music_app/url_dispatcher.py 2014-09-25 16:56:36 +0000
@@ -0,0 +1,22 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2# Copyright 2014 Canonical
3#
4# This program is free software: you can redistribute it and/or modify it
5# under the terms of the GNU General Public License version 3, as published
6# by the Free Software Foundation.
7
8import autopilot.logging as autopilot_logging
9import logging
10import subprocess
11
12logger = logging.getLogger(__name__)
13
14
15class URLDispatcher(object):
16
17 """Helper for the URLDispatcher"""
18
19 @autopilot_logging.log_action(logger.info)
20 def call_dispatcher(self, protocol, path):
21 # Run call to url-dispatcher
22 return subprocess.check_call(["url-dispatcher", protocol + path])

Subscribers

People subscribed via source and target branches

to status/vote changes: