Debian Codegraph @

closure-library/closure/goog/testing/storage/fakemechanism.js

raw
1 // Copyright 2012 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 Provides a fake storage mechanism for testing.
17 * @author [email protected] (Chris Henry)
18 */
19
20 goog.provide('goog.testing.storage.FakeMechanism');
21 goog.setTestOnly('goog.testing.storage.FakeMechanism');
22
23 goog.require('goog.storage.mechanism.IterableMechanism');
24 goog.require('goog.structs.Map');
25
26
27
28 /**
29 * Creates a fake iterable mechanism.
30 *
31 * @constructor
32 * @extends {goog.storage.mechanism.IterableMechanism}
33 * @final
34 */
35 goog.testing.storage.FakeMechanism = function() {
36 /**
37 * @type {goog.structs.Map}
38 * @private
39 */
40 this.storage_ = new goog.structs.Map();
41 };
42 goog.inherits(
43 goog.testing.storage.FakeMechanism,
44 goog.storage.mechanism.IterableMechanism);
45
46
47 /** @override */
48 goog.testing.storage.FakeMechanism.prototype.set = function(key, value) {
49 this.storage_.set(key, value);
50 };
51
52
53 /** @override */
54 goog.testing.storage.FakeMechanism.prototype.get = function(key) {
55 return /** @type {?string} */ (
56 this.storage_.get(key, null /* default value */));
57 };
58
59
60 /** @override */
61 goog.testing.storage.FakeMechanism.prototype.remove = function(key) {
62 this.storage_.remove(key);
63 };
64
65
66 /** @override */
67 goog.testing.storage.FakeMechanism.prototype.__iterator__ = function(opt_keys) {
68 return this.storage_.__iterator__(opt_keys);
69 };