Debian Codegraph @

closure-library/closure/goog/testing/mockrange.js

raw
1 // Copyright 2008 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 LooseMock of goog.dom.AbstractRange.
17 *
18 */
19
20 goog.setTestOnly('goog.testing.MockRange');
21 goog.provide('goog.testing.MockRange');
22
23 goog.require('goog.dom.AbstractRange');
24 goog.require('goog.testing.LooseMock');
25
26
27
28 /**
29 * LooseMock of goog.dom.AbstractRange. Useful because the mock framework cannot
30 * simply create a mock out of an abstract class, and cannot create a mock out
31 * of classes that implements __iterator__ because it relies on the default
32 * behavior of iterating through all of an object's properties.
33 * @constructor
34 * @extends {goog.testing.LooseMock}
35 * @final
36 */
37 goog.testing.MockRange = function() {
38 goog.testing.LooseMock.call(this, goog.testing.MockRange.ConcreteRange_);
39 };
40 goog.inherits(goog.testing.MockRange, goog.testing.LooseMock);
41
42
43 // *** Private helper class ************************************************* //
44
45
46
47 /**
48 * Concrete subclass of goog.dom.AbstractRange that simply sets the abstract
49 * method __iterator__ to undefined so that javascript defaults to iterating
50 * through all of the object's properties.
51 * @constructor
52 * @extends {goog.dom.AbstractRange}
53 * @private
54 */
55 goog.testing.MockRange.ConcreteRange_ = function() {
56 goog.dom.AbstractRange.call(this);
57 };
58 goog.inherits(goog.testing.MockRange.ConcreteRange_, goog.dom.AbstractRange);
59
60
61 /**
62 * Undefine the iterator so the mock framework can loop through this class'
63 * properties.
64 * @override
65 */
66 goog.testing.MockRange.ConcreteRange_.prototype.__iterator__ =
67 // This isn't really type-safe.
68 /** @type {?} */ (undefined);