blob: 00de40f195a4d255b5a5ff05ed91c7bc7ab3bb82 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<Module>
<ModulePrefs title="EndToEndTest">
<Require feature="opensocial-0.9"/>
<Require feature="views"/>
<Optional feature="content-rewrite">
<Param name="exclude-urls">.*</Param>
</Optional>
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript" src="/testframework.js"></script>
<script type="text/javascript">
var tests = {
/** Test fetching the owner's friends, which should be 'canonical' */
fetchOwnerFriends: function() {
var req = opensocial.newDataRequest();
var idSpec = opensocial.newIdSpec({userId : opensocial.IdSpec.PersonId.OWNER,
groupId : 'FRIENDS'})
req.add(req.newFetchPeopleRequest(idSpec), 'ownerFriends');
function receivedData(response) {
var ownerFriends = getAndCheckError(response, 'ownerFriends');
assertEquals('Wrong friend count', 4, ownerFriends.size());
var johnDoe = ownerFriends.getById('john.doe');
assertEquals('Wrong name for john doe', 'Johnny', johnDoe.getDisplayName());
finished();
}
// Send the request
req.send(receivedData);
},
/** Test fetching 'maija.m' friends, of which there are none */
fetchEmptyFriendsById: function() {
var req = opensocial.newDataRequest();
var idSpec = opensocial.newIdSpec({userId : 'maija.m', groupId : 'FRIENDS'})
req.add(req.newFetchPeopleRequest(idSpec), 'idFriends');
function receivedData(response) {
var ownerFriends = getAndCheckError(response, 'idFriends');
assertEquals('Wrong friend count', 0, ownerFriends.size());
finished();
}
// Send the request
req.send(receivedData);
},
/** Test fetching friends of a list of users */
fetchPluralUsers: function() {
var req = opensocial.newDataRequest();
var idSpec = opensocial.newIdSpec({userId : ['john.doe', 'jane.doe']})
req.add(req.newFetchPeopleRequest(idSpec), 'idUsers');
function receivedData(response) {
var users = getAndCheckError(response, 'idUsers');
assertEquals('Wrong friend count', 2, users.size());
finished();
}
// Send the request
req.send(receivedData);
}
};
function getAndCheckError(response, key) {
assertFalse('Data error', response.hadError());
var dataItem = response.get(key);
assertFalse('Data item error for ' + key, dataItem.hadError());
return dataItem.getData();
}
</script>
]]>
</Content>
</Module>