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

Subscribers

People subscribed via source and target branches