Addressing review suggestions and fixing asynchronous function calls.
This commit addresses @bartvde's review comments, adds more documentation, and fixes asynchronous function calls. Previously, when creating multiple processes with the same identifier, the describe callback would only have been called for the first process. This was fixed to move DescribeProcess handling from WPSProcess to WPSClient.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
var client;
|
||||
|
||||
function test_initialize(t) {
|
||||
t.plan(2);
|
||||
t.plan(3);
|
||||
|
||||
client = new OpenLayers.WPSClient({
|
||||
servers: {
|
||||
@@ -15,6 +15,7 @@
|
||||
});
|
||||
|
||||
t.ok(client instanceof OpenLayers.WPSClient, 'creates an instance');
|
||||
t.ok(client.events, 'has an events instance');
|
||||
t.eq(client.servers.local.url, '/geoserver/wps', 'servers stored on instance');
|
||||
}
|
||||
|
||||
@@ -36,6 +37,35 @@
|
||||
|
||||
}
|
||||
|
||||
function test_describeProcess(t) {
|
||||
t.plan(6);
|
||||
var log = {request: [], event: []};
|
||||
var originalGET = OpenLayers.Request.GET;
|
||||
OpenLayers.Request.GET = function(cfg) {
|
||||
log.request.push(cfg);
|
||||
}
|
||||
function describe(evt) {
|
||||
log.event.push(evt);
|
||||
}
|
||||
client.events.register('describeprocess', this, describe);
|
||||
|
||||
process = client.getProcess('local', 'gs:splitPolygon');
|
||||
t.eq(client.servers.local.processDescription['gs:splitPolyon'], null, 'describeProcess pending');
|
||||
process.describe();
|
||||
t.eq(log.request.length, 1, 'describeProcess request only sent once');
|
||||
log.request[0].success.call(client, {
|
||||
responseText: '<?xml version="1.0" encoding="UTF-8"?><wps:ProcessDescriptions xmlns:wps="http://www.opengis.net/wps/1.0.0"></wps:ProcessDescriptions>'
|
||||
});
|
||||
t.eq(log.event[0].type, 'describeprocess', 'describeprocess event triggered');
|
||||
t.ok(client.servers.local.processDescription['gs:splitPolygon'], 'We have a process description!');
|
||||
process.describe();
|
||||
t.eq(log.request.length, 1, 'describeProcess request only sent once');
|
||||
t.eq(log.event.length, 1, 'describeprocess event only triggered once');
|
||||
|
||||
OpenLayers.Request.GET = originalGET;
|
||||
client.events.unregister('describeprocess', this, describe);
|
||||
}
|
||||
|
||||
function test_execute(t) {
|
||||
t.plan(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user