@ray-js/ipc-player-integration 0.0.58-beta.0 → 0.0.58-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.
|
@@ -102,7 +102,6 @@ export function RecordVideo(props) {
|
|
|
102
102
|
playState: props.playState
|
|
103
103
|
});
|
|
104
104
|
const [state, setState] = useSetState({
|
|
105
|
-
showTimer: false,
|
|
106
105
|
showShot: false,
|
|
107
106
|
shotUrl: '',
|
|
108
107
|
shotCount: 0
|
|
@@ -125,7 +124,6 @@ export function RecordVideo(props) {
|
|
|
125
124
|
if (requestId !== recordResultRequestIdRef.current) return;
|
|
126
125
|
if (!summary) return;
|
|
127
126
|
setState({
|
|
128
|
-
showTimer: false,
|
|
129
127
|
showShot: true,
|
|
130
128
|
shotUrl: summary.thumbnailPath,
|
|
131
129
|
shotCount: summary.isMultiLens ? summary.count : 0
|
|
@@ -139,9 +137,6 @@ export function RecordVideo(props) {
|
|
|
139
137
|
(async () => {
|
|
140
138
|
if (playState !== PlayState.PLAYING && recording) {
|
|
141
139
|
try {
|
|
142
|
-
setState({
|
|
143
|
-
showTimer: false
|
|
144
|
-
});
|
|
145
140
|
const recordInfo = await setRecording(false);
|
|
146
141
|
await showRecordResult(recordInfo);
|
|
147
142
|
} catch {
|
|
@@ -180,16 +175,13 @@ export function RecordVideo(props) {
|
|
|
180
175
|
showRecordToast();
|
|
181
176
|
}
|
|
182
177
|
}, [state.showShot, screenType]);
|
|
183
|
-
|
|
184
|
-
/** 根据showTimer的显示定时器 */
|
|
185
178
|
useUpdateEffect(() => {
|
|
186
|
-
if (
|
|
179
|
+
if (recording) {
|
|
187
180
|
showRecordTimer();
|
|
188
181
|
} else {
|
|
189
182
|
deleteContent('absolute', RECORD_VIDEO_TIMER_ID);
|
|
190
|
-
// 清除定时器,元素移除
|
|
191
183
|
}
|
|
192
|
-
}, [
|
|
184
|
+
}, [recording]);
|
|
193
185
|
|
|
194
186
|
/** 跳转相册 */
|
|
195
187
|
const handCheck = () => {
|
|
@@ -236,8 +228,8 @@ export function RecordVideo(props) {
|
|
|
236
228
|
absoluteContentClassName: 'ipc-player-plugin-record-video-toast-wrap',
|
|
237
229
|
content: () => /*#__PURE__*/React.createElement(View, {
|
|
238
230
|
className: clsx('ipc-player-plugin-record-video-toast', {
|
|
239
|
-
'ipc-player-plugin-record-video-toast-show':
|
|
240
|
-
'ipc-player-plugin-record-video-toast-hide': !
|
|
231
|
+
'ipc-player-plugin-record-video-toast-show': recording,
|
|
232
|
+
'ipc-player-plugin-record-video-toast-hide': !recording
|
|
241
233
|
})
|
|
242
234
|
}, /*#__PURE__*/React.createElement(View, {
|
|
243
235
|
className: "ipc-player-plugin-record-video-toast-point",
|
|
@@ -281,9 +273,6 @@ export function RecordVideo(props) {
|
|
|
281
273
|
}
|
|
282
274
|
if (target) {
|
|
283
275
|
setRecordingDisabled(true);
|
|
284
|
-
setState({
|
|
285
|
-
showTimer: true
|
|
286
|
-
});
|
|
287
276
|
/** 录制开始后3秒后才可结束 */
|
|
288
277
|
timeToResetRecordDisabled();
|
|
289
278
|
} else {
|
|
@@ -298,9 +287,6 @@ export function RecordVideo(props) {
|
|
|
298
287
|
toast({
|
|
299
288
|
title: errMsg
|
|
300
289
|
});
|
|
301
|
-
setState({
|
|
302
|
-
showTimer: false
|
|
303
|
-
});
|
|
304
290
|
}
|
|
305
291
|
return true;
|
|
306
292
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.filter.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import ReactDOM from 'react-dom';
|
|
6
|
+
import { act, Simulate } from 'react-dom/test-utils';
|
|
7
|
+
import { atom, getDefaultStore } from 'jotai';
|
|
8
|
+
import { PlayState } from '../../interface';
|
|
9
|
+
import { RecordVideo } from './recordVideo';
|
|
10
|
+
jest.mock('@ray-js/ray', () => ({
|
|
11
|
+
View: 'div',
|
|
12
|
+
Text: 'span',
|
|
13
|
+
Image: 'img',
|
|
14
|
+
getSystemInfoSync: () => ({
|
|
15
|
+
platform: 'android'
|
|
16
|
+
})
|
|
17
|
+
}));
|
|
18
|
+
jest.mock('@ray-js/ray-ipc-utils', () => ({
|
|
19
|
+
goToIpcPageNativeRoute: jest.fn()
|
|
20
|
+
}));
|
|
21
|
+
jest.mock('@ray-js/ray-ipc-utils/lib/interface', () => ({}));
|
|
22
|
+
jest.mock('../../utils/device', () => ({
|
|
23
|
+
getDeviceInfo: jest.fn()
|
|
24
|
+
}));
|
|
25
|
+
jest.mock('../../i18n', () => ({
|
|
26
|
+
__esModule: true,
|
|
27
|
+
default: {
|
|
28
|
+
getLang: key => key
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
jest.mock('./recordVideo.less', () => ({}));
|
|
32
|
+
jest.mock('../captureResult/captureResult.less', () => ({}));
|
|
33
|
+
describe('RecordVideo', () => {
|
|
34
|
+
let container;
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
jest.useFakeTimers('modern');
|
|
37
|
+
container = document.createElement('div');
|
|
38
|
+
document.body.appendChild(container);
|
|
39
|
+
});
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
act(() => ReactDOM.unmountComponentAtNode(container));
|
|
42
|
+
container.remove();
|
|
43
|
+
jest.clearAllTimers();
|
|
44
|
+
jest.useRealTimers();
|
|
45
|
+
});
|
|
46
|
+
it.each([false, true])('removes the recording timer after stop (remounted: %s)', async remount => {
|
|
47
|
+
var _container$querySelec, _container$querySelec2;
|
|
48
|
+
const store = getDefaultStore();
|
|
49
|
+
const recording = atom(false);
|
|
50
|
+
const recordingDisabled = atom(false);
|
|
51
|
+
const screenType = atom('vertical');
|
|
52
|
+
const setRecording = jest.fn(async value => {
|
|
53
|
+
store.set(recording, value);
|
|
54
|
+
return value ? true : {
|
|
55
|
+
tempImagePath: 'thingfile://record.jpg'
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
function Harness(_ref) {
|
|
59
|
+
let {
|
|
60
|
+
widgetKey
|
|
61
|
+
} = _ref;
|
|
62
|
+
const [contents, setContents] = useState([]);
|
|
63
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RecordVideo, {
|
|
64
|
+
key: widgetKey,
|
|
65
|
+
devId: 'device',
|
|
66
|
+
recording,
|
|
67
|
+
recordingDisabled,
|
|
68
|
+
screenType,
|
|
69
|
+
brandColor: atom('#ff592a'),
|
|
70
|
+
playState: atom(PlayState.PLAYING),
|
|
71
|
+
setRecording,
|
|
72
|
+
setRecordingDisabled: value => store.set(recordingDisabled, value),
|
|
73
|
+
addContent: (_type, content) => setContents(items => [...items, content]),
|
|
74
|
+
deleteContent: (_type, id) => setContents(items => items.filter(item => item.id !== id))
|
|
75
|
+
}), contents.map(item => /*#__PURE__*/React.createElement(item.content, {
|
|
76
|
+
key: item.id
|
|
77
|
+
})));
|
|
78
|
+
}
|
|
79
|
+
const clickRecord = async () => {
|
|
80
|
+
await act(async () => {
|
|
81
|
+
Simulate.click(container.querySelector('.ipc-player-plugin-record-video-icon').parentElement);
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
await act(async () => {
|
|
85
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(Harness, {
|
|
86
|
+
widgetKey: 0
|
|
87
|
+
}), container);
|
|
88
|
+
});
|
|
89
|
+
await clickRecord();
|
|
90
|
+
act(() => jest.advanceTimersByTime(3000));
|
|
91
|
+
expect((_container$querySelec = container.querySelector('.ipc-player-plugin-record-video-toast-time')) === null || _container$querySelec === void 0 ? void 0 : _container$querySelec.textContent).toBe('00:03');
|
|
92
|
+
if (remount) {
|
|
93
|
+
await act(async () => {
|
|
94
|
+
store.set(screenType, 'full');
|
|
95
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(Harness, {
|
|
96
|
+
widgetKey: 1
|
|
97
|
+
}), container);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
expect((_container$querySelec2 = container.querySelector('.ipc-player-plugin-record-video-toast-time')) === null || _container$querySelec2 === void 0 ? void 0 : _container$querySelec2.textContent).toBe('00:03');
|
|
101
|
+
await clickRecord();
|
|
102
|
+
expect(setRecording).toHaveBeenLastCalledWith(false);
|
|
103
|
+
expect(container.querySelector('.icon-panel-record-stop')).toBeNull();
|
|
104
|
+
expect(container.querySelector('.ipc-player-plugin-record-video-toast-time')).toBeNull();
|
|
105
|
+
});
|
|
106
|
+
});
|