W3C home > Mailing lists > Public > public-dap-commits@w3.org > May 2011

2009/dap/contacts/tests/test-cases common.js,NONE,1.1 find_empty_fields.html,NONE,1.1

From: Dominique Hazael-Massieux via cvs-syncmail <cvsmail@w3.org>
Date: Mon, 23 May 2011 14:02:15 +0000
To: public-dap-commits@w3.org
Message-Id: <E1QOVi3-0007yl-JU@lionel-hutz.w3.org>
Update of /sources/public/2009/dap/contacts/tests/test-cases
In directory hutz:/tmp/cvs-serv30656/test-cases

Added Files:
	common.js find_empty_fields.html 
Log Message:
new test case: empty fields list implies null contacts

--- NEW FILE: find_empty_fields.html ---
<!doctype html>
<html>
 <head>
  <title>Contacts API - navigator implements contacts.find</title>
  <script src="../impl.js"></script>
  <script src="http://w3c-test.org/html/tests/resources/testharness.js"></script>
  <script src="http://w3c-test.org/html/tests/resources/testharnessreport.js"></script>
  <script src="common.js"></script>
 </head>
 <body>
   <p>Please select at least one contact when prompted.</p>
   <div id="log"></div>
   <script>
     var t = async_test("Empty contact results from empty fields search", {timeout: 15000});
     var nullContact = {"id": null,
	"displayName": null,
	"name": null,
	"nickname": null,
	"phoneNumbers": null,     
	"emails": null,
	"addresses": null, 
	"ims": null,
	"organizations": null,
	"revision": null, 
	"birthday": null,
	"gender": null,
	"note": null, 
	"photos": null,
        "categories": null, 
	"urls": null, 
	"timezone": null};

     navigator.contacts.find([], function (contacts) {
         t.step(function () {
           assert_is_contact(contacts[0]);
           assert_contact_same_as(contacts[0], nullContact);
           t.done();
         });
     });
  </script>
 </body>
</html>

--- NEW FILE: common.js ---
var _contact_properties = {"id": "string", "displayName": "string", "name": "contactname", "nickname": "string", "phoneNumbers": "contactfields", "emails": "contactfields", "addresses": "contactaddresses", "ims": "contactfields", "organizations": "contactorganizations", "revision": "date", "birthday": "date", "gender": "string", "note": "string", "photos": "contactfields", "categories": "strings", "urls": "contactfields", "timezone": "string"};

function assert_is_contact(contact) {
    for (i in _contact_properties) {
	assert_own_property(contact, i);
    }
}

function assert_contact_same_as(contact, refContact) {
    for (field in _contact_properties) {
	if (_contact_properties[field] == "string") {
	    assert_equals(contact[field], refContact[field]);
	} else {
	    // @@@ deal with composed properties
	}
    }
}
Received on Monday, 23 May 2011 14:02:17 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 May 2011 14:02:17 GMT