| 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 Mock ProgressEvent object. |
| 17 |
* |
| 18 |
*/ |
| 19 |
|
| 20 |
goog.setTestOnly('goog.testing.fs.ProgressEvent'); |
| 21 |
goog.provide('goog.testing.fs.ProgressEvent'); |
| 22 |
|
| 23 |
goog.require('goog.events.Event'); |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* A mock progress event. |
| 29 |
* |
| 30 |
* @param {!goog.fs.FileSaver.EventType|!goog.fs.FileReader.EventType} type |
| 31 |
* Event type. |
| 32 |
* @param {number} loaded The number of bytes processed. |
| 33 |
* @param {number} total The total data that was to be processed, in bytes. |
| 34 |
* @constructor |
| 35 |
* @extends {goog.events.Event} |
| 36 |
* @final |
| 37 |
*/ |
| 38 |
goog.testing.fs.ProgressEvent = function(type, loaded, total) { |
| 39 |
goog.testing.fs.ProgressEvent.base(this, 'constructor', type); |
| 40 |
|
| 41 |
/** |
| 42 |
* The number of bytes processed. |
| 43 |
* @type {number} |
| 44 |
* @private |
| 45 |
*/ |
| 46 |
this.loaded_ = loaded; |
| 47 |
|
| 48 |
|
| 49 |
/** |
| 50 |
* The total data that was to be procesed, in bytes. |
| 51 |
* @type {number} |
| 52 |
* @private |
| 53 |
*/ |
| 54 |
this.total_ = total; |
| 55 |
}; |
| 56 |
goog.inherits(goog.testing.fs.ProgressEvent, goog.events.Event); |
| 57 |
|
| 58 |
|
| 59 |
/** |
| 60 |
* @see {goog.fs.ProgressEvent#isLengthComputable} |
| 61 |
* @return {boolean} True if the length is known. |
| 62 |
*/ |
| 63 |
goog.testing.fs.ProgressEvent.prototype.isLengthComputable = function() { |
| 64 |
return true; |
| 65 |
}; |
| 66 |
|
| 67 |
|
| 68 |
/** |
| 69 |
* @see {goog.fs.ProgressEvent#getLoaded} |
| 70 |
* @return {number} The number of bytes loaded or written. |
| 71 |
*/ |
| 72 |
goog.testing.fs.ProgressEvent.prototype.getLoaded = function() { |
| 73 |
return this.loaded_; |
| 74 |
}; |
| 75 |
|
| 76 |
|
| 77 |
/** |
| 78 |
* @see {goog.fs.ProgressEvent#getTotal} |
| 79 |
* @return {number} The total bytes to load or write. |
| 80 |
*/ |
| 81 |
goog.testing.fs.ProgressEvent.prototype.getTotal = function() { |
| 82 |
return this.total_; |
| 83 |
}; |