Merge lp:~elopio/ubuntuone-testing/music into lp:ubuntuone-testing

Proposed by Leo Arias
Status: Merged
Approved by: Rick McBride
Approved revision: 65
Merged at revision: 60
Proposed branch: lp:~elopio/ubuntuone-testing/music
Merge into: lp:ubuntuone-testing
Diff against target: 276 lines (+237/-3)
5 files modified
ubuntuone/web/tests/sst/music/u1webm001_playsong.py (+34/-0)
ubuntuone/web/tests/sst/navigation/u1webn001_maintabs.py (+1/-2)
ubuntuone/web/tests/sst/shared/actions/files.py (+0/-1)
ubuntuone/web/tests/sst/shared/actions/music.py (+177/-0)
ubuntuone/web/tests/sst/shared/data/song.py (+25/-0)
To merge this branch: bzr merge lp:~elopio/ubuntuone-testing/music
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
Review via email: mp+85046@code.launchpad.net

Commit message

First part of music testing modules.

Description of the change

First part of the music actions and tests.
Music modules are not completed, but I want to merge everything I have, so tomorrow I can make the renaming and update to new sst.
On the second part a few more tests are coming, and a clever way not to require an existing user with preloaded music. I don't know yet who'll code come with that clever solution...

To post a comment you must log in.
Revision history for this message
Rick McBride (rmcbride) wrote :

