scandit-datacapture-frameworks-core 8.3.1 → 8.4.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/__mocks__/Defaults.ts +9 -0
- package/dist/dts/camera/Camera.d.ts +6 -1
- package/dist/dts/camera/CameraSettings.d.ts +3 -0
- package/dist/dts/camera/PinchToZoom.d.ts +20 -0
- package/dist/dts/camera/PrivateZoomGestureDeserializer.d.ts +5 -0
- package/dist/dts/camera/ZoomGesture.d.ts +0 -3
- package/dist/dts/camera/ZoomSwitchControl.d.ts +28 -0
- package/dist/dts/camera/ZoomSwitchOrientation.d.ts +5 -0
- package/dist/dts/camera/controller/CameraController.d.ts +4 -0
- package/dist/dts/camera/index.d.ts +3 -0
- package/dist/dts/camerahelpers/ZoomListenerEvents.d.ts +3 -0
- package/dist/dts/camerahelpers/index.d.ts +1 -0
- package/dist/dts/defaults/CoreDefaults.d.ts +11 -1
- package/dist/dts/frame/ZoomListener.d.ts +3 -0
- package/dist/dts/frame/index.d.ts +1 -0
- package/dist/dts/generated/CoreProxyAdapter.d.ts +17 -0
- package/dist/dts/view/DataCaptureView.d.ts +6 -1
- package/dist/dts/view/DataCaptureViewController.d.ts +1 -0
- package/dist/index.js +378 -83
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/test/CameraSettings.test.ts +44 -0
- package/test/ZoomSwitchControl.test.ts +130 -0
package/package.json
CHANGED
|
@@ -306,6 +306,50 @@ describe('CameraSettings', () => {
|
|
|
306
306
|
});
|
|
307
307
|
});
|
|
308
308
|
|
|
309
|
+
describe('zoomLevels', () => {
|
|
310
|
+
it('initializes with default zoomLevels from defaults', () => {
|
|
311
|
+
const settings = new CameraSettings();
|
|
312
|
+
expect(settings.zoomLevels).toEqual([1, 2]);
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('can be set to custom zoom levels', () => {
|
|
316
|
+
const settings = new CameraSettings();
|
|
317
|
+
settings.zoomLevels = [0.5, 1, 2, 3];
|
|
318
|
+
expect(settings.zoomLevels).toEqual([0.5, 1, 2, 3]);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it('is deserialized from JSON', () => {
|
|
322
|
+
const json = {
|
|
323
|
+
preferredResolution: 'auto',
|
|
324
|
+
zoomFactor: 1,
|
|
325
|
+
zoomGestureZoomFactor: 2,
|
|
326
|
+
zoomLevels: [1, 2, 5],
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
330
|
+
expect(settings.zoomLevels).toEqual([1, 2, 5]);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('defaults to [1, 2] when absent from JSON', () => {
|
|
334
|
+
const json = {
|
|
335
|
+
preferredResolution: 'auto',
|
|
336
|
+
zoomFactor: 1,
|
|
337
|
+
zoomGestureZoomFactor: 2,
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
341
|
+
expect(settings.zoomLevels).toEqual([1, 2]);
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
it('is serialized to JSON', () => {
|
|
345
|
+
const settings = new CameraSettings();
|
|
346
|
+
settings.zoomLevels = [0.5, 1, 3];
|
|
347
|
+
|
|
348
|
+
const json = JSON.parse(JSON.stringify(settings));
|
|
349
|
+
expect(json.zoomLevels).toEqual([0.5, 1, 3]);
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
|
|
309
353
|
describe('copy constructor', () => {
|
|
310
354
|
it('copies all settings including focus sub-fields', () => {
|
|
311
355
|
const original = new CameraSettings();
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach } from '@jest/globals';
|
|
2
|
+
import { ZoomSwitchControl, ZoomSwitchOrientation } from '../src';
|
|
3
|
+
import { loadMockDefaults } from '../__mocks__/Defaults';
|
|
4
|
+
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
loadMockDefaults();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe('ZoomSwitchControl', () => {
|
|
10
|
+
describe('default constructor', () => {
|
|
11
|
+
it('initializes with default v2 properties', () => {
|
|
12
|
+
const control = new ZoomSwitchControl();
|
|
13
|
+
|
|
14
|
+
expect(control.orientation).toBe(ZoomSwitchOrientation.Horizontal);
|
|
15
|
+
expect(control.isAlwaysExpanded).toBe(false);
|
|
16
|
+
expect(control.isExpanded).toBe(false);
|
|
17
|
+
expect(control.accessibilityLabel).toBe('Zoom <level>');
|
|
18
|
+
expect(control.accessibilityHint).toBe('Adjusts the camera zoom level');
|
|
19
|
+
expect(control.selectedZoomLevel).toBe(1);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('initializes with null legacy accessibility properties', () => {
|
|
23
|
+
const control = new ZoomSwitchControl();
|
|
24
|
+
|
|
25
|
+
expect(control.contentDescriptionWhenZoomedOut).toBeNull();
|
|
26
|
+
expect(control.contentDescriptionWhenZoomedIn).toBeNull();
|
|
27
|
+
expect(control.accessibilityLabelWhenZoomedOut).toBeNull();
|
|
28
|
+
expect(control.accessibilityLabelWhenZoomedIn).toBeNull();
|
|
29
|
+
expect(control.accessibilityHintWhenZoomedOut).toBeNull();
|
|
30
|
+
expect(control.accessibilityHintWhenZoomedIn).toBeNull();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('v2 property setters', () => {
|
|
35
|
+
it('allows setting orientation to Vertical', () => {
|
|
36
|
+
const control = new ZoomSwitchControl();
|
|
37
|
+
control.orientation = ZoomSwitchOrientation.Vertical;
|
|
38
|
+
expect(control.orientation).toBe(ZoomSwitchOrientation.Vertical);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('allows setting isAlwaysExpanded', () => {
|
|
42
|
+
const control = new ZoomSwitchControl();
|
|
43
|
+
control.isAlwaysExpanded = true;
|
|
44
|
+
expect(control.isAlwaysExpanded).toBe(true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('allows setting isExpanded', () => {
|
|
48
|
+
const control = new ZoomSwitchControl();
|
|
49
|
+
control.isExpanded = true;
|
|
50
|
+
expect(control.isExpanded).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('allows setting accessibilityLabel', () => {
|
|
54
|
+
const control = new ZoomSwitchControl();
|
|
55
|
+
control.accessibilityLabel = 'Camera zoom';
|
|
56
|
+
expect(control.accessibilityLabel).toBe('Camera zoom');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('allows setting accessibilityHint', () => {
|
|
60
|
+
const control = new ZoomSwitchControl();
|
|
61
|
+
control.accessibilityHint = 'Double tap to zoom';
|
|
62
|
+
expect(control.accessibilityHint).toBe('Double tap to zoom');
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('selectedZoomLevel', () => {
|
|
67
|
+
it('is read-only (no public setter)', () => {
|
|
68
|
+
const control = new ZoomSwitchControl();
|
|
69
|
+
expect(control.selectedZoomLevel).toBe(1);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('JSON serialization', () => {
|
|
74
|
+
it('serializes v2 properties with correct JSON keys', () => {
|
|
75
|
+
const control = new ZoomSwitchControl();
|
|
76
|
+
control.orientation = ZoomSwitchOrientation.Vertical;
|
|
77
|
+
control.isAlwaysExpanded = true;
|
|
78
|
+
control.isExpanded = true;
|
|
79
|
+
control.accessibilityLabel = 'Camera zoom';
|
|
80
|
+
control.accessibilityHint = 'Double tap';
|
|
81
|
+
|
|
82
|
+
const json = JSON.parse(JSON.stringify(control));
|
|
83
|
+
|
|
84
|
+
expect(json.type).toBe('zoom');
|
|
85
|
+
expect(json.orientation).toBe('vertical');
|
|
86
|
+
expect(json.isAlwaysExpanded).toBe(true);
|
|
87
|
+
expect(json.isExpanded).toBe(true);
|
|
88
|
+
expect(json.accessibilityLabel).toBe('Camera zoom');
|
|
89
|
+
expect(json.accessibilityHint).toBe('Double tap');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('does not serialize selectedZoomLevel', () => {
|
|
93
|
+
const control = new ZoomSwitchControl();
|
|
94
|
+
|
|
95
|
+
const json = JSON.parse(JSON.stringify(control));
|
|
96
|
+
|
|
97
|
+
expect(json.selectedZoomLevel).toBeUndefined();
|
|
98
|
+
expect(json._selectedZoomLevel).toBeUndefined();
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('serializes default values correctly', () => {
|
|
102
|
+
const control = new ZoomSwitchControl();
|
|
103
|
+
|
|
104
|
+
const json = JSON.parse(JSON.stringify(control));
|
|
105
|
+
|
|
106
|
+
expect(json.orientation).toBe('horizontal');
|
|
107
|
+
expect(json.isAlwaysExpanded).toBe(false);
|
|
108
|
+
expect(json.isExpanded).toBe(false);
|
|
109
|
+
expect(json.accessibilityLabel).toBe('Zoom <level>');
|
|
110
|
+
expect(json.accessibilityHint).toBe('Adjusts the camera zoom level');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('still serializes legacy icon properties', () => {
|
|
114
|
+
const control = new ZoomSwitchControl();
|
|
115
|
+
|
|
116
|
+
const json = JSON.parse(JSON.stringify(control));
|
|
117
|
+
|
|
118
|
+
expect(json.icon).toBeDefined();
|
|
119
|
+
expect(json.icon.zoomedOut).toBeDefined();
|
|
120
|
+
expect(json.icon.zoomedIn).toBeDefined();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe('ZoomSwitchOrientation', () => {
|
|
126
|
+
it('has correct string values for JSON serialization', () => {
|
|
127
|
+
expect(ZoomSwitchOrientation.Horizontal).toBe('horizontal');
|
|
128
|
+
expect(ZoomSwitchOrientation.Vertical).toBe('vertical');
|
|
129
|
+
});
|
|
130
|
+
});
|