37
|
1 |
def mda(width,height)
|
|
2 |
a = Array.new(width)
|
|
3 |
a.map! { Array.new(height) }
|
|
4 |
return a
|
|
5 |
end
|
|
6 |
|
|
7 |
def create_mp_constants
|
|
8 |
@Library = mda(4,3)
|
|
9 |
@Library[0] = ["Amen and Boys", "Stop It!!","Self Made Maps"]
|
|
10 |
@Library[1] = ["Emancipated Minor", "Ani Difranco","Red Letter Year"]
|
|
11 |
@Library[2] = ["Slowly", "Fauna","Dreamless"]
|
|
12 |
@Library[3] = ["Turkish March", "Daniel Bautista","Classics And Soundtracks"]
|
|
13 |
|
|
14 |
@PlaybackToolBarOrder = {"Shuffle"=>0,"RW"=>1,"Pause"=>2,"Play"=>2,"FW"=>3,"Flip"=>4}
|
|
15 |
|
|
16 |
@PlaybackViewOptionsMenu = {"Equaliser"=>0, "Audio effects"=>1, "Repeat off" =>2, "Exit" => 3}
|
|
17 |
|
|
18 |
@EquiliserPresetsList = {"Off"=>0, "Bass booster"=>1, "Classical" =>2, "Jazz" => 3, "Pop"=>4 , "Rock"=> 5}
|
|
19 |
|
|
20 |
@ShuffleOffIconConst = 'qtg_mono_shuffle_off'
|
|
21 |
@ShuffleOnIconConst = 'qtg_mono_shuffle'
|
|
22 |
@RWIconConst = 'qtg_mono_seek_previous'
|
|
23 |
@PauseIconConst = 'qtg_mono_pause'
|
|
24 |
@FWIconConst = 'qtg_mono_seek_next'
|
|
25 |
@InfoIconConst = 'qtg_mono_info'
|
|
26 |
@PlayIconConst = 'qtg_mono_play'
|
|
27 |
|
|
28 |
|
|
29 |
end
|
|
30 |
|
|
31 |
require 'matti'
|
|
32 |
require 'spec/expectations'
|
|
33 |
require 'nokogiri'
|
|
34 |
require 'date'
|
|
35 |
|
|
36 |
Before do
|
|
37 |
create_mp_constants
|
|
38 |
@sut = MATTI.sut(:Id=>'sut_s60_qt')
|
|
39 |
end
|
|
40 |
|
|
41 |
After do
|
|
42 |
begin
|
|
43 |
@MPapp.close
|
|
44 |
rescue
|
|
45 |
end
|
|
46 |
end
|
|
47 |
|
|
48 |
Given("the MusicPlayer application is active") do
|
|
49 |
@MPapp = @sut.run(:name => "musicplayer")
|
|
50 |
end
|
|
51 |
|
|
52 |
Then("the MusicPlayer application is not active") do
|
|
53 |
verify_true(1, 'Music Player still running') {@sut.application.name != "musicplayer"} #Verify that the app that is in the foreground is not music player, if it is that means musicplayer is still running.
|
|
54 |
end
|
|
55 |
|
|
56 |
When("I Tap on Navi pane text area Music") do
|
|
57 |
@MPapp.HbTitleBar.HbTitlePane.HbFrameItem.tap
|
|
58 |
@MenuContainer = @MPapp.HbMenu.HbMenuContainer
|
|
59 |
end
|
|
60 |
|
|
61 |
When("I select the song number $element_num of the list") do |element_num|
|
|
62 |
@MPapp.HbListView(:name=>'allSongsList').HbListViewItem(:__index=>element_num.to_i-1).tap
|
|
63 |
end
|
|
64 |
|
|
65 |
Then("The song with the title $song_title and artist $song_artist and album $song_album is shown in playback view") do |song_title, song_artist, song_album|
|
|
66 |
verify(10, "The song title is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'songText').HbTextItem(:text => song_title)}
|
|
67 |
verify(10, "The song artist is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'artistText').HbTextItem( :text => song_artist)}
|
|
68 |
verify(10, "The song album is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'albumText').HbTextItem( :text => song_album)}
|
|
69 |
end
|
|
70 |
|
|
71 |
Then("The song number $num of the library is shown in playback view") do |num|
|
|
72 |
verify(10, "The song title is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'songText').HbTextItem(:text => @Library[num.to_i-1][0])}
|
|
73 |
verify(10, "The song artist is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'artistText').HbTextItem( :text => @Library[num.to_i-1][1])}
|
|
74 |
verify(10, "The song album is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'albumText').HbTextItem( :text => @Library[num.to_i-1][2])}
|
|
75 |
end
|
|
76 |
|
|
77 |
Then ("musicplayer plays the following songs after song $num randomly") do |num|
|
|
78 |
@MPapp.MpPlaybackWidget.wait_for_signal(600, "signalPlaybackInfoChanged()")
|
|
79 |
title=@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'songText').HbTextItem.attribute("Text")
|
|
80 |
artist=@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'artistText').HbTextItem.attribute("Text")
|
|
81 |
album=@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'albumText').HbTextItem.attribute("Text")
|
|
82 |
if title != @Library[num.to_i][0] or artist != @Library[num.to_i][1] or album != @Library[num.to_i][2]
|
|
83 |
else
|
|
84 |
@MPapp.MpPlaybackWidget.wait_for_signal(600, "signalPlaybackInfoChanged()")
|
|
85 |
verify_not(10, "The song title is being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'songText').HbTextItem(:text => @Library[num.to_i+1][0])}
|
|
86 |
verify_not(10, "The song artist is being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'artistText').HbTextItem( :text => @Library[num.to_i+1][1])}
|
|
87 |
verify_not(10, "The song album is being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'albumText').HbTextItem( :text => @Library[num.to_i+1][2])}
|
|
88 |
end
|
|
89 |
end
|
|
90 |
|
|
91 |
Then("the song in the playback view is $playback_status") do |playback_status|
|
|
92 |
verify(5, "The status of the playback view is not the spected"){@MPapp.MpPlaybackView(:PlaybackStatus => playback_status)}
|
|
93 |
lb_init = @MPapp.HbProgressSlider( :name => 'progressBar' ).HbTextItem(:__index => 0).attribute("Text")
|
|
94 |
sleep 5
|
|
95 |
lb_fin = @MPapp.HbProgressSlider( :name => 'progressBar' ).HbTextItem(:__index => 0).attribute("Text")
|
|
96 |
if playback_status == 'Playing'
|
|
97 |
verify_true(1,"Time label didn't change") {lb_init != lb_fin}
|
|
98 |
end
|
|
99 |
if playback_status == 'Paused'
|
|
100 |
verify_true(1,"Time label didn't change") {lb_init == lb_fin}
|
|
101 |
end
|
|
102 |
end
|
|
103 |
|
|
104 |
When ("I press the button $button in the PlaybackToolbar") do |button|
|
|
105 |
verify_true(5,"Icon is not correct"){@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch(button)).HbIconItem.attribute("iconName") == getPlaybackToolbarIconName(button)}
|
|
106 |
@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch(button)).tap
|
|
107 |
end
|
|
108 |
|
|
109 |
When ("I sleep $number $min_sec") do |number, min_sec|
|
|
110 |
time_to_wait = 0
|
|
111 |
if(min_sec == "seconds")
|
|
112 |
time_to_wait = number.to_i
|
|
113 |
end
|
|
114 |
if(min_sec == "minutes")
|
|
115 |
time_to_wait = number.to_i*60
|
|
116 |
end
|
|
117 |
puts time_to_wait.to_s
|
|
118 |
sleep time_to_wait
|
|
119 |
end
|
|
120 |
|
|
121 |
When ("I wait until the song change") do
|
|
122 |
@MPapp.MpPlaybackWidget.wait_for_signal(600, "signalPlaybackInfoChanged()")
|
|
123 |
end
|
|
124 |
|
|
125 |
def to_true_false(param)
|
|
126 |
if param == true or param == "ON"
|
|
127 |
return "true"
|
|
128 |
end
|
|
129 |
if param == false or param == "OFF"
|
|
130 |
return "false"
|
|
131 |
end
|
|
132 |
end
|
|
133 |
|
|
134 |
When ("I set shuffle to $on_off") do |on_off|
|
|
135 |
if @MPapp.MpPlaybackView.attribute("Shuffle") != to_true_false(on_off)
|
|
136 |
@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch("Shuffle")).tap
|
|
137 |
end
|
|
138 |
verify_true(2,"Shuffle is not the expected value"){@MPapp.MpPlaybackView.attribute("Shuffle") == to_true_false(on_off)}
|
|
139 |
if on_off == "ON"
|
|
140 |
verify_true(5,"Shuffle icon is not correct"){@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch("Shuffle")).HbIconItem.attribute("iconName") == @ShuffleOnIconConst}
|
|
141 |
end
|
|
142 |
if on_off == "OFF"
|
|
143 |
verify_true(5,"Shuffle icon is not correct"){@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch("Shuffle")).HbIconItem.attribute("iconName") == @ShuffleOffIconConst}
|
|
144 |
end
|
|
145 |
|
|
146 |
end
|
|
147 |
|
|
148 |
When("shuffle is set to $on_off") do |on_off|
|
|
149 |
verify_true(3,"Shuffle is not the expected value"){@MPapp.MpPlaybackView.attribute("Shuffle") == to_true_false(on_off)}
|
|
150 |
if on_off == "ON"
|
|
151 |
verify_true(5,"Shuffle icon is not correct"){@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch("Shuffle")).HbIconItem.attribute("iconName") == @ShuffleOnIconConst}
|
|
152 |
end
|
|
153 |
if on_off == "OFF"
|
|
154 |
verify_true(5,"Shuffle icon is not correct"){@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch("Shuffle")).HbIconItem.attribute("iconName") == @ShuffleOffIconConst}
|
|
155 |
end
|
|
156 |
end
|
|
157 |
|
|
158 |
When ("I press the button $button in the PlaybackToolbar twice") do |button|
|
|
159 |
@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch(button)).tap(2)
|
|
160 |
end
|
|
161 |
|
|
162 |
When("I press the back button") do
|
|
163 |
@MPapp.HbTitleBar.HbNavigationButton.tap
|
|
164 |
end
|
|
165 |
|
|
166 |
When ("I single press the button RW in the PlaybackToolbar and it is playing it starts from the beginning") do
|
|
167 |
lb_init = @MPapp.HbProgressSlider( :name => 'progressBar' ).HbTextItem(:__index => 0).attribute("Text")
|
|
168 |
@MPapp.HbToolBar( :name => 'PlaybackToolbar' ).HbToolButton(:__index => @PlaybackToolBarOrder.fetch("RW")).tap
|
|
169 |
lb_fin = @MPapp.HbProgressSlider( :name => 'progressBar' ).HbTextItem(:__index => 0).attribute("Text")
|
|
170 |
verify_true(1,"It didn't start from the beginning"){lb_init > lb_fin}
|
|
171 |
end
|
|
172 |
|
|
173 |
When("I select $item from the Options menu") do |item|
|
|
174 |
@MenuContainer.HbMenuItem(:__index=> @PlaybackViewOptionsMenu.fetch(item)).tap
|
|
175 |
end
|
|
176 |
|
|
177 |
Then ("the playback view options menu list is shown correctly") do
|
|
178 |
i = 0
|
|
179 |
while i < @PlaybackViewOptionsMenu.length do
|
|
180 |
verify_true(2,"Menu item is incorrect"){@MenuContainer.HbMenuItem(:__index=> i).HbTextItem.attribute("Text") == @PlaybackViewOptionsMenu.index(i)}
|
|
181 |
i = i +1
|
|
182 |
end
|
|
183 |
|
|
184 |
# @PlaybackViewOptionsMenu.each{|key, value| verify_true(2,"Menu item is incorrect"){@MenuContainer.HbMenuItem(:__index=> value).HbTextItem.attribute("Text") == key} }
|
|
185 |
end
|
|
186 |
|
|
187 |
Then ("the Equaliser pop up is displayed") do
|
|
188 |
verify(3, "Equiliser pop up is not displayed"){@MPapp.MpEqualizerWidget}
|
|
189 |
i = 0
|
|
190 |
while i < @EquiliserPresetsList.length do
|
|
191 |
puts i.to_s
|
|
192 |
puts @MPapp.MpEqualizerWidget.HbRadioButtonList.HbListViewItem(:__index=> i).HbTextItem.attribute("Text")
|
|
193 |
puts @EquiliserPresetsList.index(i)
|
|
194 |
verify_true(2,"Menu item is incorrect"){@MPapp.MpEqualizerWidget.HbRadioButtonList.HbListViewItem(:__index=> i).HbTextItem.attribute("Text") == @EquiliserPresetsList.index(i)}
|
|
195 |
i = i+1
|
|
196 |
end
|
|
197 |
end
|
|
198 |
|
|
199 |
Then ("Equaliser preset $num is selected") do |num|
|
|
200 |
|
|
201 |
verify_true(3, "Item is not selected"){@MPapp.MpEqualizerWidget.HbRadioButtonList.HbListViewItem(:__index=> num.to_i-1).HbIconItem.attribute("iconName") == "qtg_small_radio_selected"}
|
|
202 |
end
|
|
203 |
|
|
204 |
When ("I select the Equaliser preset number $num from the list") do |num|
|
|
205 |
@MPapp.MpEqualizerWidget.HbRadioButtonList.HbListViewItem(:__index=>num.to_i - 1).tap
|
|
206 |
@MPapp.MpEqualizerWidget.HbToolBar.HbTextItem( :text => 'OK' ).tap
|
|
207 |
end
|
|
208 |
|
|
209 |
Then ("the Audio effects pop up is displayed") do
|
|
210 |
verify(3, "Audio effects pop up is not displayed"){@MPapp.MpSettingsAudioEffectsWidget}
|
|
211 |
verify(3, "Balance slider is not present") {@MPapp.MpSettingsAudioEffectsWidget.HbSlider}
|
|
212 |
verify(3, "Loudness toggle is not present"){@MPapp.MpSettingsAudioEffectsWidget.HbToggleItem}
|
|
213 |
end
|
|
214 |
|
|
215 |
Then ("Audio effects settings are Balance $balance_value and Loudness $loudness_value") do |balance_value, loudness_value|
|
|
216 |
verify_true(3,"Balance value is not the expected"){@MPapp.MpSettingsAudioEffectsWidget.HbSlider.attribute("sliderPosition").to_i == balance_value.to_i}
|
|
217 |
verify_true(3,"Loudness value is not the expected"){@MPapp.MpSettingsAudioEffectsWidget.HbToggleItem.attribute("Text") == loudness_value}
|
|
218 |
end
|
|
219 |
|
|
220 |
When("I drag the slider to the $dir $num_pix pixels") do |dir, num_pix|
|
|
221 |
@MPapp.MpSettingsAudioEffectsWidget.HbSliderHandle.drag(to_direction(dir), num_pix, :Left)
|
|
222 |
end
|
|
223 |
|
|
224 |
When("the application is closed") do
|
|
225 |
@MPapp.close
|
|
226 |
end
|
|
227 |
|
|
228 |
When("I tap the Loudness toggle") do
|
|
229 |
@MPapp.MpSettingsAudioEffectsWidget.HbToggleItem.tap
|
|
230 |
end
|
|
231 |
|
|
232 |
When("Repeat is set to $on_off") do |on_off|
|
|
233 |
verify_true(3,"Repeat is not the expected value"){@MPapp.MpPlaybackView.attribute("Repeat") == to_true_false(on_off)}
|
|
234 |
end
|
|
235 |
|
|
236 |
Then ("all songs are played and at the end it goes to the first one and stays in $playback_status") do |playback_status|
|
|
237 |
i = 0
|
|
238 |
while i < @Library.length do
|
|
239 |
verify(10, "The song title is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'songText').HbTextItem(:text => @Library[i][0])}
|
|
240 |
verify(10, "The song artist is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'artistText').HbTextItem( :text => @Library[i][1])}
|
|
241 |
verify(10, "The song album is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'albumText').HbTextItem( :text => @Library[i][2])}
|
|
242 |
|
|
243 |
@MPapp.MpPlaybackWidget.wait_for_signal(720, "signalPlaybackInfoChanged()")
|
|
244 |
i = i+1
|
|
245 |
end
|
|
246 |
verify(10, "The song title is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'songText').HbTextItem(:text => @Library[0][0])}
|
|
247 |
verify(10, "The song artist is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'artistText').HbTextItem( :text => @Library[0][1])}
|
|
248 |
verify(10, "The song album is not being displayed") {@MPapp.HbLabel(:visibleOnScreen => 'true', :name => 'albumText').HbTextItem( :text => @Library[0][2])}
|
|
249 |
verify_true(5, "The status of the playback view is not the spected"){@MPapp.MpPlaybackView.attribute("PlaybackStatus") == playback_status or @MPapp.MpPlaybackView.attribute("PlaybackStatus") == "Stopped"}
|
|
250 |
end
|
|
251 |
|
|
252 |
def to_direction(string)
|
|
253 |
case string
|
|
254 |
when "Right"
|
|
255 |
return :Right
|
|
256 |
when "Left"
|
|
257 |
return :Left
|
|
258 |
when "Up"
|
|
259 |
return :Up
|
|
260 |
when "Down"
|
|
261 |
return :Down
|
|
262 |
end
|
|
263 |
end
|
|
264 |
|
|
265 |
def getPlaybackToolbarIconName(button)
|
|
266 |
case button
|
|
267 |
when "RW"
|
|
268 |
return @RWIconConst
|
|
269 |
when "Pause"
|
|
270 |
return @PauseIconConst
|
|
271 |
when "FW"
|
|
272 |
return @FWIconConst
|
|
273 |
when "Info"
|
|
274 |
return @InfoIconConst
|
|
275 |
when "Play"
|
|
276 |
return @PlayIconConst
|
|
277 |
end
|
|
278 |
|
|
279 |
end
|
|
280 |
|
|
281 |
|
|
282 |
|