Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #18926 from dominickuo/bug-998906
Browse files Browse the repository at this point in the history
Bug 998906 - [Music] display the correct overlay after the enumeration in ListView, r=jimporter
  • Loading branch information
dominickuo committed Aug 15, 2014
2 parents 9979fcc + 9c56051 commit 67f0e56
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/music/js/music.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ function showCurrentView(callback) {
// because mix page is not needed in picker mode
if (pendingPick) {
showListView();
knownSongs = ListView.dataSource;

if (callback)
callback();
Expand Down Expand Up @@ -1149,6 +1148,7 @@ var ListView = {

this.info = null;
this.dataSource = [];

this.index = 0;
this.lastDataIndex = 0;
this.firstLetters = [];
Expand Down Expand Up @@ -1237,6 +1237,12 @@ var ListView = {
// the height.
count = record ? count : null;
this.adjustHeight(info.option, count);
// In picker mode we have to use the ListView's dataSource to
// display the correct overlay.
if (pendingPick) {
knownSongs = this.dataSource;
showCorrectOverlay();
}
}
}.bind(this));
}.bind(this));
Expand Down
14 changes: 14 additions & 0 deletions apps/music/test/marionette/fakeactivitycaller/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!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>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* global MozActivity */
'use strict';

var FakeActivityCaller = {
init: function() {
this.callActicity();
},

callActicity: function() {
var activity = new MozActivity({
name: 'pick',
data: {
type: 'audio/*'
}
});

activity.onerror = function(e) {
console.warn('pick activity error:', activity.error.name);
};
}
};

FakeActivityCaller.init();
10 changes: 10 additions & 0 deletions apps/music/test/marionette/fakeactivitycaller/manifest.webapp
Original file line number Diff line number Diff line change
@@ -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"
}
}
25 changes: 25 additions & 0 deletions apps/music/test/marionette/lib/fakeactivitycaller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* 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.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);
}
};
12 changes: 12 additions & 0 deletions apps/music/test/marionette/lib/music.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = Music;
Music.DEFAULT_ORIGIN = 'music.gaiamobile.org';

Music.Selector = Object.freeze({
messageOverlay: '#overlay',
firstTile: '.tile',
songsTab: '#tabs-songs',
firstSong: '.list-item',
Expand All @@ -30,6 +31,10 @@ Music.Selector = Object.freeze({
Music.prototype = {
client: null,

get messageOverlay() {
return this.client.findElement(Music.Selector.messageOverlay);
},

get firstTile() {
return this.client.findElement(Music.Selector.firstTile);
},
Expand Down Expand Up @@ -109,6 +114,13 @@ Music.prototype = {
this.client.helper.waitForElement(this.firstTile);
},

waitForMessageOverlayShown: function(shouldBeShown) {
this.client.waitFor(function() {
var volumeShown = this.messageOverlay.displayed();
return volumeShown === shouldBeShown;
}.bind(this));
},

// Because bug 862156 so we couldn't get the correct displayed value for the
// player icon, instead we use the display property to check the visibility
// of the player icon.
Expand Down
91 changes: 91 additions & 0 deletions apps/music/test/marionette/music_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* 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({
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('Launch regular music with no audio files', function() {
setup(function() {
client.fileManager.removeAllFiles();
});

test('Overlay should be shown when storage has no songs', function() {
music.launch();
music.waitForMessageOverlayShown(true);
});
});

suite('Launch regular music with one audio file', function() {
setup(function() {
client.fileManager.add([
{ type: 'music', filePath: 'test_media/samples/Music/b2g.ogg' }
]);
});

test('Overlay should be hidden when storage has some songs', function() {
music.launch();
music.waitForMessageOverlayShown(false);
music.waitForFirstTile();
});
});

suite('Launch music picker with no audio files', function() {
var activitycaller;

setup(function() {
activitycaller = new FakeActivityCaller(client);
client.fileManager.removeAllFiles();
});

test('Overlay should be shown when storage has no songs', function() {
activitycaller.launch();

music.switchToMe();
music.waitForMessageOverlayShown(true);
});
});

suite('Launch music picker with one audio file', function() {
var activitycaller;

setup(function() {
activitycaller = new FakeActivityCaller(client);

client.fileManager.add([
{ type: 'music', filePath: 'test_media/samples/Music/b2g.ogg' }
]);
});

test('Overlay should be hidden when storage has some songs', function() {
activitycaller.launch();

music.switchToMe();
music.waitForMessageOverlayShown(false);
});
});
});

0 comments on commit 67f0e56

Please sign in to comment.