testing.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /**
  2. * @license Angular v8.1.0
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { NoopAnimationPlayer, AUTO_STYLE } from '@angular/animations';
  7. import { ɵvalidateStyleProperty, ɵmatchesElement, ɵcontainsElement, ɵinvokeQuery, ɵallowPreviousPlayerStylesMerge } from '@angular/animations/browser';
  8. /**
  9. * @fileoverview added by tsickle
  10. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  11. */
  12. /**
  13. * \@publicApi
  14. */
  15. class MockAnimationDriver {
  16. /**
  17. * @param {?} prop
  18. * @return {?}
  19. */
  20. validateStyleProperty(prop) { return ɵvalidateStyleProperty(prop); }
  21. /**
  22. * @param {?} element
  23. * @param {?} selector
  24. * @return {?}
  25. */
  26. matchesElement(element, selector) {
  27. return ɵmatchesElement(element, selector);
  28. }
  29. /**
  30. * @param {?} elm1
  31. * @param {?} elm2
  32. * @return {?}
  33. */
  34. containsElement(elm1, elm2) { return ɵcontainsElement(elm1, elm2); }
  35. /**
  36. * @param {?} element
  37. * @param {?} selector
  38. * @param {?} multi
  39. * @return {?}
  40. */
  41. query(element, selector, multi) {
  42. return ɵinvokeQuery(element, selector, multi);
  43. }
  44. /**
  45. * @param {?} element
  46. * @param {?} prop
  47. * @param {?=} defaultValue
  48. * @return {?}
  49. */
  50. computeStyle(element, prop, defaultValue) {
  51. return defaultValue || '';
  52. }
  53. /**
  54. * @param {?} element
  55. * @param {?} keyframes
  56. * @param {?} duration
  57. * @param {?} delay
  58. * @param {?} easing
  59. * @param {?=} previousPlayers
  60. * @return {?}
  61. */
  62. animate(element, keyframes, duration, delay, easing, previousPlayers = []) {
  63. /** @type {?} */
  64. const player = new MockAnimationPlayer(element, keyframes, duration, delay, easing, previousPlayers);
  65. MockAnimationDriver.log.push((/** @type {?} */ (player)));
  66. return player;
  67. }
  68. }
  69. MockAnimationDriver.log = [];
  70. /**
  71. * \@publicApi
  72. */
  73. class MockAnimationPlayer extends NoopAnimationPlayer {
  74. /**
  75. * @param {?} element
  76. * @param {?} keyframes
  77. * @param {?} duration
  78. * @param {?} delay
  79. * @param {?} easing
  80. * @param {?} previousPlayers
  81. */
  82. constructor(element, keyframes, duration, delay, easing, previousPlayers) {
  83. super(duration, delay);
  84. this.element = element;
  85. this.keyframes = keyframes;
  86. this.duration = duration;
  87. this.delay = delay;
  88. this.easing = easing;
  89. this.previousPlayers = previousPlayers;
  90. this.__finished = false;
  91. this.__started = false;
  92. this.previousStyles = {};
  93. this._onInitFns = [];
  94. this.currentSnapshot = {};
  95. if (ɵallowPreviousPlayerStylesMerge(duration, delay)) {
  96. previousPlayers.forEach((/**
  97. * @param {?} player
  98. * @return {?}
  99. */
  100. player => {
  101. if (player instanceof MockAnimationPlayer) {
  102. /** @type {?} */
  103. const styles = player.currentSnapshot;
  104. Object.keys(styles).forEach((/**
  105. * @param {?} prop
  106. * @return {?}
  107. */
  108. prop => this.previousStyles[prop] = styles[prop]));
  109. }
  110. }));
  111. }
  112. }
  113. /* @internal */
  114. /**
  115. * @param {?} fn
  116. * @return {?}
  117. */
  118. onInit(fn) { this._onInitFns.push(fn); }
  119. /* @internal */
  120. /**
  121. * @return {?}
  122. */
  123. init() {
  124. super.init();
  125. this._onInitFns.forEach((/**
  126. * @param {?} fn
  127. * @return {?}
  128. */
  129. fn => fn()));
  130. this._onInitFns = [];
  131. }
  132. /**
  133. * @return {?}
  134. */
  135. finish() {
  136. super.finish();
  137. this.__finished = true;
  138. }
  139. /**
  140. * @return {?}
  141. */
  142. destroy() {
  143. super.destroy();
  144. this.__finished = true;
  145. }
  146. /* @internal */
  147. /**
  148. * @return {?}
  149. */
  150. triggerMicrotask() { }
  151. /**
  152. * @return {?}
  153. */
  154. play() {
  155. super.play();
  156. this.__started = true;
  157. }
  158. /**
  159. * @return {?}
  160. */
  161. hasStarted() { return this.__started; }
  162. /**
  163. * @return {?}
  164. */
  165. beforeDestroy() {
  166. /** @type {?} */
  167. const captures = {};
  168. Object.keys(this.previousStyles).forEach((/**
  169. * @param {?} prop
  170. * @return {?}
  171. */
  172. prop => {
  173. captures[prop] = this.previousStyles[prop];
  174. }));
  175. if (this.hasStarted()) {
  176. // when assembling the captured styles, it's important that
  177. // we build the keyframe styles in the following order:
  178. // {other styles within keyframes, ... previousStyles }
  179. this.keyframes.forEach((/**
  180. * @param {?} kf
  181. * @return {?}
  182. */
  183. kf => {
  184. Object.keys(kf).forEach((/**
  185. * @param {?} prop
  186. * @return {?}
  187. */
  188. prop => {
  189. if (prop != 'offset') {
  190. captures[prop] = this.__finished ? kf[prop] : AUTO_STYLE;
  191. }
  192. }));
  193. }));
  194. }
  195. this.currentSnapshot = captures;
  196. }
  197. }
  198. /**
  199. * @fileoverview added by tsickle
  200. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  201. */
  202. /**
  203. * @fileoverview added by tsickle
  204. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  205. */
  206. /**
  207. * @fileoverview added by tsickle
  208. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  209. */
  210. /**
  211. * Generated bundle index. Do not edit.
  212. */
  213. export { MockAnimationDriver, MockAnimationPlayer };
  214. //# sourceMappingURL=testing.js.map