Commit 8282cf9d authored by Hardik Juneja's avatar Hardik Juneja Committed by hardikj

erp5_ui_test: Add high level unit tests for webrtc gadget

parent d96d4e4d
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Zuite" module="Products.Zelenium.zuite"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>webrtc_ui_zuite</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testGadgetWebrtcQunitTests</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Webrtc Gadget</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test OfficeJS UI</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<!-- Clean Up -->
<!-- Clean Up -->
<tr>
<td>open</td>
<td>${base_url}/bar_module/ListBoxZuite_reset</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Reset Successfully.</td>
<td></td>
</tr>
<!-- Initialize -->
<tr>
<td>open</td>
<td>${base_url}/web_site_module/webrtc_unit_test/</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>3000</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//*[@id="qunit-testresult"]/span[3]</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>0 failed</td>
<td></td>
</tr>
<tr>
<td>assertTextNotPresent</td>
<td>0 passed</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
/*!
* QUnit 2.0.1
* https://qunitjs.com/
*
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2016-07-23T19:39Z
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0;
padding: 0;
}
/** Header (excluding toolbar) */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699A4;
background-color: #0D3349;
font-size: 1.5em;
line-height: 1em;
font-weight: 400;
border-radius: 5px 5px 0 0;
}
#qunit-header a {
text-decoration: none;
color: #C2CCD1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #FFF;
}
#qunit-banner {
height: 5px;
}
#qunit-filteredTest {
padding: 0.5em 1em 0.5em 1em;
color: #366097;
background-color: #F4FF77;
}
#qunit-userAgent {
padding: 0.5em 1em 0.5em 1em;
color: #FFF;
background-color: #2B81AF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
/** Toolbar */
#qunit-testrunner-toolbar {
padding: 0.5em 1em 0.5em 1em;
color: #5E740B;
background-color: #EEE;
}
#qunit-testrunner-toolbar .clearfix {
height: 0;
clear: both;
}
#qunit-testrunner-toolbar label {
display: inline-block;
}
#qunit-testrunner-toolbar input[type=checkbox],
#qunit-testrunner-toolbar input[type=radio] {
margin: 3px;
vertical-align: -2px;
}
#qunit-testrunner-toolbar input[type=text] {
box-sizing: border-box;
height: 1.6em;
}
.qunit-url-config,
.qunit-filter,
#qunit-modulefilter {
display: inline-block;
line-height: 2.1em;
}
.qunit-filter,
#qunit-modulefilter {
float: right;
position: relative;
margin-left: 1em;
}
.qunit-url-config label {
margin-right: 0.5em;
}
#qunit-modulefilter-search {
box-sizing: border-box;
width: 400px;
}
#qunit-modulefilter-search-container:after {
position: absolute;
right: 0.3em;
content: "\25bc";
color: black;
}
#qunit-modulefilter-dropdown {
/* align with #qunit-modulefilter-search */
box-sizing: border-box;
width: 400px;
position: absolute;
right: 0;
top: 50%;
margin-top: 0.8em;
border: 1px solid #D3D3D3;
border-top: none;
border-radius: 0 0 .25em .25em;
color: #000;
background-color: #F5F5F5;
z-index: 99;
}
#qunit-modulefilter-dropdown a {
color: inherit;
text-decoration: none;
}
#qunit-modulefilter-dropdown .clickable.checked {
font-weight: bold;
color: #000;
background-color: #D2E0E6;
}
#qunit-modulefilter-dropdown .clickable:hover {
color: #FFF;
background-color: #0D3349;
}
#qunit-modulefilter-actions {
display: block;
overflow: auto;
/* align with #qunit-modulefilter-dropdown-list */
font: smaller/1.5em sans-serif;
}
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > * {
box-sizing: border-box;
max-height: 2.8em;
display: block;
padding: 0.4em;
}
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > button {
float: right;
font: inherit;
}
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > :last-child {
/* insert padding to align with checkbox margins */
padding-left: 3px;
}
#qunit-modulefilter-dropdown-list {
max-height: 200px;
overflow-y: auto;
margin: 0;
border-top: 2px groove threedhighlight;
padding: 0.4em 0 0;
font: smaller/1.5em sans-serif;
}
#qunit-modulefilter-dropdown-list li {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#qunit-modulefilter-dropdown-list .clickable {
display: block;
padding-left: 0.15em;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 1em 0.4em 1em;
border-bottom: 1px solid #FFF;
list-style-position: inside;
}
#qunit-tests > li {
display: none;
}
#qunit-tests li.running,
#qunit-tests li.pass,
#qunit-tests li.fail,
#qunit-tests li.skipped {
display: list-item;
}
#qunit-tests.hidepass {
position: relative;
}
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
visibility: hidden;
position: absolute;
width: 0;
height: 0;
padding: 0;
border: 0;
margin: 0;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li.skipped strong {
cursor: default;
}
#qunit-tests li a {
padding: 0.5em;
color: #C2CCD1;
text-decoration: none;
}
#qunit-tests li p a {
padding: 0.25em;
color: #6B6464;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests li .runtime {
float: right;
font-size: smaller;
}
.qunit-assert-list {
margin-top: 0.5em;
padding: 0.5em;
background-color: #FFF;
border-radius: 5px;
}
.qunit-source {
margin: 0.6em 0 0.3em;
}
.qunit-collapsed {
display: none;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: 0.2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 0.5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
color: #374E0C;
background-color: #E0F2BE;
text-decoration: none;
}
#qunit-tests ins {
color: #500;
background-color: #FFCACA;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: #000; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
padding: 5px;
background-color: #FFF;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #3C510C;
background-color: #FFF;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #FFF;
border-left: 10px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 5px 5px;
}
#qunit-tests .fail { color: #000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: #008000; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/*** Skipped tests */
#qunit-tests .skipped {
background-color: #EBECE9;
}
#qunit-tests .qunit-skipped-label {
background-color: #F4FF77;
display: inline-block;
font-style: normal;
color: #366097;
line-height: 1.8em;
padding: 0 0.5em;
margin: -0.4em 0.4em -0.4em 0;
}
/** Result */
#qunit-testresult {
padding: 0.5em 1em 0.5em 1em;
color: #2B81AF;
background-color: #D2E0E6;
border-bottom: 1px solid #FFF;
}
#qunit-testresult .module-name {
font-weight: 700;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
width: 1000px;
height: 1000px;
}
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Style" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/css</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>qunit-2.0.1.css</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>qunit-2.0.1_css</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Style</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Qunit-2.0.1 (css)</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/javascript</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>qunit-2.0.1.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>qunit-2.0.1_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Qunit-2.0.1 (js)</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="qunit-2.0.1.css">
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="qunit-2.0.1.js"></script>
<script src="jquery.js"></script>
<script src="webrtc_unit_test.js"></script>
</head>
<body>
<div class="gadget_webrtc"></div>
<div id="qunit"></div>
<div id="qunit-fixture">
<div data-gadget-url="gadget_webrtc_handshake.html"
data-gadget-scope="alice_handshake_gadget"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_webrtc_handshake.html"
data-gadget-scope="bob_handshake_gadget"
data-gadget-sandbox="public"></div>
</div>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>webrtc_unit_test.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>webrtc_unit_test_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Unit test for webrtc gadget</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, document, rJS, JSON, QUnit, jQuery, RSVP, console, setTimeout*/
(function(rJS, QUnit, RSVP, $) {
"use strict";
var error_handler = function(e) {
window.console.error(e);
ok(false, e);
},
connection_options = [
{
// No need for stun server on the same lan / ipv6
iceServers: [
{'url': 'stun:23.21.150.121'},
{url: 'stun:stun.1.google.com:19302'}
]
},
{
'optional': [{DtlsSrtpKeyAgreement: true}]
}
],
data_channel_options = {reliable: true},
offer_contraints = {
mandatory: {
OfferToReceiveAudio: false,
OfferToReceiveVideo: false
}
},
offer = {"type":"offer", "sdp":"v=0\r\n\
o=- 2708361213080913936 2 IN IP4 127.0.0.1\r\n\
s=-\r\n\
t=0 0\r\n\
a=msid-semantic: WMS\r\n\
m=application 60581 DTLS/SCTP 5000\r\n\
c=IN IP4 82.226.112.70\r\n\
a=candidate:3097449529 1 udp 2113937151 192.168.242.146 60581 typ host generation 0 network-cost 50\r\n\
a=candidate:421107265 1 udp 2113939711 2a01:e35:2e27:460:3430:1418:c2a6:f8e5 43111 typ host generation 0 network-cost 50\r\n\
a=candidate:842163049 1 udp 1677729535 82.226.112.70 60581 typ srflx raddr 192.168.242.146 rport 60581 generation 0 network-cost 50\r\n\
a=ice-ufrag:N0ey\r\n\
a=ice-pwd:hgfceTKEWpBojQfb+iA3DG0x\r\n\
a=fingerprint:sha-256 56:82:C4:19:56:BA:BE:B2:37:E0:9B:87:44:AB:0C:D1:7A:4C:61:E1:AA:1D:56:70:91:EE:7D:1E:57:BC:28:3A\r\n\
a=setup:actpass\r\n\
a=mid:data\r\n\
a=sctpmap:5000 webrtc-datachannel 1024\r\n"
}
QUnit.config.testTimeout = 60000;
rJS(window)
.ready(function(g) {
g.props = {};
g.props.Alice = {},
g.props.Bob = {},
g.props.config = {
type: "query",
sub_storage : {
type: "uuid",
sub_storage: {
"type": "indexeddb",
"database": "serverless"
}
}
};
g.props.description_defer = new RSVP.defer();
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
.allowPublicAcquisition("notifyDescriptionCalculated", function (args) {
this.props.description_defer.resolve(args[0]);
this.props.description_defer = RSVP.defer();
})
.declareService(function() {
var g = this;
QUnit.test("Initiate Clients", function( assert ) {
assert.expect(2);
var done = assert.async();
return g.getDeclaredGadget("alice_handshake_gadget")
.then(function(new_gadget) {
g.props.Alice.alice_handshake_gadget = new_gadget;
return g.props.Alice.alice_handshake_gadget.register("meetup", "alice", g.props.config);
})
.then(function(res) {
assert.equal(res[0], "meetup_alice", "Alice initiate the handshake gadget and register");
return g.getDeclaredGadget("bob_handshake_gadget")
})
.then(function(new_gadget) {
g.props.Bob.bob_handshake_gadget = new_gadget;
return g.props.Bob.bob_handshake_gadget.register("meetup", "bob", g.props.config);
})
.then(function(res) {
assert.equal(res[0], "meetup_bob", "Bob initiate the handshake gadget and register");
})
.then(function(new_gadget) {
var new_element = document.createElement("div");
g.props.element.querySelector(".gadget_webrtc").appendChild(new_element);
var scope = "webrtc_bob";
return g.declareGadget("gadget_webrtc.html", {
scope: scope,
element: new_element
})
})
.then(function(rtc_gadget) {
g.props.Bob.webrtc_gadget = rtc_gadget;
})
.then(function(new_gadget) {
var new_element = document.createElement("div");
g.props.element.querySelector(".gadget_webrtc").appendChild(new_element);
var scope = "webrtc_alice";
return g.declareGadget("gadget_webrtc.html", {
scope: scope,
element: new_element
})
})
.then(function(rtc_gadget) {
g.props.Alice.webrtc_gadget = rtc_gadget;
})
.fail(error_handler).always(done);
});
QUnit.test("Alice waits and picks the Offer as available", function( assert ) {
var done = assert.async();
assert.expect(1);
var offer_deffer = RSVP.defer();
return g.props.Alice.alice_handshake_gadget.wait_until_available("meetup", "alice_",
function(response){
assert.equal(JSON.parse(response[0]).from, "bob", "Alice waits for the offer while other tests are running and picks the offer from bob as offer gets available.");
offer_deffer.resolve();
})
.fail(error_handler).always(done);
});
QUnit.test("Bob can create offer", function( assert ) {
var local_description;
var done = assert.async();
assert.expect(4);
return new RSVP.Queue()
.then(function() {
return g.props.Bob.webrtc_gadget.createConnection.apply(g.props.Bob.webrtc_gadget, connection_options)
.push(function () {
return g.props.Bob.webrtc_gadget.createDataChannel("bob", data_channel_options);
})
.push(function () {
return g.props.Bob.webrtc_gadget.createOffer(offer_contraints);
})
.push(function (ld) {
local_description = ld;
assert.equal(local_description.type, "offer", "Check if local driscription genrated is of type offer");
return g.props.Bob.webrtc_gadget.setLocalDescription(local_description);
})
.push(function () {
return g.props.description_defer.promise;
});
})
.then(function(description) {
// diff to check ice candidates
var parsed_desc = JSON.parse(description),
count = 0,
i;
assert.notDeepEqual(parsed_desc.sdp, local_description, "Diff the local driscription generated above with the ice candidates ");
var line_list = parsed_desc.sdp.split('\n');
for (i = 0; i < line_list.length; i += 1) {
if (line_list[i].indexOf('a=candidate:') === 0) {
count += 1;
}
}
assert.equal(count, 3, "Check if all the 3 ice candidates are generated sucessfully");
assert.equal(parsed_desc.type, "offer", "Check if final type is offer");
})
.fail(error_handler).always(done);
});
QUnit.test("Bob can send Offer", function( assert ) {
var done = assert.async();
assert.expect(2);
var params = {'name': 'alice_bob',
'data' : new Blob([JSON.stringify({from: 'bob',
action: "offer",
data: offer})],
{type : "application/json"})};
return g.props.Bob.bob_handshake_gadget.handle_offer_answer("meetup", params)
.then(function(res) {
assert.equal(res[0], "meetup_alice_bob", "Check if Bob sucessfully saves the offer into the JIO ");
return g.props.Bob.bob_handshake_gadget.get_answer('meetup', "alice_bob");
})
.then(function(res) {
assert.deepEqual(res, params.data, "Check if the data retrived is same as data entered");
})
.fail(error_handler).always(done);
});
QUnit.test("Alice generates an answer", function( assert ) {
var done = assert.async();
assert.expect(2);
var webrtc = g.props.Alice.webrtc_gadget;
return webrtc.createConnection.apply(webrtc, connection_options)
.push(function () {
return webrtc.setRemoteDescription(JSON.stringify(offer));
})
.push(function () {
return webrtc.createAnswer(offer_contraints);
})
.push(function (local_description) {
return webrtc.setLocalDescription(local_description);
})
.push(function () {
g.props.description_defer = new RSVP.defer();
return g.props.description_defer.promise;
})
.then(function(res) {
var parsed_desc = JSON.parse(res),
count = 0;
var line_list = parsed_desc.sdp.split('\n');
for (var i = 0; i < line_list.length; i += 1) {
if (line_list[i].indexOf('a=candidate:') === 0) {
count += 1;
}
}
assert.equal(count, 3, "Check if all the 3 ice candidates are generated sucessfully");
assert.equal(parsed_desc.type, "answer", "Check if genrated description is of type answer");
})
.fail(error_handler).always(done);
});
});
})(rJS, QUnit, RSVP, jQuery);
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/javascript</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>webrtc_unit_test.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>webrtc_unit_test_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Unit test for webrtc gadget (JS)</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
erp5_ui_test_core
\ No newline at end of file
erp5_ui_test_core
erp5_webrtc_gadget
\ No newline at end of file
......@@ -40,4 +40,11 @@ portal_tests/proxy_field_zuite/**
portal_tests/relation_field_zuite
portal_tests/relation_field_zuite/**
portal_tests/search_zuite
portal_tests/search_zuite/**
\ No newline at end of file
portal_tests/search_zuite/**
portal_tests/webrtc_ui_zuite
portal_tests/webrtc_ui_zuite/**
web_page_module/qunit-2.0.1_css
web_page_module/qunit-2.0.1_js
web_page_module/webrtc_unit_test_html
web_page_module/webrtc_unit_test_js
web_site_module/webrtc_unit_test
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment