progressevent.js 2.1 KB

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