Skip to content

Commit

Permalink
Merge pull request #2 from pjckcs/dap-proximity
Browse files Browse the repository at this point in the history
Update tests for DAP proximity events
  • Loading branch information
dontcallmedom committed Sep 23, 2013
2 parents 9c0b738 + d04e160 commit 4bbc503
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 62 deletions.
39 changes: 5 additions & 34 deletions proximity/DeviceProximityEvent_tests.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
/**
* W3C 3-clause BSD License
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* o Redistributions of works must retain the original copyright notice,
* this list of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the original copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* o Neither the name of the W3C nor the names of its contributors may be
* used to endorse or promote products derived from this work without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
**/

(function() {
//inheritance tests
test(function() {
Expand All @@ -41,7 +12,7 @@

//Type attribute tests
test(function() {
assert_throws(null, function() {
assert_throws(new TypeError(), function() {
new DeviceProximityEvent();
}, 'First argument is required, so was expecting a TypeError.');
}, 'Missing type argument');
Expand Down Expand Up @@ -94,7 +65,7 @@
test(function() {
var event = new DeviceProximityEvent(new Boolean(true));
assert_equals(event.type, 'true');
}, 'type argument is instance of boolean');
}, 'type argument is instance of Boolean (true)');

test(function() {
var event = new DeviceProximityEvent(false);
Expand All @@ -104,17 +75,17 @@
test(function() {
var event = new DeviceProximityEvent(new Boolean(false));
assert_equals(event.type, 'false');
}, '');
}, 'type argument is instance of Boolean (false)');

test(function() {
var event = new DeviceProximityEvent('test');
assert_equals(event.type, 'test');
}, 'type argument is instance of boolean (false)');
}, 'type argument is string');

test(function() {
var event = new DeviceProximityEvent(new String('test'));
assert_equals(event.type, 'test');
}, 'type argument is string');
}, 'type argument is instance of String');

test(function() {
var event = new DeviceProximityEvent(function test() {});
Expand Down
9 changes: 9 additions & 0 deletions proximity/ProximityEvent_tests.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<meta charset=utf8>
<meta content="width=device-width, initial-scale=1" name=viewport>
<title>Proximity Events Test Suite</title>
<h1>Test Suite for Proximity Events</h1>
<div id="log"></div>
<script src="/resources/testharness.js"></script>
<script src="DeviceProximityEvent_tests.js"></script>
<script src="UserProximityEvent_tests.js"></script>
27 changes: 13 additions & 14 deletions proximity/UserProximityEvent_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

//Type attribute tests
test(function() {
assert_throws(null, function() {
assert_throws(new TypeError(), function() {
new UserProximityEvent();
}, 'First argument is required, so was expecting a TypeError.');
}, 'Missing type argument');
Expand Down Expand Up @@ -93,7 +93,7 @@
test(function() {
var event = new UserProximityEvent(new Boolean(true));
assert_equals(event.type, 'true');
}, 'type argument is instance of boolean');
}, 'type argument is instance of Boolean (true)');

test(function() {
var event = new UserProximityEvent(false);
Expand All @@ -103,17 +103,17 @@
test(function() {
var event = new UserProximityEvent(new Boolean(false));
assert_equals(event.type, 'false');
}, '');
}, 'type argument is instance of Boolean (false)');

test(function() {
var event = new UserProximityEvent('test');
assert_equals(event.type, 'test');
}, 'type argument is instance of boolean (false)');
}, 'type argument is string');

test(function() {
var event = new UserProximityEvent(new String('test'));
assert_equals(event.type, 'test');
}, 'type argument is string');
}, 'type argument is instance of String');

test(function() {
var event = new UserProximityEvent(function test() {});
Expand Down Expand Up @@ -170,56 +170,56 @@
near: undefined
});
assert_equals(event.near, false, 'argument is truthy');
}, 'near set to a falsy object');
}, 'near set to undefined');

test(function() {
var event = new UserProximityEvent('test', {
near: null
});
assert_equals(event.near, false, 'argument is flasy');
}, 'near set to a falsy object');
}, 'near set to null');

test(function() {
var event = new UserProximityEvent('test', {
near: 0
});
assert_equals(event.near, false, 'argument is flasy');
}, 'near set to a falsy object');
}, 'near set to 0');

test(function() {
var event = new UserProximityEvent('test', {
near: ''
});
assert_equals(event.near, false, 'argument is flasy');
}, 'near set to a falsy object');
}, 'near set to empty string');

test(function() {
var event = new UserProximityEvent('test', {
near: '\u0020'
});
assert_equals(event.near, true, 'argument is truthy');
}, 'near set to a truthy object');
}, 'near set to U+0020');

test(function() {
var event = new UserProximityEvent('test', {
near: 1
});
assert_equals(event.near, true, 'argument is truthy');
}, 'near set to a truthy object');
}, 'near set to 1');

test(function() {
var event = new UserProximityEvent('test', {
near: []
});
assert_equals(event.near, true, 'argument is truthy');
}, 'near set to a truthy object');
}, 'near set to []');

test(function() {
var event = new UserProximityEvent('test', {
near: {}
});
assert_equals(event.near, true, 'argument is truthy');
}, 'near set to a truthy object');
}, 'near set to {}');

test(function() {
var dict = {
Expand Down Expand Up @@ -247,7 +247,6 @@
var desc = 'window.onuserproximity did not accept callable object',
func = function() {},
desc = 'onuserproximity does not exist';
assert_idl_attribute(window, 'onuserproximity', desc);
window.onuserproximity = func;
assert_equals(window.onuserproximity, func, desc);
}, 'onuserproximity exists and can be set to a function');
Expand Down
12 changes: 0 additions & 12 deletions proximity/index.html

This file was deleted.

3 changes: 1 addition & 2 deletions proximity/manifest.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
index.html
index.html
ProximityEvent_tests.html

0 comments on commit 4bbc503

Please sign in to comment.