@luma.gl/test-utils 8.5.13 → 8.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createTestContext = createTestContext;
7
6
  exports.createHeadlessContext = createHeadlessContext;
7
+ exports.createTestContext = createTestContext;
8
8
 
9
9
  var _gltools = require("@luma.gl/gltools");
10
10
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context.js"],"names":["ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createTestContext","opts","Object","assign","context","createHeadlessContext","options","webgl1","webgl2","onError","message","Error","gl","headlessGL","headless","module","require"],"mappings":";;;;;;;;AAAA;;AACA;;AAEA,IAAMA,qBAAqB,GACzB,sEADF;AAGA,IAAMC,mBAAmB,gPAAzB;AAKA,IAAMC,gBAAgB,GAAG;AACvBC,EAAAA,KAAK,EAAE,CADgB;AAEvBC,EAAAA,MAAM,EAAE,CAFe;AAGvBC,EAAAA,KAAK,EAAE,IAHgB;AAIvBC,EAAAA,YAAY,EAAE;AAJS,CAAzB;;AAOO,SAASC,iBAAT,GAAsC;AAAA,MAAXC,IAAW,uEAAJ,EAAI;AAC3CA,EAAAA,IAAI,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBR,gBAAlB,EAAoCM,IAApC,CAAP;AACA,MAAMG,OAAO,GAAG,wBACZ,8BAAgBH,IAAhB,CADY,GAEZ,kCAAoBI,qBAAqB,CAACJ,IAAD,CAAzC,EAAiDA,IAAjD,CAFJ;AAGA,SAAOG,OAAP;AACD;;AAGM,SAASC,qBAAT,CAA+BC,OAA/B,EAAwC;AAAA,MACtCV,KADsC,GACLU,OADK,CACtCV,KADsC;AAAA,MAC/BC,MAD+B,GACLS,OADK,CAC/BT,MAD+B;AAAA,MACvBU,MADuB,GACLD,OADK,CACvBC,MADuB;AAAA,MACfC,MADe,GACLF,OADK,CACfE,MADe;;AAG7C,WAASC,OAAT,CAAiBC,OAAjB,EAA0B;AACxB,QAAIJ,OAAO,CAACP,YAAZ,EAA0B;AACxB,YAAM,IAAIY,KAAJ,CAAUD,OAAV,CAAN;AACD;;AACD,WAAO,IAAP;AACD;;AAED,MAAIF,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,WAAOE,OAAO,CAAC,qCAAD,CAAd;AACD;;AACD,MAAMG,EAAE,GAAGC,UAAU,CAACjB,KAAD,EAAQC,MAAR,EAAgBS,OAAhB,CAArB;;AACA,MAAI,CAACM,EAAL,EAAS;AACP,WAAOH,OAAO,CAAChB,qBAAD,CAAd;AACD;;AACD,SAAOmB,EAAP;AACD;;AAGD,SAASC,UAAT,GAA6B;AAC3B,MAAMC,QAAQ,GAAGC,MAAM,CAACC,OAAP,CAAe,IAAf,CAAjB;;AACA,MAAI,CAACF,QAAL,EAAe;AACb,UAAM,IAAIH,KAAJ,CAAUjB,mBAAV,CAAN;AACD;;AACD,SAAOoB,QAAQ,MAAR,mBAAP;AACD","sourcesContent":["import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\nimport {isBrowser} from '@probe.gl/env';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\nexport function createTestContext(opts = {}) {\n opts = Object.assign({}, CONTEXT_DEFAULTS, opts);\n const context = isBrowser()\n ? createGLContext(opts)\n : instrumentGLContext(createHeadlessContext(opts), opts);\n return context;\n}\n\n// Create headless gl context (for running under Node.js)\nexport function createHeadlessContext(options) {\n const {width, height, webgl1, webgl2} = options;\n\n function onError(message) {\n if (options.throwOnError) {\n throw new Error(message);\n }\n return null;\n }\n\n if (webgl2 && !webgl1) {\n return onError('headless-gl does not support WebGL2');\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n return onError(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n\n// Load headless gl dynamically, if available\nfunction headlessGL(...args) {\n const headless = module.require('gl');\n if (!headless) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n return headless(...args);\n}\n"],"file":"context.js"}
1
+ {"version":3,"file":"context.js","names":["ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createTestContext","opts","Object","assign","context","isBrowser","createGLContext","instrumentGLContext","createHeadlessContext","options","webgl1","webgl2","onError","message","Error","gl","headlessGL","headless","module","require"],"sources":["../../src/context.js"],"sourcesContent":["import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\nimport {isBrowser} from '@probe.gl/env';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\nexport function createTestContext(opts = {}) {\n opts = Object.assign({}, CONTEXT_DEFAULTS, opts);\n const context = isBrowser()\n ? createGLContext(opts)\n : instrumentGLContext(createHeadlessContext(opts), opts);\n return context;\n}\n\n// Create headless gl context (for running under Node.js)\nexport function createHeadlessContext(options) {\n const {width, height, webgl1, webgl2} = options;\n\n function onError(message) {\n if (options.throwOnError) {\n throw new Error(message);\n }\n return null;\n }\n\n if (webgl2 && !webgl1) {\n return onError('headless-gl does not support WebGL2');\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n return onError(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n\n// Load headless gl dynamically, if available\nfunction headlessGL(...args) {\n const headless = module.require('gl');\n if (!headless) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n return headless(...args);\n}\n"],"mappings":";;;;;;;;AAAA;;AACA;;AAEA,IAAMA,qBAAqB,GACzB,sEADF;AAGA,IAAMC,mBAAmB,gPAAzB;AAKA,IAAMC,gBAAgB,GAAG;EACvBC,KAAK,EAAE,CADgB;EAEvBC,MAAM,EAAE,CAFe;EAGvBC,KAAK,EAAE,IAHgB;EAIvBC,YAAY,EAAE;AAJS,CAAzB;;AAOO,SAASC,iBAAT,GAAsC;EAAA,IAAXC,IAAW,uEAAJ,EAAI;EAC3CA,IAAI,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBR,gBAAlB,EAAoCM,IAApC,CAAP;EACA,IAAMG,OAAO,GAAG,IAAAC,cAAA,MACZ,IAAAC,wBAAA,EAAgBL,IAAhB,CADY,GAEZ,IAAAM,4BAAA,EAAoBC,qBAAqB,CAACP,IAAD,CAAzC,EAAiDA,IAAjD,CAFJ;EAGA,OAAOG,OAAP;AACD;;AAGM,SAASI,qBAAT,CAA+BC,OAA/B,EAAwC;EAC7C,IAAOb,KAAP,GAAwCa,OAAxC,CAAOb,KAAP;EAAA,IAAcC,MAAd,GAAwCY,OAAxC,CAAcZ,MAAd;EAAA,IAAsBa,MAAtB,GAAwCD,OAAxC,CAAsBC,MAAtB;EAAA,IAA8BC,MAA9B,GAAwCF,OAAxC,CAA8BE,MAA9B;;EAEA,SAASC,OAAT,CAAiBC,OAAjB,EAA0B;IACxB,IAAIJ,OAAO,CAACV,YAAZ,EAA0B;MACxB,MAAM,IAAIe,KAAJ,CAAUD,OAAV,CAAN;IACD;;IACD,OAAO,IAAP;EACD;;EAED,IAAIF,MAAM,IAAI,CAACD,MAAf,EAAuB;IACrB,OAAOE,OAAO,CAAC,qCAAD,CAAd;EACD;;EACD,IAAMG,EAAE,GAAGC,UAAU,CAACpB,KAAD,EAAQC,MAAR,EAAgBY,OAAhB,CAArB;;EACA,IAAI,CAACM,EAAL,EAAS;IACP,OAAOH,OAAO,CAACnB,qBAAD,CAAd;EACD;;EACD,OAAOsB,EAAP;AACD;;AAGD,SAASC,UAAT,GAA6B;EAC3B,IAAMC,QAAQ,GAAGC,MAAM,CAACC,OAAP,CAAe,IAAf,CAAjB;;EACA,IAAI,CAACF,QAAL,EAAe;IACb,MAAM,IAAIH,KAAJ,CAAUpB,mBAAV,CAAN;EACD;;EACD,OAAOuB,QAAQ,MAAR,mBAAP;AACD"}
package/dist/es5/index.js CHANGED
@@ -5,22 +5,16 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- Object.defineProperty(exports, "SnapshotTestRunner", {
9
- enumerable: true,
10
- get: function get() {
11
- return _snapshotTestRunner.default;
12
- }
13
- });
14
8
  Object.defineProperty(exports, "PerformanceTestRunner", {
15
9
  enumerable: true,
16
10
  get: function get() {
17
11
  return _performanceTestRunner.default;
18
12
  }
19
13
  });
