diff --git a/test/distributedscreentest/BUILD.gn b/test/distributedscreentest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d888b4682b750cdcef28817e8f02afc81998ca83 --- /dev/null +++ b/test/distributedscreentest/BUILD.gn @@ -0,0 +1,78 @@ +# Copyright (C) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +base_root = "../../../../../" +import("//test/xts/tools/build/suite.gni") +import( + "$base_root/foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +module_output_path = "distributed_screen/test" + +ohos_moduletest_suite("SubDctsdisScreenTest") { + module_out_path = module_output_path + include_dirs = [ + "$base_root/foundation/distributedhardware/distributed_screen/services/common/utils/include", + "$base_root/foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/screen_sink/include", + "$base_root/foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/screen_source/include", + "$base_root/foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/screen_source/include/callback", + "$base_root/foundation/distributedhardware/distributed_hardware_fwk/common/utils/include", + "$base_root/foundation/window/window_manager/interfaces/innerkits/dm", + "$base_root/foundation/distributedhardware/distributed_screen/services/screenclient/include", + "$base_root/foundation/window/window_manager/interfaces/innerkits/wm", + "$base_root/foundation/distributedhardware/distributed_screen/common/include", + "$base_root/foundation/distributedhardware/distributed_hardware_fwk/common/log/include", + "$base_root/foundation/distributedhardware/distributed_hardware_fwk/utils/include/log", + "$base_root/base/security/access_token/interfaces/innerkits/accesstoke/include", + "$base_root/base/security/access_token/interfaces/innerkits/nativetoken/include", + "$base_root/base/security/access_token/interfaces/innerkits/token_setproc/include", + "$base_root/foundation/communication/dsoftbus/interfaces/kits/common", + ] + + include_dirs += [ "$base_root/foundation/multimedia/player_framework/interfaces/inner_api/native" ] + + sources = [ + "decoder_demo.cpp", + "dsreen_automat_test.cpp", + "test.cpp", + ] + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"SubDctsdisScreenTest\"", + "LOG_DOMAIN=0xD004100", + ] + + deps = [ + "$base_root/base/security/access_token/interfaces/innerkits/nativetoken:libnativetoken", + "$base_root/base/security/access_token/interfaces/innerkits/token_setproc:libtoken_setproc", + "$base_root/foundation/communication/dsoftbus/adapter:softbus_adapter", + "$base_root/foundation/communication/dsoftbus/sdk:softbus_client", + "$base_root/foundation/distributedhardware/distributed_screen/common:distributed_screen_utils", + "$base_root/foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", + "$base_root/foundation/distributedhardware/distributed_screen/interfaces/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", + "$base_root/foundation/distributedhardware/distributed_screen/services/screenclient:distributed_screen_client", + "$base_root/foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client", + "$base_root/foundation/systemabilitymgr/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", + "$base_root/foundation/window/window_manager/dm:libdm", + "$base_root/foundation/window/window_manager/wm:libwm", + ] + + external_deps = [ + "access_token:libaccesstoken_sdk", + "hilog:libhilog", + "player_framework:media_client", + ] + + subsystem_name = "distributedhardware" + part_name = "distributed_screen" +} diff --git a/test/distributedscreentest/Test.json b/test/distributedscreentest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..62bce90d81dab4c670f0b27de76e2f5c461e51be --- /dev/null +++ b/test/distributedscreentest/Test.json @@ -0,0 +1,22 @@ +{ + "description": "Config for disSreen test cases", + "driver": { + "module-name": "SubDctsdisScreenTest", + "native-test-timeout": "120000", + "native-test-device-path": "/data/local/tmp", + "runtime-hint": "1s", + "type": "CppTest" + }, + "kits": [ + { + "post-push" : [ + "chmod -R 777 /data/local/tmp/*" + ], + "push": [ + "SubDctsdisScreenTest->/data/local/tmp/SubDctsdisScreenTest" + ], + "type": "PushKit" + } + ] +} + diff --git a/test/distributedscreentest/decoder_demo.cpp b/test/distributedscreentest/decoder_demo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..88aca6d916832f5cff7b773edf752241d9ba9bd5 --- /dev/null +++ b/test/distributedscreentest/decoder_demo.cpp @@ -0,0 +1,338 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "decoder_demo.h" + +#include +#include + +#include "avcodec_list.h" +#include "securec.h" +#include "wm_common.h" +#include "window.h" +#include "window_option.h" + +using namespace OHOS::DistributedHardware; + +static const int32_t ES_R[325] = { + 11895, 8109, 1578, 1616, 1313, 572, 805, 837, 755, 706, 952, 879, 13193, 422, 389, 509, 725, 465, 479, 959, + 677, 364, 541, 696, 9306, 322, 318, 767, 590, 422, 530, 403, 505, 566, 445, 508, 7783, 460, 405, 343, 451, + 608, 431, 411, 543, 487, 527, 400, 6287, 385, 418, 391, 592, 434, 412, 398, 504, 492, 479, 561, 5413, 317, + 355, 422, 467, 452, 476, 460, 490, 492, 485, 451, 5036, 312, 408, 460, 432, 502, 388, 475, 407, 544, 401, + 487, 4404, 362, 378, 427, 416, 426, 456, 414, 438, 424, 442, 444, 4310, 362, 388, 393, 390, 441, 398, 423, + 369, 443, 406, 392, 4231, 343, 363, 355, 390, 459, 371, 378, 381, 405, 392, 426, 3975, 387, 337, 393, 439, + 378, 355, 374, 484, 381, 373, 423, 3869, 312, 350, 400, 345, 356, 320, 473, 431, 386, 338, 431, 3426, 268, + 315, 416, 383, 373, 381, 354, 383, 328, 348, 418, 3715, 324, 361, 331, 350, 302, 409, 377, 359, 384, 334, + 326, 3439, 266, 324, 329, 353, 405, 303, 357, 332, 292, 361, 333, 3542, 294, 284, 247, 331, 306, 322, 287, + 367, 341, 276, 258, 3980, 246, 245, 259, 309, 333, 250, 275, 334, 281, 253, 371, 3640, 213, 231, 301, 302, + 228, 289, 290, 281, 201, 284, 277, 4242, 205, 328, 237, 283, 295, 266, 230, 321, 348, 212, 308, 4103, 259, + 238, 245, 298, 330, 265, 271, 287, 267, 286, 290, 3856, 269, 242, 209, 314, 267, 278, 280, 314, 250, 433, + 238, 3654, 195, 246, 301, 298, 250, 270, 320, 269, 305, 258, 368, 3810, 231, 212, 279, 289, 252, 303, 287, + 295, 206, 264, 349, 4071, 242, 296, 271, 231, 307, 265, 254, 267, 317, 232, 348, 4077, 259, 222, 268, 235, + 324, 266, 256, 312, 246, 248, 325, 4000, 266, 201, 230, 293, 264, 265, 273, 301, 304, 253, 266, 3978, 228, + 232, 250, 248, 281, 219, 243, 293, 287, 253, 328, 3719 +}; + +static const int32_t ES_W[183] = { + 2111, 109091, 9316, 969, 13656, 1349, 959, 10484, 1219, 14839, 1092, 23378, 1653, 1725, 1526, 8500, 15407, + 2058, 1346, 21066, 3758, 1734, 1950, 19955, 3997, 1732, 1784, 22687, 4392, 2448, 2180, 17456, 3930, 1851, + 1802, 24227, 4393, 2639, 2778, 18314, 4023, 2392, 2283, 20566, 4118, 2664, 2013, 18964, 2624, 45258, 5860, + 4124, 3473, 27772, 4687, 3140, 2939, 26288, 3808, 2967, 2823, 27219, 3943, 3242, 2667, 27372, 3522, 2899, + 2316, 26608, 3284, 2853, 2285, 19581, 2894, 2436, 24898, 4002, 2876, 2807, 25730, 3903, 2874, 2975, 26309, + 3771, 2763, 2666, 23404, 3826, 2410, 2644, 24629, 4145, 3121, 2878, 50773, 7040, 3945, 3292, 30828, 5210, + 2883, 3277, 31501, 4809, 3068, 3220, 30746, 4715, 3461, 3583, 32278, 4798, 3398, 3389, 31404, 4921, 3382, + 3766, 31821, 5848, 3860, 4047, 37642, 5793, 4271, 4094, 29853, 6163, 4399, 4063, 32151, 6038, 4332, 4041, + 30390, 5679, 4098, 3921, 29401, 5307, 3996, 3945, 45997, 7060, 3716, 4183, 26357, 6190, 3714, 4250, 29086, + 5929, 3491, 4489, 27772, 6656, 4219, 4348, 25851, 6088, 3617, 4477, 25722, 6303, 3856, 4208, 25348, 5896, + 3816, 4521, 22462, 5914, 3673, 4594, 18091, 6474, 3878, 4492, 10890, 4823, 4148 +}; + +using namespace OHOS; +using namespace OHOS::Media; +using namespace std; +namespace { + constexpr uint32_t DEFAULT_FRAME_RATE = 30; + constexpr uint32_t MAX_INPUT_BUFFER_SIZE = 30000; + constexpr uint32_t FRAME_DURATION_US = 33000; + constexpr uint32_t VIDEO_DATA_FORMAT_NV12 = 2; + constexpr uint32_t VIDEO_DATA_FORMAT_RGBA = 5; + constexpr uint32_t SLEEP_THREE_SECOND = 3; + constexpr uint32_t INDEX_CONSTANT = 10000; + const string CODEC_NAME_H264 = "OMX_hisi_video_encoder_avc"; + const string CODEC_NAME_MPEG4 = "avenc_mpeg4"; +} + +void VDecDemo::RunCase() +{ + CheckCodecType(); + CreateVdec(); + Format format; + format.PutIntValue("width", width_); + format.PutIntValue("height", height_); + if (isW) { + format.PutIntValue("pixel_format", VIDEO_DATA_FORMAT_NV12); + } else { + format.PutIntValue("pixel_format", VIDEO_DATA_FORMAT_RGBA); + } + format.PutIntValue("frame_rate", DEFAULT_FRAME_RATE); + format.PutIntValue("max_input_size", MAX_INPUT_BUFFER_SIZE); + Configure(format); + SetSurface(); + Prepare(); + Start(); + sleep(SLEEP_THREE_SECOND); + Stop(); + Release(); +} + +int32_t VDecDemo::CreateVdec() +{ + if (isW) { + vdec_ = VideoDecoderFactory::CreateByMime("video/avc"); + } else { + vdec_ = VideoDecoderFactory::CreateByMime("video/mp4v-es"); + } + + signal_ = make_shared(); + cb_ = make_unique(signal_); + vdec_->SetCallback(cb_); + return 0; +} + +int32_t VDecDemo::Configure(const Format &format) +{ + return vdec_->Configure(format); +} + +int32_t VDecDemo::Prepare() +{ + return vdec_->Prepare(); +} + +int32_t VDecDemo::Start() +{ + isRunning_.store(true); + + testFile_ = std::make_unique(); + testFile_->open("/data/media/video.es", std::ios::in | std::ios::binary); + + inputLoop_ = make_unique(&VDecDemo::InputFunc, this); + outputLoop_ = make_unique(&VDecDemo::OutputFunc, this); + return vdec_->Start(); +} + +int32_t VDecDemo::Stop() +{ + isRunning_.store(false); + + if (inputLoop_ != nullptr && inputLoop_->joinable()) { + { + unique_lock inLock(signal_->inMutex_); + signal_->inQueue_.push(INDEX_CONSTANT); + signal_->inCond_.notify_all(); + } + inputLoop_->join(); + inputLoop_.reset(); + } + + if (outputLoop_ != nullptr && outputLoop_->joinable()) { + { + unique_lock outLock(signal_->outMutex_); + signal_->outQueue_.push(INDEX_CONSTANT); + signal_->outCond_.notify_all(); + } + outputLoop_->join(); + outputLoop_.reset(); + } + + return vdec_->Stop(); +} + +int32_t VDecDemo::Flush() +{ + return vdec_->Flush(); +} + +int32_t VDecDemo::Reset() +{ + return vdec_->Reset(); +} + +int32_t VDecDemo::Release() +{ + return vdec_->Release(); +} + +void VDecDemo::SetOutputSurface(sptr surface) +{ + surface_ = surface; +} + +void VDecDemo::SetWindowSize(uint32_t width, uint32_t height) +{ + width_ = width; + height_ = height; +} + +int32_t VDecDemo::SetSurface() +{ + return vdec_->SetOutputSurface(surface_); +} + +void VDecDemo::CheckCodecType() +{ + std::vector localCodecArray; + std::shared_ptr codecList = Media::AVCodecListFactory::CreateAVCodecList(); + std::vector> caps = codecList->GetVideoEncoderCaps(); + for (const auto &cap : caps) { + std::shared_ptr codecInfo = cap->GetCodecInfo(); + localCodecArray.push_back(codecInfo->GetName()); + } + + if (std::find(localCodecArray.begin(), localCodecArray.end(), + CODEC_NAME_H264) != localCodecArray.end()) { + DHLOGI("device is W"); + isW = true; + } else if (std::find(localCodecArray.begin(), localCodecArray.end(), + CODEC_NAME_MPEG4) != localCodecArray.end()) { + DHLOGI("device is R"); + isW = false; + } +} + +const int32_t* VDecDemo::GetFrameLen() +{ + const int32_t* frameLen = nullptr; + if (isW) { + frameLen = ES_W; + defaultFrameCount_ = sizeof(ES_W) / sizeof(ES_W[0]); + } else { + frameLen = ES_R; + defaultFrameCount_ = sizeof(ES_R) / sizeof(ES_R[0]); + } + return frameLen; +} + +void VDecDemo::InputFunc() +{ + const int32_t *frameLen = GetFrameLen(); + + while (true) { + if (!isRunning_.load()) { + break; + } + + unique_lock lock(signal_->inMutex_); + signal_->inCond_.wait(lock, [this]() { return signal_->inQueue_.size() > 0; }); + + if (!isRunning_.load()) { + break; + } + + uint32_t index = signal_->inQueue_.front(); + auto buffer = vdec_->GetInputBuffer(index); + + char *fileBuffer = static_cast(malloc(sizeof(char) * (*frameLen) + 1)); + if (fileBuffer == nullptr) { + break; + } + + (void)testFile_->read(fileBuffer, *frameLen); + if (memcpy_s(buffer->GetBase(), buffer->GetSize(), fileBuffer, *frameLen) != EOK) { + free(fileBuffer); + DHLOGI("Fatal: memcpy fail"); + break; + } + + AVCodecBufferInfo info; + info.size = *frameLen; + info.offset = 0; + info.presentationTimeUs = timeStamp_; + + int32_t ret = 0; + if (isFirstFrame_) { + ret = vdec_->QueueInputBuffer(index, info, AVCODEC_BUFFER_FLAG_CODEC_DATA); + isFirstFrame_ = false; + } else { + ret = vdec_->QueueInputBuffer(index, info, AVCODEC_BUFFER_FLAG_NONE); + } + + free(fileBuffer); + frameLen++; + timeStamp_ += FRAME_DURATION_US; + signal_->inQueue_.pop(); + + frameCount_++; + if (frameCount_ == defaultFrameCount_) { + DHLOGI("Finish decode, exit"); + break; + } + + if (ret != 0) { + DHLOGI("Fatal error, exit"); + break; + } + } +} + +void VDecDemo::OutputFunc() +{ + while (true) { + if (!isRunning_.load()) { + break; + } + + unique_lock lock(signal_->outMutex_); + signal_->outCond_.wait(lock, [this]() { return signal_->outQueue_.size() > 0; }); + + if (!isRunning_.load()) { + break; + } + + uint32_t index = signal_->outQueue_.front(); + if (vdec_->ReleaseOutputBuffer(index, true) != 0) { + DHLOGI("Fatal: ReleaseOutputBuffer fail"); + break; + } + + signal_->outQueue_.pop(); + } +} + +void VDecDemoCallback::OnError(AVCodecErrorType errorType, int32_t errorCode) +{ + DHLOGI("Error received, errorType: %s, errorCode: %d", errorType, errorCode); +} + +void VDecDemoCallback::OnOutputFormatChanged(const Format &format) +{ + DHLOGI("OnOutputFormatChanged received"); +} + +void VDecDemoCallback::OnInputBufferAvailable(uint32_t index) +{ + DHLOGI("OnInputBufferAvailable received, index: %d", index); + unique_lock lock(signal_->inMutex_); + signal_->inQueue_.push(index); + signal_->inCond_.notify_all(); +} + +void VDecDemoCallback::OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) +{ + DHLOGI("OnOutputBufferAvailable received, index: %d", index); + unique_lock lock(signal_->outMutex_); + signal_->outQueue_.push(index); + signal_->outCond_.notify_all(); +} diff --git a/test/distributedscreentest/decoder_demo.h b/test/distributedscreentest/decoder_demo.h new file mode 100644 index 0000000000000000000000000000000000000000..fc7ee72d4594dd39e92f868a80573f438c13251b --- /dev/null +++ b/test/distributedscreentest/decoder_demo.h @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AVCODEC_VDEC_DEMO_H +#define AVCODEC_VDEC_DEMO_H + +#include +#include +#include +#include +#include + +#include "avcodec_video_decoder.h" +#include "nocopyable.h" +#include "distributed_hardware_log.h" + +namespace OHOS { +namespace Media { +class VDecSignal { +public: + std::mutex inMutex_; + std::mutex outMutex_; + std::condition_variable inCond_; + std::condition_variable outCond_; + std::queue inQueue_; + std::queue outQueue_; +}; + +class VDecDemoCallback : public AVCodecCallback, public NoCopyable { +public: + explicit VDecDemoCallback(std::shared_ptr signal) : signal_(signal) {}; + virtual ~VDecDemoCallback() = default; + + void OnError(AVCodecErrorType errorType, int32_t errorCode) override; + void OnOutputFormatChanged(const Format &format) override; + void OnInputBufferAvailable(uint32_t index) override; + void OnOutputBufferAvailable(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) override; + +private: + std::shared_ptr signal_; +}; + +class VDecDemo : public NoCopyable { +public: + VDecDemo() = default; + virtual ~VDecDemo() = default; + void RunCase(); + void SetOutputSurface(sptr surface); + void SetWindowSize(uint32_t width, uint32_t height); + +private: + int32_t CreateVdec(); + int32_t Configure(const Format &format); + int32_t Prepare(); + int32_t Start(); + int32_t Stop(); + int32_t Flush(); + int32_t Reset(); + int32_t Release(); + int32_t SetSurface(); + const int32_t *GetFrameLen(); + void InputFunc(); + void OutputFunc(); + void CheckCodecType(); + + std::atomic isRunning_ = false; + sptr surface_ = nullptr; + uint32_t width_ = 0; + uint32_t height_ = 0; + std::unique_ptr testFile_; + std::unique_ptr inputLoop_; + std::unique_ptr outputLoop_; + std::shared_ptr vdec_; + std::shared_ptr signal_; + std::shared_ptr cb_; + bool isFirstFrame_ = true; + bool isW = true; + int64_t timeStamp_ = 0; + uint32_t frameCount_ = 0; + uint32_t defaultFrameCount_ = 0; +}; +} // namespace Media +} // namespace OHOS + +int StartMirror(int mode); +int StopMirror(int mode); +int StartExpand(int mode); +int StopExpand(int mode); +int CreateWindow(int mode); +int CreateAnySizeWindow(int mode); +int QueryRemoteDeviceInfo(int mode); +int QueryRemoteScreenInfo(int mode); +#endif // AVCODEC_VDEC_DEMO_H \ No newline at end of file diff --git a/test/distributedscreentest/dsreen_automat_test.cpp b/test/distributedscreentest/dsreen_automat_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a1f01484404ce12004cc7b3e9a4697b8d12cfcf --- /dev/null +++ b/test/distributedscreentest/dsreen_automat_test.cpp @@ -0,0 +1,790 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "decoder_demo.h" +#include "nativetoken_kit.h" +#include "token_setproc.h" +#include "softbus_common.h" +#include "accesstoken_kit.h" + +using namespace testing::ext; +using namespace OHOS::DistributedHardware; +using namespace OHOS::Security::AccessToken; + +int32_t g_dSreenOk = 0; +int32_t g_dSleepOk = 1; +static constexpr int32_t DEFAULT_API_VERSION = 8; + +static PermissionStateFull g_testState = { + .permissionName = "ohos.permission.CAMERA", + .isGeneral = true, + .resDeviceID = {"local"}, + .grantStatus = {PermissionState::PERMISSION_GRANTED}, + .grantFlags = {1} +}; + +static HapPolicyParams g_PolicyPramsl = { + .apl = APL_NORMAL, + .domain = "test.domain.A", + .permList = {}, + .permStateList = {g_testState} +}; + + +class DSreenAutomatTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + DSreenAutomatTest(); +}; +void DSreenAutomatTest::SetUpTestCase(void) +{ + HapInfoParams info = { + .userID = 1, + .bundleName = "DctsdisScreenTest", + .instIndex = 0, + .appIDDesc = "testtesttesttest", + .apiVersion = DEFAULT_API_VERSION, + .isSystemApp = true + }; + AccessTokenIDEx tokenIdEx = {0}; + tokenIdEx = AccessTokenKit::AllocHapToken(info, g_PolicyPramsl); + SetSelfTokenID(tokenIdEx.tokenIDEx); + sleep(g_dSleepOk); + system("pidof accesstoken_ser | xargs kill -9"); +} + +void DSreenAutomatTest::TearDownTestCase(void) {} +void DSreenAutomatTest::SetUp(void) {} + +void DSreenAutomatTest::TearDown(void) {} +DSreenAutomatTest::DSreenAutomatTest(void) {} + +/** + * @tc.number : DCameraTest_0100 + * @tc.name :StartMirror() + * @tc.desc : [STD-DISTRIBUTED-0113]禁止修改OpenHarmony分布式屏幕交互协议 + * @tc.desc : The distributed screen starts mirroring the screen + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0100, TestSize.Level1) +{ + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_0200 + * @tc.name :StopMirror() + * @tc.desc : [STD-DISTRIBUTED-0113]禁止修改OpenHarmony分布式屏幕交互协议 + * @tc.desc : The distributed screen stops the image projection + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0200, TestSize.Level1) +{ + int ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_0300 + * @tc.name :StartExpand() + * @tc.desc : [STD-DISTRIBUTED-0113]禁止修改OpenHarmony分布式屏幕交互协议 + * @tc.desc : Distributed screens begin to expand the projection + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0300, TestSize.Level1) +{ + int ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartExpand fail"; +} + +/** + * @tc.number : DSreenTest_0400 + * @tc.name :StopExpand() + * @tc.desc : [STD-DISTRIBUTED-0113]禁止修改OpenHarmony分布式屏幕交互协议 + * @tc.desc : The distributed screen stops extending the projection + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0400, TestSize.Level1) +{ + int ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopExpand fail"; +} + +/** + * @tc.number : DSreenTest_0500 + * @tc.name :CreateWindow() + * @tc.desc : [STD-DISTRIBUTED-0113]禁止修改OpenHarmony分布式屏幕交互协议 + * @tc.desc : Distributed screen Creates a small window on the remote device + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0500, TestSize.Level1) +{ + int ret = CreateWindow(0); + EXPECT_EQ(g_dSreenOk, ret) << "CreateWindow fail"; +} + +/** + * @tc.number : DSreenTest_0600 + * @tc.name :QueryRemoteDeviceInfo() + * @tc.desc : [STD-DISTRIBUTED-0113]禁止修改OpenHarmony分布式屏幕交互协议 + * @tc.desc : Distributed screen Displays information about remote devices + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0600, TestSize.Level1) +{ + int ret = QueryRemoteDeviceInfo(0); + EXPECT_EQ(g_dSreenOk, ret) << "QueryRemoteDeviceInfo fail"; +} + +/** + * @tc.number : DSreenTest_0700 + * @tc.name :QueryRemoteScreenInfo() + * @tc.desc : [STD-DISTRIBUTED-0113]禁止修改OpenHarmony分布式屏幕交互协议 + * @tc.desc : Distributed screen Displays information about remote screens + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0700, TestSize.Level1) +{ + int ret = QueryRemoteScreenInfo(0); + EXPECT_EQ(g_dSreenOk, ret) << "QueryRemoteScreenInfo fail"; +} + +/** + * @tc.number : DSreenTest_0800 + * @tc.name :Call the start image projection and stop image projection to check whether it succeeds + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0800, TestSize.Level1) +{ + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_0900 + * @tc.name :Call to start and stop the extended projection to see if it is successful + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_0900, TestSize.Level1) +{ + int ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1000, TestSize.Level1) +{ + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = CreateWindow(0); + EXPECT_EQ(g_dSreenOk, ret) << "CreateWindow fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1100, TestSize.Level1) +{ + int ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = CreateWindow(0); + EXPECT_EQ(g_dSreenOk, ret) << "CreateWindow fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1200, TestSize.Level1) +{ + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = CreateWindow(0); + EXPECT_EQ(g_dSreenOk, ret) << "CreateWindow fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1300, TestSize.Level1) +{ + int ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = CreateWindow(0); + EXPECT_EQ(g_dSreenOk, ret) << "CreateWindow fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1400, TestSize.Level1) +{ + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = QueryRemoteDeviceInfo(0); + EXPECT_EQ(g_dSreenOk, ret) << "QueryRemoteDeviceInfo fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1500, TestSize.Level1) +{ + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = QueryRemoteScreenInfo(0); + EXPECT_EQ(g_dSreenOk, ret) << "QueryRemoteScreenInfo fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1600, TestSize.Level1) +{ + int ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = QueryRemoteDeviceInfo(0); + EXPECT_EQ(g_dSreenOk, ret) << "QueryRemoteDeviceInfo fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1700, TestSize.Level1) +{ + int ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = QueryRemoteScreenInfo(0); + EXPECT_EQ(g_dSreenOk, ret) << "QueryRemoteScreenInfo fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1800, TestSize.Level1) +{ + int ret = CreateWindow(0); + EXPECT_EQ(g_dSreenOk, ret) << "CreateWindow fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_1900, TestSize.Level1) +{ + int ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2000, TestSize.Level1) +{ + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2100, TestSize.Level1) +{ + int ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_1000 + * @tc.name :Scramble the method invocation order to see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2200, TestSize.Level1) +{ + int ret = CreateWindow(0); + EXPECT_EQ(g_dSreenOk, ret) << "CreateWindow fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_2300 + * @tc.name :StartMirror method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2300, TestSize.Level1) +{ + int ret = StartMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StartMirror fail"; +} + +/** + * @tc.number : DSreenTest_2400 + * @tc.name :StopMirror method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2400, TestSize.Level1) +{ + int ret = StopMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_2500 + * @tc.name :StartExpand method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2500, TestSize.Level1) +{ + int ret = StartExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StartExpand fail"; +} + +/** + * @tc.number : DSreenTest_2600 + * @tc.name :StopExpand method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2600, TestSize.Level1) +{ + int ret = StopExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StopExpand fail"; +} + +/** + * @tc.number : DSreenTest_2700 + * @tc.name :CreateWindow method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2700, TestSize.Level1) +{ + int ret = CreateWindow(2); + EXPECT_NE(g_dSreenOk, ret) << "CreateWindow fail"; +} + +/** + * @tc.number : DSreenTest_2800 + * @tc.name :QueryRemoteDeviceInfo method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2800, TestSize.Level1) +{ + int ret = QueryRemoteDeviceInfo(2); + EXPECT_NE(g_dSreenOk, ret) << "QueryRemoteDeviceInfo fail"; +} + +/** + * @tc.number : DSreenTest_2900 + * @tc.name :QueryRemoteScreenInfo method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_2900, TestSize.Level1) +{ + int ret = QueryRemoteScreenInfo(2); + EXPECT_NE(g_dSreenOk, ret) << "QueryRemoteScreenInfo fail"; +} + +/** + * @tc.number : DSreenTest_3000 + * @tc.name :StartMirror and StopMirror method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3000, TestSize.Level1) +{ + int ret = StartMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StopMirror fail"; +} + +/** + * @tc.number : DSreenTest_3100 + * @tc.name :StartMirror and StartExpand method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3100, TestSize.Level1) +{ + int ret = StartMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StartMirror fail"; + ret = StartExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StartExpand fail"; +} + +/** + * @tc.number : DSreenTest_3200 + * @tc.name :StartMirror and CreateWindow method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3200, TestSize.Level1) +{ + int ret = StartMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StartMirror fail"; + ret = CreateWindow(2); + EXPECT_NE(g_dSreenOk, ret) << "CreateWindow fail"; +} + +/** + * @tc.number : DSreenTest_3300 + * @tc.name :StartMirror and QueryRemoteDeviceInfo method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3300, TestSize.Level1) +{ + int ret = StartMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StartMirror fail"; + ret = QueryRemoteDeviceInfo(2); + EXPECT_NE(g_dSreenOk, ret) << "QueryRemoteDeviceInfo fail"; +} + +/** + * @tc.number : DSreenTest_3400 + * @tc.name :StartMirror and QueryRemoteScreenInfo method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3400, TestSize.Level1) +{ + int ret = StartMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StartMirror fail"; + ret = QueryRemoteScreenInfo(2); + EXPECT_NE(g_dSreenOk, ret) << "QueryRemoteScreenInfo fail"; +} + +/** + * @tc.number : DSreenTest_3500 + * @tc.name :StartMirror and StopExpand method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3500, TestSize.Level1) +{ + int ret = StartMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StopExpand fail"; +} + +/** + * @tc.number : DSreenTest_3600 + * @tc.name :StopMirror and StartExpand method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3600, TestSize.Level1) +{ + int ret = StopMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StopMirror fail"; + ret = StartExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StartExpand fail"; +} + +/** + * @tc.number : DSreenTest_3700 + * @tc.name :StopMirror and CreateWindow method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3700, TestSize.Level1) +{ + int ret = StopMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StopMirror fail"; + ret = CreateWindow(2); + EXPECT_NE(g_dSreenOk, ret) << "CreateWindow fail"; +} + +/** + * @tc.number : DSreenTest_3800 + * @tc.name :StopMirror and QueryRemoteDeviceInfo method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3800, TestSize.Level1) +{ + int ret = StopMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StopMirror fail"; + ret = QueryRemoteDeviceInfo(2); + EXPECT_NE(g_dSreenOk, ret) << "QueryRemoteDeviceInfo fail"; +} + +/** + * @tc.number : DSreenTest_3900 + * @tc.name :StopMirror and QueryRemoteScreenInfo method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_3900, TestSize.Level1) +{ + int ret = StopMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StopMirror fail"; + ret = QueryRemoteScreenInfo(2); + EXPECT_NE(g_dSreenOk, ret) << "QueryRemoteScreenInfo fail"; +} + +/** + * @tc.number : DSreenTest_4000 + * @tc.name :StopMirror and StopExpand method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_4000, TestSize.Level1) +{ + int ret = StopMirror(2); + EXPECT_NE(g_dSreenOk, ret) << "StopMirror fail"; + ret = StopExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StopExpand fail"; +} + +/** + * @tc.number : DSreenTest_4100 + * @tc.name :StartExpand and CreateWindow method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_4100, TestSize.Level1) +{ + int ret = StartExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StartExpand fail"; + ret = CreateWindow(2); + EXPECT_NE(g_dSreenOk, ret) << "CreateWindow fail"; +} + +/** + * @tc.number : DSreenTest_4200 + * @tc.name :StartExpand and QueryRemoteDeviceInfo method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_4200, TestSize.Level1) +{ + int ret = StartExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StartExpand fail"; + ret = QueryRemoteDeviceInfo(2); + EXPECT_NE(g_dSreenOk, ret) << "QueryRemoteDeviceInfo fail"; +} + +/** + * @tc.number : DSreenTest_4300 + * @tc.name :StartExpand and StopExpand method Enter error parameters to see the return value + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_4300, TestSize.Level1) +{ + int ret = StartExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StartExpand fail"; + ret = StopExpand(2); + EXPECT_NE(g_dSreenOk, ret) << "StopExpand fail"; +} + +/** + * @tc.number : DSreenTest_4400 + * @tc.name :CreateAnySizeWindow() + * @tc.desc : Composite test function + * @tc.desc : CreateWindow method Enter error parameters to see the return value + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_4400, TestSize.Level1) +{ + int ret = CreateAnySizeWindow(0); + EXPECT_EQ(g_dSreenOk, ret) << "CreateAnySizeWindow fail"; +} + +/** + * @tc.number : DSreenTest_4500 + * @tc.name :StartMirror and StopMirror functions are repeated 5 times see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_4500, TestSize.Level1) +{ + for (int i = 0; i < 5; ++i) { + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + } +} + +/** + * @tc.number : DSreenTest_4600 + * @tc.name :StartMirror StopMirror StartExpand StopExpand see if the method invocation fails + * @tc.desc : Composite test function + * @tc.type : FUNC + * @tc.size : Medium test + */ +HWTEST_F(DSreenAutomatTest, DSreenTest_4600, TestSize.Level1) +{ + int ret = StartMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartMirror fail"; + ret = StopMirror(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopMirror fail"; + ret = StartExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StartExpand fail"; + ret = StopExpand(0); + EXPECT_EQ(g_dSreenOk, ret) << "StopExpand fail"; +} \ No newline at end of file diff --git a/test/distributedscreentest/test.cpp b/test/distributedscreentest/test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4cfbbd6e2fd79015e5249e831c3e5e65ee9bb522 --- /dev/null +++ b/test/distributedscreentest/test.cpp @@ -0,0 +1,387 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include "accesstoken_kit.h" +#include "display.h" +#include "display_manager.h" +#include "dscreen_source_handler.h" +#include "dscreen_sink_handler.h" +#include "dscreen_util.h" +#include "idistributed_hardware_sink.h" +#include "idistributed_hardware_source.h" +#include "screen.h" +#include "screen_client.h" +#include "screen_client_common.h" +#include "screen_manager.h" +#include "wm_common.h" +#include "window.h" +#include "window_option.h" +#include "nativetoken_kit.h" +#include "token_setproc.h" + +#include "decoder_demo.h" +#include "softbus_bus_center.h" +#include "softbus_common.h" + +using namespace std; +using namespace OHOS; +using namespace OHOS::DistributedHardware; +using namespace OHOS::Rosen; +using namespace OHOS::Media; +using namespace OHOS::Security::AccessToken; + +namespace { + static char const *g_pkgName = "ohos.dsoftbus.tool"; +} + +constexpr int32_t SLEEP_FIVE_SECOND = 10; +static vector> remoteScreens; +static uint64_t g_screenId = 0; + +int QueryRemoteScreenInfo(int mode) +{ + if (mode != 0) { + DHLOGE("QueryRemoteScreenInfo mode error"); + return -1; + } + vector> allScreens; + ScreenManager::GetInstance().GetAllScreens(allScreens); + sptr defaultDisplay = DisplayManager::GetInstance().GetDefaultDisplay(); + for (const auto &screen : allScreens) { + if (screen == nullptr) { + continue; + } + if (!screen->IsReal() && screen->GetWidth() > 0) { + remoteScreens.push_back(screen); + } + } + DHLOGE("-------------remote screen info---------------"); + DHLOGE("remote screen Num: %d", remoteScreens.size()); + for (const auto &screen : remoteScreens) { + if (screen == nullptr) { + continue; + } + g_screenId = screen->GetId(); + DHLOGE("--------screen id: %d ---------", screen->GetId()); + DHLOGE("screen name: : %s", GetAnonyString(screen->GetName()).c_str()); + DHLOGE("width: : %d", screen->GetWidth()); + DHLOGE("height : %d", screen->GetHeight()); + DHLOGE("-------------------------------------------"); + } + + return 0; +} + +int StartMirror(int mode) +{ + if (mode != 0) { + DHLOGE("StartMirror mode error"); + return -1; + } + uint64_t ret = QueryRemoteScreenInfo(0); + if (ret != 0) { + DHLOGE("Error: no remote screens enabled"); + return -1; + } + + DHLOGE("select remote screen id to mirror"); + + bool isMirrorIdValid = false; + for (const auto &screen : remoteScreens) { + if (screen == nullptr) { + continue; + } + if (screen->GetId() == g_screenId) { + isMirrorIdValid = true; + break; + } + } + + if (!isMirrorIdValid) { + DHLOGE("input mirrorId is not valid!"); + return -1; + } + + sptr defaultDisplay = DisplayManager::GetInstance().GetDefaultDisplay(); + DHLOGE("------------start mirror----------"); + DHLOGE("mirror screen Id is: %d", g_screenId); + vector mirrorIds; + mirrorIds.push_back(g_screenId); + ScreenId screenGroupId; + ScreenManager::GetInstance().MakeMirror(defaultDisplay->GetScreenId(), mirrorIds, screenGroupId); + sleep(SLEEP_FIVE_SECOND); + return 0; +} + +int StopMirror(int mode) +{ + if (mode != 0) { + DHLOGE("StopMirror mode error"); + return -1; + } + uint64_t ret = QueryRemoteScreenInfo(0); + if (ret != 0) { + DHLOGE("no remote screens enabled, no need stop mirror "); + return -1; + } + + bool isStopMirrorIdValid = false; + for (const auto &screen : remoteScreens) { + if (screen == nullptr) { + continue; + } + if (screen->GetId() == g_screenId) { + isStopMirrorIdValid = true; + break; + } + } + if (!isStopMirrorIdValid) { + DHLOGE("input g_screenId is not valid! "); + return -1; + } + + DHLOGE("-------------- stop mirror ------------"); + DHLOGE("stop mirror screen id is: %d", g_screenId); + vector stopMirrorIds; + stopMirrorIds.push_back(g_screenId); + ScreenManager::GetInstance().RemoveVirtualScreenFromGroup(stopMirrorIds); + sleep(SLEEP_FIVE_SECOND); + return 0; +} + +int StartExpand(int mode) +{ + if (mode != 0) { + DHLOGE("StartExpand mode error"); + return -1; + } + uint64_t ret = QueryRemoteScreenInfo(0); + if (ret != 0) { + DHLOGE("Error: no remote screens enabled"); + return -1; + } + + bool isExpandIdValid = false; + for (const auto &screen : remoteScreens) { + if (screen == nullptr) { + continue; + } + if (screen->GetId() == g_screenId) { + isExpandIdValid = true; + break; + } + } + + if (!isExpandIdValid) { + DHLOGE("input expandId is not valid!"); + return -1; + } + + sptr defaultDisplay = DisplayManager::GetInstance().GetDefaultDisplay(); + DHLOGE("------------start expand----------"); + DHLOGE("expand screen Id is: %d", g_screenId); + vector options = {{defaultDisplay->GetScreenId(), 0, 0}, {g_screenId, defaultDisplay->GetWidth(), 0}}; + ScreenId screenGroupId; + ScreenManager::GetInstance().MakeExpand(options, screenGroupId); + sleep(SLEEP_FIVE_SECOND); + return 0; +} + +int StopExpand(int mode) +{ + if (mode != 0) { + DHLOGE("StopExpand mode error"); + return -1; + } + uint64_t ret = QueryRemoteScreenInfo(0); + if (ret != 0) { + DHLOGE("no remote screens enabled, no need stop expand"); + return -1; + } + + bool isStopExpandIdValid = false; + for (const auto &screen : remoteScreens) { + if (screen == nullptr) { + continue; + } + if (screen->GetId() == g_screenId) { + isStopExpandIdValid = true; + break; + } + } + if (!isStopExpandIdValid) { + DHLOGE("input g_screenId is not valid!"); + return -1; + } + + DHLOGE("-------------- stop expand ------------"); + DHLOGE("stop expand screen id is : %d", g_screenId); + vector stopExpandIds; + stopExpandIds.push_back(g_screenId); + ScreenManager::GetInstance().RemoveVirtualScreenFromGroup(stopExpandIds); + sleep(SLEEP_FIVE_SECOND); + return 0; +} + +static void PrintNodeProperty(NodeBasicInfo *nodeInfo) +{ + if (nodeInfo == nullptr) { + DHLOGE("nodeInfo is nullptr"); + return; + } + + DHLOGE("DeviceName = %s", nodeInfo->deviceName); + DHLOGE("NetworkId = %s", GetAnonyString(nodeInfo->networkId).c_str()); + NodeDeviceInfoKey key = NODE_KEY_UDID; + unsigned char udid[UDID_BUF_LEN] = {0}; + if (GetNodeKeyInfo(g_pkgName, nodeInfo->networkId, key, udid, UDID_BUF_LEN) != 0) { + DHLOGE("GetNodeKeyInfo Fail!"); + } + key = NODE_KEY_UUID; + unsigned char uuid[UUID_BUF_LEN] = {0}; + if (GetNodeKeyInfo(g_pkgName, nodeInfo->networkId, key, uuid, UUID_BUF_LEN) != 0) { + DHLOGE("GetNodeKeyInfo Fail!"); + } else { + DHLOGE("Uuid = %s\n", GetAnonyString(reinterpret_cast(uuid)).c_str()); + } +} + +int QueryRemoteDeviceInfo(int mode) +{ + if (mode != 0) { + DHLOGE("QueryRemoteDeviceInfo mode error"); + return -1; + } + uint64_t tokenId; + const char *perms[2]; + perms[0] = OHOS_PERMISSION_DISTRIBUTED_SOFTBUS_CENTER; + perms[1] = OHOS_PERMISSION_DISTRIBUTED_DATASYNC; + NativeTokenInfoParams infoInstance = { + .dcapsNum = 0, + .permsNum = 2, + .aclsNum = 0, + .dcaps = NULL, + .perms = perms, + .acls = NULL, + .processName = "dscreen_test_demo", + .aplStr = "system_core", + }; + tokenId = GetAccessTokenId(&infoInstance); + SetSelfTokenID(tokenId); + OHOS::Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo(); + + NodeBasicInfo localNodeinfo; + NodeBasicInfo *remoteNodeInfo = nullptr; + int32_t infoNum = 0; + + DHLOGE("-----------Local Device Info------"); + + if (GetLocalNodeDeviceInfo(g_pkgName, &localNodeinfo) != 0) { + printf("LnnGetLocalNodeInfo Fail!\n"); + DHLOGE("LnnGetLocalNodeInfo Fail!"); + return -1; + } + + PrintNodeProperty(&localNodeinfo); + DHLOGE("-------Remote Device info---------"); + if (GetAllNodeDeviceInfo(g_pkgName, &remoteNodeInfo, &infoNum) != 0) { + DHLOGE("GetAllNodeDeviceInfo Fail!"); + return -1; + } + + DHLOGE("Device Num = %d", infoNum); + for (int i = 0; i < infoNum; ++i) { + DHLOGE("[No.%d]", i + 1); + PrintNodeProperty(remoteNodeInfo + i); + } + + FreeNodeInfo(remoteNodeInfo); + DHLOGE("SoftBusDumpDeviceInfo complete"); + sleep(SLEEP_FIVE_SECOND); + return 0; +} + +int CreateWindow(int mode) +{ + if (mode != 0) { + DHLOGE("CreateWindow mode error"); + return -1; + } + DHLOGE("create window, please input window size"); + + uint32_t windowWidth = 640; + uint32_t windowHeight = 480; + + sptr defaultDisplay = DisplayManager::GetInstance().GetDefaultDisplay(); + shared_ptr windowProperty = make_shared(); + windowProperty->displayId = defaultDisplay->GetId(); + windowProperty->startX = 0; + windowProperty->startY = 0; + windowProperty->width = windowWidth; + windowProperty->height = windowHeight; + int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); + ScreenClient::GetInstance().ShowWindow(windowId); + sptr surface = ScreenClient::GetInstance().GetSurface(windowId); + DHLOGE("create window success."); + + auto vdec = make_shared(); + + vdec->SetWindowSize(windowWidth, windowHeight); + vdec->SetOutputSurface(surface); + DHLOGE("start run decoder"); + vdec->RunCase(); + DHLOGE("create window success, window id: %d, width: %d, height: %d", windowId, windowWidth, windowHeight); + ScreenClient::GetInstance().RemoveWindow(windowId); + sleep(SLEEP_FIVE_SECOND); + return 0; +} + +int CreateAnySizeWindow(int mode) +{ + if (mode != 0) { + DHLOGE("CreateAnySizeWindow mode error"); + return -1; + } + DHLOGE("Create Any Size Window, please input window size"); + std::random_device rd; + uint32_t windowWidth = rd() % 1344 + 1; + uint32_t windowHeight = rd() % 2772 + 1; + + sptr defaultDisplay = DisplayManager::GetInstance().GetDefaultDisplay(); + shared_ptr windowProperty = make_shared(); + windowProperty->displayId = defaultDisplay->GetId(); + windowProperty->startX = 0; + windowProperty->startY = 0; + windowProperty->width = windowWidth; + windowProperty->height = windowHeight; + int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); + ScreenClient::GetInstance().ShowWindow(windowId); + sptr surface = ScreenClient::GetInstance().GetSurface(windowId); + DHLOGE("CreateAnySizeWindow success."); + + auto vdec = make_shared(); + + vdec->SetWindowSize(windowWidth, windowHeight); + vdec->SetOutputSurface(surface); + DHLOGE("start run decoder"); + vdec->RunCase(); + DHLOGE("CreateAnySizeWindow success, window id: %d, width: %d, height: %d", windowId, windowWidth, windowHeight); + ScreenClient::GetInstance().RemoveWindow(windowId); + sleep(SLEEP_FIVE_SECOND); + return 0; +} \ No newline at end of file