@deck.gl/test-utils 8.7.0-alpha.3 → 8.7.0-beta.1
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 +85 -65
- package/dist/es5/generate-layer-tests.js.map +1 -1
- package/dist/es5/index.js +10 -10
- package/dist/es5/interaction-test-runner.js +91 -36
- package/dist/es5/interaction-test-runner.js.map +1 -1
- package/dist/es5/lifecycle-test.js +273 -125
- package/dist/es5/lifecycle-test.js.map +1 -1
- package/dist/es5/snapshot-test-runner.js +109 -70
- package/dist/es5/snapshot-test-runner.js.map +1 -1
- package/dist/es5/test-runner.js +154 -95
- 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 +12 -4
- package/dist/es5/utils/precision.js.map +1 -1
- package/dist/es5/utils/setup-gl.js +2 -4
- package/dist/es5/utils/setup-gl.js.map +1 -1
- package/dist/esm/utils/setup-gl.js +2 -5
- package/dist/esm/utils/setup-gl.js.map +1 -1
- package/package.json +3 -3
- package/src/utils/setup-gl.js +4 -7
|
@@ -7,102 +7,141 @@ 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
|
+
|
|
10
24
|
var _testRunner = _interopRequireDefault(require("./test-runner"));
|
|
11
25
|
|
|
12
26
|
var _dom = require("./utils/dom");
|
|
13
27
|
|
|
14
|
-
|
|
28
|
+
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; }
|
|
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 { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
35
|
+
|
|
36
|
+
var DEFAULT_TEST_OPTIONS = {
|
|
15
37
|
imageDiffOptions: {}
|
|
16
38
|
};
|
|
17
|
-
|
|
39
|
+
var DEFAULT_TEST_CASE = {
|
|
18
40
|
name: 'Unnamed snapshot test',
|
|
19
41
|
props: {},
|
|
20
|
-
onBeforeRender: ({
|
|
21
|
-
deck,
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
onAfterRender: ({
|
|
25
|
-
deck,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (layers.every(
|
|
42
|
+
onBeforeRender: function onBeforeRender(_ref) {
|
|
43
|
+
var deck = _ref.deck,
|
|
44
|
+
layers = _ref.layers;
|
|
45
|
+
},
|
|
46
|
+
onAfterRender: function onAfterRender(_ref2) {
|
|
47
|
+
var deck = _ref2.deck,
|
|
48
|
+
layers = _ref2.layers,
|
|
49
|
+
done = _ref2.done;
|
|
50
|
+
|
|
51
|
+
if (layers.every(function (layer) {
|
|
52
|
+
return layer.isLoaded;
|
|
53
|
+
})) {
|
|
30
54
|
done();
|
|
31
55
|
}
|
|
32
56
|
},
|
|
33
57
|
goldenImage: ''
|
|
34
58
|
};
|
|
35
59
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
super(props);
|
|
39
|
-
this.isDiffing = false;
|
|
40
|
-
Object.assign(this.testOptions, DEFAULT_TEST_OPTIONS);
|
|
41
|
-
}
|
|
60
|
+
var SnapshotTestRunner = function (_TestRunner) {
|
|
61
|
+
(0, _inherits2.default)(SnapshotTestRunner, _TestRunner);
|
|
42
62
|
|
|
43
|
-
|
|
44
|
-
return DEFAULT_TEST_CASE;
|
|
45
|
-
}
|
|
63
|
+
var _super = _createSuper(SnapshotTestRunner);
|
|
46
64
|
|
|
47
|
-
|
|
48
|
-
|
|
65
|
+
function SnapshotTestRunner(props) {
|
|
66
|
+
var _this;
|
|
49
67
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
68
|
+
(0, _classCallCheck2.default)(this, SnapshotTestRunner);
|
|
69
|
+
_this = _super.call(this, props);
|
|
70
|
+
_this.isDiffing = false;
|
|
71
|
+
Object.assign(_this.testOptions, DEFAULT_TEST_OPTIONS);
|
|
72
|
+
return _this;
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
(0, _createClass2.default)(SnapshotTestRunner, [{
|
|
76
|
+
key: "defaultTestCase",
|
|
77
|
+
get: function get() {
|
|
78
|
+
return DEFAULT_TEST_CASE;
|
|
79
|
+
}
|
|
80
|
+
}, {
|
|
81
|
+
key: "initTestCase",
|
|
82
|
+
value: function initTestCase(testCase) {
|
|
83
|
+
(0, _get2.default)((0, _getPrototypeOf2.default)(SnapshotTestRunner.prototype), "initTestCase", this).call(this, testCase);
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
if (!testCase.goldenImage) {
|
|
86
|
+
throw new Error("Test case ".concat(testCase.name, " does not have golden image"));
|
|
87
|
+
}
|
|
84
88
|
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "runTestCase",
|
|
91
|
+
value: function runTestCase(testCase, onDone) {
|
|
92
|
+
var deck = this.deck;
|
|
93
|
+
deck.setProps(_objectSpread(_objectSpread(_objectSpread({}, this.props), testCase), {}, {
|
|
94
|
+
onBeforeRender: function onBeforeRender() {
|
|
95
|
+
testCase.onBeforeRender({
|
|
96
|
+
deck: deck,
|
|
97
|
+
layers: deck.props.layers
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
onAfterRender: function onAfterRender() {
|
|
101
|
+
testCase.onAfterRender({
|
|
102
|
+
deck: deck,
|
|
103
|
+
layers: deck.props.layers,
|
|
104
|
+
done: onDone
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "shouldRender",
|
|
111
|
+
value: function shouldRender() {
|
|
112
|
+
return !this.isDiffing;
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "assert",
|
|
116
|
+
value: function assert(testCase) {
|
|
117
|
+
var _this2 = this;
|
|
85
118
|
|
|
86
|
-
|
|
87
|
-
|
|
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);
|
|
119
|
+
if (this.isDiffing) {
|
|
120
|
+
return;
|
|
97
121
|
}
|
|
98
122
|
|
|
99
|
-
this.isDiffing =
|
|
123
|
+
this.isDiffing = true;
|
|
100
124
|
|
|
101
|
-
this.
|
|
102
|
-
|
|
103
|
-
|
|
125
|
+
var diffOptions = _objectSpread(_objectSpread(_objectSpread({}, this.testOptions.imageDiffOptions), testCase.imageDiffOptions), {}, {
|
|
126
|
+
goldenImage: testCase.goldenImage,
|
|
127
|
+
region: (0, _dom.getBoundingBoxInPage)(this.deck.canvas)
|
|
128
|
+
});
|
|
104
129
|
|
|
105
|
-
|
|
130
|
+
window.browserTestDriver_captureAndDiffScreen(diffOptions).then(function (result) {
|
|
131
|
+
if (result.success) {
|
|
132
|
+
_this2._pass(result);
|
|
133
|
+
} else {
|
|
134
|
+
_this2._fail(result);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_this2.isDiffing = false;
|
|
138
|
+
|
|
139
|
+
_this2._next();
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}]);
|
|
143
|
+
return SnapshotTestRunner;
|
|
144
|
+
}(_testRunner.default);
|
|
106
145
|
|
|
107
146
|
exports.default = SnapshotTestRunner;
|
|
108
147
|
//# 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","
|
|
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","TestRunner"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAqBA;;AACA;;;;;;;;;;AAEA,IAAMA,oBAAoB,GAAG;AAC3BC,EAAAA,gBAAgB,EAAE;AADS,CAA7B;AAIA,IAAMC,iBAAiB,GAAG;AACxBC,EAAAA,IAAI,EAAE,uBADkB;AAExBC,EAAAA,KAAK,EAAE,EAFiB;AAGxBC,EAAAA,cAAc,EAAE,8BAAoB;AAAA,QAAlBC,IAAkB,QAAlBA,IAAkB;AAAA,QAAZC,MAAY,QAAZA,MAAY;AAEnC,GALuB;AAMxBC,EAAAA,aAAa,EAAE,8BAA0B;AAAA,QAAxBF,IAAwB,SAAxBA,IAAwB;AAAA,QAAlBC,MAAkB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AAEb,aAAO,CAAC,KAAKN,SAAb;AACD;;;WAED,gBAAOI,QAAP,EAAiB;AAAA;;AACf,UAAI,KAAKJ,SAAT,EAAoB;AAElB;AACD;;AACD,WAAKA,SAAL,GAAiB,IAAjB;;AAEA,UAAMQ,WAAW,iDACZ,KAAKL,WAAL,CAAiBjB,gBADL,GAEZkB,QAAQ,CAAClB,gBAFG;AAGfY,QAAAA,WAAW,EAAEM,QAAQ,CAACN,WAHP;AAIfW,QAAAA,MAAM,EAAE,+BAAqB,KAAKlB,IAAL,CAAUmB,MAA/B;AAJO,QAAjB;;AAOAC,MAAAA,MAAM,CAACC,sCAAP,CAA8CJ,WAA9C,EAA2DK,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,CAACd,SAAL,GAAiB,KAAjB;;AACA,QAAA,MAAI,CAACkB,KAAL;AACD,OAVD;AAWD;;;EAxE6CC,mB","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,14 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.default = void 0;
|
|
7
9
|
|
|
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
|
+
|
|
8
16
|
var _core = require("@deck.gl/core");
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
|
|
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), {}, {
|
|
12
31
|
id: 'deckgl-render-test',
|
|
13
32
|
width: 800,
|
|
14
33
|
height: 450,
|
|
@@ -20,126 +39,166 @@ const DEFAULT_DECK_PROPS = { ..._core.Deck.defaultProps,
|
|
|
20
39
|
views: [new _core.MapView()],
|
|
21
40
|
useDevicePixels: false,
|
|
22
41
|
debug: true
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
var DEFAULT_TEST_OPTIONS = {
|
|
45
|
+
onTestStart: function onTestStart(testCase) {
|
|
46
|
+
return console.log("# ".concat(testCase.name));
|
|
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
|
+
},
|
|
28
54
|
timeout: 2000
|
|
29
55
|
};
|
|
30
|
-
|
|
56
|
+
var DEFAULT_TEST_CASE = {
|
|
31
57
|
name: 'Unnamed test'
|
|
32
58
|
};
|
|
33
59
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
60
|
+
var TestRunner = function () {
|
|
61
|
+
function TestRunner() {
|
|
62
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
63
|
+
(0, _classCallCheck2.default)(this, TestRunner);
|
|
64
|
+
this.props = _objectSpread(_objectSpread({}, DEFAULT_DECK_PROPS), props);
|
|
39
65
|
this.isRunning = false;
|
|
40
66
|
this._testCases = [];
|
|
41
67
|
this._testCaseData = null;
|
|
42
68
|
this.isHeadless = Boolean(window.browserTestDriver_isHeadless);
|
|
43
|
-
this.testOptions = {
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
get defaultTestCase() {
|
|
48
|
-
return DEFAULT_TEST_CASE;
|
|
69
|
+
this.testOptions = _objectSpread({}, DEFAULT_TEST_OPTIONS);
|
|
49
70
|
}
|
|
50
71
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
72
|
+
(0, _createClass2.default)(TestRunner, [{
|
|
73
|
+
key: "defaultTestCase",
|
|
74
|
+
get: function get() {
|
|
75
|
+
return DEFAULT_TEST_CASE;
|
|
54
76
|
}
|
|
77
|
+
}, {
|
|
78
|
+
key: "add",
|
|
79
|
+
value: function add(testCases) {
|
|
80
|
+
if (!Array.isArray(testCases)) {
|
|
81
|
+
testCases = [testCases];
|
|
82
|
+
}
|
|
55
83
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
84
|
+
var _iterator = _createForOfIteratorHelper(testCases),
|
|
85
|
+
_step;
|
|
59
86
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
69
|
-
});
|
|
70
|
-
this.isRunning = true;
|
|
71
|
-
this._currentTestCase = null;
|
|
72
|
-
}).then(() => {
|
|
73
|
-
let promise = Promise.resolve();
|
|
87
|
+
try {
|
|
88
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
89
|
+
var testCase = _step.value;
|
|
74
90
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})
|
|
91
|
+
this._testCases.push(testCase);
|
|
92
|
+
}
|
|
93
|
+
} catch (err) {
|
|
94
|
+
_iterator.e(err);
|
|
95
|
+
} finally {
|
|
96
|
+
_iterator.f();
|
|
97
|
+
}
|
|
78
98
|
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "run",
|
|
103
|
+
value: function run() {
|
|
104
|
+
var _this = this;
|
|
105
|
+
|
|
106
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
107
|
+
Object.assign(this.testOptions, options);
|
|
108
|
+
return new Promise(function (resolve, reject) {
|
|
109
|
+
_this.deck = new _core.Deck(_objectSpread(_objectSpread({}, _this.props), {}, {
|
|
110
|
+
onWebGLInitialized: _this._onWebGLInitialized.bind(_this),
|
|
111
|
+
onLoad: resolve
|
|
112
|
+
}));
|
|
113
|
+
_this.isRunning = true;
|
|
114
|
+
_this._currentTestCase = null;
|
|
115
|
+
}).then(function () {
|
|
116
|
+
var promise = Promise.resolve();
|
|
117
|
+
|
|
118
|
+
_this._testCases.forEach(function (testCase) {
|
|
119
|
+
promise = promise.then(function () {
|
|
120
|
+
return _this._runTest(testCase);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return promise;
|
|
125
|
+
}).catch(function (error) {
|
|
126
|
+
_this._fail({
|
|
127
|
+
error: error.message
|
|
128
|
+
});
|
|
129
|
+
}).finally(function () {
|
|
130
|
+
_this.deck.finalize();
|
|
131
|
+
|
|
132
|
+
_this.deck = null;
|
|
83
133
|
});
|
|
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
|
-
}
|
|
95
134
|
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "initTestCase",
|
|
137
|
+
value: function initTestCase(testCase) {
|
|
138
|
+
for (var key in this.defaultTestCase) {
|
|
139
|
+
if (!(key in testCase)) {
|
|
140
|
+
testCase[key] = this.defaultTestCase[key];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
96
143
|
|
|
97
|
-
|
|
98
|
-
|
|
144
|
+
this.testOptions.onTestStart(testCase);
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "assert",
|
|
148
|
+
value: function assert(testCase) {
|
|
149
|
+
this.onTestPass(testCase);
|
|
99
150
|
|
|
100
|
-
|
|
101
|
-
|
|
151
|
+
this._next();
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "_pass",
|
|
155
|
+
value: function _pass(result) {
|
|
156
|
+
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
key: "_fail",
|
|
160
|
+
value: function _fail(result) {
|
|
161
|
+
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
162
|
+
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "_onWebGLInitialized",
|
|
165
|
+
value: function _onWebGLInitialized(gl) {
|
|
166
|
+
var vendorMasked = gl.getParameter(GL_VENDOR);
|
|
167
|
+
var ext = gl.getExtension('WEBGL_debug_renderer_info');
|
|
168
|
+
var vendorUnmasked = ext && gl.getParameter(ext.UNMASKED_VENDOR_WEBGL || GL_VENDOR);
|
|
169
|
+
this.gpuVendor = vendorUnmasked || vendorMasked;
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "_runTest",
|
|
173
|
+
value: function _runTest(testCase) {
|
|
174
|
+
var _this2 = this;
|
|
102
175
|
|
|
103
|
-
|
|
104
|
-
|
|
176
|
+
return new Promise(function (resolve, reject) {
|
|
177
|
+
_this2._currentTestCase = testCase;
|
|
178
|
+
_this2._next = resolve;
|
|
105
179
|
|
|
106
|
-
|
|
107
|
-
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
108
|
-
}
|
|
180
|
+
_this2.initTestCase(testCase);
|
|
109
181
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
182
|
+
var isDone = false;
|
|
183
|
+
var timeoutId = null;
|
|
113
184
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.gpuVendor = vendorUnmasked || vendorMasked;
|
|
119
|
-
}
|
|
185
|
+
var done = function done() {
|
|
186
|
+
if (!isDone) {
|
|
187
|
+
isDone = true;
|
|
188
|
+
window.clearTimeout(timeoutId);
|
|
120
189
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
};
|
|
190
|
+
_this2.assert(testCase);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
136
193
|
|
|
137
|
-
|
|
138
|
-
this.runTestCase(testCase, done);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
194
|
+
timeoutId = window.setTimeout(done, testCase.timeout || _this2.testOptions.timeout);
|
|
141
195
|
|
|
142
|
-
|
|
196
|
+
_this2.runTestCase(testCase, done);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}]);
|
|
200
|
+
return TestRunner;
|
|
201
|
+
}();
|
|
143
202
|
|
|
144
203
|
exports.default = TestRunner;
|
|
145
204
|
//# 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","
|
|
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","defaultTestCase","_next","result","gl","vendorMasked","getParameter","ext","getExtension","vendorUnmasked","UNMASKED_VENDOR_WEBGL","gpuVendor","initTestCase","isDone","timeoutId","done","clearTimeout","assert","setTimeout","runTestCase"],"mappings":";;;;;;;;;;;;;;;AAsBA;;;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,MAAlB;;AAEA,IAAMC,kBAAkB,mCACnBC,WAAKC,YADc;AAEtBC,EAAAA,EAAE,EAAE,oBAFkB;AAGtBC,EAAAA,KAAK,EAAE,GAHe;AAItBC,EAAAA,MAAM,EAAE,GAJc;AAKtBC,EAAAA,KAAK,EAAE;AAACC,IAAAA,QAAQ,EAAE,UAAX;AAAuBC,IAAAA,IAAI,EAAE,KAA7B;AAAoCC,IAAAA,GAAG,EAAE;AAAzC,GALe;AAMtBC,EAAAA,KAAK,EAAE,CAAC,IAAIC,aAAJ,EAAD,CANe;AAOtBC,EAAAA,eAAe,EAAE,KAPK;AAQtBC,EAAAA,KAAK,EAAE;AARe,EAAxB;;AAWA,IAAMC,oBAAoB,GAAG;AAE3BC,EAAAA,WAAW,EAAE,qBAAAC,QAAQ;AAAA,WAAIC,OAAO,CAACC,GAAR,aAAiBF,QAAQ,CAACG,IAA1B,EAAJ;AAAA,GAFM;AAG3BC,EAAAA,UAAU,EAAE,oBAAAJ,QAAQ;AAAA,WAAIC,OAAO,CAACC,GAAR,cAAkBF,QAAQ,CAACG,IAA3B,aAAJ;AAAA,GAHO;AAI3BE,EAAAA,UAAU,EAAE,oBAAAL,QAAQ;AAAA,WAAIC,OAAO,CAACC,GAAR,kBAAsBF,QAAQ,CAACG,IAA/B,aAAJ;AAAA,GAJO;AAO3BG,EAAAA,OAAO,EAAE;AAPkB,CAA7B;AAUA,IAAMC,iBAAiB,GAAG;AACxBJ,EAAAA,IAAI,EAAE;AADkB,CAA1B;;IAIqBK,U;AAKnB,wBAAwB;AAAA,QAAZC,KAAY,uEAAJ,EAAI;AAAA;AACtB,SAAKA,KAAL,m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,cAAc,GAAGF,GAAG,IAAIH,EAAE,CAACE,YAAH,CAAgBC,GAAG,CAACG,qBAAJ,IAA6BvE,SAA7C,CAA9B;AACA,WAAKwE,SAAL,GAAiBF,cAAc,IAAIJ,YAAnC;AACD;;;WAED,kBAASjD,QAAT,EAAmB;AAAA;;AACjB,aAAO,IAAIyB,OAAJ,CAAY,UAACC,OAAD,EAAUC,MAAV,EAAqB;AACtC,QAAA,MAAI,CAACM,gBAAL,GAAwBjC,QAAxB;AACA,QAAA,MAAI,CAAC8C,KAAL,GAAapB,OAAb;;AAGA,QAAA,MAAI,CAAC8B,YAAL,CAAkBxD,QAAlB;;AAEA,YAAIyD,MAAM,GAAG,KAAb;AACA,YAAIC,SAAS,GAAG,IAAhB;;AACA,YAAMC,IAAI,GAAG,SAAPA,IAAO,GAAM;AACjB,cAAI,CAACF,MAAL,EAAa;AACXA,YAAAA,MAAM,GAAG,IAAT;AACA1C,YAAAA,MAAM,CAAC6C,YAAP,CAAoBF,SAApB;;AACA,YAAA,MAAI,CAACG,MAAL,CAAY7D,QAAZ;AACD;AACF,SAND;;AAQA0D,QAAAA,SAAS,GAAG3C,MAAM,CAAC+C,UAAP,CAAkBH,IAAlB,EAAwB3D,QAAQ,CAACM,OAAT,IAAoB,MAAI,CAACW,WAAL,CAAiBX,OAA7D,CAAZ;;AAEA,QAAA,MAAI,CAACyD,WAAL,CAAiB/D,QAAjB,EAA2B2D,IAA3B;AACD,OApBM,CAAP;AAqBD","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
|
+
var 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,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":["/* 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"}
|