Debian Codegraph @

closure-library/closure/goog/testing/net/xhriopool.js

raw
1 // Copyright 2011 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 /**
16 * @fileoverview An XhrIo pool that uses a single mock XHR object for testing.
17 *
18 */
19
20 goog.setTestOnly('goog.testing.net.XhrIoPool');
21 goog.provide('goog.testing.net.XhrIoPool');
22
23 goog.require('goog.net.XhrIoPool');
24 goog.require('goog.testing.net.XhrIo');
25
26
27
28 /**
29 * A pool containing a single mock XhrIo object.
30 *
31 * @param {goog.testing.net.XhrIo=} opt_xhr The mock XhrIo object.
32 * @constructor
33 * @extends {goog.net.XhrIoPool}
34 * @final
35 */
36 goog.testing.net.XhrIoPool = function(opt_xhr) {
37 /**
38 * The mock XhrIo object.
39 * @type {!goog.testing.net.XhrIo}
40 * @private
41 */
42 this.xhr_ = opt_xhr || new goog.testing.net.XhrIo();
43
44 // Run this after setting xhr_ because xhr_ is used to initialize the pool.
45 goog.testing.net.XhrIoPool.base(this, 'constructor', undefined, 1, 1);
46 };
47 goog.inherits(goog.testing.net.XhrIoPool, goog.net.XhrIoPool);
48
49
50 /**
51 * @override
52 * @suppress {invalidCasts}
53 */
54 goog.testing.net.XhrIoPool.prototype.createObject = function() {
55 return (/** @type {!goog.net.XhrIo} */ (this.xhr_));
56 };
57
58
59 /**
60 * Get the mock XhrIo used by this pool.
61 *
62 * @return {!goog.testing.net.XhrIo} The mock XhrIo.
63 */
64 goog.testing.net.XhrIoPool.prototype.getXhr = function() {
65 return this.xhr_;
66 };