Skip to content

Commit

Permalink
added failing test: full-length deezer track repeats (requires deezer…
Browse files Browse the repository at this point in the history
… login), issue #8
  • Loading branch information
adrienjoly committed Sep 28, 2016
1 parent b3a829a commit 643a1f6
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 1 deletion.
44 changes: 44 additions & 0 deletions test/test-track-deezer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<title>Deezer Track Tests</title>
<script src="../test.js"></script>
</head>
<body>
<style>
.info {
font-family: arial;
font-weight: bold;
font-size: 10px;
}
.info span, .info div {
margin-left: 10px;
font-weight: normal;
}
</style>

<div id="toHide">
<p>Loading tests...</p>
<p>If nothing shows up, please open this page using the incognito/private mode of your browser</p>
</div>

<div class="info">
<p>current track:<span id="progress"></span></p>
<p>url:<span id="trackUrl"></span></p>
<p>player+id:<span id="playerName"></span>&nbsp;<span id="trackId"></span></p>
<p>current test:<span id="testName"></span></p>
<p>duration:<span id="duration"></span></p>
<p>position:<span id="position"></span></p>
</div>

<div id="container"></div>

<div class="info">
<p>events:</p>
<div id="eventLog"></div>
</p>

<script src="test-track.js"></script>

</body>
</html>
62 changes: 62 additions & 0 deletions test/test-track-deezer/test-track.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
new PlayemLoader().loadAllPlayers().whenReady(function(playem){

var toHide = document.getElementById("toHide");
toHide.parentElement.removeChild(toHide);

var TRACK = "/dz/73414915";

// init testing environment
var testUI = new TestUI(1, 1);
playem = testUI.wrapPlayem(playem);
playem.setPref("loop", false);
var eventLogger = new PlayemLogger().listenTo(playem, testUI.onPlayerEvent);

playem.addTrackByUrl(TRACK);
playem.play();
/*
// this is necessary to show the deezer login URL, in order to play the track in full
window.showMessage = function(msg) {
document.body.innerHTML = document.body.innerHTML
+ "<pre><code>[showMessage] " + msg + "</code></pre>";
};
// ... BUT altering innerHTML breaks the Deezer player!
// cf http://stackoverflow.com/a/39724214/592254
*/
window.showMessage('deezer app id: ' + DEEZER_APP_ID);
window.showMessage('deezer channel url: ' + DEEZER_CHANNEL_URL);

var runner = new TestRunner();
runner.addTests({
"track starts playing (or buffering) in less than 10 seconds": function(cb){
var done = false;
function singleCb(res){
!done && cb(res);
done = true;
}
eventLogger.until("onBuffering", singleCb, 9000);
eventLogger.until("onPlay", singleCb, 10000);
},
"skip to end of track": function(cb){
var targetPos = 0.997;
// give time for onTrackChange to be listened by first test
setTimeout(function(){
playem.seekTo(targetPos);
}, 100);
cb(true);
},
"reaching the end of track": function(cb){
eventLogger.until("onEnd", function(){
cb(true);
});
},
"track does not repeat": function(cb){
eventLogger.until("onPlay", function(res){
cb(!res);
}, 5000);
},
});

runner.run(function(res){
//playem.stop();
});
});
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function PlayemLoader() {

window.YOUTUBE_API_KEY = "AIzaSyAHcfP2XwN1HmvwYRp8mr1yvYn1l1WE0-A";
window.SOUNDCLOUD_CLIENT_ID = "94f7290349b7801c04969260c4433fed"; // playemjs api key
window.DEEZER_APP_ID = 125765;
window.DEEZER_APP_ID = 192342;
window.DEEZER_CHANNEL_URL = window.location.href.substr(0, window.location.href.indexOf("/", 10)) + "/lib/deezer-channel.html";
window.JAMENDO_CLIENT_ID = "c9cb2a0a";

Expand Down

0 comments on commit 643a1f6

Please sign in to comment.