Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
325
gaia/apps/music/test/marionette/Player_test.js
Executable file
325
gaia/apps/music/test/marionette/Player_test.js
Executable file
|
|
@ -0,0 +1,325 @@
|
|||
/* global require, marionette, setup, suite, test, __dirname */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var Music = require('./lib/music.js');
|
||||
var FakeRingtones = require('./lib/fakeringtones.js');
|
||||
var FakeControls = require('./lib/fakecontrols.js');
|
||||
var Statusbar = require('./lib/statusbar.js');
|
||||
|
||||
marionette('Music player tests', function() {
|
||||
var apps = {};
|
||||
apps[FakeRingtones.DEFAULT_ORIGIN] = __dirname + '/fakeringtones';
|
||||
apps[FakeControls.DEFAULT_ORIGIN] = __dirname + '/fakecontrols';
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
prefs: {
|
||||
'device.storage.enabled': true,
|
||||
'device.storage.testing': true,
|
||||
'device.storage.prompt.testing': true
|
||||
},
|
||||
|
||||
apps: apps
|
||||
},
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
|
||||
var music;
|
||||
|
||||
setup(function() {
|
||||
music = new Music(client);
|
||||
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
// Album = 'A Minute With Brendan'
|
||||
// Artist = 'Minute With'
|
||||
// Title = 'Boot To Gecko (B2G)'
|
||||
{ type: 'music', filePath: 'test_media/samples/Music/b2g.ogg' }
|
||||
]);
|
||||
});
|
||||
|
||||
suite('Audio channels tests', function() {
|
||||
var ringtones, statusbar;
|
||||
setup(function() {
|
||||
ringtones = new FakeRingtones(client);
|
||||
statusbar = new Statusbar(client);
|
||||
});
|
||||
|
||||
// This test is skipped for not failing tpbl, please see bug 997360.
|
||||
test.skip('Interrupted by a higher priority channel', function() {
|
||||
// Launch Music app and wait for the first tile to come out. Switch to
|
||||
// the all songs view then tap on the first song to play, also make sure
|
||||
// the playing icon in the status bar shows up.
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToSongsView();
|
||||
music.playFirstSong();
|
||||
statusbar.waitForPlayingIndicatorShown(true);
|
||||
|
||||
// Launch the fake ringtones app to interrupt the music app.
|
||||
// Make sure the playing icon in the status bar disappears.
|
||||
ringtones.launch();
|
||||
statusbar.waitForPlayingIndicatorShown(false);
|
||||
|
||||
// Close the fake ringtones app so that the playing icon shows up again
|
||||
// because the channel of music app is no more interrupted.
|
||||
ringtones.close();
|
||||
statusbar.waitForPlayingIndicatorShown(true);
|
||||
|
||||
// Bring the music app to foreground then tap the play button, see if the
|
||||
// play button is still functioning to pause the player. Also check the
|
||||
// style of the play button is PAUSED, and the playing icon disappears.
|
||||
music.switchToMe();
|
||||
music.tapPlayButton();
|
||||
assert.equal(music.isPlaying, false);
|
||||
statusbar.waitForPlayingIndicatorShown(false);
|
||||
|
||||
// Bring the music app to foreground then tap the play button, see if the
|
||||
// play button is still functioning to resume the player. Also check the
|
||||
// style of the play button is PLAYING, and the playing icon shows up.
|
||||
music.switchToMe();
|
||||
music.tapPlayButton();
|
||||
assert.equal(music.isPlaying, true);
|
||||
statusbar.waitForPlayingIndicatorShown(true);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Playback tests', function() {
|
||||
var controls;
|
||||
setup(function() {
|
||||
controls = new FakeControls(client);
|
||||
});
|
||||
|
||||
// Disabled See bug 1032037.
|
||||
test.skip('Check that progress bar updates when re-shown', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToSongsView();
|
||||
music.playFirstSong();
|
||||
|
||||
var dt = 5.0;
|
||||
|
||||
// We want to wait a few seconds while the music app is in the background.
|
||||
controls.launch();
|
||||
client.helper.wait(dt * 1000); // Convert to ms
|
||||
controls.playPause();
|
||||
controls.close();
|
||||
|
||||
// Try to get the songProgress when the music is still in the background
|
||||
music.switchToMe({background: true});
|
||||
var t0 = music.songProgress;
|
||||
|
||||
// Make sure the progress bar got updated when the music app is brought to
|
||||
// the foreground.
|
||||
music.launch();
|
||||
var t1 = music.songProgress;
|
||||
assert(t1 - t0 > 0, 'Progress bar not updated!');
|
||||
});
|
||||
});
|
||||
|
||||
suite('Player icon tests', function() {
|
||||
test('Check the player icon hides before play some song', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.checkPlayerIconShown(false);
|
||||
});
|
||||
|
||||
test('Check the player icon displays after play some song', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToSongsView();
|
||||
music.playFirstSong();
|
||||
music.waitForPlayerView();
|
||||
|
||||
var frame = music.playerViewFrame;
|
||||
assert.ok(frame);
|
||||
client.switchToFrame(frame);
|
||||
|
||||
// Wait for cover overlay to hide to prevent intermittent fail
|
||||
client.waitFor(function() {
|
||||
var cover = client.findElement(Music.Selector.playerCover);
|
||||
assert.ok(cover);
|
||||
client.switchToShadowRoot(cover);
|
||||
var container = client.findElement('#container');
|
||||
assert.ok(container);
|
||||
var isHidden = (container.getAttribute('class').split(' ').
|
||||
indexOf('show-overlay') === -1);
|
||||
client.switchToShadowRoot();
|
||||
return isHidden;
|
||||
}.bind(this));
|
||||
|
||||
music.switchToMe();
|
||||
|
||||
music.tapHeaderActionButton();
|
||||
music.waitForSongsView();
|
||||
music.checkPlayerIconShown(true);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Status bar', function() {
|
||||
|
||||
var statusbar;
|
||||
setup(function() {
|
||||
statusbar = new Statusbar(client);
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToSongsView();
|
||||
|
||||
// check the status bar for the hidden play icon
|
||||
client.switchToFrame();
|
||||
statusbar.waitForPlayingIndicatorShown(false);
|
||||
|
||||
music.switchToMe();
|
||||
music.playFirstSong();
|
||||
music.waitForPlayerView();
|
||||
});
|
||||
|
||||
test('Check the play icon is in the status bar. moztrap:9742', function() {
|
||||
// check the status bar
|
||||
client.switchToFrame();
|
||||
statusbar.waitForPlayingIndicatorShown(true);
|
||||
|
||||
// switch to the homescreen
|
||||
var system = client.loader.getAppClass('system');
|
||||
system.goHome();
|
||||
client.waitFor(function() {
|
||||
return client.findElement(system.Selector.activeHomescreenFrame)
|
||||
.displayed();
|
||||
});
|
||||
|
||||
// check the status bar again
|
||||
statusbar.waitForPlayingIndicatorShown(true);
|
||||
});
|
||||
|
||||
test('Check the play icon is hidden after close Music app', function() {
|
||||
// ensure statusbar icon is visible
|
||||
client.switchToFrame();
|
||||
statusbar.waitForPlayingIndicatorShown(true);
|
||||
|
||||
// close the music app
|
||||
music.switchToMe();
|
||||
music.close();
|
||||
|
||||
// make sure statusbar icon goes away
|
||||
client.switchToFrame();
|
||||
statusbar.waitForPlayingIndicatorShown(false);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Rating test', function() {
|
||||
test('Check Rating is saved. moztrap:2683', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToSongsView();
|
||||
music.playFirstSong();
|
||||
|
||||
// check there is no rating.
|
||||
music.showSongInfo();
|
||||
|
||||
var rating = music.getStarRating();
|
||||
assert.equal(rating, 0);
|
||||
|
||||
var rating_value = 4;
|
||||
music.tapRating(rating_value);
|
||||
|
||||
// wait that the rating bar disappear.
|
||||
music.waitForRatingOverlayHidden();
|
||||
|
||||
// tap to make the rating bar reappear.
|
||||
music.showSongInfo();
|
||||
|
||||
rating = music.getStarRating();
|
||||
assert.equal(rating, rating_value, 'Check rating is shown.');
|
||||
|
||||
// switch back and forth
|
||||
music.tapHeaderActionButton();
|
||||
music.playFirstSong();
|
||||
|
||||
rating = music.getStarRating();
|
||||
assert.equal(rating, rating_value,
|
||||
'Incorrect rating after switching song.');
|
||||
|
||||
// close the app because we want to test things are saved.
|
||||
music.close();
|
||||
|
||||
// start it over.
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToSongsView();
|
||||
music.playFirstSong();
|
||||
|
||||
rating = music.getStarRating();
|
||||
assert.equal(rating, rating_value,
|
||||
'Incorrect rating after restarting.');
|
||||
});
|
||||
});
|
||||
|
||||
suite('Player navigation. moztrap:2376', function() {
|
||||
test('Check that the back button works', function() {
|
||||
var title;
|
||||
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToSongsView();
|
||||
title = music.header.findElement('#header-title').text();
|
||||
music.playFirstSong();
|
||||
music.waitForPlayerView();
|
||||
assert.notEqual(title,
|
||||
music.header.findElement('#header-title').text());
|
||||
music.tapHeaderActionButton();
|
||||
music.waitForSongsView();
|
||||
client.switchToFrame(music.songsViewFrame);
|
||||
music.firstSong;
|
||||
music.switchToMe();
|
||||
assert.equal(title,
|
||||
music.header.findElement('#header-title').text());
|
||||
|
||||
music.switchToAlbumsView();
|
||||
music.selectAlbum('A Minute With Brendan');
|
||||
title = music.header.findElement('#header-title').text();
|
||||
music.playFirstSongByAlbum();
|
||||
music.waitForPlayerView();
|
||||
assert.notEqual(title,
|
||||
music.header.findElement('#header-title').text());
|
||||
music.tapHeaderActionButton();
|
||||
music.waitForAlbumDetailView();
|
||||
client.switchToFrame(music.albumDetailViewFrame);
|
||||
music.firstSong;
|
||||
music.switchToMe();
|
||||
assert.equal(title,
|
||||
music.header.findElement('#header-title').text());
|
||||
|
||||
music.switchToArtistsView();
|
||||
music.selectArtist('Minute With');
|
||||
title = music.header.findElement('#header-title').text();
|
||||
music.playFirstSongByArtist();
|
||||
music.waitForPlayerView();
|
||||
assert.notEqual(title,
|
||||
music.header.findElement('#header-title').text());
|
||||
music.tapHeaderActionButton();
|
||||
music.waitForArtistDetailView();
|
||||
client.switchToFrame(music.artistDetailViewFrame);
|
||||
music.firstSong;
|
||||
music.switchToMe();
|
||||
assert.equal(title,
|
||||
music.header.findElement('#header-title').text());
|
||||
|
||||
music.switchToPlaylistsView();
|
||||
music.selectPlaylist('Recently added');
|
||||
title = music.header.findElement('#header-title').text();
|
||||
music.playFirstSongByPlaylist();
|
||||
music.waitForPlayerView();
|
||||
assert.notEqual(title,
|
||||
music.header.findElement('#header-title').text());
|
||||
music.tapHeaderActionButton();
|
||||
music.waitForPlaylistDetailView();
|
||||
client.switchToFrame(music.playlistDetailViewFrame);
|
||||
music.firstSong;
|
||||
music.switchToMe();
|
||||
assert.equal(title,
|
||||
music.header.findElement('#header-title').text());
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
16
gaia/apps/music/test/marionette/fakeactivitycaller/index.html
Executable file
16
gaia/apps/music/test/marionette/fakeactivitycaller/index.html
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fake Remote Controls</title>
|
||||
<script defer src="/js/fakeactivitycaller.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<span>I am fake activity caller</span>
|
||||
<button id="open">Open</button>
|
||||
<button id="pick">Pick</button>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
44
gaia/apps/music/test/marionette/fakeactivitycaller/js/fakeactivitycaller.js
Executable file
44
gaia/apps/music/test/marionette/fakeactivitycaller/js/fakeactivitycaller.js
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
/* global MozActivity */
|
||||
'use strict';
|
||||
|
||||
var FakeActivityCaller = {
|
||||
init: function() {
|
||||
this.openButton = document.getElementById('open');
|
||||
this.pickButton = document.getElementById('pick');
|
||||
|
||||
this.openButton.addEventListener('click', this.openActivity);
|
||||
this.pickButton.addEventListener('click', this.pickActivity);
|
||||
},
|
||||
|
||||
openActivity: function() {
|
||||
var activity = new MozActivity({
|
||||
name: 'open',
|
||||
data: {
|
||||
type: 'audio/ogg',
|
||||
filename: 'test_media/samples/Music/treasure_island_01-02_stevenson.ogg'
|
||||
}
|
||||
});
|
||||
|
||||
activity.onerror = function(e) {
|
||||
console.warn('open activity error:', activity.error.name);
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
pickActivity: function() {
|
||||
var activity = new MozActivity({
|
||||
name: 'pick',
|
||||
data: {
|
||||
type: 'audio/*'
|
||||
}
|
||||
});
|
||||
|
||||
activity.onerror = function(e) {
|
||||
console.warn('pick activity error:', activity.error.name);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
FakeActivityCaller.init();
|
||||
});
|
||||
10
gaia/apps/music/test/marionette/fakeactivitycaller/manifest.webapp
Executable file
10
gaia/apps/music/test/marionette/fakeactivitycaller/manifest.webapp
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "Fake Activity Caller",
|
||||
"description": "A fake activity caller app",
|
||||
"type": "certified",
|
||||
"launch_path": "/index.html",
|
||||
"developer": {
|
||||
"name": "The Gaia Team",
|
||||
"url": "https://github.com/mozilla-b2g/gaia"
|
||||
}
|
||||
}
|
||||
16
gaia/apps/music/test/marionette/fakecontrols/index.html
Executable file
16
gaia/apps/music/test/marionette/fakecontrols/index.html
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fake Remote Controls</title>
|
||||
<script defer src="/js/fakecontrols.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="controls">
|
||||
<button id="playpause">Play/Pause</button>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
38
gaia/apps/music/test/marionette/fakecontrols/js/fakecontrols.js
Executable file
38
gaia/apps/music/test/marionette/fakecontrols/js/fakecontrols.js
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
/* exported controls */
|
||||
'use strict';
|
||||
|
||||
function RemoteControls() {
|
||||
this.controls = document.getElementById('controls');
|
||||
this.controls.addEventListener('click', this);
|
||||
|
||||
this.playPauseButton = document.getElementById('playpause');
|
||||
|
||||
window.navigator.mozSetMessageHandler('connection', function(request) {
|
||||
if (request.keyword !== 'mediacomms') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.port = request.port;
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
RemoteControls.prototype = {
|
||||
handleEvent: function(event) {
|
||||
if (!this.port) {
|
||||
return;
|
||||
}
|
||||
|
||||
var command = null;
|
||||
switch (event.target) {
|
||||
case this.playPauseButton:
|
||||
command = 'playpause';
|
||||
break;
|
||||
}
|
||||
|
||||
if (command) {
|
||||
this.port.postMessage({command: command});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var controls = new RemoteControls();
|
||||
16
gaia/apps/music/test/marionette/fakecontrols/manifest.webapp
Executable file
16
gaia/apps/music/test/marionette/fakecontrols/manifest.webapp
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "Fake Remote Controls",
|
||||
"description": "A fake remote controls app",
|
||||
"type": "certified",
|
||||
"launch_path": "/index.html",
|
||||
"developer": {
|
||||
"name": "The Gaia Team",
|
||||
"url": "https://github.com/mozilla-b2g/gaia"
|
||||
},
|
||||
"connections": {
|
||||
"mediacomms": {
|
||||
"description": "Communication with media apps for now playing info",
|
||||
"rules": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
gaia/apps/music/test/marionette/fakeringtones/index.html
Executable file
30
gaia/apps/music/test/marionette/fakeringtones/index.html
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Fake Ringtones</title>
|
||||
|
||||
<style>
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
#player {
|
||||
position: absolute;
|
||||
top: 10%;
|
||||
left: 10%;
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script defer src="/js/fakeringtones.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<audio id="player" controls autoplay></audio>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
41
gaia/apps/music/test/marionette/fakeringtones/js/fakeringtones.js
Executable file
41
gaia/apps/music/test/marionette/fakeringtones/js/fakeringtones.js
Executable file
|
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
|
||||
var FakeRingtones = {
|
||||
get player() {
|
||||
return document.getElementById('player');
|
||||
},
|
||||
|
||||
init: function() {
|
||||
this.loadMediaSample(function(file) {
|
||||
this.setSource(file);
|
||||
this.play();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
loadMediaSample: function(callback) {
|
||||
var songs = navigator.getDeviceStorage('music');
|
||||
|
||||
var cursor = songs.enumerate();
|
||||
|
||||
cursor.onsuccess = function(event) {
|
||||
var file = event.target.result;
|
||||
callback(file);
|
||||
};
|
||||
|
||||
cursor.onerror = function(event) {
|
||||
console.warn('No file found: ' + event.target.error);
|
||||
};
|
||||
},
|
||||
|
||||
setSource: function(file) {
|
||||
var url = window.URL.createObjectURL(file);
|
||||
this.player.mozAudioChannelType = 'ringer';
|
||||
this.player.src = url;
|
||||
},
|
||||
|
||||
play: function() {
|
||||
this.player.play();
|
||||
}
|
||||
};
|
||||
|
||||
FakeRingtones.init();
|
||||
14
gaia/apps/music/test/marionette/fakeringtones/manifest.webapp
Executable file
14
gaia/apps/music/test/marionette/fakeringtones/manifest.webapp
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "Fake Ringtones",
|
||||
"description": "A fake ringtones app",
|
||||
"type": "certified",
|
||||
"launch_path": "/index.html",
|
||||
"developer": {
|
||||
"name": "The Gaia Team",
|
||||
"url": "https://github.com/mozilla-b2g/gaia"
|
||||
},
|
||||
"permissions": {
|
||||
"device-storage:music":{ "access": "readwrite" },
|
||||
"audio-channel-ringer":{}
|
||||
}
|
||||
}
|
||||
68
gaia/apps/music/test/marionette/lib/fakeactivitycaller.js
Executable file
68
gaia/apps/music/test/marionette/lib/fakeactivitycaller.js
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
/* global module */
|
||||
'use strict';
|
||||
|
||||
function FakeActivityCaller(client, origin) {
|
||||
this.client = client;
|
||||
this.origin = origin || ('app://' + FakeActivityCaller.DEFAULT_ORIGIN);
|
||||
}
|
||||
|
||||
module.exports = FakeActivityCaller;
|
||||
|
||||
FakeActivityCaller.DEFAULT_ORIGIN = 'fakeactivity.gaiamobile.org';
|
||||
|
||||
FakeActivityCaller.Selector = Object.freeze({
|
||||
openButton: '#open',
|
||||
pickButton: '#pick',
|
||||
|
||||
actionMenu: 'form[data-z-index-level="action-menu"]'
|
||||
});
|
||||
|
||||
FakeActivityCaller.prototype = {
|
||||
client: null,
|
||||
|
||||
get openButton() {
|
||||
return this.client.helper.waitForElement(
|
||||
FakeActivityCaller.Selector.openButton);
|
||||
},
|
||||
|
||||
get pickButton() {
|
||||
return this.client.helper.waitForElement(
|
||||
FakeActivityCaller.Selector.pickButton);
|
||||
},
|
||||
|
||||
get actionMenu() {
|
||||
return this.client.helper.waitForElement(
|
||||
FakeActivityCaller.Selector.actionMenu);
|
||||
},
|
||||
|
||||
launch: function() {
|
||||
this.client.switchToFrame();
|
||||
this.client.apps.launch(this.origin);
|
||||
this.client.apps.switchToApp(this.origin);
|
||||
},
|
||||
|
||||
close: function() {
|
||||
this.client.apps.close(this.origin);
|
||||
},
|
||||
|
||||
tapOpenButton: function() {
|
||||
this.openButton.tap();
|
||||
},
|
||||
|
||||
tapPickButton: function() {
|
||||
this.pickButton.tap();
|
||||
},
|
||||
|
||||
selectMusicApp: function() {
|
||||
this.client.switchToFrame();
|
||||
|
||||
var list = this.actionMenu.findElements('button');
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i].text() === 'Music') {
|
||||
this.client.helper.waitForElement(list[i]);
|
||||
list[i].tap();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
37
gaia/apps/music/test/marionette/lib/fakecontrols.js
Executable file
37
gaia/apps/music/test/marionette/lib/fakecontrols.js
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
/* global module */
|
||||
'use strict';
|
||||
|
||||
function FakeControls(client, origin) {
|
||||
this.client = client;
|
||||
this.origin = origin || ('app://' + FakeControls.DEFAULT_ORIGIN);
|
||||
}
|
||||
|
||||
module.exports = FakeControls;
|
||||
|
||||
FakeControls.DEFAULT_ORIGIN = 'fakecontrols.gaiamobile.org';
|
||||
|
||||
FakeControls.Selector = Object.freeze({
|
||||
playPause: '#playpause'
|
||||
});
|
||||
|
||||
FakeControls.prototype = {
|
||||
client: null,
|
||||
|
||||
get playPauseElement() {
|
||||
return this.client.findElement(FakeControls.Selector.playPause);
|
||||
},
|
||||
|
||||
launch: function() {
|
||||
this.client.switchToFrame();
|
||||
this.client.apps.launch(this.origin);
|
||||
this.client.apps.switchToApp(this.origin);
|
||||
},
|
||||
|
||||
close: function() {
|
||||
this.client.apps.close(this.origin);
|
||||
},
|
||||
|
||||
playPause: function() {
|
||||
this.playPauseElement.click();
|
||||
}
|
||||
};
|
||||
25
gaia/apps/music/test/marionette/lib/fakeringtones.js
Executable file
25
gaia/apps/music/test/marionette/lib/fakeringtones.js
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
/* global module */
|
||||
'use strict';
|
||||
|
||||
function FakeRingtones(client, origin) {
|
||||
this.client = client;
|
||||
this.origin = origin || ('app://' + FakeRingtones.DEFAULT_ORIGIN);
|
||||
}
|
||||
|
||||
module.exports = FakeRingtones;
|
||||
|
||||
FakeRingtones.DEFAULT_ORIGIN = 'fakeringtones.gaiamobile.org';
|
||||
|
||||
FakeRingtones.prototype = {
|
||||
client: null,
|
||||
|
||||
launch: function() {
|
||||
this.client.switchToFrame();
|
||||
this.client.apps.launch(this.origin);
|
||||
this.client.apps.switchToApp(this.origin);
|
||||
},
|
||||
|
||||
close: function() {
|
||||
this.client.apps.close(this.origin);
|
||||
}
|
||||
};
|
||||
753
gaia/apps/music/test/marionette/lib/music.js
Executable file
753
gaia/apps/music/test/marionette/lib/music.js
Executable file
|
|
@ -0,0 +1,753 @@
|
|||
/* global require, module */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
function Music(client, origin) {
|
||||
this.client = client;
|
||||
this.origin = origin || ('app://' + Music.DEFAULT_ORIGIN);
|
||||
this.actions = client.loader.getActions();
|
||||
}
|
||||
|
||||
module.exports = Music;
|
||||
|
||||
Music.DEFAULT_ORIGIN = 'music.gaiamobile.org';
|
||||
|
||||
Music.Selector = Object.freeze({
|
||||
viewFrame: '#view-stack iframe',
|
||||
secondaryViewFrame: '#view-stack iframe:nth-child(2)',
|
||||
activeViewFrame: '#view-stack iframe.active',
|
||||
homeViewFrame: 'iframe[src*="/views/home/index.html"]',
|
||||
songsViewFrame: 'iframe[src*="/views/songs/index.html"]',
|
||||
artistsViewFrame: 'iframe[src*="/views/artists/index.html"]',
|
||||
artistDetailViewFrame: 'iframe[src*="/views/artist-detail/index.html"]',
|
||||
albumsViewFrame: 'iframe[src*="/views/albums/index.html"]',
|
||||
albumDetailViewFrame: 'iframe[src*="/views/album-detail/index.html"]',
|
||||
playlistsViewFrame: 'iframe[src*="/views/playlists/index.html"]',
|
||||
playlistDetailViewFrame: 'iframe[src*="/views/playlist-detail/index.html"]',
|
||||
playerViewFrame: 'iframe[src*="/views/player/index.html"]',
|
||||
|
||||
homeViewFrameActive:
|
||||
'iframe.active[src*="/views/home/index.html"]',
|
||||
songsViewFrameActive:
|
||||
'iframe.active[src*="/views/songs/index.html"]',
|
||||
artistsViewFrameActive:
|
||||
'iframe.active[src*="/views/artists/index.html"]',
|
||||
artistDetailViewFrameActive:
|
||||
'iframe.active[src*="/views/artist-detail/index.html"]',
|
||||
albumsViewFrameActive:
|
||||
'iframe.active[src*="/views/albums/index.html"]',
|
||||
albumDetailViewFrameActive:
|
||||
'iframe.active[src*="/views/album-detail/index.html"]',
|
||||
playlistsViewFrameActive:
|
||||
'iframe.active[src*="/views/playlists/index.html"]',
|
||||
playlistDetailViewFrameActive:
|
||||
'iframe.active[src*="/views/playlist-detail/index.html"]',
|
||||
playerViewFrameActive:
|
||||
'iframe.active[src*="/views/player/index.html"]',
|
||||
|
||||
messageOverlay: '#empty-overlay',
|
||||
firstTile: '.tile',
|
||||
tabBar: '#tab-bar',
|
||||
playlistsTab: '#tab-bar button[value="playlists"]',
|
||||
artistsTab: '#tab-bar button[value="artists"]',
|
||||
albumsTab: '#tab-bar button[value="albums"]',
|
||||
songsTab: '#tab-bar button[value="songs"]',
|
||||
playerCover: '#artwork',
|
||||
|
||||
// search fields
|
||||
searchBox: 'music-search-box',
|
||||
searchResults: 'music-search-results',
|
||||
searchField: '#input',
|
||||
// search results
|
||||
searchArtists: '#views-search-artists',
|
||||
searchAlbums: '#views-search-albums',
|
||||
searchTitles: '#views-search-titles',
|
||||
searchNoResult: '#views-search-no-result',
|
||||
|
||||
tilesView: '#tiles',
|
||||
listItem: '#list .gfl-item',
|
||||
playButton: '#player-controls-play',
|
||||
progressBar: '#player-seek-bar-progress',
|
||||
shareButton: 'button[data-action="share"]',
|
||||
shareMenu: 'form[data-z-index-level="action-menu"]',
|
||||
pickDoneButton: '#title-done',
|
||||
header: '#header',
|
||||
titleText: '#header-title',
|
||||
sublistShuffleButton: '#views-sublist-controls-shuffle',
|
||||
playerIcon: '#player-button'
|
||||
});
|
||||
|
||||
Music.prototype = {
|
||||
client: null,
|
||||
|
||||
// debug function.
|
||||
debugDocument: function() {
|
||||
var debug = this.client.executeScript(function() {
|
||||
return document.documentElement.innerHTML;
|
||||
});
|
||||
console.log('debug', debug);
|
||||
},
|
||||
|
||||
debugShadowRootDocument: function(element) {
|
||||
var debug = this.client.executeScript(function(element) {
|
||||
return element.shadowRoot.innerHTML;
|
||||
}, [element]);
|
||||
console.log('debug', debug);
|
||||
},
|
||||
|
||||
get viewFrame() {
|
||||
return this.client.findElement(Music.Selector.viewFrame);
|
||||
},
|
||||
|
||||
get secondaryViewFrame() {
|
||||
return this.client.findElement(Music.Selector.secondaryViewFrame);
|
||||
},
|
||||
|
||||
get activeViewFrame() {
|
||||
return this.client.findElement(Music.Selector.activeViewFrame);
|
||||
},
|
||||
|
||||
get homeViewFrame() {
|
||||
return this.client.findElement(Music.Selector.homeViewFrame);
|
||||
},
|
||||
|
||||
get artistsViewFrame() {
|
||||
return this.client.findElement(Music.Selector.artistsViewFrame);
|
||||
},
|
||||
|
||||
get artistDetailViewFrame() {
|
||||
return this.client.findElement(Music.Selector.artistDetailViewFrame);
|
||||
},
|
||||
|
||||
get albumsViewFrame() {
|
||||
return this.client.findElement(Music.Selector.albumsViewFrame);
|
||||
},
|
||||
|
||||
get albumDetailViewFrame() {
|
||||
return this.client.findElement(Music.Selector.albumDetailViewFrame);
|
||||
},
|
||||
|
||||
get songsViewFrame() {
|
||||
return this.client.findElement(Music.Selector.songsViewFrame);
|
||||
},
|
||||
|
||||
get playlistsViewFrame() {
|
||||
return this.client.findElement(Music.Selector.playlistsViewFrame);
|
||||
},
|
||||
|
||||
get playlistDetailViewFrame() {
|
||||
return this.client.findElement(Music.Selector.playlistDetailViewFrame);
|
||||
},
|
||||
|
||||
get playerViewFrame() {
|
||||
return this.client.findElement(Music.Selector.playerViewFrame);
|
||||
},
|
||||
|
||||
get messageOverlay() {
|
||||
return this.client.findElement(Music.Selector.messageOverlay);
|
||||
},
|
||||
|
||||
get firstTile() {
|
||||
var homeView = this.homeViewFrame;
|
||||
this.client.switchToFrame(homeView);
|
||||
var element = this.client.findElement(Music.Selector.firstTile);
|
||||
this.switchToMe();
|
||||
return element;
|
||||
},
|
||||
|
||||
get playlistsTab() {
|
||||
return this.client.helper.waitForElement(Music.Selector.playlistsTab);
|
||||
},
|
||||
|
||||
get artistsTab() {
|
||||
return this.client.helper.waitForElement(Music.Selector.artistsTab);
|
||||
},
|
||||
|
||||
get albumsTab() {
|
||||
return this.client.helper.waitForElement(Music.Selector.albumsTab);
|
||||
},
|
||||
|
||||
get songsTab() {
|
||||
return this.client.helper.waitForElement(Music.Selector.songsTab);
|
||||
},
|
||||
|
||||
// get the first song from the active frame.
|
||||
get firstSong() {
|
||||
return this.client.helper.waitForElement(Music.Selector.listItem);
|
||||
},
|
||||
|
||||
getStarRating: function() {
|
||||
var frame = this.playerViewFrame;
|
||||
assert.ok(frame);
|
||||
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
this.client.switchToShadowRoot(
|
||||
this.client.findElement(Music.Selector.playerCover));
|
||||
var ratingEl = this.client.findElement('#rating');
|
||||
this.client.switchToShadowRoot(ratingEl);
|
||||
var container = this.client.findElement('#container');
|
||||
var value = container.getAttribute('data-value');
|
||||
this.client.switchToShadowRoot();
|
||||
this.client.switchToShadowRoot();
|
||||
|
||||
this.switchToMe();
|
||||
|
||||
return value ? parseInt(value, 10) : 0;
|
||||
},
|
||||
|
||||
getShuffleSetting: function() {
|
||||
var frame = this.playerViewFrame;
|
||||
assert.ok(frame);
|
||||
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
var artwork = this.client.findElement(Music.Selector.playerCover);
|
||||
this.client.switchToShadowRoot(artwork);
|
||||
assert.ok(artwork);
|
||||
|
||||
var shuffleBtn = this.client.findElement(
|
||||
'#controls button[data-action="shuffle"]');
|
||||
assert.ok(shuffleBtn);
|
||||
|
||||
var value = shuffleBtn.getAttribute('data-value');
|
||||
assert.ok(value);
|
||||
|
||||
this.client.switchToShadowRoot();
|
||||
this.switchToMe();
|
||||
|
||||
return value;
|
||||
},
|
||||
|
||||
// Helper for the getter.
|
||||
|
||||
parseListItemsData: function(elements) {
|
||||
var elementsData = [];
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
var data = {};
|
||||
var a = elements[i];
|
||||
// We ignore items that are hidden by CSS.
|
||||
if (a.style.display === 'none') {
|
||||
continue;
|
||||
}
|
||||
data.filePath = a.dataset.filePath;
|
||||
data.href = a.href;
|
||||
data.section = a.dataset.section;
|
||||
data.index = elements[i].dataset.number;
|
||||
var h3 = elements[i].getElementsByTagName('h3');
|
||||
if (h3.length) {
|
||||
data.title = h3[0].textContent;
|
||||
}
|
||||
var p = elements[i].getElementsByTagName('p');
|
||||
if (p.length) {
|
||||
data.text = p[0].textContent;
|
||||
}
|
||||
var img = elements[i].getElementsByTagName('img');
|
||||
if (img.length) {
|
||||
data.img = img[0].src;
|
||||
}
|
||||
elementsData.push(data);
|
||||
}
|
||||
return elementsData;
|
||||
},
|
||||
|
||||
_getListItemsData: function(frame) {
|
||||
var client = this.client;
|
||||
|
||||
assert.ok(frame, 'Frame must be valid.' + frame);
|
||||
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
// Not all lists have have images
|
||||
var hasImages = client.executeScript(
|
||||
'var elements = document.querySelectorAll(\'.gfl-item img\');' +
|
||||
'return !!elements.length'
|
||||
);
|
||||
|
||||
// Wait for images to be displayed
|
||||
// before to reading their src.
|
||||
if (hasImages) {
|
||||
this.client.helper.waitForElement('.gfl-item img');
|
||||
}
|
||||
|
||||
var listItems = this.client.executeScript(
|
||||
'var parse = ' + this.parseListItemsData.toString() + '\n' +
|
||||
'var elements = document.querySelectorAll(\'.gfl-item\');\n' +
|
||||
'return parse(elements);\n'
|
||||
);
|
||||
|
||||
this.switchToMe();
|
||||
return listItems;
|
||||
},
|
||||
|
||||
get firstListItem() {
|
||||
return this.client.helper.waitForElement(Music.Selector.firstListItem);
|
||||
},
|
||||
|
||||
get albumsListItemsData() {
|
||||
return this._getListItemsData(this.albumsViewFrame);
|
||||
},
|
||||
|
||||
get artistsListItemsData() {
|
||||
return this._getListItemsData(this.artistsViewFrame);
|
||||
},
|
||||
|
||||
get songsListItemsData() {
|
||||
return this._getListItemsData(this.songsViewFrame);
|
||||
},
|
||||
|
||||
get songs() {
|
||||
return this._getListItemsData(this.activeViewFrame);
|
||||
},
|
||||
|
||||
get playButton() {
|
||||
return this.client.findElement(Music.Selector.playButton);
|
||||
},
|
||||
|
||||
get shareButton() {
|
||||
return this.client.findElement(Music.Selector.shareButton);
|
||||
},
|
||||
|
||||
get title() {
|
||||
var header = this.client.findElement(Music.Selector.header);
|
||||
return header.findElement(Music.Selector.titleText);
|
||||
},
|
||||
|
||||
get sublistShuffleButton() {
|
||||
return this.client.helper.waitForElement(
|
||||
Music.Selector.sublistShuffleButton);
|
||||
},
|
||||
|
||||
// TODO(gareth): Move this shareMenu stuff into the helper.
|
||||
get shareMenu() {
|
||||
// Switch to the system app first.
|
||||
this.client.switchToFrame();
|
||||
return this.client.helper.waitForElement(Music.Selector.shareMenu);
|
||||
},
|
||||
|
||||
get progressBar() {
|
||||
return this.client.findElement(Music.Selector.progressBar);
|
||||
},
|
||||
|
||||
get pickDoneButton() {
|
||||
return this.client.findElement(Music.Selector.pickDoneButton);
|
||||
},
|
||||
|
||||
get header() {
|
||||
return this.client.findElement(Music.Selector.header);
|
||||
},
|
||||
|
||||
get playerIcon() {
|
||||
return this.client.findElement(Music.Selector.playerIcon);
|
||||
},
|
||||
|
||||
get isPlaying() {
|
||||
return this.playButton.getAttribute('class').indexOf('is-pause') === -1;
|
||||
},
|
||||
|
||||
get songProgress() {
|
||||
return parseFloat(this.progressBar.getAttribute('value'));
|
||||
},
|
||||
|
||||
launch: function() {
|
||||
this.client.switchToFrame();
|
||||
this.client.apps.launch(this.origin);
|
||||
this.client.apps.switchToApp(this.origin);
|
||||
this.client.helper.waitForElement('body');
|
||||
},
|
||||
|
||||
close: function() {
|
||||
this.client.apps.close(this.origin);
|
||||
},
|
||||
|
||||
switchToMe: function(options) {
|
||||
options = options || {};
|
||||
|
||||
this.client.switchToFrame();
|
||||
|
||||
// Switch to music even when it is in background.
|
||||
// We cannot use switchToApp here, because it will wait
|
||||
// for the app to come to foreground.
|
||||
if (options.background) {
|
||||
var musicFrame = this.client.findElement('iframe[src*="' +
|
||||
this.origin + '"]');
|
||||
this.client.switchToFrame(musicFrame);
|
||||
} else {
|
||||
this.client.apps.switchToApp(this.origin);
|
||||
}
|
||||
},
|
||||
|
||||
waitForListEnumerate: function(frameSelector) {
|
||||
var frame = this.client.findElement(frameSelector);
|
||||
assert.ok(frame, 'Frame must be valid.' + frameSelector);
|
||||
|
||||
this.client.waitFor(function() {
|
||||
var selector = frameSelector;
|
||||
return this.client.executeScript(function(selector) {
|
||||
return document.querySelector(selector);
|
||||
}, [selector]);
|
||||
}.bind(this));
|
||||
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
this.client.waitFor(function() {
|
||||
return this.client.executeScript(function() {
|
||||
return document.readyState === 'complete';
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
// Here we assume that if the body of the document
|
||||
// is no longer hidden that we have content.
|
||||
// See view.js:View.prototype.setupList
|
||||
this.client.waitFor(function() {
|
||||
return this.client.executeScript(function() {
|
||||
return document.body.hidden === false;
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
waitFinishedScanning: function() {
|
||||
this.client.waitFor(function() {
|
||||
return this.client.executeScript(function() {
|
||||
return window.wrappedJSObject.Database.initialScanComplete === true;
|
||||
});
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
waitForFirstTile: function() {
|
||||
this.client.switchToFrame(this.homeViewFrame);
|
||||
this.client.helper.waitForElement(Music.Selector.firstTile);
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
waitForMessageOverlayShown: function(shouldBeShown) {
|
||||
this.client.waitFor(function() {
|
||||
var shown = this.messageOverlay.displayed();
|
||||
return shown === shouldBeShown;
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
waitForAList: function(frame) {
|
||||
assert.ok(frame, 'Frame must be valid ' + frame);
|
||||
this.client.switchToFrame(frame);
|
||||
this.client.waitFor(function() {
|
||||
return this.client.executeScript(function() {
|
||||
return document.querySelector('#list');
|
||||
});
|
||||
}.bind(this));
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
// In sublist view.
|
||||
// XXX allow in list view too.
|
||||
waitForSongs: function(callback) {
|
||||
this.client.waitFor(function() {
|
||||
var songs = this.songs;
|
||||
return callback(songs);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
waitForListView: function() {
|
||||
this.client.helper.waitForElement(Music.Selector.viewFrame);
|
||||
},
|
||||
|
||||
waitForSecondaryListView: function() {
|
||||
this.client.helper.waitForElement(Music.Selector.secondaryViewFrame);
|
||||
},
|
||||
|
||||
waitForSongsView: function() {
|
||||
this.client.helper.waitForElement(
|
||||
Music.Selector.songsViewFrameActive);
|
||||
},
|
||||
|
||||
waitForArtistsView: function() {
|
||||
this.client.helper
|
||||
.waitForElement(Music.Selector.artistsViewFrameActive);
|
||||
},
|
||||
|
||||
waitForArtistDetailView: function() {
|
||||
this.client.helper.waitForElement(
|
||||
Music.Selector.artistDetailViewFrameActive);
|
||||
},
|
||||
|
||||
waitForAlbumsView: function() {
|
||||
this.client.helper.waitForElement(
|
||||
Music.Selector.albumsViewFrameActive);
|
||||
},
|
||||
|
||||
waitForAlbumDetailView: function() {
|
||||
this.client.helper.waitForElement(
|
||||
Music.Selector.albumDetailViewFrameActive);
|
||||
},
|
||||
|
||||
waitForPlaylistsView: function() {
|
||||
this.client.helper.waitForElement(
|
||||
Music.Selector.playlistsViewFrameActive);
|
||||
},
|
||||
|
||||
waitForPlaylistDetailView: function() {
|
||||
this.client.helper.waitForElement(
|
||||
Music.Selector.playlistDetailViewFrameActive);
|
||||
},
|
||||
|
||||
waitForPlayerView: function() {
|
||||
this.client.helper.waitForElement(
|
||||
Music.Selector.playerViewFrameActive);
|
||||
},
|
||||
|
||||
// we check for the attribute "hidden"
|
||||
checkPlayerIconShown: function(shouldBeShown) {
|
||||
var hidden = this.playerIcon.getAttribute('hidden');
|
||||
var result = (hidden === 'false');
|
||||
assert.equal(shouldBeShown, result);
|
||||
},
|
||||
|
||||
showSearchInput: function(viewSelector) {
|
||||
var frame = this.activeViewFrame;
|
||||
assert.ok(frame);
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
var view = this.client.findElement(viewSelector);
|
||||
var chain = this.actions.press(view, 10, 10).perform();
|
||||
chain.moveByOffset(0, 110).perform();
|
||||
chain.release().perform();
|
||||
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
searchArtists: function(searchTerm) {
|
||||
this.search(Music.Selector.artistsViewFrame, searchTerm);
|
||||
},
|
||||
|
||||
searchTiles: function(searchTerm) {
|
||||
this.search(Music.Selector.homeViewFrame, searchTerm);
|
||||
},
|
||||
|
||||
search: function(viewSelector, searchTerm) {
|
||||
|
||||
assert.ok(viewSelector, 'Not a valid selector. Fix your test.');
|
||||
|
||||
var frame = this.client.findElement(viewSelector);
|
||||
assert.ok(frame, viewSelector, 'can\'t be found.');
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
var searchBox = this.client.helper.waitForElement(Music.Selector.searchBox);
|
||||
this.client.switchToShadowRoot(searchBox);
|
||||
|
||||
var input = this.client.helper.waitForElement(Music.Selector.searchField);
|
||||
assert.ok(input);
|
||||
|
||||
this.client.switchToShadowRoot(input);
|
||||
var field = this.client.helper.waitForElement('input');
|
||||
|
||||
// clear search
|
||||
// input.scriptWith(function(element) {
|
||||
// // var input = element.querySelector('gaia-text-input');
|
||||
// element.clear();
|
||||
// });
|
||||
|
||||
this.client.waitFor(field.displayed.bind(field));
|
||||
field.sendKeys(searchTerm);
|
||||
|
||||
this.client.switchToShadowRoot();
|
||||
this.client.switchToShadowRoot();
|
||||
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
switchToArtistsView: function() {
|
||||
this.artistsTab.tap();
|
||||
this.waitForArtistsView();
|
||||
},
|
||||
|
||||
switchToSongsView: function() {
|
||||
this.songsTab.tap();
|
||||
this.waitForSongsView();
|
||||
},
|
||||
|
||||
switchToAlbumsView: function() {
|
||||
this.albumsTab.tap();
|
||||
this.waitForAlbumsView();
|
||||
},
|
||||
|
||||
switchToPlaylistsView: function() {
|
||||
this.playlistsTab.tap();
|
||||
this.waitForPlaylistsView();
|
||||
},
|
||||
|
||||
_selectItem: function(name, frame) {
|
||||
assert.ok(frame, 'expected a valid frame');
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
var elements = this.client.findElements('#list .gfl-item');
|
||||
assert.ok(elements.length > 0);
|
||||
|
||||
var matching = elements.filter(function (element) {
|
||||
return element.findElement('h3').text() === name;
|
||||
});
|
||||
|
||||
assert.ok(matching.length > 0);
|
||||
matching[0].tap();
|
||||
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
selectAlbum: function(name) {
|
||||
this._selectItem(name, this.albumsViewFrame);
|
||||
},
|
||||
|
||||
selectArtist: function(name) {
|
||||
this._selectItem(name, this.artistsViewFrame);
|
||||
},
|
||||
|
||||
selectPlaylist: function(name) {
|
||||
this._selectItem(name, this.playlistsViewFrame);
|
||||
},
|
||||
|
||||
// only from a list (song list)
|
||||
playFirstSong: function() {
|
||||
this.client.switchToFrame(this.songsViewFrame);
|
||||
this.firstSong.click();
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
playFirstSongByArtist: function() {
|
||||
this.client.switchToFrame(this.artistDetailViewFrame);
|
||||
this.firstSong.click();
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
playFirstSongByAlbum: function() {
|
||||
this.client.switchToFrame(this.albumDetailViewFrame);
|
||||
this.firstSong.click();
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
playFirstSongByPlaylist: function() {
|
||||
this.client.switchToFrame(this.playlistDetailViewFrame);
|
||||
this.firstSong.click();
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
tapPlayButton: function() {
|
||||
this.actions.tap(this.playButton).perform();
|
||||
},
|
||||
|
||||
tapHeaderActionButton: function() {
|
||||
this.header.tap(25, 25);
|
||||
},
|
||||
|
||||
showSongInfo: function() {
|
||||
var frame = this.playerViewFrame;
|
||||
assert.ok(frame);
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
var playerCover =
|
||||
this.client.helper.waitForElement(Music.Selector.playerCover);
|
||||
playerCover.click();
|
||||
|
||||
this.client.switchToShadowRoot(playerCover);
|
||||
this.client.helper.waitForElement('#rating');
|
||||
this.client.switchToShadowRoot();
|
||||
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
waitForRatingOverlayHidden: function() {
|
||||
var frame = this.playerViewFrame;
|
||||
assert.ok(frame);
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
this.client.waitFor(function() {
|
||||
var cover = this.client.findElement(Music.Selector.playerCover);
|
||||
assert.ok(cover);
|
||||
this.client.switchToShadowRoot(cover);
|
||||
var container = this.client.findElement('#container');
|
||||
assert.ok(container);
|
||||
var isHidden = (container.getAttribute('class').split(' ').
|
||||
indexOf('show-overlay') === -1);
|
||||
this.client.switchToShadowRoot();
|
||||
return isHidden;
|
||||
}.bind(this));
|
||||
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
tapRating: function(rating) {
|
||||
this.showSongInfo();
|
||||
|
||||
var frame = this.playerViewFrame;
|
||||
assert.ok(frame);
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
var cover = this.client.findElement(Music.Selector.playerCover);
|
||||
this.client.switchToShadowRoot(cover);
|
||||
assert.ok(cover);
|
||||
var ratingEl = this.client.findElement('#rating');
|
||||
assert.ok(rating);
|
||||
this.client.switchToShadowRoot(ratingEl);
|
||||
// we must really wait that the element be visible. or click will fail.
|
||||
var star = this.client.helper.waitForElement(
|
||||
'button[value="' + rating + '"]');
|
||||
assert.ok(star);
|
||||
star.click();
|
||||
this.client.switchToShadowRoot();
|
||||
this.client.switchToShadowRoot();
|
||||
|
||||
this.switchToMe();
|
||||
},
|
||||
|
||||
shareWith: function(appName) {
|
||||
|
||||
// Allow findElement to fail quickly.
|
||||
var quickly = this.client.scope({
|
||||
searchTimeout: 50
|
||||
});
|
||||
|
||||
var shareMenu;
|
||||
// Wait until the share menu is displayed.
|
||||
// Try to click the cover image followed by the share button in the case
|
||||
// that it hides before we get a chance to click it.
|
||||
this.client.waitFor(function() {
|
||||
var frame = this.playerViewFrame;
|
||||
assert.ok(frame);
|
||||
this.client.switchToFrame(frame);
|
||||
|
||||
var cover = this.client.findElement(Music.Selector.playerCover);
|
||||
this.client.switchToShadowRoot(cover);
|
||||
assert.ok(cover);
|
||||
|
||||
this.shareButton.tap();
|
||||
|
||||
this.client.switchToShadowRoot();
|
||||
this.client.switchToShadowRoot();
|
||||
this.client.switchToFrame();
|
||||
|
||||
try {
|
||||
shareMenu = quickly.findElement(Music.Selector.shareMenu);
|
||||
} catch(e) {
|
||||
this.client.apps.switchToApp(this.origin);
|
||||
return false;
|
||||
}
|
||||
|
||||
var isDisplayed = shareMenu.displayed();
|
||||
this.client.apps.switchToApp(this.origin);
|
||||
return isDisplayed;
|
||||
}.bind(this));
|
||||
|
||||
var list = this.shareMenu.findElements('button');
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i].text() === appName) {
|
||||
list[i].tap();
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
finishPick: function() {
|
||||
this.actions.tap(this.pickDoneButton).perform();
|
||||
}
|
||||
};
|
||||
29
gaia/apps/music/test/marionette/lib/statusbar.js
Executable file
29
gaia/apps/music/test/marionette/lib/statusbar.js
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
/* global module */
|
||||
'use strict';
|
||||
|
||||
function Statusbar(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
module.exports = Statusbar;
|
||||
|
||||
Statusbar.Selector = Object.freeze({
|
||||
playingIndicator: '#statusbar-playing'
|
||||
});
|
||||
|
||||
Statusbar.prototype = {
|
||||
client: null,
|
||||
|
||||
get playingIndicator() {
|
||||
this.client.switchToFrame();
|
||||
return this.client.findElement(Statusbar.Selector.playingIndicator);
|
||||
},
|
||||
|
||||
waitForPlayingIndicatorShown: function(shouldBeShown) {
|
||||
if (shouldBeShown) {
|
||||
this.client.helper.waitForElement(this.playingIndicator);
|
||||
} else {
|
||||
this.client.helper.waitForElementToDisappear(this.playingIndicator);
|
||||
}
|
||||
}
|
||||
};
|
||||
82
gaia/apps/music/test/marionette/loading_test.js
Executable file
82
gaia/apps/music/test/marionette/loading_test.js
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
/* global require, marionette, setup, suite, test */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var Music = require('./lib/music.js');
|
||||
|
||||
marionette('Music files loading', function() {
|
||||
var apps = {};
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
prefs: {
|
||||
'device.storage.enabled': true,
|
||||
'device.storage.testing': true,
|
||||
'device.storage.prompt.testing': true
|
||||
},
|
||||
|
||||
settings: {
|
||||
'lockscreen.enabled': false,
|
||||
'ftu.manifestURL': null
|
||||
},
|
||||
|
||||
apps: apps
|
||||
}
|
||||
});
|
||||
|
||||
var music;
|
||||
|
||||
setup(function() {
|
||||
music = new Music(client);
|
||||
|
||||
});
|
||||
|
||||
suite('Detection of movies.', function () {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
{
|
||||
// Regular Ogg Vorbis.
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/a.ogg'
|
||||
},
|
||||
{
|
||||
// AAC file.
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/aac-tags.mp4'
|
||||
},
|
||||
{
|
||||
// MPEG4 video file. Shouldn't load.
|
||||
type: 'music',
|
||||
filePath: 'test_media/Movies/gizmo2.mp4'
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
test('Check the mp4 video isn\'t loaded. moztrap:8456', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.waitFinishedScanning();
|
||||
|
||||
music.switchToSongsView();
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.songsViewFrame);
|
||||
|
||||
var songs = music.songsListItemsData;
|
||||
assert.equal(songs.length, 2, 'Wrong number of songs');
|
||||
var songNames = [];
|
||||
|
||||
songs.forEach(function(song) {
|
||||
songNames.push(song.filePath);
|
||||
});
|
||||
songNames.sort();
|
||||
|
||||
assert.equal(songNames.length, 2,
|
||||
'Data source have wrong number of songs');
|
||||
|
||||
assert.equal(songNames[0], 'music/a.ogg');
|
||||
assert.equal(songNames[1], 'music/aac-tags.mp4');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
128
gaia/apps/music/test/marionette/metadata_test.js
Executable file
128
gaia/apps/music/test/marionette/metadata_test.js
Executable file
|
|
@ -0,0 +1,128 @@
|
|||
/* global require, marionette, setup, suite, test */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var Music = require('./lib/music.js');
|
||||
|
||||
function assertStartsWith(start, actual) {
|
||||
assert.equal(actual.indexOf(start), 0,
|
||||
'"' + actual + '" does not start with "' + start + '"');
|
||||
}
|
||||
|
||||
marionette('Music player metadata', function() {
|
||||
var apps = {};
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
prefs: {
|
||||
'device.storage.enabled': true,
|
||||
'device.storage.testing': true,
|
||||
'device.storage.prompt.testing': true
|
||||
},
|
||||
|
||||
settings: {
|
||||
'lockscreen.enabled': false,
|
||||
'ftu.manifestURL': null
|
||||
},
|
||||
|
||||
apps: apps
|
||||
}
|
||||
});
|
||||
|
||||
var music;
|
||||
|
||||
setup(function() {
|
||||
music = new Music(client);
|
||||
|
||||
});
|
||||
|
||||
suite('Album art display', function () {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
// if the metadata changes in any of this files
|
||||
// the test might break. Artist, Title, Album, Art.
|
||||
{
|
||||
// blue art.
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/a.ogg'
|
||||
},
|
||||
{
|
||||
// red art
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/01.ogg'
|
||||
},
|
||||
{
|
||||
// no art
|
||||
type: 'music',
|
||||
filePath: 'test_media/samples/Music/b2g.ogg'
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Check album art is displayed. moztrap:8749', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
|
||||
music.switchToArtistsView();
|
||||
|
||||
music.waitForArtistsView();
|
||||
|
||||
var bg, placeholder, blue, red;
|
||||
|
||||
// We test the album art url.
|
||||
// an "app:" URL is the default placeholder.
|
||||
// a "blob:" URL is a blob. Produced from the metadata.
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
|
||||
var listItemsData = music.artistsListItemsData;
|
||||
|
||||
placeholder = listItemsData[0].img;
|
||||
|
||||
assertStartsWith('app:', placeholder);
|
||||
|
||||
blue = listItemsData[1].img;
|
||||
assertStartsWith('blob:', blue);
|
||||
|
||||
red = listItemsData[2].img;
|
||||
assertStartsWith('blob:', red);
|
||||
|
||||
assert.notEqual(placeholder, blue,
|
||||
'Placeholder and Blue should be different');
|
||||
assert.notEqual(placeholder, red,
|
||||
'Placeholder and Red should be different');
|
||||
assert.notEqual(blue, red, 'Red and Blue should be different');
|
||||
|
||||
//
|
||||
|
||||
music.switchToAlbumsView();
|
||||
|
||||
listItemsData = music.albumsListItemsData;
|
||||
|
||||
bg = listItemsData[0].img;
|
||||
assert.equal(bg, placeholder, 'Is not the placeholder art');
|
||||
|
||||
bg = listItemsData[1].img;
|
||||
assert.equal(bg, blue, 'Is not the blue art');
|
||||
|
||||
bg = listItemsData[2].img;
|
||||
assert.equal(bg, red, 'Is not the red art');
|
||||
|
||||
//
|
||||
|
||||
music.switchToSongsView();
|
||||
|
||||
listItemsData = music.songsListItemsData;
|
||||
|
||||
bg = listItemsData[0].img;
|
||||
assert.equal(bg, blue, 'Is not the blue art');
|
||||
|
||||
bg = listItemsData[1].img;
|
||||
assert.equal(bg, placeholder, 'Is not the placeholder art');
|
||||
|
||||
bg = listItemsData[2].img;
|
||||
assert.equal(bg, red, 'Is not the red art');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
115
gaia/apps/music/test/marionette/music_test.js
Executable file
115
gaia/apps/music/test/marionette/music_test.js
Executable file
|
|
@ -0,0 +1,115 @@
|
|||
/* global require, marionette, setup, suite, test, __dirname */
|
||||
'use strict';
|
||||
|
||||
var Music = require('./lib/music.js');
|
||||
var FakeActivityCaller = require('./lib/fakeactivitycaller.js');
|
||||
|
||||
marionette('Music ui tests', function() {
|
||||
var apps = {};
|
||||
apps[FakeActivityCaller.DEFAULT_ORIGIN] = __dirname + '/fakeactivitycaller';
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
prefs: {
|
||||
'device.storage.enabled': true,
|
||||
'device.storage.testing': true,
|
||||
'device.storage.prompt.testing': true
|
||||
},
|
||||
|
||||
apps: apps
|
||||
}
|
||||
});
|
||||
|
||||
var music, system;
|
||||
|
||||
setup(function() {
|
||||
music = new Music(client);
|
||||
system = client.loader.getAppClass('system');
|
||||
system.waitForFullyLoaded();
|
||||
});
|
||||
|
||||
suite('Test overlay', function() {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
});
|
||||
|
||||
test('Overlay visible when storage has no songs', function() {
|
||||
music.launch();
|
||||
music.waitFinishedScanning();
|
||||
music.waitForMessageOverlayShown(true);
|
||||
});
|
||||
|
||||
test('Overlay hidden when storage has some songs', function() {
|
||||
client.fileManager.add([
|
||||
{ type: 'music', filePath: 'test_media/samples/Music/b2g.ogg' }
|
||||
]);
|
||||
music.launch();
|
||||
music.waitFinishedScanning();
|
||||
music.waitForFirstTile();
|
||||
music.waitForMessageOverlayShown(false);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Test picker activity', function() {
|
||||
var activitycaller;
|
||||
|
||||
function performTest(shown) {
|
||||
activitycaller.launch();
|
||||
activitycaller.tapPickButton();
|
||||
activitycaller.selectMusicApp();
|
||||
|
||||
music.switchToMe();
|
||||
music.waitFinishedScanning();
|
||||
music.waitForMessageOverlayShown(shown);
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
activitycaller = new FakeActivityCaller(client);
|
||||
client.fileManager.removeAllFiles();
|
||||
});
|
||||
|
||||
test('Overlay visible with no songs', function() {
|
||||
performTest(true);
|
||||
});
|
||||
|
||||
test('Overlay hidden with some songs', function() {
|
||||
client.fileManager.add([
|
||||
{ type: 'music', filePath: 'test_media/samples/Music/b2g.ogg' }
|
||||
]);
|
||||
performTest(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
suite('Test open activity', function() {
|
||||
var activitycaller;
|
||||
|
||||
function performTest() {
|
||||
activitycaller.launch();
|
||||
activitycaller.tapOpenButton();
|
||||
activitycaller.selectMusicApp();
|
||||
|
||||
music.switchToMe();
|
||||
music.waitFinishedScanning();
|
||||
music.waitForPlayerView();
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
activitycaller = new FakeActivityCaller(client);
|
||||
client.fileManager.removeAllFiles();
|
||||
});
|
||||
|
||||
test('Player shows with no song in database.', function() {
|
||||
performTest();
|
||||
});
|
||||
|
||||
test('Player shows with one song in database.', function() {
|
||||
client.fileManager.add([
|
||||
{ type: 'music', filePath: 'test_media/samples/Music/b2g.ogg' }
|
||||
]);
|
||||
|
||||
performTest();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
484
gaia/apps/music/test/marionette/playlist_test.js
Executable file
484
gaia/apps/music/test/marionette/playlist_test.js
Executable file
|
|
@ -0,0 +1,484 @@
|
|||
/* global require, marionette, setup, suite, test, __dirname,
|
||||
marionetteScriptFinished */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var Music = require('./lib/music.js');
|
||||
var FakeRingtones = require('./lib/fakeringtones.js');
|
||||
var FakeControls = require('./lib/fakecontrols.js');
|
||||
|
||||
marionette('Music player playlist', function() {
|
||||
var apps = {};
|
||||
apps[FakeRingtones.DEFAULT_ORIGIN] = __dirname + '/fakeringtones';
|
||||
apps[FakeControls.DEFAULT_ORIGIN] = __dirname + '/fakecontrols';
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
prefs: {
|
||||
'device.storage.enabled': true,
|
||||
'device.storage.testing': true,
|
||||
'device.storage.prompt.testing': true
|
||||
},
|
||||
|
||||
apps: apps
|
||||
},
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
|
||||
var music;
|
||||
|
||||
setup(function() {
|
||||
music = new Music(client);
|
||||
});
|
||||
|
||||
|
||||
suite('Special names', function() {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
// Title: "dump 2>&1 < ~/® <b>& Injection Vulnerablity</b>"
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/d.ogg'
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
test('Check name with >, <, ~, &, markup and some Unicode. ' +
|
||||
'moztrap:2346,2347,8499,8491',
|
||||
function() {
|
||||
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToSongsView();
|
||||
|
||||
// this will wait on the first song as well.
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
var songs = music.songs;
|
||||
assert.equal(songs.length, 1);
|
||||
assert.equal(songs[0].title,
|
||||
'dump 2>&1 < ~/® <b>& Injection Vulnerablity</b>');
|
||||
});
|
||||
});
|
||||
|
||||
suite('Test empty metadata', function () {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
{
|
||||
type: 'music',
|
||||
filePath:
|
||||
'test_media/samples/Music/treasure_island_01-02_stevenson.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath:
|
||||
'test_media/samples/Music/Salt_Creek.ogg'
|
||||
}
|
||||
]);
|
||||
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
});
|
||||
|
||||
// Test for bug 1209798
|
||||
test('Check the lack of track index', function() {
|
||||
music.switchToAlbumsView();
|
||||
|
||||
music.selectAlbum('Treasure Island');
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 1;
|
||||
});
|
||||
|
||||
var songs = music.songs;
|
||||
|
||||
assert.equal(songs[0].index, '');
|
||||
assert.equal(songs[0].title,
|
||||
'01 At the Admiral Benbow - ' +
|
||||
'02 Black Dog Appears and Disappears');
|
||||
});
|
||||
|
||||
test('Check the lack of artist or album', function() {
|
||||
music.switchToAlbumsView();
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
var results = music.albumsListItemsData;
|
||||
var unknownAlbumStr = client.executeAsyncScript(function () {
|
||||
window.wrappedJSObject.document.l10n.formatValue('unknownAlbum').
|
||||
then(function(str) {
|
||||
marionetteScriptFinished(str);
|
||||
});
|
||||
});
|
||||
assert.equal(results[0].title, unknownAlbumStr);
|
||||
|
||||
|
||||
music.switchToArtistsView();
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
results = music.artistsListItemsData;
|
||||
var unknownArtistStr = client.executeAsyncScript(function () {
|
||||
window.wrappedJSObject.document.l10n.formatValue('unknownArtist').
|
||||
then(function(str) {
|
||||
marionetteScriptFinished(str);
|
||||
});
|
||||
});
|
||||
|
||||
assert.equal(results[0].title, unknownArtistStr);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('Single disc tests', function () {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/01.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/02.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/03.ogg'
|
||||
},
|
||||
]);
|
||||
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
});
|
||||
|
||||
test('Check the sort order', function() {
|
||||
music.switchToAlbumsView();
|
||||
|
||||
music.selectAlbum('Where is Julian Assange?');
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 3;
|
||||
});
|
||||
|
||||
var songs = music.songs;
|
||||
|
||||
assert.equal(songs.length, 3);
|
||||
|
||||
assert.equal(songs[0].index, '1');
|
||||
assert.equal(songs[0].title, 'Australian citizen is a US traitor');
|
||||
|
||||
assert.equal(songs[1].index, '4');
|
||||
assert.equal(songs[1].title, 'Ich bin ein Berliner');
|
||||
|
||||
assert.equal(songs[2].index, '8');
|
||||
assert.equal(songs[2].title, 'The Ecuadorian Embassy');
|
||||
});
|
||||
|
||||
test('Check the playlist indexes', function() {
|
||||
// this test will check that the index value of each song is the index
|
||||
// and not the track number.
|
||||
// See bug 1129708
|
||||
music.switchToPlaylistsView();
|
||||
|
||||
music.selectPlaylist('Recently added');
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 3;
|
||||
});
|
||||
|
||||
var songs = music.songs;
|
||||
|
||||
assert.equal(songs.length, 3);
|
||||
assert.equal(songs[0].index, '1');
|
||||
assert.equal(songs[1].index, '2');
|
||||
assert.equal(songs[2].index, '3');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('Multi disc tests', function() {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/a.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/b.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/c.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/w.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/x.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/y.ogg'
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Check the sort order', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.switchToAlbumsView();
|
||||
|
||||
music.selectAlbum('We crash computers');
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 6;
|
||||
});
|
||||
|
||||
var songs = music.songs;
|
||||
|
||||
assert.equal(songs.length, 6);
|
||||
|
||||
assert.equal(songs[0].index, '1.01');
|
||||
assert.equal(songs[0].title, 'Yield to thread');
|
||||
|
||||
assert.equal(songs[2].index, '1.03');
|
||||
assert.equal(songs[2].title, 'Windows BSOD');
|
||||
|
||||
assert.equal(songs[3].index, '2.01');
|
||||
assert.equal(songs[3].title, 'Crash');
|
||||
});
|
||||
});
|
||||
|
||||
suite('Default playlists', function() {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
{
|
||||
// Track 1.01 "Yield to Thread"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/y.ogg'
|
||||
},
|
||||
{
|
||||
// Track 1.02 "XOXO"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/x.ogg'
|
||||
},
|
||||
{
|
||||
// Track 1.03 "Windows BSOD"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/w.ogg'
|
||||
},
|
||||
{
|
||||
// Track 2.01 "Crash"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/c.ogg'
|
||||
},
|
||||
{
|
||||
// Track 2.02 "Break"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/b.ogg'
|
||||
},
|
||||
{
|
||||
// Track 2.03 "Abort"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/a.ogg'
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Highest rated playlist sort order. moztrap:3674', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
|
||||
music.switchToAlbumsView();
|
||||
|
||||
music.selectAlbum('We crash computers');
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 6;
|
||||
});
|
||||
|
||||
var songs = music.songs;
|
||||
assert.equal(songs.length, 6);
|
||||
|
||||
var title1 = songs[1].title;
|
||||
var title3 = songs[3].title;
|
||||
|
||||
client.switchToFrame(music.activeViewFrame);
|
||||
client.executeScript(function(songs) {
|
||||
var w = window.wrappedJSObject;
|
||||
w.view.fetch('/api/songs/rating/4/' + songs[3].filePath).
|
||||
catch(function(error) {
|
||||
throw error;
|
||||
});
|
||||
w.view.fetch('/api/songs/rating/5/' + songs[1].filePath).
|
||||
catch(function(error) {
|
||||
throw error;
|
||||
});
|
||||
}, [songs]);
|
||||
music.switchToMe();
|
||||
|
||||
music.switchToPlaylistsView();
|
||||
|
||||
music.selectPlaylist('Highest rated');
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 6;
|
||||
});
|
||||
songs = music.songs;
|
||||
|
||||
assert.equal(songs[0].index, '1');
|
||||
assert.equal(songs[0].title, title1);
|
||||
|
||||
assert.equal(songs[1].index, '2');
|
||||
assert.equal(songs[1].title, title3);
|
||||
});
|
||||
|
||||
test('Recently added playlist sort order. moztrap:3675', function() {
|
||||
// start the app so the music files are added to the database.
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.waitFinishedScanning();
|
||||
|
||||
// close the app
|
||||
music.close();
|
||||
|
||||
// add more files.
|
||||
client.fileManager.add([
|
||||
{
|
||||
// This song has the title 'The Ecuadorian Embassy'
|
||||
// And the index '1'
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/01.ogg'
|
||||
}
|
||||
]);
|
||||
|
||||
// start it over. It will add the file above.
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
music.waitFinishedScanning();
|
||||
music.switchToPlaylistsView();
|
||||
|
||||
music.selectPlaylist('Recently added');
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 6;
|
||||
});
|
||||
var songs = music.songs;
|
||||
|
||||
assert.equal(songs[0].index, '1');
|
||||
assert.equal(songs[0].title,
|
||||
'The Ecuadorian Embassy');
|
||||
});
|
||||
|
||||
// XXX fixme we can't set the playcount properly it seems....
|
||||
test('Most played playlist sort order. moztrap:3676,3677', function() {
|
||||
function incrementPlayCount(filePath, value) {
|
||||
|
||||
var result = client.executeAsyncScript(function(filePath, value) {
|
||||
|
||||
var w = window.wrappedJSObject;
|
||||
|
||||
w.Database.getFileInfo(filePath).
|
||||
then(function(song) {
|
||||
var p = [];
|
||||
for (var i = 0; i < value; i++) {
|
||||
p.push(w.Database.incrementPlayCount(song));
|
||||
}
|
||||
Promise.all(p).
|
||||
then(function() {
|
||||
marionetteScriptFinished(null);
|
||||
}).
|
||||
catch(function (r) {
|
||||
marionetteScriptFinished('increment-fail ' + r);
|
||||
});
|
||||
}).catch(function (r) {
|
||||
marionetteScriptFinished('get-file-info-fail ' + r);
|
||||
});
|
||||
|
||||
}, [filePath, value]);
|
||||
assert.ok(!result);
|
||||
}
|
||||
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
|
||||
music.switchToAlbumsView();
|
||||
|
||||
music.selectAlbum('We crash computers');
|
||||
|
||||
var songs = music.songs;
|
||||
assert.equal(songs.length, 6);
|
||||
|
||||
var playCounts = {
|
||||
'XOXO': 5,
|
||||
'Crash': 4,
|
||||
|
||||
'Break': 3,
|
||||
'Windows BSOD': 2,
|
||||
|
||||
'Yield to thread': 1,
|
||||
'Abort': 0
|
||||
};
|
||||
|
||||
music.switchToMe();
|
||||
// we set the playcount.
|
||||
songs.forEach(function (e) {
|
||||
var c = playCounts[e.title];
|
||||
if (c) {
|
||||
incrementPlayCount(e.filePath, c);
|
||||
}
|
||||
});
|
||||
|
||||
music.switchToPlaylistsView();
|
||||
|
||||
// Most played
|
||||
music.selectPlaylist('Most played');
|
||||
music.waitForPlaylistDetailView();
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 6;
|
||||
});
|
||||
songs = music.songs;
|
||||
|
||||
assert.equal(songs[0].index, '1');
|
||||
assert.equal(songs[0].title, 'XOXO');
|
||||
|
||||
assert.equal(songs[1].index, '2');
|
||||
assert.equal(songs[1].title, 'Crash');
|
||||
|
||||
|
||||
music.tapHeaderActionButton();
|
||||
music.waitForPlaylistsView();
|
||||
|
||||
// Least played
|
||||
music.selectPlaylist('Least played');
|
||||
music.waitForPlaylistDetailView();
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
music.waitForSongs(function(songs) {
|
||||
return songs.length >= 6;
|
||||
});
|
||||
songs = music.songs;
|
||||
|
||||
assert.equal(songs[0].index, '1');
|
||||
assert.equal(songs[0].title, 'Abort');
|
||||
|
||||
assert.equal(songs[1].index, '2');
|
||||
assert.equal(songs[1].title, 'Yield to thread');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
189
gaia/apps/music/test/marionette/search_test.js
Executable file
189
gaia/apps/music/test/marionette/search_test.js
Executable file
|
|
@ -0,0 +1,189 @@
|
|||
/* global require, marionette, setup, suite, test, __dirname,
|
||||
marionetteScriptFinished */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var Music = require('./lib/music.js');
|
||||
var FakeRingtones = require('./lib/fakeringtones.js');
|
||||
var FakeControls = require('./lib/fakecontrols.js');
|
||||
|
||||
marionette('Music player search', function() {
|
||||
var apps = {};
|
||||
apps[FakeRingtones.DEFAULT_ORIGIN] = __dirname + '/fakeringtones';
|
||||
apps[FakeControls.DEFAULT_ORIGIN] = __dirname + '/fakecontrols';
|
||||
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
prefs: {
|
||||
'device.storage.enabled': true,
|
||||
'device.storage.testing': true,
|
||||
'device.storage.prompt.testing': true
|
||||
},
|
||||
|
||||
apps: apps
|
||||
}
|
||||
});
|
||||
|
||||
var music;
|
||||
|
||||
setup(function() {
|
||||
music = new Music(client);
|
||||
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/01.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/02.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/03.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/a.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/b.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/c.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/w.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/x.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/y.ogg'
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
function testSearchResults(expectedCount) {
|
||||
client.switchToFrame(music.activeViewFrame);
|
||||
|
||||
var search = client.findElement('music-search-results');
|
||||
assert.ok(search);
|
||||
|
||||
var results = client.helper.waitForElement('#list');
|
||||
assert.ok(results);
|
||||
|
||||
// wait for the results to be displayed.
|
||||
// XXX this mostly assume we populate before showing the div.
|
||||
client.waitFor(function() {
|
||||
return results.displayed();
|
||||
});
|
||||
|
||||
// XXX fix me when this is true
|
||||
// since we display the count, just get it.
|
||||
//var count = results.findElement('.search-result-count').text();
|
||||
|
||||
|
||||
// XXX when the count is back
|
||||
// check what we expect.
|
||||
// assert.equal(count, expectedCount);
|
||||
|
||||
var resultsData = client.executeScript(
|
||||
'var parse = ' + music.parseListItemsData.toString() + '\n' +
|
||||
'var search = document.querySelector(\'music-search-results\');\n' +
|
||||
'var elements = search.querySelectorAll(\'a\');\n' +
|
||||
'return parse(elements);\n'
|
||||
);
|
||||
|
||||
// detect inconsistency.
|
||||
assert.equal(resultsData.length, expectedCount);
|
||||
music.switchToMe();
|
||||
return resultsData;
|
||||
}
|
||||
|
||||
suite('Search tests', function () {
|
||||
|
||||
setup(function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
|
||||
// Here we wait 1.5 seconds for the search input hides completely.
|
||||
// it will re-show after we scroll the target view.
|
||||
music.showSearchInput(Music.Selector.tilesView);
|
||||
});
|
||||
|
||||
test('Check simple search results in artists.', function() {
|
||||
music.searchTiles('the');
|
||||
// check for the results in "artists"
|
||||
var resultsList = testSearchResults(3);
|
||||
|
||||
assert.equal(resultsList[1].title, 'The NSA');
|
||||
assert.equal(resultsList[1].section, 'artists');
|
||||
// XXX fixme when we have the search highlights
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1209432
|
||||
// assert.equal(resultsList[1].highlight, 'The');
|
||||
assert.equal(resultsList[2].title, 'The Ecuadorian Embassy');
|
||||
assert.equal(resultsList[2].section, 'songs');
|
||||
|
||||
music.searchTiles(' n');
|
||||
resultsList = testSearchResults(1);
|
||||
});
|
||||
|
||||
test('Check empty results', function() {
|
||||
music.searchTiles('qwerty');
|
||||
|
||||
// current implement of empty result is ONE line
|
||||
// with a string indicating nothing was found.
|
||||
var resultsList = testSearchResults(1);
|
||||
assert.equal(resultsList.length, 1);
|
||||
|
||||
client.switchToFrame(music.activeViewFrame);
|
||||
|
||||
var search = client.findElement('music-search-results');
|
||||
assert.ok(search);
|
||||
|
||||
// ensure that we get the properly localized string.
|
||||
var noResultString = client.executeAsyncScript(function () {
|
||||
window.wrappedJSObject.document.l10n.formatValue('search-no-result').
|
||||
then(function(noResult) {
|
||||
marionetteScriptFinished(noResult);
|
||||
});
|
||||
});
|
||||
|
||||
music.switchToMe();
|
||||
|
||||
assert.equal(resultsList[0].title, noResultString);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Search context tests', function () {
|
||||
|
||||
setup(function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
});
|
||||
|
||||
// Test contextual search
|
||||
// XXX fixme: currently make the app *crash*
|
||||
test('Check the context for artists', function() {
|
||||
music.switchToArtistsView();
|
||||
|
||||
music.showSearchInput('#list');
|
||||
music.searchArtists('the');
|
||||
|
||||
var resultsList = testSearchResults(2);
|
||||
|
||||
assert.equal(resultsList[1].title, 'The NSA');
|
||||
// XXX fix when we have highlights
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1209432
|
||||
// assert.equal(resultsList[1].highlight, 'The');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
149
gaia/apps/music/test/marionette/shuffle_test.js
Executable file
149
gaia/apps/music/test/marionette/shuffle_test.js
Executable file
|
|
@ -0,0 +1,149 @@
|
|||
/* global require, marionette, setup, suite, test */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var Music = require('./lib/music.js');
|
||||
|
||||
marionette('Music player shuffle', function() {
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
prefs: {
|
||||
'device.storage.enabled': true,
|
||||
'device.storage.testing': true,
|
||||
'device.storage.prompt.testing': true
|
||||
}
|
||||
},
|
||||
desiredCapabilities: { raisesAccessibilityExceptions: false }
|
||||
});
|
||||
|
||||
var music;
|
||||
|
||||
setup(function() {
|
||||
music = new Music(client);
|
||||
});
|
||||
|
||||
suite('Default playlists', function() {
|
||||
setup(function() {
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
{
|
||||
// Track 1.01 "Yield to Thread"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/y.ogg'
|
||||
},
|
||||
{
|
||||
// Track 1.02 "XOXO"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/x.ogg'
|
||||
},
|
||||
{
|
||||
// Track 1.03 "Windows BSOD"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/w.ogg'
|
||||
},
|
||||
{
|
||||
// Track 2.01 "Crash"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/c.ogg'
|
||||
},
|
||||
{
|
||||
// Track 2.02 "Break"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/b.ogg'
|
||||
},
|
||||
{
|
||||
// Track 2.03 "Abort"
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/a.ogg'
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('The "Shuffle all" playlist sets the "Shuffle" button in Player view',
|
||||
function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
|
||||
music.switchToSongsView();
|
||||
music.playFirstSong();
|
||||
|
||||
var shuffle = music.getShuffleSetting();
|
||||
assert.equal(shuffle, 'off');
|
||||
|
||||
music.tapHeaderActionButton();
|
||||
music.waitForSongsView();
|
||||
|
||||
music.switchToPlaylistsView();
|
||||
music.selectPlaylist('Shuffle all');
|
||||
|
||||
music.waitForPlayerView();
|
||||
|
||||
shuffle = music.getShuffleSetting();
|
||||
assert.equal(shuffle, 'on');
|
||||
}
|
||||
);
|
||||
|
||||
test('Shuffle all sort order. moztrap:2357', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
|
||||
music.switchToPlaylistsView();
|
||||
|
||||
var notrandom = 0;
|
||||
var lastTitle = '';
|
||||
var loopCount = 10;
|
||||
for (var i = 0; i < loopCount; i++) {
|
||||
|
||||
// selecting the playlist will put us into the player.
|
||||
music.selectPlaylist('Shuffle all');
|
||||
|
||||
// wait for the player.
|
||||
// XXX figure out why this times out.
|
||||
// still seems to work with it. but ain't liking it.
|
||||
// music.waitForPlayerView();
|
||||
|
||||
var title = music.title.text();
|
||||
if (title === lastTitle) {
|
||||
notrandom++;
|
||||
}
|
||||
lastTitle = title;
|
||||
// tap back
|
||||
music.tapHeaderActionButton();
|
||||
}
|
||||
// the first loop will never be "notrandom".
|
||||
assert.notEqual(notrandom, loopCount - 1, 'we didn\'t randomise');
|
||||
});
|
||||
|
||||
// XXX fix when bug 1204664 is fixed.
|
||||
test.skip('Shuffle playlist order. moztrap:2357', function() {
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
|
||||
music.switchToPlaylistsView();
|
||||
|
||||
music.selectPlaylist('Least played');
|
||||
|
||||
var notrandom = 0;
|
||||
var lastTitle = '';
|
||||
var loopCount = 10;
|
||||
for (var i = 0; i < loopCount; i++) {
|
||||
|
||||
// tapping shuffle will put us into the player.
|
||||
music.sublistShuffleButton.tap();
|
||||
|
||||
// wait for the player.
|
||||
music.waitForPlayerView();
|
||||
|
||||
var title = music.title.text();
|
||||
if (title === lastTitle) {
|
||||
notrandom++;
|
||||
}
|
||||
lastTitle = title;
|
||||
// tap back
|
||||
music.tapHeaderActionButton();
|
||||
}
|
||||
assert.notEqual(notrandom, loopCount - 1, 'we didn\'t randomise');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
119
gaia/apps/music/test/marionette/views_test.js
Executable file
119
gaia/apps/music/test/marionette/views_test.js
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
/* global require, marionette, setup, test */
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var Music = require('./lib/music.js');
|
||||
|
||||
|
||||
marionette('Music views', function() {
|
||||
var client = marionette.client({
|
||||
profile: {
|
||||
prefs: {
|
||||
'device.storage.enabled': true,
|
||||
'device.storage.testing': true,
|
||||
'device.storage.prompt.testing': true
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
var music;
|
||||
|
||||
setup(function() {
|
||||
music = new Music(client);
|
||||
client.fileManager.removeAllFiles();
|
||||
client.fileManager.add([
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/01.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/02.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/03.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/a.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/b.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/c.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/w.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/x.ogg'
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
filePath: 'apps/music/test-data/playlists/y.ogg'
|
||||
},
|
||||
]);
|
||||
|
||||
music.launch();
|
||||
music.waitForFirstTile();
|
||||
});
|
||||
|
||||
|
||||
test('Check tile view', function() {
|
||||
client.switchToFrame(music.homeViewFrame);
|
||||
var tile = client.findElement(Music.Selector.firstTile);
|
||||
assert.ok(tile);
|
||||
tile.tap();
|
||||
music.switchToMe();
|
||||
|
||||
music.waitForPlayerView();
|
||||
});
|
||||
|
||||
|
||||
// ported from GiP test_music_album_mp3.py
|
||||
test('Check album view. moztrap:3755', function() {
|
||||
music.switchToAlbumsView();
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
var list = music.albumsListItemsData;
|
||||
|
||||
var album = list[0].title;
|
||||
assert.equal(album, 'We crash computers');
|
||||
music.selectAlbum(album);
|
||||
music.playFirstSongByAlbum();
|
||||
music.waitForPlayerView();
|
||||
});
|
||||
|
||||
// ported from GiP test_music_artist_mp3.py
|
||||
test('Check artist view. moztrap:4031', function() {
|
||||
music.switchToArtistsView();
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
var list = music.artistsListItemsData;
|
||||
|
||||
var artist = list[0].title;
|
||||
assert.equal(artist, 'The Angry Programmers');
|
||||
music.selectArtist(artist);
|
||||
music.playFirstSongByArtist();
|
||||
music.waitForPlayerView();
|
||||
});
|
||||
|
||||
// ported from GiP test_music_songs_mp3.py
|
||||
test('Check songs view. moztrap:4031', function() {
|
||||
music.switchToSongsView();
|
||||
|
||||
music.waitForListEnumerate(Music.Selector.activeViewFrame);
|
||||
var list = music.songsListItemsData;
|
||||
|
||||
assert.equal(list[0].title, 'Abort');
|
||||
music.playFirstSong();
|
||||
music.waitForPlayerView();
|
||||
});
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue