@deck.gl/test-utils 8.7.0-alpha.1 → 8.7.0-alpha.2
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.
- package/dist/es5/generate-layer-tests.js +65 -85
- package/dist/es5/generate-layer-tests.js.map +1 -1
- package/dist/es5/index.js +10 -10
- package/dist/es5/interaction-test-runner.js +37 -92
- package/dist/es5/interaction-test-runner.js.map +1 -1
- package/dist/es5/lifecycle-test.js +125 -273
- package/dist/es5/lifecycle-test.js.map +1 -1
- package/dist/es5/snapshot-test-runner.js +70 -109
- package/dist/es5/snapshot-test-runner.js.map +1 -1
- package/dist/es5/test-runner.js +96 -155
- package/dist/es5/test-runner.js.map +1 -1
- package/dist/es5/utils/dom.js +1 -1
- package/dist/es5/utils/dom.js.map +1 -1
- package/dist/es5/utils/precision.js +4 -12
- package/dist/es5/utils/precision.js.map +1 -1
- package/dist/es5/utils/setup-gl.js +1 -1
- package/dist/es5/utils/setup-gl.js.map +1 -1
- package/dist/esm/interaction-test-runner.js.map +1 -1
- package/dist/esm/snapshot-test-runner.js.map +1 -1
- package/dist/esm/test-runner.js.map +1 -1
- package/package.json +2 -2
|
@@ -7,141 +7,102 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
10
|
var _testRunner = _interopRequireDefault(require("./test-runner"));
|
|
25
11
|
|
|
26
12
|
var _dom = require("./utils/dom");
|
|
27
13
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
31
|
-
|
|
32
|
-
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); }; }
|
|
33
|
-
|
|
34
|
-
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; } }
|
|
35
|
-
|
|
36
|
-
var DEFAULT_TEST_OPTIONS = {
|
|
14
|
+
const DEFAULT_TEST_OPTIONS = {
|
|
37
15
|
imageDiffOptions: {}
|
|
38
16
|
};
|
|
39
|
-
|
|
17
|
+
const DEFAULT_TEST_CASE = {
|
|
40
18
|
name: 'Unnamed snapshot test',
|
|
41
19
|
props: {},
|
|
42
|
-
onBeforeRender:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
onAfterRender:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (layers.every(
|
|
52
|
-
return layer.isLoaded;
|
|
53
|
-
})) {
|
|
20
|
+
onBeforeRender: ({
|
|
21
|
+
deck,
|
|
22
|
+
layers
|
|
23
|
+
}) => {},
|
|
24
|
+
onAfterRender: ({
|
|
25
|
+
deck,
|
|
26
|
+
layers,
|
|
27
|
+
done
|
|
28
|
+
}) => {
|
|
29
|
+
if (layers.every(layer => layer.isLoaded)) {
|
|
54
30
|
done();
|
|
55
31
|
}
|
|
56
32
|
},
|
|
57
33
|
goldenImage: ''
|
|
58
34
|
};
|
|
59
35
|
|
|
60
|
-
|
|
61
|
-
(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var _this;
|
|
36
|
+
class SnapshotTestRunner extends _testRunner.default {
|
|
37
|
+
constructor(props) {
|
|
38
|
+
super(props);
|
|
39
|
+
this.isDiffing = false;
|
|
40
|
+
Object.assign(this.testOptions, DEFAULT_TEST_OPTIONS);
|
|
41
|
+
}
|
|
67
42
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
_this.isDiffing = false;
|
|
71
|
-
Object.assign(_this.testOptions, DEFAULT_TEST_OPTIONS);
|
|
72
|
-
return _this;
|
|
43
|
+
get defaultTestCase() {
|
|
44
|
+
return DEFAULT_TEST_CASE;
|
|
73
45
|
}
|
|
74
46
|
|
|
75
|
-
(
|
|
76
|
-
|
|
77
|
-
value: function initTestCase(testCase) {
|
|
78
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(SnapshotTestRunner.prototype), "initTestCase", this).call(this, testCase);
|
|
47
|
+
initTestCase(testCase) {
|
|
48
|
+
super.initTestCase(testCase);
|
|
79
49
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "runTestCase",
|
|
86
|
-
value: function runTestCase(testCase, onDone) {
|
|
87
|
-
var deck = this.deck;
|
|
88
|
-
deck.setProps(_objectSpread(_objectSpread(_objectSpread({}, this.props), testCase), {}, {
|
|
89
|
-
onBeforeRender: function onBeforeRender() {
|
|
90
|
-
testCase.onBeforeRender({
|
|
91
|
-
deck: deck,
|
|
92
|
-
layers: deck.props.layers
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
onAfterRender: function onAfterRender() {
|
|
96
|
-
testCase.onAfterRender({
|
|
97
|
-
deck: deck,
|
|
98
|
-
layers: deck.props.layers,
|
|
99
|
-
done: onDone
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "shouldRender",
|
|
106
|
-
value: function shouldRender() {
|
|
107
|
-
return !this.isDiffing;
|
|
50
|
+
if (!testCase.goldenImage) {
|
|
51
|
+
throw new Error("Test case ".concat(testCase.name, " does not have golden image"));
|
|
108
52
|
}
|
|
109
|
-
}
|
|
110
|
-
key: "assert",
|
|
111
|
-
value: function assert(testCase) {
|
|
112
|
-
var _this2 = this;
|
|
53
|
+
}
|
|
113
54
|
|
|
114
|
-
|
|
115
|
-
|
|
55
|
+
runTestCase(testCase, onDone) {
|
|
56
|
+
const {
|
|
57
|
+
deck
|
|
58
|
+
} = this;
|
|
59
|
+
deck.setProps({ ...this.props,
|
|
60
|
+
...testCase,
|
|
61
|
+
onBeforeRender: () => {
|
|
62
|
+
testCase.onBeforeRender({
|
|
63
|
+
deck,
|
|
64
|
+
layers: deck.props.layers
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
onAfterRender: () => {
|
|
68
|
+
testCase.onAfterRender({
|
|
69
|
+
deck,
|
|
70
|
+
layers: deck.props.layers,
|
|
71
|
+
done: onDone
|
|
72
|
+
});
|
|
116
73
|
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
117
76
|
|
|
118
|
-
|
|
77
|
+
shouldRender() {
|
|
78
|
+
return !this.isDiffing;
|
|
79
|
+
}
|
|
119
80
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
81
|
+
assert(testCase) {
|
|
82
|
+
if (this.isDiffing) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
124
85
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
86
|
+
this.isDiffing = true;
|
|
87
|
+
const diffOptions = { ...this.testOptions.imageDiffOptions,
|
|
88
|
+
...testCase.imageDiffOptions,
|
|
89
|
+
goldenImage: testCase.goldenImage,
|
|
90
|
+
region: (0, _dom.getBoundingBoxInPage)(this.deck.canvas)
|
|
91
|
+
};
|
|
92
|
+
window.browserTestDriver_captureAndDiffScreen(diffOptions).then(result => {
|
|
93
|
+
if (result.success) {
|
|
94
|
+
this._pass(result);
|
|
95
|
+
} else {
|
|
96
|
+
this._fail(result);
|
|
97
|
+
}
|
|
131
98
|
|
|
132
|
-
|
|
99
|
+
this.isDiffing = false;
|
|
133
100
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
get: function get() {
|
|
140
|
-
return DEFAULT_TEST_CASE;
|
|
141
|
-
}
|
|
142
|
-
}]);
|
|
143
|
-
return SnapshotTestRunner;
|
|
144
|
-
}(_testRunner.default);
|
|
101
|
+
this._next();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
145
106
|
|
|
146
107
|
exports.default = SnapshotTestRunner;
|
|
147
108
|
//# sourceMappingURL=snapshot-test-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/snapshot-test-runner.js"],"names":["DEFAULT_TEST_OPTIONS","imageDiffOptions","DEFAULT_TEST_CASE","name","props","onBeforeRender","deck","layers","onAfterRender","done","every","layer","isLoaded","goldenImage","SnapshotTestRunner","isDiffing","Object","assign","testOptions","testCase","Error","onDone","setProps","diffOptions","region","canvas","window","browserTestDriver_captureAndDiffScreen","then","result","success","_pass","_fail","_next"
|
|
1
|
+
{"version":3,"sources":["../../src/snapshot-test-runner.js"],"names":["DEFAULT_TEST_OPTIONS","imageDiffOptions","DEFAULT_TEST_CASE","name","props","onBeforeRender","deck","layers","onAfterRender","done","every","layer","isLoaded","goldenImage","SnapshotTestRunner","TestRunner","constructor","isDiffing","Object","assign","testOptions","defaultTestCase","initTestCase","testCase","Error","runTestCase","onDone","setProps","shouldRender","assert","diffOptions","region","canvas","window","browserTestDriver_captureAndDiffScreen","then","result","success","_pass","_fail","_next"],"mappings":";;;;;;;;;AAqBA;;AACA;;AAEA,MAAMA,oBAAoB,GAAG;AAC3BC,EAAAA,gBAAgB,EAAE;AADS,CAA7B;AAIA,MAAMC,iBAAiB,GAAG;AACxBC,EAAAA,IAAI,EAAE,uBADkB;AAExBC,EAAAA,KAAK,EAAE,EAFiB;AAGxBC,EAAAA,cAAc,EAAE,CAAC;AAACC,IAAAA,IAAD;AAAOC,IAAAA;AAAP,GAAD,KAAoB,CAEnC,CALuB;AAMxBC,EAAAA,aAAa,EAAE,CAAC;AAACF,IAAAA,IAAD;AAAOC,IAAAA,MAAP;AAAeE,IAAAA;AAAf,GAAD,KAA0B;AACvC,QAAIF,MAAM,CAACG,KAAP,CAAaC,KAAK,IAAIA,KAAK,CAACC,QAA5B,CAAJ,EAA2C;AACzCH,MAAAA,IAAI;AACL;AACF,GAVuB;AAWxBI,EAAAA,WAAW,EAAE;AAXW,CAA1B;;AAce,MAAMC,kBAAN,SAAiCC,mBAAjC,CAA4C;AACzDC,EAAAA,WAAW,CAACZ,KAAD,EAAQ;AACjB,UAAMA,KAAN;AAEA,SAAKa,SAAL,GAAiB,KAAjB;AAEAC,IAAAA,MAAM,CAACC,MAAP,CAAc,KAAKC,WAAnB,EAAgCpB,oBAAhC;AACD;;AAEkB,MAAfqB,eAAe,GAAG;AACpB,WAAOnB,iBAAP;A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WAA9C,EAA2DK,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,WAAKnB,SAAL,GAAiB,KAAjB;;AACA,WAAKuB,KAAL;AACD,KAVD;AAWD;;AAxEwD","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* global window */\nimport TestRunner from './test-runner';\nimport {getBoundingBoxInPage} from './utils/dom';\n\nconst DEFAULT_TEST_OPTIONS = {\n imageDiffOptions: {}\n};\n\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed snapshot test',\n props: {},\n onBeforeRender: ({deck, layers}) => {\n // eslint-disable-line\n },\n onAfterRender: ({deck, layers, done}) => {\n if (layers.every(layer => layer.isLoaded)) {\n done(); // eslint-disable-line\n }\n },\n goldenImage: ''\n};\n\nexport default class SnapshotTestRunner extends TestRunner {\n constructor(props) {\n super(props);\n\n this.isDiffing = false;\n\n Object.assign(this.testOptions, DEFAULT_TEST_OPTIONS);\n }\n\n get defaultTestCase() {\n return DEFAULT_TEST_CASE;\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 runTestCase(testCase, onDone) {\n const {deck} = this;\n\n deck.setProps({\n ...this.props,\n ...testCase,\n onBeforeRender: () => {\n testCase.onBeforeRender({\n deck,\n layers: deck.props.layers\n });\n },\n onAfterRender: () => {\n testCase.onAfterRender({\n deck,\n layers: deck.props.layers,\n done: onDone\n });\n }\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 = {\n ...this.testOptions.imageDiffOptions,\n ...testCase.imageDiffOptions,\n goldenImage: testCase.goldenImage,\n region: getBoundingBoxInPage(this.deck.canvas)\n };\n // Take screenshot and compare\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"}
|
package/dist/es5/test-runner.js
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
7
|
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
8
|
var _core = require("@deck.gl/core");
|
|
17
9
|
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
23
|
-
|
|
24
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
-
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
27
|
-
|
|
28
|
-
var GL_VENDOR = 0x1f00;
|
|
29
|
-
|
|
30
|
-
var DEFAULT_DECK_PROPS = _objectSpread(_objectSpread({}, _core.Deck.defaultProps), {}, {
|
|
10
|
+
const GL_VENDOR = 0x1f00;
|
|
11
|
+
const DEFAULT_DECK_PROPS = { ..._core.Deck.defaultProps,
|
|
31
12
|
id: 'deckgl-render-test',
|
|
32
13
|
width: 800,
|
|
33
14
|
height: 450,
|
|
@@ -39,166 +20,126 @@ var DEFAULT_DECK_PROPS = _objectSpread(_objectSpread({}, _core.Deck.defaultProps
|
|
|
39
20
|
views: [new _core.MapView()],
|
|
40
21
|
useDevicePixels: false,
|
|
41
22
|
debug: true
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
onTestPass: function onTestPass(testCase) {
|
|
49
|
-
return console.log("ok ".concat(testCase.name, " passed"));
|
|
50
|
-
},
|
|
51
|
-
onTestFail: function onTestFail(testCase) {
|
|
52
|
-
return console.log("not ok ".concat(testCase.name, " failed"));
|
|
53
|
-
},
|
|
23
|
+
};
|
|
24
|
+
const DEFAULT_TEST_OPTIONS = {
|
|
25
|
+
onTestStart: testCase => console.log("# ".concat(testCase.name)),
|
|
26
|
+
onTestPass: testCase => console.log("ok ".concat(testCase.name, " passed")),
|
|
27
|
+
onTestFail: testCase => console.log("not ok ".concat(testCase.name, " failed")),
|
|
54
28
|
timeout: 2000
|
|
55
29
|
};
|
|
56
|
-
|
|
30
|
+
const DEFAULT_TEST_CASE = {
|
|
57
31
|
name: 'Unnamed test'
|
|
58
32
|
};
|
|
59
33
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
34
|
+
class TestRunner {
|
|
35
|
+
constructor(props = {}) {
|
|
36
|
+
this.props = { ...DEFAULT_DECK_PROPS,
|
|
37
|
+
...props
|
|
38
|
+
};
|
|
65
39
|
this.isRunning = false;
|
|
66
40
|
this._testCases = [];
|
|
67
41
|
this._testCaseData = null;
|
|
68
42
|
this.isHeadless = Boolean(window.browserTestDriver_isHeadless);
|
|
69
|
-
this.testOptions =
|
|
43
|
+
this.testOptions = { ...DEFAULT_TEST_OPTIONS
|
|
44
|
+
};
|
|
70
45
|
}
|
|
71
46
|
|
|
72
|
-
(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (!Array.isArray(testCases)) {
|
|
76
|
-
testCases = [testCases];
|
|
77
|
-
}
|
|
47
|
+
get defaultTestCase() {
|
|
48
|
+
return DEFAULT_TEST_CASE;
|
|
49
|
+
}
|
|
78
50
|
|
|
79
|
-
|
|
80
|
-
|
|
51
|
+
add(testCases) {
|
|
52
|
+
if (!Array.isArray(testCases)) {
|
|
53
|
+
testCases = [testCases];
|
|
54
|
+
}
|
|
81
55
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
56
|
+
for (const testCase of testCases) {
|
|
57
|
+
this._testCases.push(testCase);
|
|
58
|
+
}
|
|
85
59
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} catch (err) {
|
|
89
|
-
_iterator.e(err);
|
|
90
|
-
} finally {
|
|
91
|
-
_iterator.f();
|
|
92
|
-
}
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
93
62
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
102
|
-
Object.assign(this.testOptions, options);
|
|
103
|
-
return new Promise(function (resolve, reject) {
|
|
104
|
-
_this.deck = new _core.Deck(_objectSpread(_objectSpread({}, _this.props), {}, {
|
|
105
|
-
onWebGLInitialized: _this._onWebGLInitialized.bind(_this),
|
|
106
|
-
onLoad: resolve
|
|
107
|
-
}));
|
|
108
|
-
_this.isRunning = true;
|
|
109
|
-
_this._currentTestCase = null;
|
|
110
|
-
}).then(function () {
|
|
111
|
-
var promise = Promise.resolve();
|
|
112
|
-
|
|
113
|
-
_this._testCases.forEach(function (testCase) {
|
|
114
|
-
promise = promise.then(function () {
|
|
115
|
-
return _this._runTest(testCase);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
return promise;
|
|
120
|
-
}).catch(function (error) {
|
|
121
|
-
_this._fail({
|
|
122
|
-
error: error.message
|
|
123
|
-
});
|
|
124
|
-
}).finally(function () {
|
|
125
|
-
_this.deck.finalize();
|
|
126
|
-
|
|
127
|
-
_this.deck = null;
|
|
63
|
+
run(options = {}) {
|
|
64
|
+
Object.assign(this.testOptions, options);
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
this.deck = new _core.Deck({ ...this.props,
|
|
67
|
+
onWebGLInitialized: this._onWebGLInitialized.bind(this),
|
|
68
|
+
onLoad: resolve
|
|
128
69
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
for (var key in this.defaultTestCase) {
|
|
134
|
-
if (!(key in testCase)) {
|
|
135
|
-
testCase[key] = this.defaultTestCase[key];
|
|
136
|
-
}
|
|
137
|
-
}
|
|
70
|
+
this.isRunning = true;
|
|
71
|
+
this._currentTestCase = null;
|
|
72
|
+
}).then(() => {
|
|
73
|
+
let promise = Promise.resolve();
|
|
138
74
|
|
|
139
|
-
this.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
key: "assert",
|
|
143
|
-
value: function assert(testCase) {
|
|
144
|
-
this.onTestPass(testCase);
|
|
75
|
+
this._testCases.forEach(testCase => {
|
|
76
|
+
promise = promise.then(() => this._runTest(testCase));
|
|
77
|
+
});
|
|
145
78
|
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
var ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
163
|
-
var vendorUnmasked = ext && gl.getParameter(ext.UNMASKED_VENDOR_WEBGL || GL_VENDOR);
|
|
164
|
-
this.gpuVendor = vendorUnmasked || vendorMasked;
|
|
79
|
+
return promise;
|
|
80
|
+
}).catch(error => {
|
|
81
|
+
this._fail({
|
|
82
|
+
error: error.message
|
|
83
|
+
});
|
|
84
|
+
}).finally(() => {
|
|
85
|
+
this.deck.finalize();
|
|
86
|
+
this.deck = null;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
initTestCase(testCase) {
|
|
91
|
+
for (const key in this.defaultTestCase) {
|
|
92
|
+
if (!(key in testCase)) {
|
|
93
|
+
testCase[key] = this.defaultTestCase[key];
|
|
94
|
+
}
|
|
165
95
|
}
|
|
166
|
-
}, {
|
|
167
|
-
key: "_runTest",
|
|
168
|
-
value: function _runTest(testCase) {
|
|
169
|
-
var _this2 = this;
|
|
170
96
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
_this2._next = resolve;
|
|
97
|
+
this.testOptions.onTestStart(testCase);
|
|
98
|
+
}
|
|
174
99
|
|
|
175
|
-
|
|
100
|
+
assert(testCase) {
|
|
101
|
+
this.onTestPass(testCase);
|
|
176
102
|
|
|
177
|
-
|
|
178
|
-
|
|
103
|
+
this._next();
|
|
104
|
+
}
|
|
179
105
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
window.clearTimeout(timeoutId);
|
|
106
|
+
_pass(result) {
|
|
107
|
+
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
108
|
+
}
|
|
184
109
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
110
|
+
_fail(result) {
|
|
111
|
+
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
112
|
+
}
|
|
188
113
|
|
|
189
|
-
|
|
114
|
+
_onWebGLInitialized(gl) {
|
|
115
|
+
const vendorMasked = gl.getParameter(GL_VENDOR);
|
|
116
|
+
const ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
117
|
+
const vendorUnmasked = ext && gl.getParameter(ext.UNMASKED_VENDOR_WEBGL || GL_VENDOR);
|
|
118
|
+
this.gpuVendor = vendorUnmasked || vendorMasked;
|
|
119
|
+
}
|
|
190
120
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
121
|
+
_runTest(testCase) {
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
this._currentTestCase = testCase;
|
|
124
|
+
this._next = resolve;
|
|
125
|
+
this.initTestCase(testCase);
|
|
126
|
+
let isDone = false;
|
|
127
|
+
let timeoutId = null;
|
|
128
|
+
|
|
129
|
+
const done = () => {
|
|
130
|
+
if (!isDone) {
|
|
131
|
+
isDone = true;
|
|
132
|
+
window.clearTimeout(timeoutId);
|
|
133
|
+
this.assert(testCase);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
timeoutId = window.setTimeout(done, testCase.timeout || this.testOptions.timeout);
|
|
138
|
+
this.runTestCase(testCase, done);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|
|
202
143
|
|
|
203
144
|
exports.default = TestRunner;
|
|
204
145
|
//# sourceMappingURL=test-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test-runner.js"],"names":["GL_VENDOR","DEFAULT_DECK_PROPS","Deck","defaultProps","id","width","height","style","position","left","top","views","MapView","useDevicePixels","debug","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","name","onTestPass","onTestFail","timeout","DEFAULT_TEST_CASE","TestRunner","props","isRunning","_testCases","_testCaseData","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","testCases","Array","isArray","push","options","Object","assign","Promise","resolve","reject","deck","onWebGLInitialized","_onWebGLInitialized","bind","onLoad","_currentTestCase","then","promise","forEach","_runTest","catch","error","_fail","message","finally","finalize","key","
|
|
1
|
+
{"version":3,"sources":["../../src/test-runner.js"],"names":["GL_VENDOR","DEFAULT_DECK_PROPS","Deck","defaultProps","id","width","height","style","position","left","top","views","MapView","useDevicePixels","debug","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","name","onTestPass","onTestFail","timeout","DEFAULT_TEST_CASE","TestRunner","constructor","props","isRunning","_testCases","_testCaseData","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","defaultTestCase","add","testCases","Array","isArray","push","run","options","Object","assign","Promise","resolve","reject","deck","onWebGLInitialized","_onWebGLInitialized","bind","onLoad","_currentTestCase","then","promise","forEach","_runTest","catch","error","_fail","message","finally","finalize","initTestCase","key","assert","_next","_pass","result","gl","vendorMasked","getParameter","ext","getExtension","vendorUnmasked","UNMASKED_VENDOR_WEBGL","gpuVendor","isDone","timeoutId","done","clearTimeout","setTimeout","runTestCase"],"mappings":";;;;;;;AAsBA;;AAEA,MAAMA,SAAS,GAAG,MAAlB;AAEA,MAAMC,kBAAkB,GAAG,EACzB,GAAGC,WAAKC,YADiB;AAEzBC,EAAAA,EAAE,EAAE,oBAFqB;AAGzBC,EAAAA,KAAK,EAAE,GAHkB;AAIzBC,EAAAA,MAAM,EAAE,GAJiB;AAKzBC,EAAAA,KAAK,EAAE;AAACC,IAAAA,QAAQ,EAAE,UAAX;AAAuBC,IAAAA,IAAI,EAAE,KAA7B;AAAoCC,IAAAA,GAAG,EAAE;AAAzC,GALkB;AAMzBC,EAAAA,KAAK,EAAE,CAAC,IAAIC,aAAJ,EAAD,CANkB;AAOzBC,EAAAA,eAAe,EAAE,KAPQ;AAQzBC,EAAAA,KAAK,EAAE;AARkB,CAA3B;AAWA,MAAMC,oBAAoB,GAAG;AAE3BC,EAAAA,WAAW,EAAEC,QAAQ,IAAIC,OAAO,CAACC,GAAR,aAAiBF,QAAQ,CAACG,IAA1B,EAFE;AAG3BC,EAAAA,UAAU,EAAEJ,QAAQ,IAAIC,OAAO,CAACC,GAAR,cAAkBF,QAAQ,CAACG,IAA3B,aAHG;AAI3BE,EAAAA,UAAU,EAAEL,QAAQ,IAAIC,OAAO,CAAC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CAA4B,KAAKgC,gBAAjC,EAAmDgB,MAAnD;AACD;;AAIDnB,EAAAA,mBAAmB,CAACoB,EAAD,EAAK;AACtB,UAAMC,YAAY,GAAGD,EAAE,CAACE,YAAH,CAAgBzE,SAAhB,CAArB;AACA,UAAM0E,GAAG,GAAGH,EAAE,CAACI,YAAH,CAAgB,2BAAhB,CAAZ;AACA,UAAMC,cAAc,GAAGF,GAAG,IAAIH,EAAE,CAACE,YAAH,CAAgBC,GAAG,CAACG,qBAAJ,IAA6B7E,SAA7C,CAA9B;AACA,SAAK8E,SAAL,GAAiBF,cAAc,IAAIJ,YAAnC;AACD;;AAEDd,EAAAA,QAAQ,CAACzC,QAAD,EAAW;AACjB,WAAO,IAAI6B,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;AACtC,WAAKM,gBAAL,GAAwBrC,QAAxB;AACA,WAAKmD,KAAL,GAAarB,OAAb;AAGA,WAAKkB,YAAL,CAAkBhD,QAAlB;AAEA,UAAI8D,MAAM,GAAG,KAAb;AACA,UAAIC,SAAS,GAAG,IAAhB;;AACA,YAAMC,IAAI,GAAG,MAAM;AACjB,YAAI,CAACF,MAAL,EAAa;AACXA,UAAAA,MAAM,GAAG,IAAT;AACA9C,UAAAA,MAAM,CAACiD,YAAP,CAAoBF,SAApB;AACA,eAAKb,MAAL,CAAYlD,QAAZ;AACD;AACF,OAND;;AAQA+D,MAAAA,SAAS,GAAG/C,MAAM,CAACkD,UAAP,CAAkBF,IAAlB,EAAwBhE,QAAQ,CAACM,OAAT,IAAoB,KAAKY,WAAL,CAAiBZ,OAA7D,CAAZ;AAEA,WAAK6D,WAAL,CAAiBnE,QAAjB,EAA2BgE,IAA3B;AACD,KApBM,CAAP;AAqBD;;AA5H6B","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/* global window, console */\n/* eslint-disable no-console */\nimport {Deck, MapView} from '@deck.gl/core';\n\nconst GL_VENDOR = 0x1f00;\n\nconst DEFAULT_DECK_PROPS = {\n ...Deck.defaultProps,\n id: 'deckgl-render-test',\n width: 800,\n height: 450,\n style: {position: 'absolute', left: '0px', top: '0px'},\n views: [new MapView()],\n useDevicePixels: false,\n debug: true\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\nconst DEFAULT_TEST_CASE = {\n name: 'Unnamed test'\n};\n\nexport default class TestRunner {\n /**\n * props\n * Deck props\n */\n constructor(props = {}) {\n this.props = {...DEFAULT_DECK_PROPS, ...props};\n\n this.isRunning = false;\n this._testCases = [];\n this._testCaseData = null;\n\n this.isHeadless = Boolean(window.browserTestDriver_isHeadless);\n\n this.testOptions = {...DEFAULT_TEST_OPTIONS};\n }\n\n get defaultTestCase() {\n return DEFAULT_TEST_CASE;\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, reject) => {\n this.deck = new Deck({\n ...this.props,\n onWebGLInitialized: this._onWebGLInitialized.bind(this),\n onLoad: resolve\n });\n\n this.isRunning = true;\n this._currentTestCase = null;\n })\n .then(() => {\n let promise = Promise.resolve();\n // chain test case promises\n this._testCases.forEach(testCase => {\n promise = promise.then(() => this._runTest(testCase));\n });\n return promise;\n })\n .catch(error => {\n this._fail({error: error.message});\n })\n .finally(() => {\n this.deck.finalize();\n this.deck = null;\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase) {\n for (const key in this.defaultTestCase) {\n if (!(key in testCase)) {\n testCase[key] = this.defaultTestCase[key];\n }\n }\n this.testOptions.onTestStart(testCase);\n }\n\n assert(testCase) {\n this.onTestPass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result) {\n this.testOptions.onTestPass(this._currentTestCase, result);\n }\n\n _fail(result) {\n this.testOptions.onTestFail(this._currentTestCase, result);\n }\n\n /* Private Methods */\n\n _onWebGLInitialized(gl) {\n const vendorMasked = gl.getParameter(GL_VENDOR);\n const ext = gl.getExtension('WEBGL_debug_renderer_info');\n const vendorUnmasked = ext && gl.getParameter(ext.UNMASKED_VENDOR_WEBGL || GL_VENDOR);\n this.gpuVendor = vendorUnmasked || vendorMasked;\n }\n\n _runTest(testCase) {\n return new Promise((resolve, reject) => {\n this._currentTestCase = testCase;\n this._next = resolve;\n\n // normalize test case\n this.initTestCase(testCase);\n\n let isDone = false;\n let timeoutId = null;\n const done = () => {\n if (!isDone) {\n isDone = true;\n window.clearTimeout(timeoutId);\n this.assert(testCase);\n }\n };\n\n timeoutId = window.setTimeout(done, testCase.timeout || this.testOptions.timeout);\n\n this.runTestCase(testCase, done);\n });\n }\n}\n"],"file":"test-runner.js"}
|
package/dist/es5/utils/dom.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getBoundingBoxInPage = getBoundingBoxInPage;
|
|
7
7
|
|
|
8
8
|
function getBoundingBoxInPage(domElement) {
|
|
9
|
-
|
|
9
|
+
const bbox = domElement.getBoundingClientRect();
|
|
10
10
|
return {
|
|
11
11
|
x: window.scrollX + bbox.x,
|
|
12
12
|
y: window.scrollY + bbox.y,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/dom.js"],"names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"mappings":";;;;;;;AAEO,SAASA,oBAAT,CAA8BC,UAA9B,EAA0C;AAC/C,
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/dom.js"],"names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"mappings":";;;;;;;AAEO,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":["/* global window */\n// 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":"dom.js"}
|