20
- Object.defineProperty(exports, "createTestContext", {
14
+ Object.defineProperty(exports, "SnapshotTestRunner", {
21
15
  enumerable: true,
22
16
  get: function get() {
23
- return _context.createTestContext;
17
+ return _snapshotTestRunner.default;
24
18
  }
25
19
  });
26
20
  Object.defineProperty(exports, "createHeadlessContext", {
@@ -29,6 +23,12 @@ Object.defineProperty(exports, "createHeadlessContext", {
29
23
  return _context.createHeadlessContext;
30
24
  }
31
25
  });
26
+ Object.defineProperty(exports, "createTestContext", {
27
+ enumerable: true,
28
+ get: function get() {
29
+ return _context.createTestContext;
30
+ }
31
+ });
32
32
 
33
33
  var _snapshotTestRunner = _interopRequireDefault(require("./snapshot-test-runner"));
34
34
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA","sourcesContent":["export {default as SnapshotTestRunner} from './snapshot-test-runner';\nexport {default as PerformanceTestRunner} from './performance-test-runner';\nexport {createTestContext, createHeadlessContext} from './context';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.js"],"sourcesContent":["export {default as SnapshotTestRunner} from './snapshot-test-runner';\nexport {default as PerformanceTestRunner} from './performance-test-runner';\nexport {createTestContext, createHeadlessContext} from './context';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA"}
@@ -19,13 +19,13 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
19
19
 
20
20
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
21
 
22
- var _probe = require("probe.gl");
22
+ var _stats = require("@probe.gl/stats");
23
23
 
24
24
  var _testRunner = _interopRequireDefault(require("./test-runner"));
25
25
 
26
26
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
27
27
 
28
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
28
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
29
 
30
30
  var PerformanceTestRunner = function (_TestRunner) {
31
31
  (0, _inherits2.default)(PerformanceTestRunner, _TestRunner);
@@ -48,7 +48,7 @@ var PerformanceTestRunner = function (_TestRunner) {
48
48
  key: "initTestCase",
49
49
  value: function initTestCase(testCase) {
50
50
  (0, _get2.default)((0, _getPrototypeOf2.default)(PerformanceTestRunner.prototype), "initTestCase", this).call(this, testCase);
51
- this._stats = new _probe.Stats({
51
+ this._stats = new _stats.Stats({
52
52
  id: testCase.name
53
53
  });
54
54
  this._fps = this._stats.get('fps');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/performance-test-runner.js"],"names":["PerformanceTestRunner","props","Object","assign","testOptions","maxFramesToRender","targetFPS","testCase","_stats","Stats","id","name","_fps","get","animationProps","timeEnd","timeStart","count","done","fps","getHz","_pass","framesRendered","_fail","_next","TestRunner"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAEqBA,qB;;;;;AACnB,iCAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AAEAC,IAAAA,MAAM,CAACC,MAAP,CAAc,MAAKC,WAAnB,EAAgC;AAC9BC,MAAAA,iBAAiB,EAAE,EADW;AAE9BC,MAAAA,SAAS,EAAE;AAFmB,KAAhC;AAHiB;AAOlB;;;;iCAEYC,Q,EAAU;AACrB,0HAAmBA,QAAnB;AACA,WAAKC,MAAL,GAAc,IAAIC,YAAJ,CAAU;AAACC,QAAAA,EAAE,EAAEH,QAAQ,CAACI;AAAd,OAAV,CAAd;AACA,WAAKC,IAAL,GAAY,KAAKJ,MAAL,CAAYK,GAAZ,CAAgB,KAAhB,CAAZ;AACD;;;iCAEYC,c,EAAgB;AAC3B,WAAKF,IAAL,CAAUG,OAAV;;AACA,WAAKH,IAAL,CAAUI,SAAV;;AAGA,UAAI,KAAKJ,IAAL,CAAUK,KAAV,GAAkB,KAAKb,WAAL,CAAiBC,iBAAvC,EAA0D;AACxDS,QAAAA,cAAc,CAACI,IAAf;AACD;;AAED,aAAO,IAAP;AACD;;;2BAEMX,Q,EAAU;AAEf,UAAMD,SAAS,GAAGC,QAAQ,CAACD,SAAT,IAAsB,KAAKF,WAAL,CAAiBE,SAAzD;AACA,UAAMW,KAAK,GAAG,KAAKL,IAAL,CAAUK,KAAxB;;AACA,UAAME,GAAG,GAAG,KAAKP,IAAL,CAAUQ,KAAV,EAAZ;;AAEA,UAAID,GAAG,IAAIb,SAAX,EAAsB;AACpB,aAAKe,KAAL,CAAW;AAACF,UAAAA,GAAG,EAAHA,GAAD;AAAMG,UAAAA,cAAc,EAAEL;AAAtB,SAAX;AACD,OAFD,MAEO;AACL,aAAKM,KAAL,CAAW;AAACJ,UAAAA,GAAG,EAAHA,GAAD;AAAMG,UAAAA,cAAc,EAAEL;AAAtB,SAAX;AACD;;AACD,WAAKO,KAAL;AACD;;;EAxCgDC,mB","sourcesContent":["import {Stats} from 'probe.gl';\nimport TestRunner from './test-runner';\n\nexport default class PerformanceTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n shouldRender(animationProps) {\n this._fps.timeEnd();\n this._fps.timeStart();\n\n // @ts-ignore\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n assert(testCase) {\n // @ts-ignore\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps.count;\n const fps = this._fps.getHz();\n\n if (fps >= targetFPS) {\n this._pass({fps, framesRendered: count});\n } else {\n this._fail({fps, framesRendered: count});\n }\n this._next();\n }\n}\n"],"file":"performance-test-runner.js"}
1
+ {"version":3,"file":"performance-test-runner.js","names":["PerformanceTestRunner","props","Object","assign","testOptions","maxFramesToRender","targetFPS","testCase","_stats","Stats","id","name","_fps","get","animationProps","timeEnd","timeStart","count","done","fps","getHz","_pass","framesRendered","_fail","_next","TestRunner"],"sources":["../../src/performance-test-runner.js"],"sourcesContent":["import {Stats} from '@probe.gl/stats';\nimport TestRunner from './test-runner';\n\nexport default class PerformanceTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n shouldRender(animationProps) {\n this._fps.timeEnd();\n this._fps.timeStart();\n\n // @ts-ignore\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n assert(testCase) {\n // @ts-ignore\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps.count;\n const fps = this._fps.getHz();\n\n if (fps >= targetFPS) {\n this._pass({fps, framesRendered: count});\n } else {\n this._fail({fps, framesRendered: count});\n }\n this._next();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAEqBA,qB;;;;;EACnB,+BAAYC,KAAZ,EAAmB;IAAA;;IAAA;IACjB,0BAAMA,KAAN;IAEAC,MAAM,CAACC,MAAP,CAAc,MAAKC,WAAnB,EAAgC;MAC9BC,iBAAiB,EAAE,EADW;MAE9BC,SAAS,EAAE;IAFmB,CAAhC;IAHiB;EAOlB;;;;WAED,sBAAaC,QAAb,EAAuB;MACrB,oHAAmBA,QAAnB;MACA,KAAKC,MAAL,GAAc,IAAIC,YAAJ,CAAU;QAACC,EAAE,EAAEH,QAAQ,CAACI;MAAd,CAAV,CAAd;MACA,KAAKC,IAAL,GAAY,KAAKJ,MAAL,CAAYK,GAAZ,CAAgB,KAAhB,CAAZ;IACD;;;WAED,sBAAaC,cAAb,EAA6B;MAC3B,KAAKF,IAAL,CAAUG,OAAV;;MACA,KAAKH,IAAL,CAAUI,SAAV;;MAGA,IAAI,KAAKJ,IAAL,CAAUK,KAAV,GAAkB,KAAKb,WAAL,CAAiBC,iBAAvC,EAA0D;QACxDS,cAAc,CAACI,IAAf;MACD;;MAED,OAAO,IAAP;IACD;;;WAED,gBAAOX,QAAP,EAAiB;MAEf,IAAMD,SAAS,GAAGC,QAAQ,CAACD,SAAT,IAAsB,KAAKF,WAAL,CAAiBE,SAAzD;MACA,IAAMW,KAAK,GAAG,KAAKL,IAAL,CAAUK,KAAxB;;MACA,IAAME,GAAG,GAAG,KAAKP,IAAL,CAAUQ,KAAV,EAAZ;;MAEA,IAAID,GAAG,IAAIb,SAAX,EAAsB;QACpB,KAAKe,KAAL,CAAW;UAACF,GAAG,EAAHA,GAAD;UAAMG,cAAc,EAAEL;QAAtB,CAAX;MACD,CAFD,MAEO;QACL,KAAKM,KAAL,CAAW;UAACJ,GAAG,EAAHA,GAAD;UAAMG,cAAc,EAAEL;QAAtB,CAAX;MACD;;MACD,KAAKO,KAAL;IACD;;;EAxCgDC,mB"}
@@ -25,7 +25,7 @@ var _utils = require("./utils");
25
25
 
26
26
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
27
27
 
28
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
28
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
29
29
 
30
30
  var SnapshotTestRunner = function (_TestRunner) {
31
31
  (0, _inherits2.default)(SnapshotTestRunner, _TestRunner);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/snapshot-test-runner.js"],"names":["SnapshotTestRunner","props","testOptions","imageDiffOptions","testCase","goldenImage","Error","name","isDiffing","diffOptions","Object","assign","region","_animationProps","canvas","window","browserTestDriver_captureAndDiffScreen","then","result","success","_pass","_fail","_next","TestRunner"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAEqBA,kB;;;;;AACnB,8BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AAGA,UAAKC,WAAL,CAAiBC,gBAAjB,GAAoC,EAApC;AAJiB;AAKlB;;;;iCAEYC,Q,EAAU;AACrB,uHAAmBA,QAAnB;;AACA,UAAI,CAACA,QAAQ,CAACC,WAAd,EAA2B;AACzB,cAAM,IAAIC,KAAJ,qBAAuBF,QAAQ,CAACG,IAAhC,iCAAN;AACD;AACF;;;mCAEc;AAEb,aAAO,CAAC,KAAKC,SAAb;AACD;;;2BAEMJ,Q,EAAU;AAAA;;AACf,UAAI,KAAKI,SAAT,EAAoB;AAElB;AACD;;AACD,WAAKA,SAAL,GAAiB,IAAjB;AAEA,UAAMC,WAAW,GAAGC,MAAM,CAACC,MAAP,CAClB,EADkB,EAGlB,KAAKT,WAAL,CAAiBC,gBAHC,EAIlBC,QAAQ,CAACD,gBAJS,EAKlB;AACEE,QAAAA,WAAW,EAAED,QAAQ,CAACC,WADxB;AAGEO,QAAAA,MAAM,EAAE,iCAAqB,KAAKC,eAAL,CAAqBC,MAA1C;AAHV,OALkB,CAApB;AAcAC,MAAAA,MAAM,CAACC,sCAAP,CAA8CP,WAA9C,EAA2DQ,IAA3D,CAAgE,UAAAC,MAAM,EAAI;AAExE,YAAIA,MAAM,CAACC,OAAX,EAAoB;AAClB,UAAA,MAAI,CAACC,KAAL,CAAWF,MAAX;AACD,SAFD,MAEO;AACL,UAAA,MAAI,CAACG,KAAL,CAAWH,MAAX;AACD;;AAED,QAAA,MAAI,CAACV,SAAL,GAAiB,KAAjB;;AACA,QAAA,MAAI,CAACc,KAAL;AACD,OAVD;AAWD;;;EApD6CC,mB","sourcesContent":["import TestRunner from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\nexport default class SnapshotTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n // @ts-ignore\n this.testOptions.imageDiffOptions = {};\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n if (!testCase.goldenImage) {\n throw new Error(`Test case ${testCase.name} does not have golden image`);\n }\n }\n\n shouldRender() {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n assert(testCase) {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const diffOptions = Object.assign(\n {},\n // @ts-ignore\n this.testOptions.imageDiffOptions,\n testCase.imageDiffOptions,\n {\n goldenImage: testCase.goldenImage,\n // @ts-ignore\n region: getBoundingBoxInPage(this._animationProps.canvas)\n }\n );\n\n // Take screenshot and compare\n // @ts-ignore\n window.browserTestDriver_captureAndDiffScreen(diffOptions).then(result => {\n // invoke user callback\n if (result.success) {\n this._pass(result);\n } else {\n this._fail(result);\n }\n\n this.isDiffing = false;\n this._next();\n });\n }\n}\n"],"file":"snapshot-test-runner.js"}
1
+ {"version":3,"file":"snapshot-test-runner.js","names":["SnapshotTestRunner","props","testOptions","imageDiffOptions","testCase","goldenImage","Error","name","isDiffing","diffOptions","Object","assign","region","getBoundingBoxInPage","_animationProps","canvas","window","browserTestDriver_captureAndDiffScreen","then","result","success","_pass","_fail","_next","TestRunner"],"sources":["../../src/snapshot-test-runner.js"],"sourcesContent":["import TestRunner from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\nexport default class SnapshotTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n // @ts-ignore\n this.testOptions.imageDiffOptions = {};\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n if (!testCase.goldenImage) {\n throw new Error(`Test case ${testCase.name} does not have golden image`);\n }\n }\n\n shouldRender() {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n assert(testCase) {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const diffOptions = Object.assign(\n {},\n // @ts-ignore\n this.testOptions.imageDiffOptions,\n testCase.imageDiffOptions,\n {\n goldenImage: testCase.goldenImage,\n // @ts-ignore\n region: getBoundingBoxInPage(this._animationProps.canvas)\n }\n );\n\n // Take screenshot and compare\n // @ts-ignore\n window.browserTestDriver_captureAndDiffScreen(diffOptions).then(result => {\n // invoke user callback\n if (result.success) {\n this._pass(result);\n } else {\n this._fail(result);\n }\n\n this.isDiffing = false;\n this._next();\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAEqBA,kB;;;;;EACnB,4BAAYC,KAAZ,EAAmB;IAAA;;IAAA;IACjB,0BAAMA,KAAN;IAGA,MAAKC,WAAL,CAAiBC,gBAAjB,GAAoC,EAApC;IAJiB;EAKlB;;;;WAED,sBAAaC,QAAb,EAAuB;MACrB,iHAAmBA,QAAnB;;MACA,IAAI,CAACA,QAAQ,CAACC,WAAd,EAA2B;QACzB,MAAM,IAAIC,KAAJ,qBAAuBF,QAAQ,CAACG,IAAhC,iCAAN;MACD;IACF;;;WAED,wBAAe;MAEb,OAAO,CAAC,KAAKC,SAAb;IACD;;;WAED,gBAAOJ,QAAP,EAAiB;MAAA;;MACf,IAAI,KAAKI,SAAT,EAAoB;QAElB;MACD;;MACD,KAAKA,SAAL,GAAiB,IAAjB;MAEA,IAAMC,WAAW,GAAGC,MAAM,CAACC,MAAP,CAClB,EADkB,EAGlB,KAAKT,WAAL,CAAiBC,gBAHC,EAIlBC,QAAQ,CAACD,gBAJS,EAKlB;QACEE,WAAW,EAAED,QAAQ,CAACC,WADxB;QAGEO,MAAM,EAAE,IAAAC,2BAAA,EAAqB,KAAKC,eAAL,CAAqBC,MAA1C;MAHV,CALkB,CAApB;MAcAC,MAAM,CAACC,sCAAP,CAA8CR,WAA9C,EAA2DS,IAA3D,CAAgE,UAAAC,MAAM,EAAI;QAExE,IAAIA,MAAM,CAACC,OAAX,EAAoB;UAClB,MAAI,CAACC,KAAL,CAAWF,MAAX;QACD,CAFD,MAEO;UACL,MAAI,CAACG,KAAL,CAAWH,MAAX;QACD;;QAED,MAAI,CAACX,SAAL,GAAiB,KAAjB;;QACA,MAAI,CAACe,KAAL;MACD,CAVD;IAWD;;;EApD6CC,mB"}
@@ -15,7 +15,7 @@ var _core = require("@luma.gl/core");
15
15
 
16
16
  var _gltools = require("@luma.gl/gltools");
17
17
 
18
- function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
18
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
19
19
 
20
20
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
21
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test-runner.js"],"names":["noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","done","onFinalize","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","onTestPass","onTestFail","timeout","TestRunner","props","isRunning","_animationProps","_testCases","_testCaseData","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","Object","assign","testCases","Array","isArray","push","options","Promise","resolve","_animationLoop","AnimationLoop","_onRender","bind","start","isDiffing","_currentTestCase","catch","error","_fail","message","animationLoop","key","animationProps","_pass","_next","result","_nextTestCase","stop","isDone","testCaseAnimationProps","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","shouldRender","assert","value","delete","gl","shift","initTestCase","then","userData"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;;;;;;;AAEA,SAASA,IAAT,GAAgB,CAAE;;AAElB,IAAMC,iBAAiB,GAAG;AACxBC,EAAAA,IAAI,EAAE,cADkB;AAExBC,EAAAA,YAAY,EAAEH,IAFU;AAGxBI,EAAAA,QAAQ,EAAE;AAAA,QAAEC,IAAF,QAAEA,IAAF;AAAA,WAAYA,IAAI,EAAhB;AAAA,GAHc;AAIxBC,EAAAA,UAAU,EAAEN;AAJY,CAA1B;AAOA,IAAMO,oBAAoB,GAAG;AAE3BC,EAAAA,WAAW,EAAE,qBAAAC,QAAQ;AAAA,WAAIC,OAAO,CAACC,GAAR,aAAi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IAAI,EAAE,CAH0B;AAIhCC,UAAAA,IAAI,EAAE;AAJ0B,SAAlC,CADF,CADF,EASES,IATF,CASO,UAAAC,QAAQ,EAAI;AACjB,UAAA,MAAI,CAACjD,aAAL,GAAqBiD,QAAQ,IAAI,EAAjC;AACD,SAXD;AAaA,aAAK5C,WAAL,CAAiBjB,WAAjB,CAA6BC,QAA7B;AACD;;AACD,aAAOA,QAAP;AACD","sourcesContent":["/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/gltools';\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\nconst DEFAULT_TEST_OPTIONS = {\n // test lifecycle callback\n onTestStart: testCase => console.log(`# ${testCase.name}`),\n onTestPass: testCase => console.log(`ok ${testCase.name} passed`),\n onTestFail: testCase => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\nexport default class TestRunner {\n /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\n this.isRunning = false;\n this._animationProps = {};\n this._testCases = [];\n this._testCaseData = null;\n\n // @ts-ignore\n this.isHeadless = Boolean(window.browserTestDriver_isHeadless);\n\n this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);\n }\n\n /**\n * Add testCase(s)\n */\n add(testCases) {\n if (!Array.isArray(testCases)) {\n testCases = [testCases];\n }\n for (const testCase of testCases) {\n this._testCases.push(testCase);\n }\n return this;\n }\n\n /**\n * Returns a promise that resolves when all the test cases are done\n */\n run(options = {}) {\n Object.assign(this.testOptions, options);\n\n return new Promise(resolve => {\n this._animationLoop = new AnimationLoop(\n // @ts-ignore TODO\n Object.assign({}, this.props, {\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\n })\n );\n this._animationLoop.start(this.props);\n\n this.isRunning = true;\n this.isDiffing = false;\n this._currentTestCase = null;\n }).catch(error => {\n this._fail({error: error.message});\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.onFinalize.bind(animationLoop);\n }\n for (const key in DEFAULT_TEST_CASE) {\n testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];\n }\n }\n\n shouldRender(animationProps) {\n return true;\n }\n\n assert(testCase) {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result) {\n // @ts-ignore\n this.testOptions.onTestPass(this._currentTestCase, result);\n }\n\n _fail(result) {\n // @ts-ignore\n this.testOptions.onTestFail(this._currentTestCase, result);\n }\n\n _next() {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps) {\n this._animationProps = animationProps;\n\n const testCase = this._currentTestCase || this._nextTestCase();\n if (!testCase) {\n // all test cases are done\n this._animationLoop.stop();\n return;\n }\n\n let isDone = false;\n const testCaseAnimationProps = Object.assign({}, animationProps, this._testCaseData, {\n // tick/time starts from 0 for each test case\n startTime: this._currentTestCaseStartTime,\n time: animationProps.time - this._currentTestCaseStartTime,\n tick: animationProps.tick - this._currentTestCaseStartTick,\n // called by the test case when it is done rendering and ready for capture and diff\n done: () => {\n isDone = true;\n }\n });\n\n if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n }\n\n const timeout = testCase.timeout || this.testOptions.timeout;\n if (timeout && testCaseAnimationProps.time > timeout) {\n isDone = true;\n }\n\n if (isDone) {\n this.assert(testCase);\n }\n }\n\n _nextTestCase() {\n const animationProps = this._animationProps;\n\n // finalize the current test case\n if (this._testCaseData) {\n for (const key in this._testCaseData) {\n const value = this._testCaseData[key];\n if (value && value.delete) {\n value.delete();\n }\n }\n this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));\n\n // reset WebGL context\n popContextState(animationProps.gl);\n\n this._currentTestCase = null;\n this._testCaseData = null;\n }\n\n // get the next test case\n const testCase = this._testCases.shift();\n if (testCase) {\n // start new test case\n this._currentTestCase = testCase;\n this._currentTestCaseStartTime = animationProps.time;\n this._currentTestCaseStartTick = animationProps.tick;\n this.initTestCase(testCase);\n\n // initialize test case\n\n // save WebGL context\n pushContextState(animationProps.gl);\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(\n testCase.onInitialize(\n Object.assign({}, animationProps, {\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n })\n )\n ).then(userData => {\n this._testCaseData = userData || {};\n });\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"file":"test-runner.js"}
1
+ {"version":3,"file":"test-runner.js","names":["noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","done","onFinalize","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","onTestPass","onTestFail","timeout","TestRunner","props","isRunning","_animationProps","_testCases","_testCaseData","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","Object","assign","testCases","Array","isArray","push","options","Promise","resolve","_animationLoop","AnimationLoop","_onRender","bind","start","isDiffing","_currentTestCase","catch","error","_fail","message","animationLoop","key","animationProps","_pass","_next","result","_nextTestCase","stop","isDone","testCaseAnimationProps","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","shouldRender","assert","value","delete","popContextState","gl","shift","initTestCase","pushContextState","then","userData"],"sources":["../../src/test-runner.js"],"sourcesContent":["/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/gltools';\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\nconst DEFAULT_TEST_OPTIONS = {\n // test lifecycle callback\n onTestStart: testCase => console.log(`# ${testCase.name}`),\n onTestPass: testCase => console.log(`ok ${testCase.name} passed`),\n onTestFail: testCase => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\nexport default class TestRunner {\n /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\n this.isRunning = false;\n this._animationProps = {};\n this._testCases = [];\n this._testCaseData = null;\n\n // @ts-ignore\n this.isHeadless = Boolean(window.browserTestDriver_isHeadless);\n\n this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);\n }\n\n /**\n * Add testCase(s)\n */\n add(testCases) {\n if (!Array.isArray(testCases)) {\n testCases = [testCases];\n }\n for (const testCase of testCases) {\n this._testCases.push(testCase);\n }\n return this;\n }\n\n /**\n * Returns a promise that resolves when all the test cases are done\n */\n run(options = {}) {\n Object.assign(this.testOptions, options);\n\n return new Promise(resolve => {\n this._animationLoop = new AnimationLoop(\n // @ts-ignore TODO\n Object.assign({}, this.props, {\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\n })\n );\n this._animationLoop.start(this.props);\n\n this.isRunning = true;\n this.isDiffing = false;\n this._currentTestCase = null;\n }).catch(error => {\n this._fail({error: error.message});\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.onFinalize.bind(animationLoop);\n }\n for (const key in DEFAULT_TEST_CASE) {\n testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];\n }\n }\n\n shouldRender(animationProps) {\n return true;\n }\n\n assert(testCase) {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result) {\n // @ts-ignore\n this.testOptions.onTestPass(this._currentTestCase, result);\n }\n\n _fail(result) {\n // @ts-ignore\n this.testOptions.onTestFail(this._currentTestCase, result);\n }\n\n _next() {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps) {\n this._animationProps = animationProps;\n\n const testCase = this._currentTestCase || this._nextTestCase();\n if (!testCase) {\n // all test cases are done\n this._animationLoop.stop();\n return;\n }\n\n let isDone = false;\n const testCaseAnimationProps = Object.assign({}, animationProps, this._testCaseData, {\n // tick/time starts from 0 for each test case\n startTime: this._currentTestCaseStartTime,\n time: animationProps.time - this._currentTestCaseStartTime,\n tick: animationProps.tick - this._currentTestCaseStartTick,\n // called by the test case when it is done rendering and ready for capture and diff\n done: () => {\n isDone = true;\n }\n });\n\n if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n }\n\n const timeout = testCase.timeout || this.testOptions.timeout;\n if (timeout && testCaseAnimationProps.time > timeout) {\n isDone = true;\n }\n\n if (isDone) {\n this.assert(testCase);\n }\n }\n\n _nextTestCase() {\n const animationProps = this._animationProps;\n\n // finalize the current test case\n if (this._testCaseData) {\n for (const key in this._testCaseData) {\n const value = this._testCaseData[key];\n if (value && value.delete) {\n value.delete();\n }\n }\n this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));\n\n // reset WebGL context\n popContextState(animationProps.gl);\n\n this._currentTestCase = null;\n this._testCaseData = null;\n }\n\n // get the next test case\n const testCase = this._testCases.shift();\n if (testCase) {\n // start new test case\n this._currentTestCase = testCase;\n this._currentTestCaseStartTime = animationProps.time;\n this._currentTestCaseStartTick = animationProps.tick;\n this.initTestCase(testCase);\n\n // initialize test case\n\n // save WebGL context\n pushContextState(animationProps.gl);\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(\n testCase.onInitialize(\n Object.assign({}, animationProps, {\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n })\n )\n ).then(userData => {\n this._testCaseData = userData || {};\n });\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;;;;;;;AAEA,SAASA,IAAT,GAAgB,CAAE;;AAElB,IAAMC,iBAAiB,GAAG;EACxBC,IAAI,EAAE,cADkB;EAExBC,YAAY,EAAEH,IAFU;EAGxBI,QAAQ,EAAE;IAAA,IAAEC,IAAF,QAAEA,IAAF;IAAA,OAAYA,IAAI,EAAhB;EAAA,CAHc;EAIxBC,UAAU,EAAEN;AAJY,CAA1B;AAOA,IAAMO,oBAAoB,GAAG;EAE3BC,WAAW,EAAE,qBAAAC,QAAQ;IAAA,OAAIC,OAAO,CAACC,GAAR,aAAiBF,QAAQ,CAACP,IAA1B,EAAJ;EAAA,CAFM;EAG3BU,UAAU,EAAE,oBAAAH,QAAQ;IAAA,OAAIC,OAAO,CAACC,GAAR,cAAkBF,QAAQ,CAACP,IAA3B,aAAJ;EAAA,CAHO;EAI3BW,UAAU,EAAE,oBAAAJ,QAAQ;IAAA,OAAIC,OAAO,CAACC,GAAR,kBAAsBF,QAAQ,CAACP,IAA/B,aAAJ;EAAA,CAJO;EAO3BY,OAAO,EAAE;AAPkB,CAA7B;;IAUqBC,U;EAKnB,sBAAwB;IAAA,IAAZC,KAAY,uEAAJ,EAAI;IAAA;IACtB,KAAKA,KAAL,GAAaA,KAAb;IACA,KAAKC,SAAL,GAAiB,KAAjB;IACA,KAAKC,eAAL,GAAuB,EAAvB;IACA,KAAKC,UAAL,GAAkB,EAAlB;IACA,KAAKC,aAAL,GAAqB,IAArB;IAGA,KAAKC,UAAL,GAAkBC,OAAO,CAACC,MAAM,CAACC,4BAAR,CAAzB;IAEA,KAAKC,WAAL,GAAmBC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBpB,oBAAlB,CAAnB;EACD;;;;WAKD,aAAIqB,SAAJ,EAAe;MACb,IAAI,CAACC,KAAK,CAACC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C,gBAAL,GAAwBhC,QAAxB;QACA,KAAKgD,yBAAL,GAAiCT,cAAc,CAACU,IAAhD;QACA,KAAKE,yBAAL,GAAiCZ,cAAc,CAACW,IAAhD;QACA,KAAKS,YAAL,CAAkB3D,QAAlB;QAKA,IAAA4D,yBAAA,EAAiBrB,cAAc,CAACkB,EAAhC;QAIAjC,OAAO,CAACC,OAAR,CACEzB,QAAQ,CAACN,YAAT,CACEuB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBqB,cAAlB,EAAkC;UAEhCQ,SAAS,EAAER,cAAc,CAACU,IAFM;UAGhCA,IAAI,EAAE,CAH0B;UAIhCC,IAAI,EAAE;QAJ0B,CAAlC,CADF,CADF,EASEW,IATF,CASO,UAAAC,QAAQ,EAAI;UACjB,MAAI,CAACnD,aAAL,GAAqBmD,QAAQ,IAAI,EAAjC;QACD,CAXD;QAaA,KAAK9C,WAAL,CAAiBjB,WAAjB,CAA6BC,QAA7B;MACD;;MACD,OAAOA,QAAP;IACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils.js"],"names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"mappings":";;;;;;;AACO,SAASA,oBAAT,CAA8BC,UAA9B,EAA0C;AAC/C,MAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAX,EAAb;AACA,SAAO;AACLC,IAAAA,CAAC,EAAEC,MAAM,CAACC,OAAP,GAAiBJ,IAAI,CAACE,CADpB;AAELG,IAAAA,CAAC,EAAEF,MAAM,CAACG,OAAP,GAAiBN,IAAI,CAACK,CAFpB;AAGLE,IAAAA,KAAK,EAAEP,IAAI,CAACO,KAHP;AAILC,IAAAA,MAAM,EAAER,IAAI,CAACQ;AAJR,GAAP;AAMD","sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement) {\n const bbox = domElement.getBoundingClientRect();\n return {\n x: window.scrollX + bbox.x,\n y: window.scrollY + bbox.y,\n width: bbox.width,\n height: bbox.height\n };\n}\n"],"file":"utils.js"}
1
+ {"version":3,"file":"utils.js","names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"sources":["../../src/utils.js"],"sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement) {\n const bbox = domElement.getBoundingClientRect();\n return {\n x: window.scrollX + bbox.x,\n y: window.scrollY + bbox.y,\n width: bbox.width,\n height: bbox.height\n };\n}\n"],"mappings":";;;;;;;AACO,SAASA,oBAAT,CAA8BC,UAA9B,EAA0C;EAC/C,IAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAX,EAAb;EACA,OAAO;IACLC,CAAC,EAAEC,MAAM,CAACC,OAAP,GAAiBJ,IAAI,CAACE,CADpB;IAELG,CAAC,EAAEF,MAAM,CAACG,OAAP,GAAiBN,IAAI,CAACK,CAFpB;IAGLE,KAAK,EAAEP,IAAI,CAACO,KAHP;IAILC,MAAM,EAAER,IAAI,CAACQ;EAJR,CAAP;AAMD"}
@@ -1,17 +1,15 @@
1
1
  import { createGLContext, instrumentGLContext } from '@luma.gl/gltools';
2
2
  import { isBrowser } from '@probe.gl/env';
3
3
  const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
4
- const ERR_HEADLESSGL_LOAD = `\
5
- luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
6
- contexts can not be created. This may not be an error. For example, this is a \
7
- typical configuration for isorender applications running on the server.`;
4
+ const ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
8
5
  const CONTEXT_DEFAULTS = {
9
6
  width: 1,
10
7
  height: 1,
11
8
  debug: true,
12
9
  throwOnError: false
13
10
  };
14
- export function createTestContext(opts = {}) {
11
+ export function createTestContext() {
12
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
15
13
  opts = Object.assign({}, CONTEXT_DEFAULTS, opts);
16
14
  const context = isBrowser() ? createGLContext(opts) : instrumentGLContext(createHeadlessContext(opts), opts);
17
15
  return context;
@@ -45,13 +43,13 @@ export function createHeadlessContext(options) {
45
43
  return gl;
46
44
  }
47
45
 
48
- function headlessGL(...args) {
46
+ function headlessGL() {
49
47
  const headless = module.require('gl');
50
48
 
51
49
  if (!headless) {
52
50
  throw new Error(ERR_HEADLESSGL_LOAD);
53
51
  }
54
52
 
55
- return headless(...args);
53
+ return headless(...arguments);
56
54
  }
57
55
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context.js"],"names":["createGLContext","instrumentGLContext","isBrowser","ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createTestContext","opts","Object","assign","context","createHeadlessContext","options","webgl1","webgl2","onError","message","Error","gl","headlessGL","args","headless","module","require"],"mappings":"AAAA,SAAQA,eAAR,EAAyBC,mBAAzB,QAAmD,kBAAnD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AAEA,MAAMC,qBAAqB,GACzB,sEADF;AAGA,MAAMC,mBAAmB,GAAI;AAC7B;AACA;AACA,0EAHA;AAKA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,KAAK,EAAE,CADgB;AAEvBC,EAAAA,MAAM,EAAE,CAFe;AAGvBC,EAAAA,KAAK,EAAE,IAHgB;AAIvBC,EAAAA,YAAY,EAAE;AAJS,CAAzB;AAOA,OAAO,SAASC,iBAAT,CAA2BC,IAAI,GAAG,EAAlC,EAAsC;AAC3CA,EAAAA,IAAI,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBR,gBAAlB,EAAoCM,IAApC,CAAP;AACA,QAAMG,OAAO,GAAGZ,SAAS,KACrBF,eAAe,CAACW,IAAD,CADM,GAErBV,mBAAmB,CAACc,qBAAqB,CAACJ,IAAD,CAAtB,EAA8BA,IAA9B,CAFvB;AAGA,SAAOG,OAAP;AACD;AAGD,OAAO,SAASC,qBAAT,CAA+BC,OAA/B,EAAwC;AAC7C,QAAM;AAACV,IAAAA,KAAD;AAAQC,IAAAA,MAAR;AAAgBU,IAAAA,MAAhB;AAAwBC,IAAAA;AAAxB,MAAkCF,OAAxC;;AAEA,WAASG,OAAT,CAAiBC,OAAjB,EAA0B;AACxB,QAAIJ,OAAO,CAACP,YAAZ,EAA0B;AACxB,YAAM,IAAIY,KAAJ,CAAUD,OAAV,CAAN;AACD;;AACD,WAAO,IAAP;AACD;;AAED,MAAIF,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,WAAOE,OAAO,CAAC,qCAAD,CAAd;AACD;;AACD,QAAMG,EAAE,GAAGC,UAAU,CAACjB,KAAD,EAAQC,MAAR,EAAgBS,OAAhB,CAArB;;AACA,MAAI,CAACM,EAAL,EAAS;AACP,WAAOH,OAAO,CAAChB,qBAAD,CAAd;AACD;;AACD,SAAOmB,EAAP;AACD;;AAGD,SAASC,UAAT,CAAoB,GAAGC,IAAvB,EAA6B;AAC3B,QAAMC,QAAQ,GAAGC,MAAM,CAACC,OAAP,CAAe,IAAf,CAAjB;;AACA,MAAI,CAACF,QAAL,EAAe;AACb,UAAM,IAAIJ,KAAJ,CAAUjB,mBAAV,CAAN;AACD;;AACD,SAAOqB,QAAQ,CAAC,GAAGD,IAAJ,CAAf;AACD","sourcesContent":["import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\nimport {isBrowser} from '@probe.gl/env';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\nexport function createTestContext(opts = {}) {\n opts = Object.assign({}, CONTEXT_DEFAULTS, opts);\n const context = isBrowser()\n ? createGLContext(opts)\n : instrumentGLContext(createHeadlessContext(opts), opts);\n return context;\n}\n\n// Create headless gl context (for running under Node.js)\nexport function createHeadlessContext(options) {\n const {width, height, webgl1, webgl2} = options;\n\n function onError(message) {\n if (options.throwOnError) {\n throw new Error(message);\n }\n return null;\n }\n\n if (webgl2 && !webgl1) {\n return onError('headless-gl does not support WebGL2');\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n return onError(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n\n// Load headless gl dynamically, if available\nfunction headlessGL(...args) {\n const headless = module.require('gl');\n if (!headless) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n return headless(...args);\n}\n"],"file":"context.js"}
1
+ {"version":3,"file":"context.js","names":["createGLContext","instrumentGLContext","isBrowser","ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createTestContext","opts","Object","assign","context","createHeadlessContext","options","webgl1","webgl2","onError","message","Error","gl","headlessGL","headless","module","require"],"sources":["../../src/context.js"],"sourcesContent":["import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\nimport {isBrowser} from '@probe.gl/env';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\nexport function createTestContext(opts = {}) {\n opts = Object.assign({}, CONTEXT_DEFAULTS, opts);\n const context = isBrowser()\n ? createGLContext(opts)\n : instrumentGLContext(createHeadlessContext(opts), opts);\n return context;\n}\n\n// Create headless gl context (for running under Node.js)\nexport function createHeadlessContext(options) {\n const {width, height, webgl1, webgl2} = options;\n\n function onError(message) {\n if (options.throwOnError) {\n throw new Error(message);\n }\n return null;\n }\n\n if (webgl2 && !webgl1) {\n return onError('headless-gl does not support WebGL2');\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n return onError(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n\n// Load headless gl dynamically, if available\nfunction headlessGL(...args) {\n const headless = module.require('gl');\n if (!headless) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n return headless(...args);\n}\n"],"mappings":"AAAA,SAAQA,eAAR,EAAyBC,mBAAzB,QAAmD,kBAAnD;AACA,SAAQC,SAAR,QAAwB,eAAxB;AAEA,MAAMC,qBAAqB,GACzB,sEADF;AAGA,MAAMC,mBAAmB,gPAAzB;AAKA,MAAMC,gBAAgB,GAAG;EACvBC,KAAK,EAAE,CADgB;EAEvBC,MAAM,EAAE,CAFe;EAGvBC,KAAK,EAAE,IAHgB;EAIvBC,YAAY,EAAE;AAJS,CAAzB;AAOA,OAAO,SAASC,iBAAT,GAAsC;EAAA,IAAXC,IAAW,uEAAJ,EAAI;EAC3CA,IAAI,GAAGC,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBR,gBAAlB,EAAoCM,IAApC,CAAP;EACA,MAAMG,OAAO,GAAGZ,SAAS,KACrBF,eAAe,CAACW,IAAD,CADM,GAErBV,mBAAmB,CAACc,qBAAqB,CAACJ,IAAD,CAAtB,EAA8BA,IAA9B,CAFvB;EAGA,OAAOG,OAAP;AACD;AAGD,OAAO,SAASC,qBAAT,CAA+BC,OAA/B,EAAwC;EAC7C,MAAM;IAACV,KAAD;IAAQC,MAAR;IAAgBU,MAAhB;IAAwBC;EAAxB,IAAkCF,OAAxC;;EAEA,SAASG,OAAT,CAAiBC,OAAjB,EAA0B;IACxB,IAAIJ,OAAO,CAACP,YAAZ,EAA0B;MACxB,MAAM,IAAIY,KAAJ,CAAUD,OAAV,CAAN;IACD;;IACD,OAAO,IAAP;EACD;;EAED,IAAIF,MAAM,IAAI,CAACD,MAAf,EAAuB;IACrB,OAAOE,OAAO,CAAC,qCAAD,CAAd;EACD;;EACD,MAAMG,EAAE,GAAGC,UAAU,CAACjB,KAAD,EAAQC,MAAR,EAAgBS,OAAhB,CAArB;;EACA,IAAI,CAACM,EAAL,EAAS;IACP,OAAOH,OAAO,CAAChB,qBAAD,CAAd;EACD;;EACD,OAAOmB,EAAP;AACD;;AAGD,SAASC,UAAT,GAA6B;EAC3B,MAAMC,QAAQ,GAAGC,MAAM,CAACC,OAAP,CAAe,IAAf,CAAjB;;EACA,IAAI,CAACF,QAAL,EAAe;IACb,MAAM,IAAIH,KAAJ,CAAUjB,mBAAV,CAAN;EACD;;EACD,OAAOoB,QAAQ,CAAC,YAAD,CAAf;AACD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.js"],"names":["default","SnapshotTestRunner","PerformanceTestRunner","createTestContext","createHeadlessContext"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,kBAAnB,QAA4C,wBAA5C;AACA,SAAQD,OAAO,IAAIE,qBAAnB,QAA+C,2BAA/C;AACA,SAAQC,iBAAR,EAA2BC,qBAA3B,QAAuD,WAAvD","sourcesContent":["export {default as SnapshotTestRunner} from './snapshot-test-runner';\nexport {default as PerformanceTestRunner} from './performance-test-runner';\nexport {createTestContext, createHeadlessContext} from './context';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":["default","SnapshotTestRunner","PerformanceTestRunner","createTestContext","createHeadlessContext"],"sources":["../../src/index.js"],"sourcesContent":["export {default as SnapshotTestRunner} from './snapshot-test-runner';\nexport {default as PerformanceTestRunner} from './performance-test-runner';\nexport {createTestContext, createHeadlessContext} from './context';\n"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,kBAAnB,QAA4C,wBAA5C;AACA,SAAQD,OAAO,IAAIE,qBAAnB,QAA+C,2BAA/C;AACA,SAAQC,iBAAR,EAA2BC,qBAA3B,QAAuD,WAAvD"}
@@ -1,4 +1,4 @@
1
- import { Stats } from 'probe.gl';
1
+ import { Stats } from '@probe.gl/stats';
2
2
  import TestRunner from './test-runner';
3
3
  export default class PerformanceTestRunner extends TestRunner {
4
4
  constructor(props) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/performance-test-runner.js"],"names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","timeEnd","timeStart","count","done","assert","fps","getHz","_pass","framesRendered","_fail","_next"],"mappings":"AAAA,SAAQA,KAAR,QAAoB,UAApB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AAEA,eAAe,MAAMC,qBAAN,SAAoCD,UAApC,CAA+C;AAC5DE,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,UAAMA,KAAN;AAEAC,IAAAA,MAAM,CAACC,MAAP,CAAc,KAAKC,WAAnB,EAAgC;AAC9BC,MAAAA,iBAAiB,EAAE,EADW;AAE9BC,MAAAA,SAAS,EAAE;AAFmB,KAAhC;AAID;;AAEDC,EAAAA,YAAY,CAACC,QAAD,EAAW;AACrB,UAAMD,YAAN,CAAmBC,QAAnB;AACA,SAAKC,MAAL,GAAc,IAAIZ,KAAJ,CAAU;AAACa,MAAAA,EAAE,EAAEF,QAAQ,CAACG;AAAd,KAAV,CAAd;AACA,SAAKC,IAAL,GAAY,KAAKH,MAAL,CAAYI,GAAZ,CAAgB,KAAhB,CAAZ;AACD;;AAEDC,EAAAA,YAAY,CAACC,cAAD,EAAiB;AAC3B,SAAKH,IAAL,CAAUI,OAAV;;AACA,SAAKJ,IAAL,CAAUK,SAAV;;AAGA,QAAI,KAAKL,IAAL,CAAUM,KAAV,GAAkB,KAAKd,WAAL,CAAiBC,iBAAvC,EAA0D;AACxDU,MAAAA,cAAc,CAACI,IAAf;AACD;;AAED,WAAO,IAAP;AACD;;AAEDC,EAAAA,MAAM,CAACZ,QAAD,EAAW;AAEf,UAAMF,SAAS,GAAGE,QAAQ,CAACF,SAAT,IAAsB,KAAKF,WAAL,CAAiBE,SAAzD;AACA,UAAMY,KAAK,GAAG,KAAKN,IAAL,CAAUM,KAAxB;;AACA,UAAMG,GAAG,GAAG,KAAKT,IAAL,CAAUU,KAAV,EAAZ;;AAEA,QAAID,GAAG,IAAIf,SAAX,EAAsB;AACpB,WAAKiB,KAAL,CAAW;AAACF,QAAAA,GAAD;AAAMG,QAAAA,cAAc,EAAEN;AAAtB,OAAX;AACD,KAFD,MAEO;AACL,WAAKO,KAAL,CAAW;AAACJ,QAAAA,GAAD;AAAMG,QAAAA,cAAc,EAAEN;AAAtB,OAAX;AACD;;AACD,SAAKQ,KAAL;AACD;;AAxC2D","sourcesContent":["import {Stats} from 'probe.gl';\nimport TestRunner from './test-runner';\n\nexport default class PerformanceTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n shouldRender(animationProps) {\n this._fps.timeEnd();\n this._fps.timeStart();\n\n // @ts-ignore\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n assert(testCase) {\n // @ts-ignore\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps.count;\n const fps = this._fps.getHz();\n\n if (fps >= targetFPS) {\n this._pass({fps, framesRendered: count});\n } else {\n this._fail({fps, framesRendered: count});\n }\n this._next();\n }\n}\n"],"file":"performance-test-runner.js"}
1
+ {"version":3,"file":"performance-test-runner.js","names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","timeEnd","timeStart","count","done","assert","fps","getHz","_pass","framesRendered","_fail","_next"],"sources":["../../src/performance-test-runner.js"],"sourcesContent":["import {Stats} from '@probe.gl/stats';\nimport TestRunner from './test-runner';\n\nexport default class PerformanceTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n shouldRender(animationProps) {\n this._fps.timeEnd();\n this._fps.timeStart();\n\n // @ts-ignore\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n assert(testCase) {\n // @ts-ignore\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps.count;\n const fps = this._fps.getHz();\n\n if (fps >= targetFPS) {\n this._pass({fps, framesRendered: count});\n } else {\n this._fail({fps, framesRendered: count});\n }\n this._next();\n }\n}\n"],"mappings":"AAAA,SAAQA,KAAR,QAAoB,iBAApB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AAEA,eAAe,MAAMC,qBAAN,SAAoCD,UAApC,CAA+C;EAC5DE,WAAW,CAACC,KAAD,EAAQ;IACjB,MAAMA,KAAN;IAEAC,MAAM,CAACC,MAAP,CAAc,KAAKC,WAAnB,EAAgC;MAC9BC,iBAAiB,EAAE,EADW;MAE9BC,SAAS,EAAE;IAFmB,CAAhC;EAID;;EAEDC,YAAY,CAACC,QAAD,EAAW;IACrB,MAAMD,YAAN,CAAmBC,QAAnB;IACA,KAAKC,MAAL,GAAc,IAAIZ,KAAJ,CAAU;MAACa,EAAE,EAAEF,QAAQ,CAACG;IAAd,CAAV,CAAd;IACA,KAAKC,IAAL,GAAY,KAAKH,MAAL,CAAYI,GAAZ,CAAgB,KAAhB,CAAZ;EACD;;EAEDC,YAAY,CAACC,cAAD,EAAiB;IAC3B,KAAKH,IAAL,CAAUI,OAAV;;IACA,KAAKJ,IAAL,CAAUK,SAAV;;IAGA,IAAI,KAAKL,IAAL,CAAUM,KAAV,GAAkB,KAAKd,WAAL,CAAiBC,iBAAvC,EAA0D;MACxDU,cAAc,CAACI,IAAf;IACD;;IAED,OAAO,IAAP;EACD;;EAEDC,MAAM,CAACZ,QAAD,EAAW;IAEf,MAAMF,SAAS,GAAGE,QAAQ,CAACF,SAAT,IAAsB,KAAKF,WAAL,CAAiBE,SAAzD;IACA,MAAMY,KAAK,GAAG,KAAKN,IAAL,CAAUM,KAAxB;;IACA,MAAMG,GAAG,GAAG,KAAKT,IAAL,CAAUU,KAAV,EAAZ;;IAEA,IAAID,GAAG,IAAIf,SAAX,EAAsB;MACpB,KAAKiB,KAAL,CAAW;QAACF,GAAD;QAAMG,cAAc,EAAEN;MAAtB,CAAX;IACD,CAFD,MAEO;MACL,KAAKO,KAAL,CAAW;QAACJ,GAAD;QAAMG,cAAc,EAAEN;MAAtB,CAAX;IACD;;IACD,KAAKQ,KAAL;EACD;;AAxC2D"}
@@ -10,7 +10,7 @@ export default class SnapshotTestRunner extends TestRunner {
10
10
  super.initTestCase(testCase);
11
11
 
12
12
  if (!testCase.goldenImage) {
13
- throw new Error(`Test case ${testCase.name} does not have golden image`);
13
+ throw new Error("Test case ".concat(testCase.name, " does not have golden image"));
14
14
  }
15
15
  }
16
16
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/snapshot-test-runner.js"],"names":["TestRunner","getBoundingBoxInPage","SnapshotTestRunner","constructor","props","testOptions","imageDiffOptions","initTestCase","testCase","goldenImage","Error","name","shouldRender","isDiffing","assert","diffOptions","Object","assign","region","_animationProps","canvas","window","browserTestDriver_captureAndDiffScreen","then","result","success","_pass","_fail","_next"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,eAAvB;AACA,SAAQC,oBAAR,QAAmC,SAAnC;AAEA,eAAe,MAAMC,kBAAN,SAAiCF,UAAjC,CAA4C;AACzDG,EAAAA,WAAW,CAACC,KAAD,EAAQ;AACjB,UAAMA,KAAN;AAGA,SAAKC,WAAL,CAAiBC,gBAAjB,GAAoC,EAApC;AACD;;AAEDC,EAAAA,YAAY,CAACC,QAAD,EAAW;AACrB,UAAMD,YAAN,CAAmBC,QAAnB;;AACA,QAAI,CAACA,QAAQ,CAACC,WAAd,EAA2B;AACzB,YAAM,IAAIC,KAAJ,CAAW,aAAYF,QAAQ,CAACG,IAAK,6BAArC,CAAN;AACD;AACF;;AAEDC,EAAAA,YAAY,GAAG;AAEb,WAAO,CAAC,KAAKC,SAAb;AACD;;AAEDC,EAAAA,MAAM,CAACN,QAAD,EAAW;AACf,QAAI,KAAKK,SAAT,EAAoB;AAElB;AACD;;AACD,SAAKA,SAAL,GAAiB,IAAjB;AAEA,UAAME,WAAW,GAAGC,MAAM,CAACC,MAAP,CAClB,EADkB,EAGlB,KAAKZ,WAAL,CAAiBC,gBAHC,EAIlBE,QAAQ,CAACF,gBAJS,EAKlB;AACEG,MAAAA,WAAW,EAAED,QAAQ,CAACC,WADxB;AAGES,MAAAA,MAAM,EAAEjB,oBAAoB,CAAC,KAAKkB,eAAL,CAAqBC,MAAtB;AAH9B,KALkB,CAApB;AAcAC,IAAAA,MAAM,CAACC,sCAAP,CAA8CP,WAA9C,EAA2DQ,IAA3D,CAAgEC,MAAM,IAAI;AAExE,UAAIA,MAAM,CAACC,OAAX,EAAoB;AAClB,aAAKC,KAAL,CAAWF,MAAX;AACD,OAFD,MAEO;AACL,aAAKG,KAAL,CAAWH,MAAX;AACD;;AAED,WAAKX,SAAL,GAAiB,KAAjB;;AACA,WAAKe,KAAL;AACD,KAVD;AAWD;;AApDwD","sourcesContent":["import TestRunner from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\nexport default class SnapshotTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n // @ts-ignore\n this.testOptions.imageDiffOptions = {};\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n if (!testCase.goldenImage) {\n throw new Error(`Test case ${testCase.name} does not have golden image`);\n }\n }\n\n shouldRender() {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n assert(testCase) {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const diffOptions = Object.assign(\n {},\n // @ts-ignore\n this.testOptions.imageDiffOptions,\n testCase.imageDiffOptions,\n {\n goldenImage: testCase.goldenImage,\n // @ts-ignore\n region: getBoundingBoxInPage(this._animationProps.canvas)\n }\n );\n\n // Take screenshot and compare\n // @ts-ignore\n window.browserTestDriver_captureAndDiffScreen(diffOptions).then(result => {\n // invoke user callback\n if (result.success) {\n this._pass(result);\n } else {\n this._fail(result);\n }\n\n this.isDiffing = false;\n this._next();\n });\n }\n}\n"],"file":"snapshot-test-runner.js"}
1
+ {"version":3,"file":"snapshot-test-runner.js","names":["TestRunner","getBoundingBoxInPage","SnapshotTestRunner","constructor","props","testOptions","imageDiffOptions","initTestCase","testCase","goldenImage","Error","name","shouldRender","isDiffing","assert","diffOptions","Object","assign","region","_animationProps","canvas","window","browserTestDriver_captureAndDiffScreen","then","result","success","_pass","_fail","_next"],"sources":["../../src/snapshot-test-runner.js"],"sourcesContent":["import TestRunner from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\nexport default class SnapshotTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n // @ts-ignore\n this.testOptions.imageDiffOptions = {};\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n if (!testCase.goldenImage) {\n throw new Error(`Test case ${testCase.name} does not have golden image`);\n }\n }\n\n shouldRender() {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n assert(testCase) {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const diffOptions = Object.assign(\n {},\n // @ts-ignore\n this.testOptions.imageDiffOptions,\n testCase.imageDiffOptions,\n {\n goldenImage: testCase.goldenImage,\n // @ts-ignore\n region: getBoundingBoxInPage(this._animationProps.canvas)\n }\n );\n\n // Take screenshot and compare\n // @ts-ignore\n window.browserTestDriver_captureAndDiffScreen(diffOptions).then(result => {\n // invoke user callback\n if (result.success) {\n this._pass(result);\n } else {\n this._fail(result);\n }\n\n this.isDiffing = false;\n this._next();\n });\n }\n}\n"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,eAAvB;AACA,SAAQC,oBAAR,QAAmC,SAAnC;AAEA,eAAe,MAAMC,kBAAN,SAAiCF,UAAjC,CAA4C;EACzDG,WAAW,CAACC,KAAD,EAAQ;IACjB,MAAMA,KAAN;IAGA,KAAKC,WAAL,CAAiBC,gBAAjB,GAAoC,EAApC;EACD;;EAEDC,YAAY,CAACC,QAAD,EAAW;IACrB,MAAMD,YAAN,CAAmBC,QAAnB;;IACA,IAAI,CAACA,QAAQ,CAACC,WAAd,EAA2B;MACzB,MAAM,IAAIC,KAAJ,qBAAuBF,QAAQ,CAACG,IAAhC,iCAAN;IACD;EACF;;EAEDC,YAAY,GAAG;IAEb,OAAO,CAAC,KAAKC,SAAb;EACD;;EAEDC,MAAM,CAACN,QAAD,EAAW;IACf,IAAI,KAAKK,SAAT,EAAoB;MAElB;IACD;;IACD,KAAKA,SAAL,GAAiB,IAAjB;IAEA,MAAME,WAAW,GAAGC,MAAM,CAACC,MAAP,CAClB,EADkB,EAGlB,KAAKZ,WAAL,CAAiBC,gBAHC,EAIlBE,QAAQ,CAACF,gBAJS,EAKlB;MACEG,WAAW,EAAED,QAAQ,CAACC,WADxB;MAGES,MAAM,EAAEjB,oBAAoB,CAAC,KAAKkB,eAAL,CAAqBC,MAAtB;IAH9B,CALkB,CAApB;IAcAC,MAAM,CAACC,sCAAP,CAA8CP,WAA9C,EAA2DQ,IAA3D,CAAgEC,MAAM,IAAI;MAExE,IAAIA,MAAM,CAACC,OAAX,EAAoB;QAClB,KAAKC,KAAL,CAAWF,MAAX;MACD,CAFD,MAEO;QACL,KAAKG,KAAL,CAAWH,MAAX;MACD;;MAED,KAAKX,SAAL,GAAiB,KAAjB;;MACA,KAAKe,KAAL;IACD,CAVD;EAWD;;AApDwD"}
@@ -6,19 +6,23 @@ function noop() {}
6
6
  const DEFAULT_TEST_CASE = {
7
7
  name: 'Unnamed test',
8
8
  onInitialize: noop,
9
- onRender: ({
10
- done
11
- }) => done(),
9
+ onRender: _ref => {
10
+ let {
11
+ done
12
+ } = _ref;
13
+ return done();
14
+ },
12
15
  onFinalize: noop
13
16
  };
14
17
  const DEFAULT_TEST_OPTIONS = {
15
- onTestStart: testCase => console.log(`# ${testCase.name}`),
16
- onTestPass: testCase => console.log(`ok ${testCase.name} passed`),
17
- onTestFail: testCase => console.log(`not ok ${testCase.name} failed`),
18
+ onTestStart: testCase => console.log("# ".concat(testCase.name)),
19
+ onTestPass: testCase => console.log("ok ".concat(testCase.name, " passed")),
20
+ onTestFail: testCase => console.log("not ok ".concat(testCase.name, " failed")),
18
21
  timeout: 2000
19
22
  };
20
23
  export default class TestRunner {
21
- constructor(props = {}) {
24
+ constructor() {
25
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
22
26
  this.props = props;
23
27
  this.isRunning = false;
24
28
  this._animationProps = {};
@@ -40,7 +44,8 @@ export default class TestRunner {
40
44
  return this;
41
45
  }
42
46
 
43
- run(options = {}) {
47
+ run() {
48
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
44
49
  Object.assign(this.testOptions, options);
45
50
  return new Promise(resolve => {
46
51
  this._animationLoop = new AnimationLoop(Object.assign({}, this.props, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test-runner.js"],"names":["AnimationLoop","pushContextState","popContextState","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","done","onFinalize","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","onTestPass","onTestFail","timeout","TestRunner","constructor","props","isRunning","_animationProps","_testCases","_testCaseData","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","Object","assign","add","testCases","Array","isArray","push","run","options","Promise","resolve","_animationLoop","_onRender","bind","start","isDiffing","_currentTestCase","catch","error","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","result","_nextTestCase","stop","isDone","testCaseAnimationProps","startTime","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L,GAAqB,IAArB;AACD;;AAGD,UAAMZ,QAAQ,GAAG,KAAKW,UAAL,CAAgBiD,KAAhB,EAAjB;;AACA,QAAI5D,QAAJ,EAAc;AAEZ,WAAKkC,gBAAL,GAAwBlC,QAAxB;AACA,WAAKqD,yBAAL,GAAiCV,cAAc,CAACW,IAAhD;AACA,WAAKE,yBAAL,GAAiCb,cAAc,CAACY,IAAhD;AACA,WAAKhB,YAAL,CAAkBvC,QAAlB;AAKAX,MAAAA,gBAAgB,CAACsD,cAAc,CAACgB,EAAhB,CAAhB;AAIAhC,MAAAA,OAAO,CAACC,OAAR,CACE5B,QAAQ,CAACN,YAAT,CACEwB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBwB,cAAlB,EAAkC;AAEhCS,QAAAA,SAAS,EAAET,cAAc,CAACW,IAFM;AAGhCA,QAAAA,IAAI,EAAE,CAH0B;AAIhCC,QAAAA,IAAI,EAAE;AAJ0B,OAAlC,CADF,CADF,EASEM,IATF,CASOC,QAAQ,IAAI;AACjB,aAAKlD,aAAL,GAAqBkD,QAAQ,IAAI,EAAjC;AACD,OAXD;AAaA,WAAK7C,WAAL,CAAiBlB,WAAjB,CAA6BC,QAA7B;AACD;;AACD,WAAOA,QAAP;AACD;;AA5L6B","sourcesContent":["/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/gltools';\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\nconst DEFAULT_TEST_OPTIONS = {\n // test lifecycle callback\n onTestStart: testCase => console.log(`# ${testCase.name}`),\n onTestPass: testCase => console.log(`ok ${testCase.name} passed`),\n onTestFail: testCase => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\nexport default class TestRunner {\n /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\n this.isRunning = false;\n this._animationProps = {};\n this._testCases = [];\n this._testCaseData = null;\n\n // @ts-ignore\n this.isHeadless = Boolean(window.browserTestDriver_isHeadless);\n\n this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);\n }\n\n /**\n * Add testCase(s)\n */\n add(testCases) {\n if (!Array.isArray(testCases)) {\n testCases = [testCases];\n }\n for (const testCase of testCases) {\n this._testCases.push(testCase);\n }\n return this;\n }\n\n /**\n * Returns a promise that resolves when all the test cases are done\n */\n run(options = {}) {\n Object.assign(this.testOptions, options);\n\n return new Promise(resolve => {\n this._animationLoop = new AnimationLoop(\n // @ts-ignore TODO\n Object.assign({}, this.props, {\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\n })\n );\n this._animationLoop.start(this.props);\n\n this.isRunning = true;\n this.isDiffing = false;\n this._currentTestCase = null;\n }).catch(error => {\n this._fail({error: error.message});\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.onFinalize.bind(animationLoop);\n }\n for (const key in DEFAULT_TEST_CASE) {\n testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];\n }\n }\n\n shouldRender(animationProps) {\n return true;\n }\n\n assert(testCase) {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result) {\n // @ts-ignore\n this.testOptions.onTestPass(this._currentTestCase, result);\n }\n\n _fail(result) {\n // @ts-ignore\n this.testOptions.onTestFail(this._currentTestCase, result);\n }\n\n _next() {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps) {\n this._animationProps = animationProps;\n\n const testCase = this._currentTestCase || this._nextTestCase();\n if (!testCase) {\n // all test cases are done\n this._animationLoop.stop();\n return;\n }\n\n let isDone = false;\n const testCaseAnimationProps = Object.assign({}, animationProps, this._testCaseData, {\n // tick/time starts from 0 for each test case\n startTime: this._currentTestCaseStartTime,\n time: animationProps.time - this._currentTestCaseStartTime,\n tick: animationProps.tick - this._currentTestCaseStartTick,\n // called by the test case when it is done rendering and ready for capture and diff\n done: () => {\n isDone = true;\n }\n });\n\n if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n }\n\n const timeout = testCase.timeout || this.testOptions.timeout;\n if (timeout && testCaseAnimationProps.time > timeout) {\n isDone = true;\n }\n\n if (isDone) {\n this.assert(testCase);\n }\n }\n\n _nextTestCase() {\n const animationProps = this._animationProps;\n\n // finalize the current test case\n if (this._testCaseData) {\n for (const key in this._testCaseData) {\n const value = this._testCaseData[key];\n if (value && value.delete) {\n value.delete();\n }\n }\n this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));\n\n // reset WebGL context\n popContextState(animationProps.gl);\n\n this._currentTestCase = null;\n this._testCaseData = null;\n }\n\n // get the next test case\n const testCase = this._testCases.shift();\n if (testCase) {\n // start new test case\n this._currentTestCase = testCase;\n this._currentTestCaseStartTime = animationProps.time;\n this._currentTestCaseStartTick = animationProps.tick;\n this.initTestCase(testCase);\n\n // initialize test case\n\n // save WebGL context\n pushContextState(animationProps.gl);\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(\n testCase.onInitialize(\n Object.assign({}, animationProps, {\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n })\n )\n ).then(userData => {\n this._testCaseData = userData || {};\n });\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"file":"test-runner.js"}
1
+ {"version":3,"file":"test-runner.js","names":["AnimationLoop","pushContextState","popContextState","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","done","onFinalize","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","onTestPass","onTestFail","timeout","TestRunner","constructor","props","isRunning","_animationProps","_testCases","_testCaseData","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","Object","assign","add","testCases","Array","isArray","push","run","options","Promise","resolve","_animationLoop","_onRender","bind","start","isDiffing","_currentTestCase","catch","error","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","result","_nextTestCase","stop","isDone","testCaseAnimationProps","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","value","delete","gl","shift","then","userData"],"sources":["../../src/test-runner.js"],"sourcesContent":["/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/gltools';\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\nconst DEFAULT_TEST_OPTIONS = {\n // test lifecycle callback\n onTestStart: testCase => console.log(`# ${testCase.name}`),\n onTestPass: testCase => console.log(`ok ${testCase.name} passed`),\n onTestFail: testCase => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\nexport default class TestRunner {\n /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\n this.isRunning = false;\n this._animationProps = {};\n this._testCases = [];\n this._testCaseData = null;\n\n // @ts-ignore\n this.isHeadless = Boolean(window.browserTestDriver_isHeadless);\n\n this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);\n }\n\n /**\n * Add testCase(s)\n */\n add(testCases) {\n if (!Array.isArray(testCases)) {\n testCases = [testCases];\n }\n for (const testCase of testCases) {\n this._testCases.push(testCase);\n }\n return this;\n }\n\n /**\n * Returns a promise that resolves when all the test cases are done\n */\n run(options = {}) {\n Object.assign(this.testOptions, options);\n\n return new Promise(resolve => {\n this._animationLoop = new AnimationLoop(\n // @ts-ignore TODO\n Object.assign({}, this.props, {\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\n })\n );\n this._animationLoop.start(this.props);\n\n this.isRunning = true;\n this.isDiffing = false;\n this._currentTestCase = null;\n }).catch(error => {\n this._fail({error: error.message});\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.onFinalize.bind(animationLoop);\n }\n for (const key in DEFAULT_TEST_CASE) {\n testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];\n }\n }\n\n shouldRender(animationProps) {\n return true;\n }\n\n assert(testCase) {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result) {\n // @ts-ignore\n this.testOptions.onTestPass(this._currentTestCase, result);\n }\n\n _fail(result) {\n // @ts-ignore\n this.testOptions.onTestFail(this._currentTestCase, result);\n }\n\n _next() {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps) {\n this._animationProps = animationProps;\n\n const testCase = this._currentTestCase || this._nextTestCase();\n if (!testCase) {\n // all test cases are done\n this._animationLoop.stop();\n return;\n }\n\n let isDone = false;\n const testCaseAnimationProps = Object.assign({}, animationProps, this._testCaseData, {\n // tick/time starts from 0 for each test case\n startTime: this._currentTestCaseStartTime,\n time: animationProps.time - this._currentTestCaseStartTime,\n tick: animationProps.tick - this._currentTestCaseStartTick,\n // called by the test case when it is done rendering and ready for capture and diff\n done: () => {\n isDone = true;\n }\n });\n\n if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n }\n\n const timeout = testCase.timeout || this.testOptions.timeout;\n if (timeout && testCaseAnimationProps.time > timeout) {\n isDone = true;\n }\n\n if (isDone) {\n this.assert(testCase);\n }\n }\n\n _nextTestCase() {\n const animationProps = this._animationProps;\n\n // finalize the current test case\n if (this._testCaseData) {\n for (const key in this._testCaseData) {\n const value = this._testCaseData[key];\n if (value && value.delete) {\n value.delete();\n }\n }\n this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));\n\n // reset WebGL context\n popContextState(animationProps.gl);\n\n this._currentTestCase = null;\n this._testCaseData = null;\n }\n\n // get the next test case\n const testCase = this._testCases.shift();\n if (testCase) {\n // start new test case\n this._currentTestCase = testCase;\n this._currentTestCaseStartTime = animationProps.time;\n this._currentTestCaseStartTick = animationProps.tick;\n this.initTestCase(testCase);\n\n // initialize test case\n\n // save WebGL context\n pushContextState(animationProps.gl);\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(\n testCase.onInitialize(\n Object.assign({}, animationProps, {\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n })\n )\n ).then(userData => {\n this._testCaseData = userData || {};\n });\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"mappings":"AACA,SAAQA,aAAR,QAA4B,eAA5B;AACA,SAAQC,gBAAR,EAA0BC,eAA1B,QAAgD,kBAAhD;;AAEA,SAASC,IAAT,GAAgB,CAAE;;AAElB,MAAMC,iBAAiB,GAAG;EACxBC,IAAI,EAAE,cADkB;EAExBC,YAAY,EAAEH,IAFU;EAGxBI,QAAQ,EAAE;IAAA,IAAC;MAACC;IAAD,CAAD;IAAA,OAAYA,IAAI,EAAhB;EAAA,CAHc;EAIxBC,UAAU,EAAEN;AAJY,CAA1B;AAOA,MAAMO,oBAAoB,GAAG;EAE3BC,WAAW,EAAEC,QAAQ,IAAIC,OAAO,CAACC,GAAR,aAAiBF,QAAQ,CAACP,IAA1B,EAFE;EAG3BU,UAAU,EAAEH,QAAQ,IAAIC,OAAO,CAACC,GAAR,cAAkBF,QAAQ,CAACP,IAA3B,aAHG;EAI3BW,UAAU,EAAEJ,QAAQ,IAAIC,OAAO,CAACC,GAAR,kBAAsBF,QAAQ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,IAAIA,KAAK,CAACC,MAAnB,EAA2B;UACzBD,KAAK,CAACC,MAAN;QACD;MACF;;MACD,KAAKxB,gBAAL,CAAsBrC,UAAtB,CAAiCqB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBwB,cAAlB,EAAkC,KAAK/B,aAAvC,CAAjC;;MAGAtB,eAAe,CAACqD,cAAc,CAACgB,EAAhB,CAAf;MAEA,KAAKzB,gBAAL,GAAwB,IAAxB;MACA,KAAKtB,aAAL,GAAqB,IAArB;IACD;;IAGD,MAAMZ,QAAQ,GAAG,KAAKW,UAAL,CAAgBiD,KAAhB,EAAjB;;IACA,IAAI5D,QAAJ,EAAc;MAEZ,KAAKkC,gBAAL,GAAwBlC,QAAxB;MACA,KAAKqD,yBAAL,GAAiCV,cAAc,CAACW,IAAhD;MACA,KAAKE,yBAAL,GAAiCb,cAAc,CAACY,IAAhD;MACA,KAAKhB,YAAL,CAAkBvC,QAAlB;MAKAX,gBAAgB,CAACsD,cAAc,CAACgB,EAAhB,CAAhB;MAIAhC,OAAO,CAACC,OAAR,CACE5B,QAAQ,CAACN,YAAT,CACEwB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBwB,cAAlB,EAAkC;QAEhCS,SAAS,EAAET,cAAc,CAACW,IAFM;QAGhCA,IAAI,EAAE,CAH0B;QAIhCC,IAAI,EAAE;MAJ0B,CAAlC,CADF,CADF,EASEM,IATF,CASOC,QAAQ,IAAI;QACjB,KAAKlD,aAAL,GAAqBkD,QAAQ,IAAI,EAAjC;MACD,CAXD;MAaA,KAAK7C,WAAL,CAAiBlB,WAAjB,CAA6BC,QAA7B;IACD;;IACD,OAAOA,QAAP;EACD;;AA5L6B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils.js"],"names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"mappings":"AACA,OAAO,SAASA,oBAAT,CAA8BC,UAA9B,EAA0C;AAC/C,QAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAX,EAAb;AACA,SAAO;AACLC,IAAAA,CAAC,EAAEC,MAAM,CAACC,OAAP,GAAiBJ,IAAI,CAACE,CADpB;AAELG,IAAAA,CAAC,EAAEF,MAAM,CAACG,OAAP,GAAiBN,IAAI,CAACK,CAFpB;AAGLE,IAAAA,KAAK,EAAEP,IAAI,CAACO,KAHP;AAILC,IAAAA,MAAM,EAAER,IAAI,CAACQ;AAJR,GAAP;AAMD","sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement) {\n const bbox = domElement.getBoundingClientRect();\n return {\n x: window.scrollX + bbox.x,\n y: window.scrollY + bbox.y,\n width: bbox.width,\n height: bbox.height\n };\n}\n"],"file":"utils.js"}
1
+ {"version":3,"file":"utils.js","names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"sources":["../../src/utils.js"],"sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement) {\n const bbox = domElement.getBoundingClientRect();\n return {\n x: window.scrollX + bbox.x,\n y: window.scrollY + bbox.y,\n width: bbox.width,\n height: bbox.height\n };\n}\n"],"mappings":"AACA,OAAO,SAASA,oBAAT,CAA8BC,UAA9B,EAA0C;EAC/C,MAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAX,EAAb;EACA,OAAO;IACLC,CAAC,EAAEC,MAAM,CAACC,OAAP,GAAiBJ,IAAI,CAACE,CADpB;IAELG,CAAC,EAAEF,MAAM,CAACG,OAAP,GAAiBN,IAAI,CAACK,CAFpB;IAGLE,KAAK,EAAEP,IAAI,CAACO,KAHP;IAILC,MAAM,EAAER,IAAI,CAACQ;EAJR,CAAP;AAMD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luma.gl/test-utils",
3
- "version": "8.5.13",
3
+ "version": "8.5.16",
4
4
  "description": "Automated WebGL testing utilities with Puppeteer and image diffing",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -28,7 +28,7 @@
28
28
  "pre-build": "echo test utils has no bundle"
29
29
  },
30
30
  "dependencies": {
31
- "probe.gl": "^3.4.0"
31
+ "@probe.gl/stats": "^3.5.0"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@luma.gl/core": "^8.4.0",
@@ -36,7 +36,7 @@
36
36
  "@luma.gl/gltools": "^8.4.0",
37
37
  "@luma.gl/webgl": "^8.4.0",
38
38
  "@probe.gl/env": "^3.5.0",
39
- "@probe.gl/test-utils": "^3.4.0"
39
+ "@probe.gl/test-utils": "^3.5.0"
40
40
  },
41
- "gitHead": "a46f53790803d9986e6bdf509828496f154f7c34"
41
+ "gitHead": "7ee91b978c80b39ce6d997f27d3cdeea79e054ae"
42
42
  }
@@ -1,4 +1,4 @@
1
- import {Stats} from 'probe.gl';
1
+ import {Stats} from '@probe.gl/stats';
2
2
  import TestRunner from './test-runner';
3
3
 
4
4
  export default class PerformanceTestRunner extends TestRunner {