scandit-datacapture-frameworks-core 8.4.0 → 8.5.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 +61 -61
- package/__mocks__/ScanditDataCaptureCore.ts +7 -5
- package/dist/dts/LicenseInfo.d.ts +2 -2
- package/dist/dts/camera/Camera.d.ts +7 -7
- package/dist/dts/camera/CameraSettings.d.ts +5 -5
- package/dist/dts/camera/FocusGesture.d.ts +2 -2
- package/dist/dts/camera/FocusGestureListener.d.ts +2 -2
- package/dist/dts/camera/PinchToZoom.d.ts +4 -4
- package/dist/dts/camera/PrivateFocusGestureDeserializer.d.ts +1 -1
- package/dist/dts/camera/PrivateZoomGestureDeserializer.d.ts +1 -1
- package/dist/dts/camera/SwipeToZoom.d.ts +4 -4
- package/dist/dts/camera/TapToFocus.d.ts +5 -5
- package/dist/dts/camera/TorchSwitchControl.d.ts +2 -2
- package/dist/dts/camera/ZoomGesture.d.ts +1 -1
- package/dist/dts/camera/ZoomGestureListener.d.ts +1 -1
- package/dist/dts/camera/ZoomSwitchControl.d.ts +3 -3
- package/dist/dts/camera/controller/CameraController.d.ts +4 -4
- package/dist/dts/camera/index.d.ts +24 -24
- package/dist/dts/camerahelpers/CameraOwnershipHelper.d.ts +3 -3
- package/dist/dts/camerahelpers/CameraOwnershipManager.d.ts +2 -2
- package/dist/dts/camerahelpers/index.d.ts +8 -8
- package/dist/dts/common/Brush.d.ts +2 -2
- package/dist/dts/common/MarginsWithUnit.d.ts +2 -2
- package/dist/dts/common/NumberWithUnit.d.ts +2 -2
- package/dist/dts/common/Observable.d.ts +1 -1
- package/dist/dts/common/Payload.d.ts +3 -3
- package/dist/dts/common/Point.d.ts +1 -1
- package/dist/dts/common/PointWithUnit.d.ts +2 -2
- package/dist/dts/common/Quadrilateral.d.ts +2 -2
- package/dist/dts/common/Rect.d.ts +3 -3
- package/dist/dts/common/RectWithUnit.d.ts +3 -3
- package/dist/dts/common/ScanIntention.d.ts +3 -0
- package/dist/dts/common/ScanditIcon.d.ts +4 -4
- package/dist/dts/common/ScanditIconBuilder.d.ts +4 -4
- package/dist/dts/common/ScanditIconType.d.ts +5 -1
- package/dist/dts/common/SelectionMode.d.ts +5 -0
- package/dist/dts/common/Size.d.ts +1 -1
- package/dist/dts/common/SizeWithAspect.d.ts +2 -2
- package/dist/dts/common/SizeWithUnit.d.ts +2 -2
- package/dist/dts/common/SizeWithUnitAndAspect.d.ts +5 -5
- package/dist/dts/common/index.d.ts +57 -55
- package/dist/dts/context/DataCaptureComponent.d.ts +1 -1
- package/dist/dts/context/DataCaptureContextListener.d.ts +2 -2
- package/dist/dts/context/DataCaptureContextSettings.d.ts +3 -3
- package/dist/dts/context/DataCaptureMode.d.ts +2 -2
- package/dist/dts/context/index.d.ts +12 -12
- package/dist/dts/controllers/index.d.ts +1 -1
- package/dist/dts/defaults/CoreDefaults.d.ts +12 -3
- package/dist/dts/defaults/index.d.ts +3 -3
- package/dist/dts/defaults/loadCoreDefaults.d.ts +1 -1
- package/dist/dts/feedback/Sound.d.ts +1 -1
- package/dist/dts/feedback/Vibration.d.ts +3 -2
- package/dist/dts/feedback/VibrationType.d.ts +1 -0
- package/dist/dts/feedback/index.d.ts +7 -7
- package/dist/dts/frame/FrameData.d.ts +1 -1
- package/dist/dts/frame/FrameDataSettingsBuilder.d.ts +1 -1
- package/dist/dts/frame/FrameSource.d.ts +4 -4
- package/dist/dts/frame/FrameSourceListener.d.ts +2 -2
- package/dist/dts/frame/ImageFrameSource.d.ts +8 -7
- package/dist/dts/frame/MacroModeListener.d.ts +1 -1
- package/dist/dts/frame/TorchListener.d.ts +1 -1
- package/dist/dts/frame/index.d.ts +13 -13
- package/dist/dts/helpers/index.d.ts +1 -1
- package/dist/dts/locationselection/RadiusLocationSelection.d.ts +3 -3
- package/dist/dts/locationselection/RectangularLocationSelection.d.ts +3 -3
- package/dist/dts/locationselection/index.d.ts +6 -6
- package/dist/dts/proxies/NativeProxy.d.ts +2 -2
- package/dist/dts/proxies/index.d.ts +5 -5
- package/dist/dts/proxy-types.d.ts +1 -1
- package/dist/dts/serializable/DefaultSerializable.d.ts +1 -1
- package/dist/dts/serializable/index.d.ts +7 -7
- package/dist/dts/view/Control.d.ts +2 -2
- package/dist/dts/view/ControlImage.d.ts +1 -1
- package/dist/dts/view/DataCaptureOverlay.d.ts +2 -2
- package/dist/dts/view/DataCaptureViewController.d.ts +7 -7
- package/dist/dts/view/DataCaptureViewListener.d.ts +2 -2
- package/dist/dts/view/index.d.ts +7 -7
- package/dist/dts/viewfinder/AimerViewfinder.d.ts +3 -3
- package/dist/dts/viewfinder/LaserlineViewfinder.d.ts +3 -3
- package/dist/dts/viewfinder/RectangularViewfinderAnimation.d.ts +1 -1
- package/dist/dts/viewfinder/index.d.ts +9 -9
- package/dist/index.js +1696 -1651
- package/dist/index.js.map +1 -1
- package/jest.config.js +5 -15
- package/package.json +1 -1
- package/test/Camera.test.ts +18 -8
- package/test/CameraSettings.test.ts +340 -341
- package/test/ProxyRegistration.test.ts +6 -7
- package/test/ZoomSwitchControl.test.ts +100 -100
- package/test/generated/CoreProxyAdapter.test.ts +4 -7
|
@@ -8,372 +8,371 @@ import { MacroMode } from '../src/camera/MacroMode';
|
|
|
8
8
|
import { loadMockDefaults, mockCoreDefaultsData } from '../__mocks__/Defaults';
|
|
9
9
|
|
|
10
10
|
beforeEach(() => {
|
|
11
|
-
|
|
11
|
+
loadMockDefaults();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
describe('CameraSettings', () => {
|
|
15
|
+
describe('default constructor', () => {
|
|
16
|
+
it('initializes all fields from mock defaults', () => {
|
|
17
|
+
const settings = new CameraSettings();
|
|
18
|
+
|
|
19
|
+
expect(settings.preferredResolution).toBe(VideoResolution.Auto);
|
|
20
|
+
expect(settings.zoomFactor).toBe(1);
|
|
21
|
+
expect(settings.zoomGestureZoomFactor).toBe(2);
|
|
22
|
+
expect(settings.torchLevel).toBe(1);
|
|
23
|
+
expect(settings.macroMode).toBe('auto');
|
|
24
|
+
expect(settings.adaptiveExposure).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('initializes focus sub-fields via getProperty', () => {
|
|
28
|
+
const settings = new CameraSettings();
|
|
29
|
+
|
|
30
|
+
expect(settings.focusRange).toBe('near');
|
|
31
|
+
expect(settings.focusGestureStrategy).toBe('manualUntilCapture');
|
|
32
|
+
expect(settings.shouldPreferSmoothAutoFocus).toBe(false);
|
|
33
|
+
// manualLensPosition and focusStrategy are optional — undefined until explicitly set
|
|
34
|
+
expect(settings.getProperty('manualLensPosition')).toBeUndefined();
|
|
35
|
+
expect(settings.getProperty('focusStrategy')).toBeUndefined();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('fromJSON — native format (flat top-level + properties bag)', () => {
|
|
40
|
+
// This is what Android and iOS actually send.
|
|
41
|
+
// Focus basics (focusRange, focusGestureStrategy, shouldPreferSmoothAutoFocus) are
|
|
42
|
+
// at the top level. manualLensPosition and focusStrategy come in the properties bag.
|
|
43
|
+
// iOS additionally sends "range" in properties (same value as focusRange).
|
|
44
|
+
it('deserializes top-level focus fields and properties bag', () => {
|
|
45
|
+
const json = {
|
|
46
|
+
preferredResolution: 'fullHd',
|
|
47
|
+
zoomFactor: 1.5,
|
|
48
|
+
zoomGestureZoomFactor: 3,
|
|
49
|
+
focusRange: 'full',
|
|
50
|
+
focusGestureStrategy: 'autoFocus',
|
|
51
|
+
shouldPreferSmoothAutoFocus: true,
|
|
52
|
+
macroMode: 'disabled',
|
|
53
|
+
adaptiveExposure: true,
|
|
54
|
+
torchLevel: 0.8,
|
|
55
|
+
properties: {
|
|
56
|
+
range: 'full', // iOS sends this (same as focusRange)
|
|
57
|
+
manualLensPosition: 0.5,
|
|
58
|
+
focusStrategy: 'autoFocus',
|
|
59
|
+
overwriteWithHighestResolution: true,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
64
|
+
|
|
65
|
+
expect(settings.preferredResolution).toBe('fullHd');
|
|
66
|
+
expect(settings.zoomFactor).toBe(1.5);
|
|
67
|
+
expect(settings.zoomGestureZoomFactor).toBe(3);
|
|
68
|
+
expect(settings.macroMode).toBe('disabled');
|
|
69
|
+
expect(settings.adaptiveExposure).toBe(true);
|
|
70
|
+
expect(settings.torchLevel).toBe(0.8);
|
|
71
|
+
|
|
72
|
+
// All focus properties end up in the focus bag
|
|
73
|
+
expect(settings.focusRange).toBe('full');
|
|
74
|
+
expect(settings.focusGestureStrategy).toBe('autoFocus');
|
|
75
|
+
expect(settings.shouldPreferSmoothAutoFocus).toBe(true);
|
|
76
|
+
expect(settings.getProperty('range')).toBe('full');
|
|
77
|
+
expect(settings.getProperty('manualLensPosition')).toBe(0.5);
|
|
78
|
+
expect(settings.getProperty('focusStrategy')).toBe('autoFocus');
|
|
79
|
+
// Non-focus property goes to top-level field
|
|
80
|
+
expect(settings.getProperty('overwriteWithHighestResolution')).toBe(true);
|
|
81
|
+
});
|
|
15
82
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
83
|
+
it('focus properties from properties bag all route to the focus bag', () => {
|
|
84
|
+
const json = {
|
|
85
|
+
preferredResolution: 'auto',
|
|
86
|
+
zoomFactor: 1,
|
|
87
|
+
zoomGestureZoomFactor: 2,
|
|
88
|
+
properties: {
|
|
89
|
+
range: 'near',
|
|
90
|
+
manualLensPosition: 0.3,
|
|
91
|
+
focusStrategy: 'onlyOnRequest',
|
|
92
|
+
focusGestureStrategy: 'manualUntilCapture',
|
|
93
|
+
shouldPreferSmoothAutoFocus: false,
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
98
|
+
|
|
99
|
+
// All focusHiddenProperties members routed to focus bag regardless of source
|
|
100
|
+
expect(settings.getProperty('range')).toBe('near');
|
|
101
|
+
expect(settings.focusRange).toBe('near');
|
|
102
|
+
expect(settings.getProperty('manualLensPosition')).toBe(0.3);
|
|
103
|
+
expect(settings.getProperty('focusStrategy')).toBe('onlyOnRequest');
|
|
104
|
+
expect(settings.getProperty('focusGestureStrategy')).toBe('manualUntilCapture');
|
|
105
|
+
expect(settings.focusGestureStrategy).toBe('manualUntilCapture');
|
|
106
|
+
expect(settings.getProperty('shouldPreferSmoothAutoFocus')).toBe(false);
|
|
107
|
+
expect(settings.shouldPreferSmoothAutoFocus).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('fromJSON — Android format (no range in properties)', () => {
|
|
112
|
+
// Android CameraSettingsPropertiesDefaults does NOT include "range" in the properties bag.
|
|
113
|
+
// Only manualLensPosition and focusStrategy are sent. focus.range must come from
|
|
114
|
+
// the top-level focusRange field, and getProperty('range') must stay consistent.
|
|
115
|
+
it('sets focus.range from top-level focusRange when range is absent from properties', () => {
|
|
116
|
+
const json = {
|
|
117
|
+
preferredResolution: 'auto',
|
|
118
|
+
zoomFactor: 1,
|
|
119
|
+
zoomGestureZoomFactor: 2,
|
|
120
|
+
focusRange: 'full',
|
|
121
|
+
focusGestureStrategy: 'manualUntilCapture',
|
|
122
|
+
shouldPreferSmoothAutoFocus: false,
|
|
123
|
+
macroMode: 'auto',
|
|
124
|
+
adaptiveExposure: false,
|
|
125
|
+
torchLevel: 1,
|
|
126
|
+
properties: {
|
|
127
|
+
manualLensPosition: 0.2,
|
|
128
|
+
focusStrategy: 'onlyOnRequest',
|
|
129
|
+
// no "range" key — Android does not send it
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
134
|
+
|
|
135
|
+
expect(settings.focusRange).toBe('full');
|
|
136
|
+
// getProperty('range') reads from the same focus bag as focusRange
|
|
137
|
+
expect(settings.getProperty('range')).toBe('full');
|
|
138
|
+
expect(settings.getProperty('manualLensPosition')).toBe(0.2);
|
|
139
|
+
expect(settings.getProperty('focusStrategy')).toBe('onlyOnRequest');
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe('fromJSON — sparse properties bag (null-filtered by native)', () => {
|
|
144
|
+
// Both Android and iOS filter null values from the properties bag before sending.
|
|
145
|
+
// When manualLensPosition or focusStrategy are null on the native side, they are
|
|
146
|
+
// absent from properties entirely. The TS side must fall back to coreDefaults.
|
|
147
|
+
it('leaves manualLensPosition and focusStrategy as undefined when absent from properties', () => {
|
|
148
|
+
const json = {
|
|
149
|
+
preferredResolution: 'auto',
|
|
150
|
+
zoomFactor: 1,
|
|
151
|
+
zoomGestureZoomFactor: 2,
|
|
152
|
+
properties: {
|
|
153
|
+
// manualLensPosition and focusStrategy absent (filtered as null by native)
|
|
154
|
+
overwriteWithHighestResolution: false,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
159
|
+
|
|
160
|
+
// Not present in properties bag — remain undefined (not defaulted from coreDefaults)
|
|
161
|
+
expect(settings.getProperty('manualLensPosition')).toBeUndefined();
|
|
162
|
+
expect(settings.getProperty('focusStrategy')).toBeUndefined();
|
|
38
163
|
});
|
|
39
164
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
expect(settings.getProperty('overwriteWithHighestResolution')).toBe(true);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('focus properties from properties bag all route to the focus bag', () => {
|
|
85
|
-
const json = {
|
|
86
|
-
preferredResolution: 'auto',
|
|
87
|
-
zoomFactor: 1,
|
|
88
|
-
zoomGestureZoomFactor: 2,
|
|
89
|
-
properties: {
|
|
90
|
-
range: 'near',
|
|
91
|
-
manualLensPosition: 0.3,
|
|
92
|
-
focusStrategy: 'onlyOnRequest',
|
|
93
|
-
focusGestureStrategy: 'manualUntilCapture',
|
|
94
|
-
shouldPreferSmoothAutoFocus: false,
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const settings = (CameraSettings as any).fromJSON(json);
|
|
99
|
-
|
|
100
|
-
// All focusHiddenProperties members routed to focus bag regardless of source
|
|
101
|
-
expect(settings.getProperty('range')).toBe('near');
|
|
102
|
-
expect(settings.focusRange).toBe('near');
|
|
103
|
-
expect(settings.getProperty('manualLensPosition')).toBe(0.3);
|
|
104
|
-
expect(settings.getProperty('focusStrategy')).toBe('onlyOnRequest');
|
|
105
|
-
expect(settings.getProperty('focusGestureStrategy')).toBe('manualUntilCapture');
|
|
106
|
-
expect(settings.focusGestureStrategy).toBe('manualUntilCapture');
|
|
107
|
-
expect(settings.getProperty('shouldPreferSmoothAutoFocus')).toBe(false);
|
|
108
|
-
expect(settings.shouldPreferSmoothAutoFocus).toBe(false);
|
|
109
|
-
});
|
|
165
|
+
it('leaves focus basics as undefined when top-level focus fields are absent from JSON', () => {
|
|
166
|
+
// In practice native always sends these fields, but when absent fromJSON does not
|
|
167
|
+
// fall back to defaults — callers are expected to provide them.
|
|
168
|
+
const json = {
|
|
169
|
+
preferredResolution: 'auto',
|
|
170
|
+
zoomFactor: 1,
|
|
171
|
+
zoomGestureZoomFactor: 2,
|
|
172
|
+
properties: {},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
176
|
+
|
|
177
|
+
expect(settings.focusRange).toBeUndefined();
|
|
178
|
+
expect(settings.focusGestureStrategy).toBeUndefined();
|
|
179
|
+
expect(settings.shouldPreferSmoothAutoFocus).toBeUndefined();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
describe('parseDefaults — new fields with fallbacks', () => {
|
|
184
|
+
// parseDefaults (CoreDefaults.ts) applies hardcoded fallbacks for fields introduced
|
|
185
|
+
// after the initial release. Older native builds may omit torchLevel, macroMode,
|
|
186
|
+
// adaptiveExposure, manualLensPosition, focusStrategy from the defaults JSON.
|
|
187
|
+
// Tested via parseDefaults directly since loadCoreDefaults uses bindInstanceIfNotExists
|
|
188
|
+
// and won't replace already-loaded defaults.
|
|
189
|
+
it('uses hardcoded fallbacks when new fields are absent from native defaults JSON', () => {
|
|
190
|
+
// Build from the full mock so parseDefaults has all the sections it needs,
|
|
191
|
+
// then strip the new Camera.Settings fields to simulate an older native build.
|
|
192
|
+
const { torchLevel, macroMode, adaptiveExposure, manualLensPosition, focusStrategy, ...oldSettings } =
|
|
193
|
+
mockCoreDefaultsData.Camera.Settings;
|
|
194
|
+
const oldNativeData = {
|
|
195
|
+
...mockCoreDefaultsData,
|
|
196
|
+
Camera: { ...mockCoreDefaultsData.Camera, Settings: oldSettings },
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const defaults = parseDefaults(oldNativeData);
|
|
200
|
+
|
|
201
|
+
expect(defaults.Camera.Settings.torchLevel).toBe(1.0); // ?? 1.0
|
|
202
|
+
expect(defaults.Camera.Settings.macroMode).toBe('auto'); // ?? 'auto'
|
|
203
|
+
expect(defaults.Camera.Settings.adaptiveExposure).toBe(false); // ?? false
|
|
204
|
+
expect(defaults.Camera.Settings.manualLensPosition).toBe(0); // ?? 0
|
|
205
|
+
expect(defaults.Camera.Settings.focusStrategy).toBe('auto'); // ?? 'auto'
|
|
110
206
|
});
|
|
111
207
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
expect(settings.focusRange).toBe('full');
|
|
137
|
-
// getProperty('range') reads from the same focus bag as focusRange
|
|
138
|
-
expect(settings.getProperty('range')).toBe('full');
|
|
139
|
-
expect(settings.getProperty('manualLensPosition')).toBe(0.2);
|
|
140
|
-
expect(settings.getProperty('focusStrategy')).toBe('onlyOnRequest');
|
|
141
|
-
});
|
|
208
|
+
it('reads new fields when present in native defaults JSON', () => {
|
|
209
|
+
const newNativeData = {
|
|
210
|
+
...mockCoreDefaultsData,
|
|
211
|
+
Camera: {
|
|
212
|
+
...mockCoreDefaultsData.Camera,
|
|
213
|
+
Settings: {
|
|
214
|
+
...mockCoreDefaultsData.Camera.Settings,
|
|
215
|
+
torchLevel: 0.5,
|
|
216
|
+
macroMode: 'disabled',
|
|
217
|
+
adaptiveExposure: true,
|
|
218
|
+
manualLensPosition: 0.8,
|
|
219
|
+
focusStrategy: 'autoFocus',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const defaults = parseDefaults(newNativeData);
|
|
225
|
+
|
|
226
|
+
expect(defaults.Camera.Settings.torchLevel).toBe(0.5);
|
|
227
|
+
expect(defaults.Camera.Settings.macroMode).toBe('disabled');
|
|
228
|
+
expect(defaults.Camera.Settings.adaptiveExposure).toBe(true);
|
|
229
|
+
expect(defaults.Camera.Settings.manualLensPosition).toBe(0.8);
|
|
230
|
+
expect(defaults.Camera.Settings.focusStrategy).toBe('autoFocus');
|
|
142
231
|
});
|
|
232
|
+
});
|
|
143
233
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
properties: {
|
|
154
|
-
// manualLensPosition and focusStrategy absent (filtered as null by native)
|
|
155
|
-
overwriteWithHighestResolution: false,
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const settings = (CameraSettings as any).fromJSON(json);
|
|
160
|
-
|
|
161
|
-
// Not present in properties bag — remain undefined (not defaulted from coreDefaults)
|
|
162
|
-
expect(settings.getProperty('manualLensPosition')).toBeUndefined();
|
|
163
|
-
expect(settings.getProperty('focusStrategy')).toBeUndefined();
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('leaves focus basics as undefined when top-level focus fields are absent from JSON', () => {
|
|
167
|
-
// In practice native always sends these fields, but when absent fromJSON does not
|
|
168
|
-
// fall back to defaults — callers are expected to provide them.
|
|
169
|
-
const json = {
|
|
170
|
-
preferredResolution: 'auto',
|
|
171
|
-
zoomFactor: 1,
|
|
172
|
-
zoomGestureZoomFactor: 2,
|
|
173
|
-
properties: {},
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const settings = (CameraSettings as any).fromJSON(json);
|
|
177
|
-
|
|
178
|
-
expect(settings.focusRange).toBeUndefined();
|
|
179
|
-
expect(settings.focusGestureStrategy).toBeUndefined();
|
|
180
|
-
expect(settings.shouldPreferSmoothAutoFocus).toBeUndefined();
|
|
181
|
-
});
|
|
234
|
+
describe('fromJSON — missing optional fields fall back to defaults', () => {
|
|
235
|
+
it('does not crash when focus, properties, and optional fields are all absent', () => {
|
|
236
|
+
const json = {
|
|
237
|
+
preferredResolution: 'auto',
|
|
238
|
+
zoomFactor: 1,
|
|
239
|
+
zoomGestureZoomFactor: 2,
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
expect(() => (CameraSettings as any).fromJSON(json)).not.toThrow();
|
|
182
243
|
});
|
|
183
244
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
...mockCoreDefaultsData,
|
|
197
|
-
Camera: { ...mockCoreDefaultsData.Camera, Settings: oldSettings },
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const defaults = parseDefaults(oldNativeData);
|
|
201
|
-
|
|
202
|
-
expect(defaults.Camera.Settings.torchLevel).toBe(1.0); // ?? 1.0
|
|
203
|
-
expect(defaults.Camera.Settings.macroMode).toBe('auto'); // ?? 'auto'
|
|
204
|
-
expect(defaults.Camera.Settings.adaptiveExposure).toBe(false); // ?? false
|
|
205
|
-
expect(defaults.Camera.Settings.manualLensPosition).toBe(0); // ?? 0
|
|
206
|
-
expect(defaults.Camera.Settings.focusStrategy).toBe('auto'); // ?? 'auto'
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('reads new fields when present in native defaults JSON', () => {
|
|
210
|
-
const newNativeData = {
|
|
211
|
-
...mockCoreDefaultsData,
|
|
212
|
-
Camera: {
|
|
213
|
-
...mockCoreDefaultsData.Camera,
|
|
214
|
-
Settings: {
|
|
215
|
-
...mockCoreDefaultsData.Camera.Settings,
|
|
216
|
-
torchLevel: 0.5,
|
|
217
|
-
macroMode: 'disabled',
|
|
218
|
-
adaptiveExposure: true,
|
|
219
|
-
manualLensPosition: 0.8,
|
|
220
|
-
focusStrategy: 'autoFocus',
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const defaults = parseDefaults(newNativeData);
|
|
226
|
-
|
|
227
|
-
expect(defaults.Camera.Settings.torchLevel).toBe(0.5);
|
|
228
|
-
expect(defaults.Camera.Settings.macroMode).toBe('disabled');
|
|
229
|
-
expect(defaults.Camera.Settings.adaptiveExposure).toBe(true);
|
|
230
|
-
expect(defaults.Camera.Settings.manualLensPosition).toBe(0.8);
|
|
231
|
-
expect(defaults.Camera.Settings.focusStrategy).toBe('autoFocus');
|
|
232
|
-
});
|
|
245
|
+
it('uses defaults for macroMode, adaptiveExposure, torchLevel when absent', () => {
|
|
246
|
+
const json = {
|
|
247
|
+
preferredResolution: 'auto',
|
|
248
|
+
zoomFactor: 1,
|
|
249
|
+
zoomGestureZoomFactor: 2,
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
253
|
+
|
|
254
|
+
expect(settings.torchLevel).toBe(1);
|
|
255
|
+
expect(settings.macroMode).toBe('auto');
|
|
256
|
+
expect(settings.adaptiveExposure).toBe(false);
|
|
233
257
|
});
|
|
234
258
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
expect(settings.getProperty('manualLensPosition')).toBeUndefined();
|
|
273
|
-
expect(settings.getProperty('focusStrategy')).toBeUndefined();
|
|
274
|
-
});
|
|
259
|
+
it('leaves all focus fields as undefined when both focus object and top-level focus fields are absent', () => {
|
|
260
|
+
const json = {
|
|
261
|
+
preferredResolution: 'auto',
|
|
262
|
+
zoomFactor: 1,
|
|
263
|
+
zoomGestureZoomFactor: 2,
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
267
|
+
|
|
268
|
+
expect(settings.focusRange).toBeUndefined();
|
|
269
|
+
expect(settings.focusGestureStrategy).toBeUndefined();
|
|
270
|
+
expect(settings.shouldPreferSmoothAutoFocus).toBeUndefined();
|
|
271
|
+
expect(settings.getProperty('manualLensPosition')).toBeUndefined();
|
|
272
|
+
expect(settings.getProperty('focusStrategy')).toBeUndefined();
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
describe('setProperty / getProperty', () => {
|
|
277
|
+
it('routes all focusHiddenProperties to the focus bag', () => {
|
|
278
|
+
const settings = new CameraSettings();
|
|
279
|
+
|
|
280
|
+
settings.setProperty('range', 'infinite' as FocusRange);
|
|
281
|
+
settings.setProperty('manualLensPosition', 0.75);
|
|
282
|
+
settings.setProperty('focusStrategy', 'autoFocus');
|
|
283
|
+
settings.setProperty('focusGestureStrategy', 'manual' as FocusGestureStrategy);
|
|
284
|
+
settings.setProperty('shouldPreferSmoothAutoFocus', true);
|
|
285
|
+
|
|
286
|
+
expect(settings.getProperty('range')).toBe('infinite');
|
|
287
|
+
expect(settings.getProperty('manualLensPosition')).toBe(0.75);
|
|
288
|
+
expect(settings.getProperty('focusStrategy')).toBe('autoFocus');
|
|
289
|
+
expect(settings.getProperty('focusGestureStrategy')).toBe('manual');
|
|
290
|
+
expect(settings.getProperty('shouldPreferSmoothAutoFocus')).toBe(true);
|
|
291
|
+
|
|
292
|
+
// Public accessors also reflect the updated values
|
|
293
|
+
expect(settings.focusRange).toBe('infinite');
|
|
294
|
+
expect(settings.focusGestureStrategy).toBe('manual');
|
|
295
|
+
expect(settings.shouldPreferSmoothAutoFocus).toBe(true);
|
|
275
296
|
});
|
|
276
297
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const settings = new CameraSettings();
|
|
298
|
+
it('routes non-focus properties to top-level fields', () => {
|
|
299
|
+
const settings = new CameraSettings();
|
|
280
300
|
|
|
281
|
-
|
|
282
|
-
settings.setProperty('manualLensPosition', 0.75);
|
|
283
|
-
settings.setProperty('focusStrategy', 'autoFocus');
|
|
284
|
-
settings.setProperty('focusGestureStrategy', 'manual' as FocusGestureStrategy);
|
|
285
|
-
settings.setProperty('shouldPreferSmoothAutoFocus', true);
|
|
301
|
+
settings.setProperty('zoomFactor', 3.5);
|
|
286
302
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
expect(settings.getProperty('shouldPreferSmoothAutoFocus')).toBe(true);
|
|
303
|
+
expect(settings.getProperty('zoomFactor')).toBe(3.5);
|
|
304
|
+
expect(settings.zoomFactor).toBe(3.5);
|
|
305
|
+
});
|
|
306
|
+
});
|
|
292
307
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
308
|
+
describe('zoomLevels', () => {
|
|
309
|
+
it('initializes with default zoomLevels from defaults', () => {
|
|
310
|
+
const settings = new CameraSettings();
|
|
311
|
+
expect(settings.zoomLevels).toEqual([1, 2]);
|
|
312
|
+
});
|
|
298
313
|
|
|
299
|
-
|
|
300
|
-
|
|
314
|
+
it('can be set to custom zoom levels', () => {
|
|
315
|
+
const settings = new CameraSettings();
|
|
316
|
+
settings.zoomLevels = [0.5, 1, 2, 3];
|
|
317
|
+
expect(settings.zoomLevels).toEqual([0.5, 1, 2, 3]);
|
|
318
|
+
});
|
|
301
319
|
|
|
302
|
-
|
|
320
|
+
it('is deserialized from JSON', () => {
|
|
321
|
+
const json = {
|
|
322
|
+
preferredResolution: 'auto',
|
|
323
|
+
zoomFactor: 1,
|
|
324
|
+
zoomGestureZoomFactor: 2,
|
|
325
|
+
zoomLevels: [1, 2, 5],
|
|
326
|
+
};
|
|
303
327
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
});
|
|
328
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
329
|
+
expect(settings.zoomLevels).toEqual([1, 2, 5]);
|
|
307
330
|
});
|
|
308
331
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
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
|
-
});
|
|
332
|
+
it('defaults to [1, 2] when absent from JSON', () => {
|
|
333
|
+
const json = {
|
|
334
|
+
preferredResolution: 'auto',
|
|
335
|
+
zoomFactor: 1,
|
|
336
|
+
zoomGestureZoomFactor: 2,
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
const settings = (CameraSettings as any).fromJSON(json);
|
|
340
|
+
expect(settings.zoomLevels).toEqual([1, 2]);
|
|
351
341
|
});
|
|
352
342
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
343
|
+
it('is serialized to JSON', () => {
|
|
344
|
+
const settings = new CameraSettings();
|
|
345
|
+
settings.zoomLevels = [0.5, 1, 3];
|
|
346
|
+
|
|
347
|
+
const json = JSON.parse(JSON.stringify(settings));
|
|
348
|
+
expect(json.zoomLevels).toEqual([0.5, 1, 3]);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
describe('copy constructor', () => {
|
|
353
|
+
it('copies all settings including focus sub-fields', () => {
|
|
354
|
+
const original = new CameraSettings();
|
|
355
|
+
original.zoomFactor = 2.5;
|
|
356
|
+
original.torchLevel = 0.5;
|
|
357
|
+
original.macroMode = 'disabled' as MacroMode;
|
|
358
|
+
original.adaptiveExposure = true;
|
|
359
|
+
original.focusRange = 'far' as FocusRange;
|
|
360
|
+
original.focusGestureStrategy = 'autoFocus' as FocusGestureStrategy;
|
|
361
|
+
original.shouldPreferSmoothAutoFocus = true;
|
|
362
|
+
original.setProperty('manualLensPosition', 0.3);
|
|
363
|
+
original.setProperty('focusStrategy', 'autoFocus');
|
|
364
|
+
|
|
365
|
+
const copy = new CameraSettings(original);
|
|
366
|
+
|
|
367
|
+
expect(copy.zoomFactor).toBe(2.5);
|
|
368
|
+
expect(copy.torchLevel).toBe(0.5);
|
|
369
|
+
expect(copy.macroMode).toBe('disabled');
|
|
370
|
+
expect(copy.adaptiveExposure).toBe(true);
|
|
371
|
+
expect(copy.focusRange).toBe('far');
|
|
372
|
+
expect(copy.focusGestureStrategy).toBe('autoFocus');
|
|
373
|
+
expect(copy.shouldPreferSmoothAutoFocus).toBe(true);
|
|
374
|
+
expect(copy.getProperty('manualLensPosition')).toBe(0.3);
|
|
375
|
+
expect(copy.getProperty('focusStrategy')).toBe('autoFocus');
|
|
378
376
|
});
|
|
377
|
+
});
|
|
379
378
|
});
|