Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic tests for Presentation API #3063

Merged
merged 11 commits into from
Jun 8, 2016
32 changes: 32 additions & 0 deletions presentation-api/controlling-ua/PresentationRequest_error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API PresentationRequest for Controlling User Agent (Error)</title>
<link rel="author" title="Franck William Taffo" href="http://www.fokus.fraunhofer.de">
<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-controlling-user-agent">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>

var wrong_presentation_url = null;

/**
* Test if PresentationRequest constructor returns a TypeError() by missing presentation URL
*/

test(function() {
assert_throws(new TypeError(), function() {
new PresentationRequest();
});
}, 'Call PresentationRequest() constructor without presentation URL. TypeError Exception expected.');

/**
* Test if PresentationRequest constructor returns a TypeError() by wrong presentation URL
*/

test(function() {
assert_throws(new TypeError(), function() {
new PresentationRequest(wrong_presentation_url);
});
}, 'Call PresentationRequest() constructor with null presentation URL. TypeError Exception expected.');

</script>
29 changes: 29 additions & 0 deletions presentation-api/controlling-ua/PresentationRequest_success.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Presentation API PresentationRequest for Controlling User Agent (Success)</title>
<link rel="author" title="Franck William Taffo" href="http://www.fokus.fraunhofer.de">
<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-controlling-user-agent">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>

var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
//relative presentation URL
var presentation_url = "../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__="+ client_id;

/**
* Test if PresentationRequest constructor returns a SyntaxError() by missing presentation URL
*/

test(function() {
try{
var request = new PresentationRequest(presentation_url);
assert_true(request instanceof PresentationRequest);
}
catch (ex){
assert_unreached("Call PresentationRequest() constructor with valid presentation URL....????");
}
}, 'Call PresentationRequest() constructor with valid presentation URL. No Exception expected.');

</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!doctype html>
<meta charset="utf-8">
<title>Presentation API reconnect a presentation for Controlling User Agent (Error - manual test)</title>
<link rel="author" title="Franck William Taffo" href="http://www.fokus.fraunhofer.de">
<link rel="help" href="http://w3c.github.io/presentation-api/#dfn-controlling-user-agent">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>

/**
*
* Test if reconnect returns a NotFoundError() by wrong presentation ID
*/

var client_id = String(new Date().getTime()) + String(Math.floor(Math.random() * 1e5));
//relative presentation URL
var presentation_url = "../receiving-ua/idlharness.html#__castAppId__=2334D33A/__castClientId__="+ client_id;
var request = new PresentationRequest(presentation_url);
var wrong_presentationId = null;

var reconnect = function () {
promise_test(function () {

var presId = "presId";
// presId is mandatory when reconnecting to a presentation.
return request.reconnect(presId)
.then(function (setConnection) {
assert_unreached("reconnect should not return a Promise resolve by wrong presentation ID");
})
}, "Check that the promise is rejected by wrong presentation Id");
};

setup({explicit_timeout: true})
</script>
<p>click on the button to the perfom the test</p>
<button id="reconnectBtn" onclick="reconnect()">Reconnect</button>