This is a great start.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'ubuntuone/web/tests/sst/music'
=== added file 'ubuntuone/web/tests/sst/music/u1webm001_playsong.py'
--- ubuntuone/web/tests/sst/music/u1webm001_playsong.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/music/u1webm001_playsong.py 2011-12-08 23:07:24 +0000
@@ -0,0 +1,34 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Test case u1webm-001 Play song.
18Play a song on the Ubuntu One web music player.
19
20"""
21
22from sst.actions import *
23import actions.setup as setup_actions
24import actions.music as music_actions
25from data.song import Song
26
27setup_actions.setup()
28music_actions.open()
29song = Song('gentle marimba', 'Alastair Cameron', 'Free Film Music (cameronmusic.co.uk)')
30music_actions.play_song(song)
31music_actions.assert_songs_added_to_queue([song])
32music_actions.assert_current_song(song)
33music_actions.assert_player_playing()
34music_actions.assert_player_title(1, 1)
035
=== modified file 'ubuntuone/web/tests/sst/navigation/u1webn001_maintabs.py'
--- ubuntuone/web/tests/sst/navigation/u1webn001_maintabs.py 2011-11-15 06:58:55 +0000
+++ ubuntuone/web/tests/sst/navigation/u1webn001_maintabs.py 2011-12-08 23:07:24 +0000
@@ -28,7 +28,6 @@
28setup_actions.setup()28setup_actions.setup()
29dashboard_actions.assert_title()29dashboard_actions.assert_title()
30files_actions.open()30files_actions.open()
31# TODO waiting for Rick's branch.31notes_actions.open()
32#notes_actions.open()
33contacts_actions.open()32contacts_actions.open()
34dashboard_actions.open()33dashboard_actions.open()
3534
=== modified file 'ubuntuone/web/tests/sst/shared/actions/files.py'
--- ubuntuone/web/tests/sst/shared/actions/files.py 2011-11-17 21:59:58 +0000
+++ ubuntuone/web/tests/sst/shared/actions/files.py 2011-12-08 23:07:24 +0000
@@ -21,7 +21,6 @@
2121
22from sst.actions import *22from sst.actions import *
23from sst.actions import _get_elem23from sst.actions import _get_elem
24from config import DEFAULT_TIMEOUT
25from loading import *24from loading import *
26import urlparse25import urlparse
2726
2827
=== added file 'ubuntuone/web/tests/sst/shared/actions/music.py'
--- ubuntuone/web/tests/sst/shared/actions/music.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/shared/actions/music.py 2011-12-08 23:07:24 +0000
@@ -0,0 +1,177 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Actions for the Music page of the Ubuntu One website."""
18
19from sst.actions import *
20from loading import *
21import urlparse
22
23def open():
24 """Open the music page and assert it's title."""
25 # TODO when the music player is released, then we have to uncomment the following line and delete the goto,
26 # to access the tab properly.
27 #link_click(_get_music_link())
28 goto('music/player')
29 switch_to_window()
30 assert_title()
31
32def _get_music_link():
33 return get_element_by_css('#main-nav .music')
34
35def assert_title():
36 """Assert that the title of the page is the expected."""
37 title_is(u'Ubuntu One : Music')
38
39def play_song(song):
40 _open_songs()
41 song_id = _get_song_id(song.title, song.artist, song.album)
42 _play_song_by_id(song_id)
43
44def _play_song_by_id(identifier):
45 song_play_button = get_element_by_css('tr[data-u1m-songid="%s"] > ' \
46 'td.c1 > button' \
47 % identifier)
48 button_click(song_play_button)
49 assert not song_play_button.is_displayed()
50
51def assert_songs_added_to_queue(songs_list):
52 number_of_songs = len(songs_list)
53 assert number_of_songs > 0
54 _assert_message_displayed()
55 _assert_songs_added_to_queue_message(number_of_songs)
56 for song in songs_list:
57 assert_song_in_queue(song)
58
59def _assert_songs_added_to_queue_message(number_of_songs):
60 message_content = None
61 if number_of_songs == 1:
62 message_content = '1 song added to the queue.'
63 else:
64 message_content = '%d songs added to the queue.'
65 _assert_message_content(message_content)
66
67def _assert_message_displayed():
68 assert _get_message_element().is_displayed()
69
70def _assert_message_content(message_content):
71 assert _get_message_element().text == message_content
72
73def _get_message_element():
74 return get_element_by_css('.yui3-message.yui3-info .yui3-widget-bd')
75
76def select_song(song):
77 _open_songs()
78 song_id = _get_song_id(song.title, song.artist, song.album)
79 _select_song_by_id(song_id)
80
81def _select_song_by_id(identifier):
82 song_checkbox = get_element_by_css('.c2 > input[value="%s"]' % identifier)
83 checkbox_set(song_checkbox, True)
84
85def _open_songs():
86 if not _is_songs_opened():
87 songs_element = _get_songs_element()
88 element_click(songs_element)
89 _wait_for_action_to_complete()
90
91def _is_songs_opened():
92 songs_element = _get_songs_element()
93 return _is_active(songs_element)
94
95def _get_songs_element():
96 return get_element(css_class='my-songs')
97
98def _get_song_id(title, artist, album):
99 song_row_xpath = '//td[@class="c3" and text()="%(title)s"]/' \
100 '../td[@class="c4 artist" and text()="%(artist)s"]/../' \
101 'td[@class="c5 album" and text()="%(album)s"]/..' \
102 % {'title': title, 'artist': artist, 'album': album}
103 song_row_element = get_element_by_xpath(song_row_xpath)
104 return song_row_element.get_attribute('data-u1m-songid')
105
106def assert_player_title(number_of_song, total_songs):
107 player_title_element = get_element_by_css('.player > h1')
108 expected_title = 'Now playing %d of %d songs' \
109 % (number_of_song, total_songs)
110 assert expected_title == player_title_element.text
111
112def assert_player_playing():
113 assert _get_stop_button().is_displayed()
114 assert not _get_play_button().is_displayed()
115
116def assert_player_paused():
117 assert not _get_stop_button().is_displayed()
118 assert _get_play_button().is_displayed()
119
120def _get_stop_button():
121 return get_element_by_css('#stop')
122
123def _get_play_button():
124 return get_element_by_css('#play')
125
126def assert_current_song(song):
127 assert song.title == _get_current_song_title()
128 assert song.artist == _get_current_song_artist()
129 assert song.album == _get_current_song_album()
130
131def _get_current_song_title():
132 current_song_title_element = get_element_by_css('.current-song .title')
133 return current_song_title_element.text
134
135def _get_current_song_artist():
136 current_song_artist_element = get_element_by_css('.current-song .artist')
137 return current_song_artist_element.text
138
139def _get_current_song_album():
140 current_song_album_element = get_element_by_css('.current-song .album')
141 return current_song_album_element.text
142
143def assert_song_in_queue(song):
144 _open_now_playing()
145 song_row_xpath = '//tr[contains(@class, "song-listing")]/' \
146 'td[text()="%(title)s"]/../td[text()="%(artist)s"]/../' \
147 'td[text()="%(album)s"]/..' % {'title': song.title,
148 'artist': song.artist,
149 'album': song.album}
150 get_element_by_xpath(song_row_xpath)
151
152def _open_now_playing():
153 if not _is_now_playing_opened():
154 element_click(_get_now_playing_element())
155
156def _is_now_playing_opened():
157 now_playing_element = _get_now_playing_element()
158 return _is_active(now_playing_element)
159
160def _get_now_playing_element():
161 return get_element(css_class='nowplaying')
162
163def _is_active(element):
164 element_class = element.get_attribute('class')
165 return 'active' in element_class
166
167def _wait_for_action_to_complete():
168 """Wait for the last action to complete.
169
170 This function waits for the waiting bar to disappear.
171
172 """
173 # Added a little sleep because if this function is called to fast before
174 # the bar appears tests will fail.
175 sleep(3)
176 waiting_bar = get_element_by_css('.loading-view > .indicator')
177 waitfor(fails, is_displayed, waiting_bar)
0178
=== added file 'ubuntuone/web/tests/sst/shared/data/song.py'
--- ubuntuone/web/tests/sst/shared/data/song.py 1970-01-01 00:00:00 +0000
+++ ubuntuone/web/tests/sst/shared/data/song.py 2011-12-08 23:07:24 +0000
@@ -0,0 +1,25 @@
1# -*- coding: utf-8 -*-
2
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""Data class for a Song."""
18
19class Song:
20 "Class for Song information."
21
22 def __init__(self, title, artist, album):
23 self.title = title
24 self.artist = artist
25 self.album = album

Subscribers

People subscribed via source and target branches