1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <cstdint>
17 #include <cstring>
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
20 #include <securec.h>
21 #include <thread>
22
23 #include "accesstoken_kit.h"
24 #include "surface_buffer_impl.h"
25 #include "nativetoken_kit.h"
26 #include "nweb_adapter_helper.h"
27 #include "screen_capture.h"
28 #include "token_setproc.h"
29
30 #define private public
31 #include "screen_capture_adapter_impl.h"
32 #undef private
33 #include "../native/media_errors.h"
34
35 using namespace testing;
36 using namespace testing::ext;
37 using namespace OHOS::Rosen;
38 using namespace OHOS::Media;
39
40 namespace OHOS {
41 namespace Media {
42 class ScreenCaptureImplMock : public ScreenCapture {
43 public:
44 MOCK_METHOD1(Init, int32_t(AVScreenCaptureConfig));
45 MOCK_METHOD1(Init, int32_t(OHOS::AudioStandard::AppInfo&));
46 MOCK_METHOD1(SetMicrophoneEnabled, int32_t(bool));
47 MOCK_METHOD1(SetCanvasRotation, int32_t(bool));
48 MOCK_METHOD1(ShowCursor, int32_t(bool));
49 MOCK_METHOD2(ResizeCanvas, int32_t(int32_t, int32_t));
50 MOCK_METHOD1(SkipPrivacyMode, int32_t(std::vector<uint64_t>&));
51 MOCK_METHOD1(SetMaxVideoFrameRate, int32_t(int32_t));
52 MOCK_METHOD0(StartScreenCapture, int32_t());
53 MOCK_METHOD1(StartScreenCaptureWithSurface, int32_t(sptr<Surface>));
54 MOCK_METHOD0(StopScreenCapture, int32_t());
55 MOCK_METHOD0(StartScreenRecording, int32_t());
56 MOCK_METHOD0(StopScreenRecording, int32_t());
57 MOCK_METHOD2(AcquireAudioBuffer, int32_t(std::shared_ptr<AudioBuffer>&, AudioCaptureSourceType));
58 MOCK_METHOD3(AcquireVideoBuffer, sptr<OHOS::SurfaceBuffer>(int32_t&, int64_t&, OHOS::Rect&));
59 MOCK_METHOD1(ReleaseAudioBuffer, int32_t(AudioCaptureSourceType));
60 MOCK_METHOD0(ReleaseVideoBuffer, int32_t());
61 MOCK_METHOD0(Release, int32_t());
62 MOCK_METHOD1(SetScreenCaptureCallback, int32_t(const std::shared_ptr<ScreenCaptureCallBack>&));
63 MOCK_METHOD1(ExcludeContent, int32_t(ScreenCaptureContentFilter&));
64 MOCK_METHOD0(SetPrivacyAuthorityEnabled, int32_t());
65 MOCK_METHOD1(SetScreenCaptureStrategy, int32_t(ScreenCaptureStrategy));
66 MOCK_METHOD1(UpdateSurface, int32_t(sptr<Surface>));
67 MOCK_METHOD2(SetCaptureArea, int32_t(uint64_t, OHOS::Rect));
68 };
69 } // namespace Media
70 namespace NWeb {
71
72 class MockAudioCaptureInfoAdapter : public AudioCaptureInfoAdapter {
73 public:
74 MockAudioCaptureInfoAdapter() = default;
75
GetAudioSampleRate()76 int32_t GetAudioSampleRate() override
77 {
78 return audioSampleRate;
79 }
80
GetAudioChannels()81 int32_t GetAudioChannels() override
82 {
83 return audioChannels;
84 }
85
GetAudioSource()86 AudioCaptureSourceTypeAdapter GetAudioSource() override
87 {
88 return audioSource;
89 }
90
91 int32_t audioSampleRate;
92 int32_t audioChannels;
93 AudioCaptureSourceTypeAdapter audioSource = AudioCaptureSourceTypeAdapter::SOURCE_DEFAULT;
94 };
95
96 class MockAudioEncInfoAdapter : public AudioEncInfoAdapter {
97 public:
98 MockAudioEncInfoAdapter() = default;
99
GetAudioBitrate()100 int32_t GetAudioBitrate() override
101 {
102 return audioBitrate;
103 }
104
GetAudioCodecformat()105 AudioCodecFormatAdapter GetAudioCodecformat() override
106 {
107 return audioCodecformat;
108 }
109
110 int32_t audioBitrate = 0;
111 AudioCodecFormatAdapter audioCodecformat = AudioCodecFormatAdapter::AUDIO_DEFAULT;
112 };
113
114 class MockAudioInfoAdapter : public AudioInfoAdapter {
115 public:
116 MockAudioInfoAdapter() = default;
117
GetMicCapInfo()118 std::shared_ptr<AudioCaptureInfoAdapter> GetMicCapInfo() override
119 {
120 return micCapInfo;
121 }
122
GetInnerCapInfo()123 std::shared_ptr<AudioCaptureInfoAdapter> GetInnerCapInfo() override
124 {
125 return innerCapInfo;
126 }
127
GetAudioEncInfo()128 std::shared_ptr<AudioEncInfoAdapter> GetAudioEncInfo() override
129 {
130 return audioEncInfo;
131 }
132
133 std::shared_ptr<MockAudioCaptureInfoAdapter> micCapInfo = nullptr;
134 std::shared_ptr<MockAudioCaptureInfoAdapter> innerCapInfo = nullptr;
135 std::shared_ptr<MockAudioEncInfoAdapter> audioEncInfo = nullptr;
136 };
137
138 class MockVideoCaptureInfoAdapter : public VideoCaptureInfoAdapter {
139 public:
140 MockVideoCaptureInfoAdapter() = default;
141
GetDisplayId()142 uint64_t GetDisplayId() override
143 {
144 return displayId;
145 }
146
GetTaskIDs()147 std::list<int32_t> GetTaskIDs() override
148 {
149 return taskIDs;
150 }
151
GetVideoFrameWidth()152 int32_t GetVideoFrameWidth() override
153 {
154 return videoFrameWidth;
155 }
156
GetVideoFrameHeight()157 int32_t GetVideoFrameHeight() override
158 {
159 return videoFrameHeight;
160 }
161
GetVideoSourceType()162 VideoSourceTypeAdapter GetVideoSourceType() override
163 {
164 return videoSource;
165 }
166
167 uint64_t displayId = 0;
168 std::list<int32_t> taskIDs;
169 int32_t videoFrameWidth = 0;
170 int32_t videoFrameHeight = 0;
171 VideoSourceTypeAdapter videoSource = VideoSourceTypeAdapter::VIDEO_SOURCE_SURFACE_RGBA;
172 };
173
174 class MockVideoEncInfoAdapter : public VideoEncInfoAdapter {
175 public:
176 MockVideoEncInfoAdapter() = default;
177
GetVideoCodecFormat()178 VideoCodecFormatAdapter GetVideoCodecFormat() override
179 {
180 return videoCodec;
181 }
182
GetVideoBitrate()183 int32_t GetVideoBitrate() override
184 {
185 return videoBitrate;
186 }
187
GetVideoFrameRate()188 int32_t GetVideoFrameRate() override
189 {
190 return videoFrameRate;
191 }
192
193 VideoCodecFormatAdapter videoCodec = VideoCodecFormatAdapter::VIDEO_DEFAULT;
194 int32_t videoBitrate = 0;
195 int32_t videoFrameRate = 0;
196 };
197
198 class MockVideoInfoAdapter : public VideoInfoAdapter {
199 public:
200 MockVideoInfoAdapter() = default;
201
GetVideoCapInfo()202 std::shared_ptr<VideoCaptureInfoAdapter> GetVideoCapInfo()
203 {
204 return videoCapInfo;
205 }
206
GetVideoEncInfo()207 std::shared_ptr<VideoEncInfoAdapter> GetVideoEncInfo()
208 {
209 return videoEncInfo;
210 }
211
212 std::shared_ptr<MockVideoCaptureInfoAdapter> videoCapInfo = nullptr;
213 std::shared_ptr<MockVideoEncInfoAdapter> videoEncInfo = nullptr;
214 };
215
216 class MockRecorderInfoAdapter : public RecorderInfoAdapter {
217 public:
218 MockRecorderInfoAdapter() = default;
219
GetUrl()220 std::string GetUrl() override
221 {
222 return url;
223 }
224
GetFileFormat()225 ContainerFormatTypeAdapter GetFileFormat() override
226 {
227 return fileFormat;
228 }
229
230 std::string url = "";
231 ContainerFormatTypeAdapter fileFormat = ContainerFormatTypeAdapter::CFT_MPEG_4A_TYPE;
232 };
233
234 class MockScreenCaptureConfigAdapter : public ScreenCaptureConfigAdapter {
235 public:
236 MockScreenCaptureConfigAdapter() = default;
237
GetCaptureMode()238 CaptureModeAdapter GetCaptureMode() override
239 {
240 return captureMode;
241 }
242
GetDataType()243 DataTypeAdapter GetDataType() override
244 {
245 return dataType;
246 }
247
GetAudioInfo()248 std::shared_ptr<AudioInfoAdapter> GetAudioInfo()
249 {
250 return audioInfo;
251 }
252
GetVideoInfo()253 std::shared_ptr<VideoInfoAdapter> GetVideoInfo()
254 {
255 return videoInfo;
256 }
257
GetRecorderInfo()258 std::shared_ptr<RecorderInfoAdapter> GetRecorderInfo()
259 {
260 return recorderInfo;
261 }
262
263 CaptureModeAdapter captureMode = CaptureModeAdapter::CAPTURE_INVAILD;
264 DataTypeAdapter dataType = DataTypeAdapter::INVAILD_DATA_TYPE;
265 std::shared_ptr<MockAudioInfoAdapter> audioInfo = nullptr;
266 std::shared_ptr<MockVideoInfoAdapter> videoInfo = nullptr;
267 std::shared_ptr<MockRecorderInfoAdapter> recorderInfo = nullptr;
268 };
269
270 class MockAudioBufferAdapter : public AudioBufferAdapter {
271 public:
272 MockAudioBufferAdapter() = default;
273
GetBuffer()274 uint8_t* GetBuffer() override
275 {
276 return m_buffer;
277 }
278
GetLength()279 int32_t GetLength() override
280 {
281 return m_length;
282 }
283
GetTimestamp()284 int64_t GetTimestamp() override
285 {
286 return m_timestamp;
287 }
288
GetSourcetype()289 AudioCaptureSourceTypeAdapter GetSourcetype() override
290 {
291 return m_sourcetype;
292 }
293
SetBuffer(uint8_t * buffer)294 void SetBuffer(uint8_t* buffer) override
295 {
296 m_buffer = buffer;
297 }
298
SetLength(int32_t length)299 void SetLength(int32_t length) override
300 {
301 m_length = length;
302 }
303
SetTimestamp(int64_t timestamp)304 void SetTimestamp(int64_t timestamp) override
305 {
306 m_timestamp = timestamp;
307 }
308
SetSourcetype(AudioCaptureSourceTypeAdapter sourcetype)309 void SetSourcetype(AudioCaptureSourceTypeAdapter sourcetype) override
310 {
311 m_sourcetype = sourcetype;
312 }
313
314 uint8_t* m_buffer = nullptr;
315 int32_t m_length = 0;
316 int64_t m_timestamp = 0;
317 AudioCaptureSourceTypeAdapter m_sourcetype = AudioCaptureSourceTypeAdapter::SOURCE_INVALID;
318 };
319
GetScreenCaptureStateCodeAdapter(const OHOS::Media::AVScreenCaptureStateCode & stateCode)320 ScreenCaptureStateCodeAdapter GetScreenCaptureStateCodeAdapter(const OHOS::Media::AVScreenCaptureStateCode& stateCode)
321 {
322 switch (stateCode) {
323 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_STARTED:
324 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_STARTED;
325 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_CANCELED:
326 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_CANCELED;
327 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_STOPPED_BY_USER:
328 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_STOPPED_BY_USER;
329 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER:
330 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER;
331 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_STOPPED_BY_CALL:
332 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_STOPPED_BY_CALL;
333 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE:
334 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE;
335 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER:
336 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER;
337 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER:
338 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER;
339 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE:
340 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE;
341 case OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE:
342 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE;
343 default:
344 return ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_INVLID;
345 }
346 }
347
ConvertAudioCaptureSourceType(const AudioCaptureSourceTypeAdapter & type)348 OHOS::Media::AudioCaptureSourceType ConvertAudioCaptureSourceType(const AudioCaptureSourceTypeAdapter& type)
349 {
350 switch (type) {
351 case AudioCaptureSourceTypeAdapter::SOURCE_DEFAULT:
352 return OHOS::Media::AudioCaptureSourceType::SOURCE_DEFAULT;
353 case AudioCaptureSourceTypeAdapter::MIC:
354 return OHOS::Media::AudioCaptureSourceType::MIC;
355 case AudioCaptureSourceTypeAdapter::ALL_PLAYBACK:
356 return OHOS::Media::AudioCaptureSourceType::ALL_PLAYBACK;
357 case AudioCaptureSourceTypeAdapter::APP_PLAYBACK:
358 return OHOS::Media::AudioCaptureSourceType::APP_PLAYBACK;
359 default:
360 return OHOS::Media::AudioCaptureSourceType::SOURCE_INVALID;
361 }
362 }
363
364 namespace {
365 constexpr int32_t AUDIO_SAMPLE_RATE = 16000;
366 constexpr int32_t AUDIO_CHANNELS = 2;
367 constexpr int32_t SCREEN_WIDTH = 1080;
368 constexpr int32_t SCREEN_HEIGHT = 720;
369 std::shared_ptr<ScreenCaptureAdapterImpl> g_screenCapture = nullptr;
370 std::shared_ptr<MockAudioCaptureInfoAdapter> g_micCapInfo = nullptr;
371 std::shared_ptr<MockAudioCaptureInfoAdapter> g_innerCapInfo = nullptr;
372 std::shared_ptr<MockAudioEncInfoAdapter> g_audioEncInfo = nullptr;
373 std::shared_ptr<MockAudioInfoAdapter> g_audioInfo = nullptr;
374 std::shared_ptr<MockVideoCaptureInfoAdapter> g_videoCaptureInfo = nullptr;
375 std::shared_ptr<MockVideoEncInfoAdapter> g_videoEncInfo = nullptr;
376 std::shared_ptr<MockVideoInfoAdapter> g_videoInfo = nullptr;
377 std::shared_ptr<MockRecorderInfoAdapter> g_recorderInfo = nullptr;
378 std::shared_ptr<MockScreenCaptureConfigAdapter> g_screenCaptureConfig = nullptr;
379 std::shared_ptr<MockAudioBufferAdapter> g_audioBufferAdapter = nullptr;
380
381 class ScreenCaptureCallbackAdapterTest : public ScreenCaptureCallbackAdapter {
382 public:
383 ScreenCaptureCallbackAdapterTest() = default;
384 ~ScreenCaptureCallbackAdapterTest() override = default;
385
OnError(int32_t errorCode)386 void OnError(int32_t errorCode) override
387 {
388 (void)errorCode;
389 }
390
OnAudioBufferAvailable(bool isReady,AudioCaptureSourceTypeAdapter type)391 void OnAudioBufferAvailable(bool isReady, AudioCaptureSourceTypeAdapter type) override
392 {
393 (void)isReady;
394 (void)type;
395 }
396
OnVideoBufferAvailable(bool isReady)397 void OnVideoBufferAvailable(bool isReady) override
398 {
399 if (!isReady || !g_screenCapture) {
400 return;
401 }
402 std::shared_ptr<SurfaceBufferAdapter> buffer = g_screenCapture->AcquireVideoBuffer();
403 if (buffer) {
404 g_screenCapture->ReleaseVideoBuffer();
405 }
406 }
407 };
408 } // namespace
409
410 class ScreenCaptureAdapterImplTest : public testing::Test {
411 public:
412 static void SetUpTestCase(void);
413 static void TearDownTestCase(void);
414 void SetUp();
415 void TearDown();
416 };
417
SetUpTestCase(void)418 void ScreenCaptureAdapterImplTest::SetUpTestCase(void)
419 {
420 // set native token
421 uint64_t tokenId;
422 const char* perms[2];
423 perms[0] = "ohos.permission.CAPTURE_SCREEN";
424 perms[1] = "ohos.permission.MICROPHONE";
425 NativeTokenInfoParams infoInstance = {
426 .dcapsNum = 0,
427 .permsNum = 1,
428 .aclsNum = 0,
429 .dcaps = NULL,
430 .perms = perms,
431 .acls = NULL,
432 .processName = "web_screen_capture_tdd",
433 .aplStr = "system_basic",
434 };
435 tokenId = GetAccessTokenId(&infoInstance);
436 SetSelfTokenID(tokenId);
437 OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
438
439 g_screenCapture = std::make_shared<ScreenCaptureAdapterImpl>();
440 g_micCapInfo = std::make_shared<MockAudioCaptureInfoAdapter>();
441 g_innerCapInfo = std::make_shared<MockAudioCaptureInfoAdapter>();
442 g_audioEncInfo = std::make_shared<MockAudioEncInfoAdapter>();
443 g_audioInfo = std::make_shared<MockAudioInfoAdapter>();
444 g_videoCaptureInfo = std::make_shared<MockVideoCaptureInfoAdapter>();
445 g_videoEncInfo = std::make_shared<MockVideoEncInfoAdapter>();
446 g_videoInfo = std::make_shared<MockVideoInfoAdapter>();
447 g_recorderInfo = std::make_shared<MockRecorderInfoAdapter>();
448 g_screenCaptureConfig = std::make_shared<MockScreenCaptureConfigAdapter>();
449 g_audioBufferAdapter = std::make_shared<MockAudioBufferAdapter>();
450
451 EXPECT_NE(g_screenCapture, nullptr);
452 EXPECT_NE(g_micCapInfo, nullptr);
453 EXPECT_NE(g_innerCapInfo, nullptr);
454 EXPECT_NE(g_audioEncInfo, nullptr);
455 EXPECT_NE(g_audioInfo, nullptr);
456 EXPECT_NE(g_videoCaptureInfo, nullptr);
457 EXPECT_NE(g_videoEncInfo, nullptr);
458 EXPECT_NE(g_videoInfo, nullptr);
459 EXPECT_NE(g_recorderInfo, nullptr);
460 EXPECT_NE(g_screenCaptureConfig, nullptr);
461 EXPECT_NE(g_audioBufferAdapter, nullptr);
462 int32_t result = g_screenCapture->Init(nullptr);
463 EXPECT_EQ(result, -1);
464
465 g_screenCaptureConfig->captureMode = CaptureModeAdapter::CAPTURE_HOME_SCREEN;
466 g_screenCaptureConfig->dataType = DataTypeAdapter::ORIGINAL_STREAM_DATA_TYPE;
467 g_micCapInfo->audioSampleRate = AUDIO_SAMPLE_RATE;
468 g_micCapInfo->audioChannels = AUDIO_CHANNELS;
469 g_innerCapInfo->audioSampleRate = AUDIO_SAMPLE_RATE;
470 g_innerCapInfo->audioChannels = AUDIO_CHANNELS;
471 g_audioInfo->micCapInfo = g_micCapInfo;
472 g_audioInfo->innerCapInfo = g_innerCapInfo;
473 g_audioInfo->audioEncInfo = g_audioEncInfo;
474 g_videoCaptureInfo->videoFrameWidth = SCREEN_WIDTH;
475 g_videoCaptureInfo->videoFrameHeight = SCREEN_HEIGHT;
476 g_videoInfo->videoCapInfo = g_videoCaptureInfo;
477 g_videoInfo->videoEncInfo = g_videoEncInfo;
478 result = g_screenCapture->Init(g_screenCaptureConfig);
479 EXPECT_EQ(result, 0);
480 g_screenCaptureConfig->audioInfo = g_audioInfo;
481 result = g_screenCapture->Init(g_screenCaptureConfig);
482 EXPECT_EQ(result, 0);
483 g_screenCaptureConfig->videoInfo = g_videoInfo;
484 result = g_screenCapture->Init(g_screenCaptureConfig);
485 EXPECT_EQ(result, 0);
486 g_screenCaptureConfig->recorderInfo = g_recorderInfo;
487 result = g_screenCapture->Init(g_screenCaptureConfig);
488 EXPECT_EQ(result, 0);
489 }
490
TearDownTestCase(void)491 void ScreenCaptureAdapterImplTest::TearDownTestCase(void) {}
492
SetUp(void)493 void ScreenCaptureAdapterImplTest::SetUp(void) {}
494
TearDown(void)495 void ScreenCaptureAdapterImplTest::TearDown(void) {}
496
497 /**
498 * @tc.name: ScreenCaptureAdapterImplTest_Init_001
499 * @tc.desc: Init.
500 * @tc.type: FUNC
501 * @tc.require: AR000I7I57
502 */
503 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_Init_001, TestSize.Level1)
504 {
505 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
506 EXPECT_NE(adapterImpl, nullptr);
507 g_screenCaptureConfig->captureMode = CaptureModeAdapter::CAPTURE_INVAILD;
508 g_screenCaptureConfig->dataType = DataTypeAdapter::INVAILD_DATA_TYPE;
509 g_screenCaptureConfig->audioInfo->micCapInfo->audioSampleRate = AUDIO_SAMPLE_RATE;
510 g_screenCaptureConfig->audioInfo->micCapInfo->audioChannels = AUDIO_CHANNELS;
511 g_screenCaptureConfig->audioInfo->innerCapInfo->audioSampleRate = AUDIO_SAMPLE_RATE;
512 g_screenCaptureConfig->audioInfo->innerCapInfo->audioChannels = AUDIO_CHANNELS;
513 g_screenCaptureConfig->videoInfo->videoCapInfo->videoFrameWidth = SCREEN_WIDTH;
514 g_screenCaptureConfig->videoInfo->videoCapInfo->videoFrameHeight = SCREEN_HEIGHT;
515 g_screenCaptureConfig->audioInfo->micCapInfo->audioSource = AudioCaptureSourceTypeAdapter::SOURCE_INVALID;
516 g_screenCaptureConfig->audioInfo->audioEncInfo->audioCodecformat = AudioCodecFormatAdapter::AUDIO_DEFAULT;
517 g_screenCaptureConfig->videoInfo->videoCapInfo->videoSource = VideoSourceTypeAdapter::VIDEO_SOURCE_SURFACE_YUV;
518 g_screenCaptureConfig->videoInfo->videoEncInfo->videoCodec = VideoCodecFormatAdapter::VIDEO_DEFAULT;
519 int32_t result = adapterImpl->Init(g_screenCaptureConfig);
520 EXPECT_EQ(result, -1);
521 g_screenCaptureConfig->captureMode = CaptureModeAdapter::CAPTURE_HOME_SCREEN;
522 g_screenCaptureConfig->dataType = DataTypeAdapter::ENCODED_STREAM_DATA_TYPE;
523 g_screenCaptureConfig->audioInfo->micCapInfo->audioSource = AudioCaptureSourceTypeAdapter::SOURCE_DEFAULT;
524 g_screenCaptureConfig->audioInfo->audioEncInfo->audioCodecformat = AudioCodecFormatAdapter::AAC_LC;
525 g_screenCaptureConfig->videoInfo->videoCapInfo->videoSource = VideoSourceTypeAdapter::VIDEO_SOURCE_SURFACE_ES;
526 g_screenCaptureConfig->videoInfo->videoEncInfo->videoCodec = VideoCodecFormatAdapter::H264;
527 result = adapterImpl->Init(g_screenCaptureConfig);
528 EXPECT_EQ(result, -1);
529 g_screenCaptureConfig->captureMode = CaptureModeAdapter::CAPTURE_SPECIFIED_SCREEN;
530 g_screenCaptureConfig->dataType = DataTypeAdapter::CAPTURE_FILE_DATA_TYPE;
531 g_screenCaptureConfig->audioInfo->micCapInfo->audioSource = AudioCaptureSourceTypeAdapter::MIC;
532 g_screenCaptureConfig->audioInfo->audioEncInfo->audioCodecformat = AudioCodecFormatAdapter::AUDIO_CODEC_FORMAT_BUTT;
533 g_screenCaptureConfig->videoInfo->videoCapInfo->videoSource = VideoSourceTypeAdapter::VIDEO_SOURCE_SURFACE_RGBA;
534 g_screenCaptureConfig->videoInfo->videoEncInfo->videoCodec = VideoCodecFormatAdapter::H265;
535 result = adapterImpl->Init(g_screenCaptureConfig);
536 EXPECT_EQ(result, -1);
537 g_screenCaptureConfig->captureMode = CaptureModeAdapter::CAPTURE_SPECIFIED_WINDOW;
538 g_screenCaptureConfig->dataType = DataTypeAdapter::ORIGINAL_STREAM_DATA_TYPE;
539 g_screenCaptureConfig->audioInfo->micCapInfo->audioSource = AudioCaptureSourceTypeAdapter::ALL_PLAYBACK;
540 g_screenCaptureConfig->videoInfo->videoCapInfo->videoSource = VideoSourceTypeAdapter::VIDEO_SOURCE_BUTT;
541 g_screenCaptureConfig->videoInfo->videoEncInfo->videoCodec = VideoCodecFormatAdapter::MPEG4;
542 result = adapterImpl->Init(g_screenCaptureConfig);
543 EXPECT_EQ(result, -1);
544 g_screenCaptureConfig->audioInfo->micCapInfo->audioSource = AudioCaptureSourceTypeAdapter::APP_PLAYBACK;
545 g_screenCaptureConfig->videoInfo->videoEncInfo->videoCodec = VideoCodecFormatAdapter::VP8;
546 result = adapterImpl->Init(g_screenCaptureConfig);
547 EXPECT_EQ(result, -1);
548 g_screenCaptureConfig->videoInfo->videoEncInfo->videoCodec = VideoCodecFormatAdapter::VP9;
549 result = adapterImpl->Init(g_screenCaptureConfig);
550 EXPECT_EQ(result, -1);
551 }
552
553 /**
554 * @tc.name: ScreenCaptureAdapterImplTest_SetMicrophoneEnable_002
555 * @tc.desc: SetMicrophoneEnable.
556 * @tc.type: FUNC
557 * @tc.require: AR000I7I57
558 */
559 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_SetMicrophoneEnable_002, TestSize.Level1)
560 {
561 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
562 EXPECT_NE(adapterImpl, nullptr);
563 int32_t result = adapterImpl->SetMicrophoneEnable(false);
564 EXPECT_EQ(result, -1);
565 result = g_screenCapture->SetMicrophoneEnable(false);
566 EXPECT_EQ(result, 0);
567 result = g_screenCapture->SetMicrophoneEnable(true);
568 EXPECT_EQ(result, 0);
569 }
570
571 /**
572 * @tc.name: ScreenCaptureAdapterImplTest_AcquireVideoBuffer_003
573 * @tc.desc: AcquireVideoBuffer.
574 * @tc.type: FUNC
575 * @tc.require: AR000I7I57
576 */
577 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_AcquireVideoBuffer_003, TestSize.Level1)
578 {
579 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
580 EXPECT_NE(adapterImpl, nullptr);
581 std::shared_ptr<SurfaceBufferAdapter> buffer = adapterImpl->AcquireVideoBuffer();
582 EXPECT_EQ(buffer, nullptr);
583 int32_t result = adapterImpl->ReleaseVideoBuffer();
584 EXPECT_EQ(result, -1);
585 g_screenCapture->AcquireVideoBuffer();
586 g_screenCapture->ReleaseVideoBuffer();
587 }
588
589 /**
590 * @tc.name: ScreenCaptureAdapterImplTest_Capture_004
591 * @tc.desc: Capture.
592 * @tc.type: FUNC
593 * @tc.require: AR000I7I57
594 */
595 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_Capture_004, TestSize.Level1)
596 {
597 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
598 EXPECT_NE(adapterImpl, nullptr);
599 int32_t result = adapterImpl->StartCapture();
600 EXPECT_EQ(result, -1);
601 result = adapterImpl->StopCapture();
602 EXPECT_EQ(result, -1);
603 ScreenCaptureImplMock* mock = new ScreenCaptureImplMock();
604 EXPECT_NE(mock, nullptr);
605 adapterImpl->screenCapture_.reset(mock);
606 EXPECT_CALL(*mock, StartScreenCapture()).Times(1).WillRepeatedly(::testing::Return(Media::MSERR_OK));
607 EXPECT_CALL(*mock, StopScreenCapture()).Times(1).WillRepeatedly(::testing::Return(Media::MSERR_OK));
608 EXPECT_CALL(*mock, SetMicrophoneEnabled(::testing::_))
609 .Times(1)
610 .WillRepeatedly(::testing::Return(Media::MSERR_NO_MEMORY));
611 result = adapterImpl->StartCapture();
612 EXPECT_EQ(result, 0);
613 adapterImpl->SetMicrophoneEnable(true);
614 result = adapterImpl->StopCapture();
615 EXPECT_EQ(result, 0);
616 EXPECT_CALL(*mock, StartScreenCapture()).Times(1).WillRepeatedly(::testing::Return(Media::MSERR_NO_MEMORY));
617 EXPECT_CALL(*mock, StopScreenCapture()).Times(1).WillRepeatedly(::testing::Return(Media::MSERR_NO_MEMORY));
618 result = adapterImpl->StartCapture();
619 EXPECT_EQ(result, -1);
620 result = adapterImpl->StopCapture();
621 EXPECT_EQ(result, -1);
622 auto callbackAdapter = std::make_shared<ScreenCaptureCallbackAdapterTest>();
623 EXPECT_NE(callbackAdapter, nullptr);
624 result = g_screenCapture->SetCaptureCallback(callbackAdapter);
625 EXPECT_EQ(result, 0);
626 EXPECT_CALL(*mock, SetScreenCaptureCallback(::testing::_))
627 .Times(1)
628 .WillRepeatedly(::testing::Return(Media::MSERR_NO_MEMORY));
629 adapterImpl->SetCaptureCallback(callbackAdapter);
630 result = g_screenCapture->SetCaptureCallback(nullptr);
631 EXPECT_EQ(result, -1);
632 g_screenCapture->screenCapture_ = nullptr;
633 result = g_screenCapture->SetCaptureCallback(callbackAdapter);
634 EXPECT_EQ(result, -1);
635 }
636
637 /**
638 * @tc.name: ScreenCaptureAdapterImplTest_OHScreenCaptureCallback_005
639 * @tc.desc: OHScreenCaptureCallback.
640 * @tc.type: FUNC
641 * @tc.require: AR000I7I57
642 */
643 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_OHScreenCaptureCallback_005, TestSize.Level1)
644 {
645 auto callbackMock = std::make_shared<ScreenCaptureCallbackAdapterTest>();
646 EXPECT_NE(callbackMock, nullptr);
647 auto callback = std::make_shared<OHScreenCaptureCallback>(callbackMock);
648 EXPECT_NE(callback, nullptr);
649 EXPECT_NE(callback->callback_, nullptr);
650 callback->OnError(ScreenCaptureErrorType::SCREEN_CAPTURE_ERROR_EXTEND_START, 0);
651 callback->OnAudioBufferAvailable(true, AudioCaptureSourceType::SOURCE_DEFAULT);
652 callback->OnAudioBufferAvailable(true, AudioCaptureSourceType::MIC);
653 callback->OnAudioBufferAvailable(true, AudioCaptureSourceType::ALL_PLAYBACK);
654 callback->OnAudioBufferAvailable(true, AudioCaptureSourceType::APP_PLAYBACK);
655 callback->OnAudioBufferAvailable(true, AudioCaptureSourceType::SOURCE_INVALID);
656 callback->OnVideoBufferAvailable(true);
657 callback->callback_ = nullptr;
658 callback->OnError(ScreenCaptureErrorType::SCREEN_CAPTURE_ERROR_EXTEND_START, 0);
659 callback->OnAudioBufferAvailable(true, AudioCaptureSourceType::SOURCE_DEFAULT);
660 callback->OnVideoBufferAvailable(true);
661 }
662
663 /**
664 * @tc.name: ScreenCaptureAdapterImplTest_Init_006
665 * @tc.desc: Init.
666 * @tc.type: FUNC
667 * @tc.require: AR000I7I57
668 */
669 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_Init_006, TestSize.Level1)
670 {
671 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
672 EXPECT_NE(adapterImpl, nullptr);
673 g_screenCaptureConfig->captureMode = CaptureModeAdapter::CAPTURE_HOME_SCREEN;
674 g_screenCaptureConfig->dataType = DataTypeAdapter::ENCODED_STREAM_DATA_TYPE;
675 int32_t result = adapterImpl->Init(g_screenCaptureConfig);
676 EXPECT_EQ(result, -1);
677 g_screenCaptureConfig->dataType = DataTypeAdapter::CAPTURE_FILE_DATA_TYPE;
678 g_screenCaptureConfig->audioInfo->micCapInfo->audioSampleRate = AUDIO_SAMPLE_RATE;
679 g_screenCaptureConfig->audioInfo->micCapInfo->audioChannels = AUDIO_CHANNELS;
680 g_screenCaptureConfig->audioInfo->innerCapInfo->audioSampleRate = AUDIO_SAMPLE_RATE;
681 g_screenCaptureConfig->audioInfo->innerCapInfo->audioChannels = AUDIO_CHANNELS;
682 g_screenCaptureConfig->videoInfo->videoCapInfo->videoFrameWidth = SCREEN_WIDTH;
683 g_screenCaptureConfig->videoInfo->videoCapInfo->videoFrameHeight = SCREEN_HEIGHT;
684 g_screenCaptureConfig->videoInfo->videoEncInfo->videoCodec = VideoCodecFormatAdapter::VIDEO_CODEC_FORMAT_BUTT;
685 g_screenCaptureConfig->recorderInfo->fileFormat = ContainerFormatTypeAdapter::CFT_MPEG_4A_TYPE;
686 result = adapterImpl->Init(g_screenCaptureConfig);
687 EXPECT_EQ(result, -1);
688 g_screenCaptureConfig->recorderInfo->fileFormat = ContainerFormatTypeAdapter::CFT_MPEG_4_TYPE;
689 result = adapterImpl->Init(g_screenCaptureConfig);
690 EXPECT_EQ(result, -1);
691 adapterImpl->screenCapture_ = OHOS::Media::ScreenCaptureFactory::CreateScreenCapture();
692 result = adapterImpl->Init(g_screenCaptureConfig);
693 EXPECT_EQ(result, 0);
694 }
695
696 /**
697 * @tc.name: ScreenCaptureAdapterImplTest_AcquireVideoBuffer_007
698 * @tc.desc: AcquireVideoBuffer.
699 * @tc.type: FUNC
700 * @tc.require:
701 */
702 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_AcquireVideoBuffer_007, TestSize.Level1)
703 {
704 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
705 EXPECT_NE(adapterImpl, nullptr);
706 ScreenCaptureImplMock* mock = new ScreenCaptureImplMock();
707 EXPECT_NE(mock, nullptr);
708 sptr<OHOS::SurfaceBuffer> surfacebuffer = new SurfaceBufferImpl(0);
709 EXPECT_NE(surfacebuffer, nullptr);
710 adapterImpl->screenCapture_.reset(mock);
711 EXPECT_CALL(*mock, AcquireVideoBuffer(::testing::_, ::testing::_, ::testing::_))
712 .Times(1)
713 .WillRepeatedly(::testing::Return(surfacebuffer));
714
715 EXPECT_CALL(*mock, ReleaseVideoBuffer()).Times(1).WillRepeatedly(::testing::Return(Media::MSERR_OK));
716 std::shared_ptr<SurfaceBufferAdapter> buffer = adapterImpl->AcquireVideoBuffer();
717 EXPECT_NE(buffer, nullptr);
718 int32_t result = adapterImpl->ReleaseVideoBuffer();
719 EXPECT_EQ(result, 0);
720 adapterImpl->screenCapture_.reset();
721 }
722
723 /**
724 * @tc.name: ScreenCaptureAdapterImplTest_AcquireAudioBuffer_008
725 * @tc.desc: AcquireAudioBuffer.
726 * @tc.type: FUNC
727 * @tc.require:
728 */
729 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_AcquireAudioBuffer_008, TestSize.Level1)
730 {
731 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
732 EXPECT_NE(adapterImpl, nullptr);
733 ScreenCaptureImplMock* mock = new ScreenCaptureImplMock();
734 EXPECT_NE(mock, nullptr);
735 std::shared_ptr<MockAudioBufferAdapter> audiobuffer = nullptr;
736 EXPECT_EQ(audiobuffer, nullptr);
737 adapterImpl->screenCapture_.reset(mock);
738
739 EXPECT_CALL(*mock, ReleaseAudioBuffer(::testing::_)).Times(1).WillRepeatedly(::testing::Return(0));
740 AudioCaptureSourceTypeAdapter type = AudioCaptureSourceTypeAdapter::MIC;
741 int32_t ret = adapterImpl->AcquireAudioBuffer(audiobuffer, type);
742 EXPECT_EQ(ret, -1);
743 int32_t result = adapterImpl->ReleaseAudioBuffer(type);
744 EXPECT_EQ(result, 0);
745 adapterImpl->screenCapture_.reset();
746 }
747
748 /**
749 * @tc.name: ScreenCaptureAdapterImplTest_AcquireAudioBuffer_009
750 * @tc.desc: AcquireAudioBuffer.
751 * @tc.type: FUNC
752 * @tc.require:
753 */
754 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_AcquireAudioBuffer_009, TestSize.Level1)
755 {
756 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
757 EXPECT_NE(adapterImpl, nullptr);
758 ScreenCaptureImplMock* mock = new ScreenCaptureImplMock();
759 EXPECT_NE(mock, nullptr);
760 adapterImpl->screenCapture_.reset(mock);
761 EXPECT_CALL(*mock, AcquireAudioBuffer(::testing::_, ::testing::_))
762 .Times(1)
763 .WillRepeatedly(::testing::Return(-1));
764
765 EXPECT_CALL(*mock, ReleaseAudioBuffer(::testing::_)).Times(1).WillRepeatedly(::testing::Return(-1));
766 AudioCaptureSourceTypeAdapter type = AudioCaptureSourceTypeAdapter::ALL_PLAYBACK;
767 int32_t ret = adapterImpl->AcquireAudioBuffer(g_audioBufferAdapter, type);
768 EXPECT_EQ(ret, -1);
769 int32_t result = adapterImpl->ReleaseAudioBuffer(type);
770 EXPECT_EQ(result, -1);
771 adapterImpl->screenCapture_.reset();
772 }
773
774 /**
775 * @tc.name: ScreenCaptureAdapterImplTest_ConvertAudioCaptureSourceType_010
776 * @tc.desc: ConvertAudioCaptureSourceType.
777 * @tc.type: FUNC
778 * @tc.require:
779 */
780 HWTEST_F(ScreenCaptureAdapterImplTest, ScreenCaptureAdapterImplTest_ConvertAudioCaptureSourceType_010, TestSize.Level1)
781 {
782 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
783 EXPECT_NE(adapterImpl, nullptr);
784 AudioCaptureSourceTypeAdapter type;
785 OHOS::Media::AudioCaptureSourceType result;
786
787 type = AudioCaptureSourceTypeAdapter::SOURCE_DEFAULT;
788 result = ConvertAudioCaptureSourceType(type);
789 EXPECT_EQ(result, OHOS::Media::AudioCaptureSourceType::SOURCE_DEFAULT);
790
791 type = AudioCaptureSourceTypeAdapter::MIC;
792 result = ConvertAudioCaptureSourceType(type);
793 EXPECT_EQ(result, OHOS::Media::AudioCaptureSourceType::MIC);
794
795 type = AudioCaptureSourceTypeAdapter::ALL_PLAYBACK;
796 result = ConvertAudioCaptureSourceType(type);
797 EXPECT_EQ(result, OHOS::Media::AudioCaptureSourceType::ALL_PLAYBACK);
798
799 type = AudioCaptureSourceTypeAdapter::APP_PLAYBACK;
800 result = ConvertAudioCaptureSourceType(type);
801 EXPECT_EQ(result, OHOS::Media::AudioCaptureSourceType::APP_PLAYBACK);
802
803 type = static_cast<AudioCaptureSourceTypeAdapter>(999); // Invalid source
804 result = ConvertAudioCaptureSourceType(type);
805 EXPECT_EQ(result, OHOS::Media::AudioCaptureSourceType::SOURCE_INVALID);
806 }
807
808 /**
809 * @tc.name: ScreenCaptureAdapterImplTest_GetScreenCaptureStateCodeAdapter_011
810 * @tc.desc: GetScreenCaptureStateCodeAdapter.
811 * @tc.type: FUNC
812 * @tc.require:
813 */
814 HWTEST_F(ScreenCaptureAdapterImplTest,
815 ScreenCaptureAdapterImplTest_GetScreenCaptureStateCodeAdapter_011, TestSize.Level1)
816 {
817 auto adapterImpl = std::make_shared<ScreenCaptureAdapterImpl>();
818 EXPECT_NE(adapterImpl, nullptr);
819 OHOS::Media::AVScreenCaptureStateCode stateCode;
820 ScreenCaptureStateCodeAdapter result;
821
822 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_STARTED;
823 result = GetScreenCaptureStateCodeAdapter(stateCode);
824 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_STARTED);
825
826 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_CANCELED;
827 result = GetScreenCaptureStateCodeAdapter(stateCode);
828 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_CANCELED);
829
830 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_STOPPED_BY_USER;
831 result = GetScreenCaptureStateCodeAdapter(stateCode);
832 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_STOPPED_BY_USER);
833
834 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER;
835 result = GetScreenCaptureStateCodeAdapter(stateCode);
836 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_INTERRUPTED_BY_OTHER);
837
838 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_STOPPED_BY_CALL;
839 result = GetScreenCaptureStateCodeAdapter(stateCode);
840 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_STOPPED_BY_CALL);
841
842 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE;
843 result = GetScreenCaptureStateCodeAdapter(stateCode);
844 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_MIC_UNAVAILABLE);
845
846 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER;
847 result = GetScreenCaptureStateCodeAdapter(stateCode);
848 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_MIC_MUTED_BY_USER);
849
850 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER;
851 result = GetScreenCaptureStateCodeAdapter(stateCode);
852 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_MIC_UNMUTED_BY_USER);
853
854 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE;
855 result = GetScreenCaptureStateCodeAdapter(stateCode);
856 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE);
857
858 stateCode = OHOS::Media::AVScreenCaptureStateCode::SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE;
859 result = GetScreenCaptureStateCodeAdapter(stateCode);
860 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE);
861
862 stateCode = static_cast<OHOS::Media::AVScreenCaptureStateCode>(999);;
863 result = GetScreenCaptureStateCodeAdapter(stateCode);
864 EXPECT_EQ(result, ScreenCaptureStateCodeAdapter::SCREEN_CAPTURE_STATE_INVLID);
865 }
866 } // namespace NWeb
867 } // namespace OHOS
868