-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added failing test: full-length deezer track repeats (requires deezer…
… login), issue #8
- Loading branch information
1 parent
b3a829a
commit 643a1f6
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> <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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters