Update wmts-hidpi, add nicer-api-docs

This commit is contained in:
Andreas Hocevar
2014-05-06 13:02:46 -05:00
parent b3ac1afd00
commit 1e25fc5585
2239 changed files with 3726515 additions and 37010 deletions

View File

@@ -0,0 +1,79 @@
// Copyright 2010 The Closure Library Authors. All Rights Reserved.
//
// Licensed 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.
/**
* @fileoverview Mock MessageChannel implementation that can receive fake
* messages and test that the right messages are sent.
*
*/
goog.provide('goog.testing.messaging.MockMessageChannel');
goog.require('goog.messaging.AbstractChannel');
goog.require('goog.testing.asserts');
/**
* Class for unit-testing code that communicates over a MessageChannel.
* @param {goog.testing.MockControl} mockControl The mock control used to create
* the method mock for #send.
* @extends {goog.messaging.AbstractChannel}
* @constructor
*/
goog.testing.messaging.MockMessageChannel = function(mockControl) {
goog.base(this);
/**
* Whether the channel has been disposed.
* @type {boolean}
*/
this.disposed = false;
mockControl.createMethodMock(this, 'send');
};
goog.inherits(goog.testing.messaging.MockMessageChannel,
goog.messaging.AbstractChannel);
/**
* A mock send function. Actually an instance of
* {@link goog.testing.FunctionMock}.
* @param {string} serviceName The name of the remote service to run.
* @param {string|!Object} payload The payload to send to the remote page.
* @override
*/
goog.testing.messaging.MockMessageChannel.prototype.send = function(
serviceName, payload) {};
/**
* Sets a flag indicating that this is disposed.
* @override
*/
goog.testing.messaging.MockMessageChannel.prototype.dispose = function() {
this.disposed = true;
};
/**
* Mocks the receipt of a message. Passes the payload the appropriate service.
* @param {string} serviceName The service to run.
* @param {string|!Object} payload The argument to pass to the service.
*/
goog.testing.messaging.MockMessageChannel.prototype.receive = function(
serviceName, payload) {
this.deliver(serviceName, payload);
};

View File

@@ -0,0 +1,100 @@
// Copyright 2010 The Closure Library Authors. All Rights Reserved.
//
// Licensed 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.
/**
* @fileoverview A simple mock class for imitating HTML5 MessageEvents.
*
*/
goog.provide('goog.testing.messaging.MockMessageEvent');
goog.require('goog.events.BrowserEvent');
goog.require('goog.events.EventType');
goog.require('goog.testing.events');
/**
* Creates a new fake MessageEvent.
*
* @param {*} data The data of the message.
* @param {string=} opt_origin The origin of the message, for server-sent and
* cross-document events.
* @param {string=} opt_lastEventId The last event ID, for server-sent events.
* @param {Window=} opt_source The proxy for the source window, for
* cross-document events.
* @param {Array.<MessagePort>=} opt_ports The Array of ports sent with the
* message, for cross-document and channel events.
* @extends {goog.testing.events.Event}
* @constructor
*/
goog.testing.messaging.MockMessageEvent = function(
data, opt_origin, opt_lastEventId, opt_source, opt_ports) {
goog.base(this, goog.events.EventType.MESSAGE);
/**
* The data of the message.
* @type {*}
*/
this.data = data;
/**
* The origin of the message, for server-sent and cross-document events.
* @type {?string}
*/
this.origin = opt_origin || null;
/**
* The last event ID, for server-sent events.
* @type {?string}
*/
this.lastEventId = opt_lastEventId || null;
/**
* The proxy for the source window, for cross-document events.
* @type {Window}
*/
this.source = opt_source || null;
/**
* The Array of ports sent with the message, for cross-document and channel
* events.
* @type {Array.<!MessagePort>}
*/
this.ports = opt_ports || null;
};
goog.inherits(
goog.testing.messaging.MockMessageEvent, goog.testing.events.Event);
/**
* Wraps a new fake MessageEvent in a BrowserEvent, like how a real MessageEvent
* would be wrapped.
*
* @param {*} data The data of the message.
* @param {string=} opt_origin The origin of the message, for server-sent and
* cross-document events.
* @param {string=} opt_lastEventId The last event ID, for server-sent events.
* @param {Window=} opt_source The proxy for the source window, for
* cross-document events.
* @param {Array.<MessagePort>=} opt_ports The Array of ports sent with the
* message, for cross-document and channel events.
* @return {goog.events.BrowserEvent} The wrapping event.
*/
goog.testing.messaging.MockMessageEvent.wrap = function(
data, opt_origin, opt_lastEventId, opt_source, opt_ports) {
return new goog.events.BrowserEvent(
new goog.testing.messaging.MockMessageEvent(
data, opt_origin, opt_lastEventId, opt_source, opt_ports));
};

View File

@@ -0,0 +1,85 @@
// Copyright 2011 The Closure Library Authors. All Rights Reserved.
//
// Licensed 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.
/**
* @fileoverview A simple dummy class for representing message ports in tests.
*
*/
goog.provide('goog.testing.messaging.MockMessagePort');
goog.require('goog.events.EventTarget');
/**
* Class for unit-testing code that uses MessagePorts.
* @param {*} id An opaque identifier, used because message ports otherwise have
* no distinguishing characteristics.
* @param {goog.testing.MockControl} mockControl The mock control used to create
* the method mock for #postMessage.
* @constructor
* @extends {goog.events.EventTarget}
*/
goog.testing.messaging.MockMessagePort = function(id, mockControl) {
goog.base(this);
/**
* An opaque identifier, used because message ports otherwise have no
* distinguishing characteristics.
* @type {*}
*/
this.id = id;
/**
* Whether or not the port has been started.
* @type {boolean}
*/
this.started = false;
/**
* Whether or not the port has been closed.
* @type {boolean}
*/
this.closed = false;
mockControl.createMethodMock(this, 'postMessage');
};
goog.inherits(goog.testing.messaging.MockMessagePort, goog.events.EventTarget);
/**
* A mock postMessage funciton. Actually an instance of
* {@link goog.testing.FunctionMock}.
* @param {*} message The message to send.
* @param {Array.<MessagePort>=} opt_ports Ports to send with the message.
*/
goog.testing.messaging.MockMessagePort.prototype.postMessage = function(
message, opt_ports) {};
/**
* Starts the port.
*/
goog.testing.messaging.MockMessagePort.prototype.start = function() {
this.started = true;
};
/**
* Closes the port.
*/
goog.testing.messaging.MockMessagePort.prototype.close = function() {
this.closed = true;
};

View File

@@ -0,0 +1,65 @@
// Copyright 2011 The Closure Library Authors. All Rights Reserved.
//
// Licensed 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.
/**
* @fileoverview A fake PortNetwork implementation that simply produces
* MockMessageChannels for all ports.
*
*/
goog.provide('goog.testing.messaging.MockPortNetwork');
goog.require('goog.messaging.PortNetwork'); // interface
goog.require('goog.testing.messaging.MockMessageChannel');
/**
* The fake PortNetwork.
*
* @param {!goog.testing.MockControl} mockControl The mock control for creating
* the mock message channels.
* @constructor
* @implements {goog.messaging.PortNetwork}
*/
goog.testing.messaging.MockPortNetwork = function(mockControl) {
/**
* The mock control for creating mock message channels.
* @type {!goog.testing.MockControl}
* @private
*/
this.mockControl_ = mockControl;
/**
* The mock ports that have been created.
* @type {!Object.<!goog.testing.messaging.MockMessageChannel>}
* @private
*/
this.ports_ = {};
};
/**
* Get the mock port with the given name.
* @param {string} name The name of the port to get.
* @return {!goog.testing.messaging.MockMessageChannel} The mock port.
* @override
*/
goog.testing.messaging.MockPortNetwork.prototype.dial = function(name) {
if (!(name in this.ports_)) {
this.ports_[name] =
new goog.testing.messaging.MockMessageChannel(this.mockControl_);
}
return this.ports_[name];
};