17c804472Sopenharmony_ci/* 27c804472Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 37c804472Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47c804472Sopenharmony_ci * you may not use this file except in compliance with the License. 57c804472Sopenharmony_ci * You may obtain a copy of the License at 67c804472Sopenharmony_ci * 77c804472Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87c804472Sopenharmony_ci * 97c804472Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107c804472Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117c804472Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127c804472Sopenharmony_ci * See the License for the specific language governing permissions and 137c804472Sopenharmony_ci * limitations under the License. 147c804472Sopenharmony_ci */ 157c804472Sopenharmony_ci 167c804472Sopenharmony_ci#include <string> 177c804472Sopenharmony_ci#include <vector> 187c804472Sopenharmony_ci#include "gtest/gtest.h" 197c804472Sopenharmony_ci#define private public 207c804472Sopenharmony_ci#define protected public 217c804472Sopenharmony_ci#include "VirtualScreenImpl.h" 227c804472Sopenharmony_ci#include "MockGlobalResult.h" 237c804472Sopenharmony_ci#include "CommandParser.h" 247c804472Sopenharmony_ci#include "VirtualScreen.h" 257c804472Sopenharmony_ci#include "CommandLineInterface.h" 267c804472Sopenharmony_ci 277c804472Sopenharmony_cinamespace { 287c804472Sopenharmony_ci class VirtualScreenImplTest : public ::testing::Test { 297c804472Sopenharmony_ci public: 307c804472Sopenharmony_ci VirtualScreenImplTest() {} 317c804472Sopenharmony_ci ~VirtualScreenImplTest() {} 327c804472Sopenharmony_ci protected: 337c804472Sopenharmony_ci static void InitBuffer() 347c804472Sopenharmony_ci { 357c804472Sopenharmony_ci int retHeight = 100; 367c804472Sopenharmony_ci int retWidth = 100; 377c804472Sopenharmony_ci int jpgPix = 4; 387c804472Sopenharmony_ci int pixelSize = 4; 397c804472Sopenharmony_ci uint8_t defaultVal = 200; 407c804472Sopenharmony_ci jpgWidth = retWidth; 417c804472Sopenharmony_ci jpgHeight = retHeight; 427c804472Sopenharmony_ci jpgBuffSize = static_cast<long>(retWidth) * static_cast<long>(retHeight) * static_cast<long>(jpgPix); 437c804472Sopenharmony_ci jpgBuff = new unsigned char[jpgBuffSize]; 447c804472Sopenharmony_ci for (int i = 0; i < jpgBuffSize ; i++) { 457c804472Sopenharmony_ci jpgBuff[i] = defaultVal; 467c804472Sopenharmony_ci } 477c804472Sopenharmony_ci } 487c804472Sopenharmony_ci 497c804472Sopenharmony_ci static void SetUpTestCase() 507c804472Sopenharmony_ci { 517c804472Sopenharmony_ci CommandLineInterface::GetInstance().InitPipe("phone"); 527c804472Sopenharmony_ci socket = std::make_unique<LocalSocket>(); 537c804472Sopenharmony_ci } 547c804472Sopenharmony_ci 557c804472Sopenharmony_ci static std::unique_ptr<LocalSocket> socket; 567c804472Sopenharmony_ci static unsigned char* jpgBuff; 577c804472Sopenharmony_ci static unsigned long jpgBuffSize; 587c804472Sopenharmony_ci static int32_t jpgWidth; 597c804472Sopenharmony_ci static int32_t jpgHeight; 607c804472Sopenharmony_ci }; 617c804472Sopenharmony_ci 627c804472Sopenharmony_ci std::unique_ptr<LocalSocket> VirtualScreenImplTest::socket = nullptr; 637c804472Sopenharmony_ci unsigned char* VirtualScreenImplTest::jpgBuff = nullptr; 647c804472Sopenharmony_ci unsigned long VirtualScreenImplTest::jpgBuffSize = 0; 657c804472Sopenharmony_ci int32_t VirtualScreenImplTest::jpgWidth = 0; 667c804472Sopenharmony_ci int32_t VirtualScreenImplTest::jpgHeight = 0; 677c804472Sopenharmony_ci 687c804472Sopenharmony_ci // 测试拷贝构造函数是否被删除 697c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, CopyConstructorDeletedTest) 707c804472Sopenharmony_ci { 717c804472Sopenharmony_ci EXPECT_TRUE(std::is_copy_constructible<VirtualScreenImpl>::value == false); 727c804472Sopenharmony_ci } 737c804472Sopenharmony_ci 747c804472Sopenharmony_ci // 测试赋值运算符是否被删除 757c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, AssignmentOperatorDeletedTest) 767c804472Sopenharmony_ci { 777c804472Sopenharmony_ci EXPECT_TRUE(std::is_copy_assignable<VirtualScreenImpl>::value == false); 787c804472Sopenharmony_ci } 797c804472Sopenharmony_ci 807c804472Sopenharmony_ci // VirtualScreen start 817c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetOrignalWidthTest) 827c804472Sopenharmony_ci { 837c804472Sopenharmony_ci int32_t width = 100; 847c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetOrignalWidth(width); 857c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetOrignalWidth(), width); 867c804472Sopenharmony_ci } 877c804472Sopenharmony_ci 887c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetCurrentRouterTest) 897c804472Sopenharmony_ci { 907c804472Sopenharmony_ci std::string router = "aaa"; 917c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetCurrentRouter(router); 927c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetCurrentRouter(), router); 937c804472Sopenharmony_ci } 947c804472Sopenharmony_ci 957c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetAbilityCurrentRouterTest) 967c804472Sopenharmony_ci { 977c804472Sopenharmony_ci std::string router = "aaa"; 987c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetAbilityCurrentRouter(router); 997c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetAbilityCurrentRouter(), router); 1007c804472Sopenharmony_ci } 1017c804472Sopenharmony_ci 1027c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetOrignalHeightTest) 1037c804472Sopenharmony_ci { 1047c804472Sopenharmony_ci int32_t width = 100; 1057c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetOrignalHeight(width); 1067c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetOrignalHeight(), width); 1077c804472Sopenharmony_ci } 1087c804472Sopenharmony_ci 1097c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetCompressionWidthTest) 1107c804472Sopenharmony_ci { 1117c804472Sopenharmony_ci int32_t width = 100; 1127c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetCompressionWidth(width); 1137c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetCompressionWidth(), width); 1147c804472Sopenharmony_ci } 1157c804472Sopenharmony_ci 1167c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetCompressionHeightTest) 1177c804472Sopenharmony_ci { 1187c804472Sopenharmony_ci int32_t width = 100; 1197c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetCompressionHeight(width); 1207c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetCompressionHeight(), width); 1217c804472Sopenharmony_ci } 1227c804472Sopenharmony_ci 1237c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, InitPipeTest) 1247c804472Sopenharmony_ci { 1257c804472Sopenharmony_ci std::string port = "8888"; 1267c804472Sopenharmony_ci g_run = false; 1277c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().InitPipe("aaa", port); 1287c804472Sopenharmony_ci EXPECT_EQ(WebSocketServer::GetInstance().serverPort, atoi(port.c_str())); 1297c804472Sopenharmony_ci EXPECT_TRUE(g_run); 1307c804472Sopenharmony_ci } 1317c804472Sopenharmony_ci 1327c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, InitVirtualScreenTest) 1337c804472Sopenharmony_ci { 1347c804472Sopenharmony_ci int width = 1111; 1357c804472Sopenharmony_ci int height = 2222; 1367c804472Sopenharmony_ci CommandParser::GetInstance().orignalResolutionWidth = width; 1377c804472Sopenharmony_ci CommandParser::GetInstance().orignalResolutionHeight = height; 1387c804472Sopenharmony_ci CommandParser::GetInstance().compressionResolutionWidth = width; 1397c804472Sopenharmony_ci CommandParser::GetInstance().compressionResolutionHeight = height; 1407c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().InitVirtualScreen(); 1417c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().orignalResolutionWidth, width); 1427c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().orignalResolutionHeight, height); 1437c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().compressionResolutionWidth, width); 1447c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().compressionResolutionHeight, height); 1457c804472Sopenharmony_ci } 1467c804472Sopenharmony_ci 1477c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, InitFrameCountTimerTest) 1487c804472Sopenharmony_ci { 1497c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().inputMethodCountPerMinute = 0; 1507c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().InitFrameCountTimer(); 1517c804472Sopenharmony_ci EXPECT_FALSE(VirtualScreenImpl::GetInstance().frameCountTimer == nullptr); 1527c804472Sopenharmony_ci 1537c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().InitFrameCountTimer(); 1547c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().inputMethodCountPerMinute, 0); 1557c804472Sopenharmony_ci } 1567c804472Sopenharmony_ci 1577c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, PrintFrameCountTest) 1587c804472Sopenharmony_ci { 1597c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().inputMethodCountPerMinute = 0; 1607c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().PrintFrameCount(); 1617c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().inputMethodCountPerMinute, 0); 1627c804472Sopenharmony_ci 1637c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().inputMethodCountPerMinute = 1; 1647c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().PrintFrameCount(); 1657c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().inputMethodCountPerMinute, 0); 1667c804472Sopenharmony_ci } 1677c804472Sopenharmony_ci 1687c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, WidthAndHeightReverseTest) 1697c804472Sopenharmony_ci { 1707c804472Sopenharmony_ci int32_t width = 1080; 1717c804472Sopenharmony_ci int32_t height = 2340; 1727c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().orignalResolutionHeight = height; 1737c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().orignalResolutionWidth = width; 1747c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().compressionResolutionHeight = height; 1757c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().compressionResolutionWidth = width; 1767c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().WidthAndHeightReverse(); 1777c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().orignalResolutionHeight, width); 1787c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().orignalResolutionWidth, height); 1797c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().compressionResolutionHeight, width); 1807c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().compressionResolutionWidth, height); 1817c804472Sopenharmony_ci } 1827c804472Sopenharmony_ci 1837c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetVirtualScreenWidthAndHeightTest) 1847c804472Sopenharmony_ci { 1857c804472Sopenharmony_ci int32_t width = 1080; 1867c804472Sopenharmony_ci int32_t height = 2340; 1877c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().orignalResolutionHeight = height; 1887c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().orignalResolutionWidth = width; 1897c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().compressionResolutionHeight = height; 1907c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().compressionResolutionWidth = width; 1917c804472Sopenharmony_ci int32_t newWidth = 2000; 1927c804472Sopenharmony_ci int32_t newHeight = 3000; 1937c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetVirtualScreenWidthAndHeight(newWidth, newHeight, newWidth, newHeight); 1947c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().orignalResolutionHeight, newHeight); 1957c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().orignalResolutionWidth, newWidth); 1967c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().compressionResolutionHeight, newHeight); 1977c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().compressionResolutionWidth, newWidth); 1987c804472Sopenharmony_ci } 1997c804472Sopenharmony_ci 2007c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, GetJpgQualityValueTest) 2017c804472Sopenharmony_ci { 2027c804472Sopenharmony_ci // <= 100000 2037c804472Sopenharmony_ci int32_t width = 200; 2047c804472Sopenharmony_ci int32_t height = 300; 2057c804472Sopenharmony_ci int ret = VirtualScreenImpl::GetInstance().GetJpgQualityValue(width, height); 2067c804472Sopenharmony_ci EXPECT_EQ(ret, 100); // 100 is jpeg quality 2077c804472Sopenharmony_ci // <= 300000 && > 100000 2087c804472Sopenharmony_ci width = 400; 2097c804472Sopenharmony_ci height = 500; 2107c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().GetJpgQualityValue(width, height); 2117c804472Sopenharmony_ci EXPECT_EQ(ret, 90); // 90 is jpeg quality 2127c804472Sopenharmony_ci width = 500; 2137c804472Sopenharmony_ci height = 600; 2147c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().GetJpgQualityValue(width, height); 2157c804472Sopenharmony_ci EXPECT_EQ(ret, 90); // 90 is jpeg quality 2167c804472Sopenharmony_ci // <= 500000 && > 300000 2177c804472Sopenharmony_ci width = 600; 2187c804472Sopenharmony_ci height = 700; 2197c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().GetJpgQualityValue(width, height); 2207c804472Sopenharmony_ci EXPECT_EQ(ret, 85); // 85 is jpeg quality 2217c804472Sopenharmony_ci width = 500; 2227c804472Sopenharmony_ci height = 1000; 2237c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().GetJpgQualityValue(width, height); 2247c804472Sopenharmony_ci EXPECT_EQ(ret, 85); // 85 is jpeg quality 2257c804472Sopenharmony_ci // > 500000 2267c804472Sopenharmony_ci width = 700; 2277c804472Sopenharmony_ci height = 800; 2287c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().GetJpgQualityValue(width, height); 2297c804472Sopenharmony_ci EXPECT_EQ(ret, 75); // 75 is jpeg quality 2307c804472Sopenharmony_ci } 2317c804472Sopenharmony_ci 2327c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetLoadDocFlagTest) 2337c804472Sopenharmony_ci { 2347c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().startLoadDoc = VirtualScreen::LoadDocType::INIT; 2357c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetLoadDocFlag(VirtualScreen::LoadDocType::FINISHED); 2367c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetLoadDocFlag(), VirtualScreen::LoadDocType::FINISHED); 2377c804472Sopenharmony_ci } 2387c804472Sopenharmony_ci 2397c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, GetFastPreviewMsgTest) 2407c804472Sopenharmony_ci { 2417c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().fastPreviewMsg = ""; 2427c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetFastPreviewMsg("FastPreviewMsg"); 2437c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetFastPreviewMsg(), "FastPreviewMsg"); 2447c804472Sopenharmony_ci } 2457c804472Sopenharmony_ci 2467c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, JudgeAndDropFrameTest) 2477c804472Sopenharmony_ci { 2487c804472Sopenharmony_ci int frequency = 0; // 0 ms 2497c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetDropFrameFrequency(frequency); 2507c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().dropFrameFrequency, frequency); 2517c804472Sopenharmony_ci EXPECT_FALSE(VirtualScreenImpl::GetInstance().JudgeAndDropFrame()); 2527c804472Sopenharmony_ci 2537c804472Sopenharmony_ci auto time1 = std::chrono::system_clock::now(); 2547c804472Sopenharmony_ci frequency = 1; // 1 ms 2557c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetDropFrameFrequency(frequency); 2567c804472Sopenharmony_ci while (VirtualScreenImpl::GetInstance().JudgeAndDropFrame()) { 2577c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().startDropFrameTime > time1); 2587c804472Sopenharmony_ci } 2597c804472Sopenharmony_ci } 2607c804472Sopenharmony_ci 2617c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, JudgeStaticImageTest) 2627c804472Sopenharmony_ci { 2637c804472Sopenharmony_ci CommandParser::GetInstance().screenMode = CommandParser::ScreenMode::DYNAMIC; 2647c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().JudgeStaticImage(1)); 2657c804472Sopenharmony_ci 2667c804472Sopenharmony_ci CommandParser::GetInstance().screenMode = CommandParser::ScreenMode::STATIC; 2677c804472Sopenharmony_ci VirtualScreen::isOutOfSeconds = true; 2687c804472Sopenharmony_ci EXPECT_FALSE(VirtualScreenImpl::GetInstance().JudgeStaticImage(1)); 2697c804472Sopenharmony_ci 2707c804472Sopenharmony_ci VirtualScreen::isOutOfSeconds = false; 2717c804472Sopenharmony_ci VirtualScreen::isStartCount = true; 2727c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().JudgeStaticImage(0)); 2737c804472Sopenharmony_ci } 2747c804472Sopenharmony_ci 2757c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, StopSendStaticCardImageTest) 2767c804472Sopenharmony_ci { 2777c804472Sopenharmony_ci CommandParser::GetInstance().staticCard = false; 2787c804472Sopenharmony_ci EXPECT_FALSE(VirtualScreenImpl::GetInstance().StopSendStaticCardImage(0)); 2797c804472Sopenharmony_ci 2807c804472Sopenharmony_ci CommandParser::GetInstance().staticCard = true; 2817c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().StopSendStaticCardImage(-1)); 2827c804472Sopenharmony_ci } 2837c804472Sopenharmony_ci 2847c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, RgbToJpgTest) 2857c804472Sopenharmony_ci { 2867c804472Sopenharmony_ci InitBuffer(); 2877c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().jpgBufferSize = 0; 2887c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().RgbToJpg(jpgBuff, 3, 3); 2897c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().jpgBufferSize > 0); 2907c804472Sopenharmony_ci delete[] jpgBuff; 2917c804472Sopenharmony_ci jpgBuff = nullptr; 2927c804472Sopenharmony_ci if (VirtualScreenImpl::GetInstance().jpgScreenBuffer) { 2937c804472Sopenharmony_ci free(VirtualScreenImpl::GetInstance().jpgScreenBuffer); 2947c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().jpgScreenBuffer = NULL; 2957c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().jpgBufferSize = 0; 2967c804472Sopenharmony_ci } 2977c804472Sopenharmony_ci } 2987c804472Sopenharmony_ci 2997c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetFoldableTest) 3007c804472Sopenharmony_ci { 3017c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetFoldable(true); 3027c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().GetFoldable()); 3037c804472Sopenharmony_ci 3047c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetFoldable(false); 3057c804472Sopenharmony_ci EXPECT_FALSE(VirtualScreenImpl::GetInstance().GetFoldable()); 3067c804472Sopenharmony_ci } 3077c804472Sopenharmony_ci 3087c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetFoldStatusTest) 3097c804472Sopenharmony_ci { 3107c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetFoldStatus("fold"); 3117c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetFoldStatus(), "fold"); 3127c804472Sopenharmony_ci 3137c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetFoldStatus("unfold"); 3147c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetFoldStatus(), "unfold"); 3157c804472Sopenharmony_ci } 3167c804472Sopenharmony_ci 3177c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetFoldResolutionTest) 3187c804472Sopenharmony_ci { 3197c804472Sopenharmony_ci int32_t foldWidth = 300; 3207c804472Sopenharmony_ci int32_t foldHeight = 400; 3217c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetFoldResolution(foldWidth, foldHeight); 3227c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetFoldWidth(), foldWidth); 3237c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetFoldHeight(), foldHeight); 3247c804472Sopenharmony_ci } 3257c804472Sopenharmony_ci 3267c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SetCurrentResolutionTest) 3277c804472Sopenharmony_ci { 3287c804472Sopenharmony_ci int32_t foldWidth = 300; 3297c804472Sopenharmony_ci int32_t foldHeight = 400; 3307c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetCurrentResolution(foldWidth, foldHeight); 3317c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetCurrentWidth(), foldWidth); 3327c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetCurrentHeight(), foldHeight); 3337c804472Sopenharmony_ci } 3347c804472Sopenharmony_ci // VirtualScreen end 3357c804472Sopenharmony_ci 3367c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, InitFlushEmptyTimeTest) 3377c804472Sopenharmony_ci { 3387c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocTimeStamp = 0; 3397c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().InitFlushEmptyTime(); 3407c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().loadDocTimeStamp > 0); 3417c804472Sopenharmony_ci } 3427c804472Sopenharmony_ci 3437c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SendBufferOnTimerTest) 3447c804472Sopenharmony_ci { 3457c804472Sopenharmony_ci g_writeData = false; 3467c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocTempBuffer = nullptr; 3477c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SendBufferOnTimer(); 3487c804472Sopenharmony_ci 3497c804472Sopenharmony_ci InitBuffer(); // jpgBuffer在loadDocTempBuffer释放时释放 3507c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().lengthTemp = jpgBuffSize; 3517c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocTempBuffer = jpgBuff; 3527c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().widthTemp = jpgWidth; 3537c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().heightTemp = jpgHeight; 3547c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocCopyBuffer = new unsigned char[0]; 3557c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SendBufferOnTimer(); 3567c804472Sopenharmony_ci EXPECT_TRUE(g_writeData); 3577c804472Sopenharmony_ci } 3587c804472Sopenharmony_ci 3597c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, CallbackTest) 3607c804472Sopenharmony_ci { 3617c804472Sopenharmony_ci CommandParser::GetInstance().staticCard = false; 3627c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocTimeStamp = 0; 3637c804472Sopenharmony_ci CommandParser::GetInstance().screenMode = CommandParser::ScreenMode::DYNAMIC; 3647c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetLoadDocFlag(VirtualScreen::LoadDocType::INIT); 3657c804472Sopenharmony_ci g_writeData = false; 3667c804472Sopenharmony_ci InitBuffer(); 3677c804472Sopenharmony_ci int tm = 100; 3687c804472Sopenharmony_ci VirtualScreenImpl::Callback(jpgBuff, jpgBuffSize, jpgWidth, jpgHeight, tm); 3697c804472Sopenharmony_ci EXPECT_TRUE(g_writeData); 3707c804472Sopenharmony_ci delete[] jpgBuff; 3717c804472Sopenharmony_ci jpgBuff = nullptr; 3727c804472Sopenharmony_ci } 3737c804472Sopenharmony_ci 3747c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, FlushEmptyCallbackTest) 3757c804472Sopenharmony_ci { 3767c804472Sopenharmony_ci int tm = 100; 3777c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocTimeStamp = tm; 3787c804472Sopenharmony_ci tm = 10; 3797c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().FlushEmptyCallback(tm); 3807c804472Sopenharmony_ci EXPECT_NE(VirtualScreenImpl::GetInstance().flushEmptyTimeStamp, tm); 3817c804472Sopenharmony_ci tm = 200; 3827c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().FlushEmptyCallback(tm); 3837c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().flushEmptyTimeStamp, tm); 3847c804472Sopenharmony_ci } 3857c804472Sopenharmony_ci 3867c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, InitAllTest) 3877c804472Sopenharmony_ci { 3887c804472Sopenharmony_ci std::string port = "8888"; 3897c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().InitAll("aaa", port); 3907c804472Sopenharmony_ci EXPECT_EQ(WebSocketServer::GetInstance().serverPort, atoi(port.c_str())); 3917c804472Sopenharmony_ci } 3927c804472Sopenharmony_ci 3937c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, GetScreenInfoTest) 3947c804472Sopenharmony_ci { 3957c804472Sopenharmony_ci int width = 1000; 3967c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().SetOrignalWidth(width); 3977c804472Sopenharmony_ci ScreenInfo info = VirtualScreenImpl::GetInstance().GetScreenInfo(); 3987c804472Sopenharmony_ci EXPECT_EQ(info.orignalResolutionWidth, width); 3997c804472Sopenharmony_ci } 4007c804472Sopenharmony_ci 4017c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, InitFoldParamsTest) 4027c804472Sopenharmony_ci { 4037c804472Sopenharmony_ci int width = 1080; 4047c804472Sopenharmony_ci int height = 2504; 4057c804472Sopenharmony_ci std::string foldable = "true"; 4067c804472Sopenharmony_ci std::string foldStatus = "half_fold"; 4077c804472Sopenharmony_ci CommandParser& parser = CommandParser::GetInstance(); 4087c804472Sopenharmony_ci CommandParser::GetInstance().argsMap.clear(); 4097c804472Sopenharmony_ci CommandParser::GetInstance().argsMap["-foldable"] = { foldable }; 4107c804472Sopenharmony_ci CommandParser::GetInstance().argsMap["-foldStatus"] = { foldStatus }; 4117c804472Sopenharmony_ci CommandParser::GetInstance().argsMap["-fr"] = { std::to_string(width), std::to_string(height) }; 4127c804472Sopenharmony_ci CommandParser::GetInstance().foldable = (foldable == "true"); 4137c804472Sopenharmony_ci CommandParser::GetInstance().foldStatus = foldStatus; 4147c804472Sopenharmony_ci CommandParser::GetInstance().foldResolutionWidth = width; 4157c804472Sopenharmony_ci CommandParser::GetInstance().foldResolutionHeight = height; 4167c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().InitFoldParams(); 4177c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().GetFoldable()); 4187c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetFoldStatus(), "half_fold"); 4197c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetFoldWidth(), width); 4207c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetFoldHeight(), height); 4217c804472Sopenharmony_ci } 4227c804472Sopenharmony_ci 4237c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SendPixmapTest_Err) 4247c804472Sopenharmony_ci { 4257c804472Sopenharmony_ci int height = 100; 4267c804472Sopenharmony_ci int width = 100; 4277c804472Sopenharmony_ci int pixSize = 4; 4287c804472Sopenharmony_ci int length = height * width * pixSize; 4297c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().bufferSize = length + VirtualScreenImpl::GetInstance().headSize; 4307c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().wholeBuffer = 4317c804472Sopenharmony_ci new uint8_t[LWS_PRE + VirtualScreenImpl::GetInstance().bufferSize]; 4327c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().screenBuffer = VirtualScreenImpl::GetInstance().wholeBuffer + LWS_PRE; 4337c804472Sopenharmony_ci // data is nullptr 4347c804472Sopenharmony_ci bool ret = VirtualScreenImpl::GetInstance().SendPixmap(nullptr, length, width, height); 4357c804472Sopenharmony_ci EXPECT_FALSE(ret); 4367c804472Sopenharmony_ci // isWebSocketConfiged is false 4377c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().isWebSocketConfiged = false; 4387c804472Sopenharmony_ci InitBuffer(); 4397c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().SendPixmap(jpgBuff, length, width, height); 4407c804472Sopenharmony_ci EXPECT_FALSE(ret); 4417c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().isWebSocketConfiged = true; 4427c804472Sopenharmony_ci // IsRegionRefresh function retrun true 4437c804472Sopenharmony_ci bool temp = CommandParser::GetInstance().isRegionRefresh; 4447c804472Sopenharmony_ci CommandParser::GetInstance().isRegionRefresh = true; 4457c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().SendPixmap(jpgBuff, length, width, height); 4467c804472Sopenharmony_ci CommandParser::GetInstance().isRegionRefresh = temp; 4477c804472Sopenharmony_ci EXPECT_FALSE(ret); 4487c804472Sopenharmony_ci delete[] jpgBuff; 4497c804472Sopenharmony_ci jpgBuff = nullptr; 4507c804472Sopenharmony_ci } 4517c804472Sopenharmony_ci 4527c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, PageCallbackTest) 4537c804472Sopenharmony_ci { 4547c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().PageCallback("pages/Index")); 4557c804472Sopenharmony_ci } 4567c804472Sopenharmony_ci 4577c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, LoadContentCallbackTest) 4587c804472Sopenharmony_ci { 4597c804472Sopenharmony_ci EXPECT_TRUE(VirtualScreenImpl::GetInstance().LoadContentCallback("pages/Index")); 4607c804472Sopenharmony_ci } 4617c804472Sopenharmony_ci 4627c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, FastPreviewCallbackTest) 4637c804472Sopenharmony_ci { 4647c804472Sopenharmony_ci g_output = false; 4657c804472Sopenharmony_ci std::string jsonStr = R"({"FastPreview" : "true"})";; 4667c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().FastPreviewCallback(jsonStr); 4677c804472Sopenharmony_ci EXPECT_TRUE(g_output); 4687c804472Sopenharmony_ci } 4697c804472Sopenharmony_ci 4707c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, SendTest_Err) 4717c804472Sopenharmony_ci { 4727c804472Sopenharmony_ci int width = 100; 4737c804472Sopenharmony_ci int pixSize = 4; 4747c804472Sopenharmony_ci int height = 100; 4757c804472Sopenharmony_ci int length = height * width * pixSize; 4767c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().bufferSize = length + VirtualScreenImpl::GetInstance().headSize; 4777c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().wholeBuffer = 4787c804472Sopenharmony_ci new uint8_t[LWS_PRE + VirtualScreenImpl::GetInstance().bufferSize]; 4797c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().screenBuffer = VirtualScreenImpl::GetInstance().wholeBuffer + LWS_PRE; 4807c804472Sopenharmony_ci // static mode 4817c804472Sopenharmony_ci CommandParser::ScreenMode tempMode = CommandParser::GetInstance().screenMode; 4827c804472Sopenharmony_ci CommandParser::GetInstance().screenMode = CommandParser::ScreenMode::STATIC; 4837c804472Sopenharmony_ci bool isOutOfSecondsTemp = VirtualScreen::isOutOfSeconds; 4847c804472Sopenharmony_ci VirtualScreen::isOutOfSeconds = true; 4857c804472Sopenharmony_ci InitBuffer(); 4867c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().Send(jpgBuff, width, height); 4877c804472Sopenharmony_ci VirtualScreen::isOutOfSeconds = false; 4887c804472Sopenharmony_ci CommandParser::GetInstance().screenMode = tempMode; 4897c804472Sopenharmony_ci EXPECT_NE(VirtualScreenImpl::GetInstance().screenBuffer, nullptr); 4907c804472Sopenharmony_ci // height < 1 4917c804472Sopenharmony_ci height = 0; 4927c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().Send(jpgBuff, width, height); 4937c804472Sopenharmony_ci EXPECT_NE(VirtualScreenImpl::GetInstance().screenBuffer, nullptr); 4947c804472Sopenharmony_ci height = 100; 4957c804472Sopenharmony_ci // width < 1 4967c804472Sopenharmony_ci width = 0; 4977c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().Send(jpgBuff, width, height); 4987c804472Sopenharmony_ci EXPECT_NE(VirtualScreenImpl::GetInstance().screenBuffer, nullptr); 4997c804472Sopenharmony_ci width = 100; 5007c804472Sopenharmony_ci // jpgBufferSize > bufferSize - headSize 5017c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().bufferSize = VirtualScreenImpl::GetInstance().headSize; 5027c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().Send(jpgBuff, width, height); 5037c804472Sopenharmony_ci EXPECT_NE(VirtualScreenImpl::GetInstance().screenBuffer, nullptr); 5047c804472Sopenharmony_ci delete[] jpgBuff; 5057c804472Sopenharmony_ci jpgBuff = nullptr; 5067c804472Sopenharmony_ci } 5077c804472Sopenharmony_ci 5087c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, InitResolutionTest_Err) 5097c804472Sopenharmony_ci { 5107c804472Sopenharmony_ci int width = 200; 5117c804472Sopenharmony_ci int height = 100; 5127c804472Sopenharmony_ci CommandParser::GetInstance().orignalResolutionWidth = width; 5137c804472Sopenharmony_ci CommandParser::GetInstance().orignalResolutionHeight = height; 5147c804472Sopenharmony_ci CommandParser::GetInstance().compressionResolutionWidth = width; 5157c804472Sopenharmony_ci CommandParser::GetInstance().compressionResolutionHeight = height; 5167c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().InitResolution(); 5177c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetOrignalWidth(), width); 5187c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetOrignalHeight(), height); 5197c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetCompressionWidth(), width); 5207c804472Sopenharmony_ci EXPECT_EQ(VirtualScreenImpl::GetInstance().GetCompressionHeight(), height); 5217c804472Sopenharmony_ci } 5227c804472Sopenharmony_ci 5237c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, LoadDocCallbackTest) 5247c804472Sopenharmony_ci { 5257c804472Sopenharmony_ci InitBuffer(); 5267c804472Sopenharmony_ci int tm = 100; 5277c804472Sopenharmony_ci // timeStamp < loadDocTimeStamp 5287c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocTimeStamp = 200; 5297c804472Sopenharmony_ci bool ret = VirtualScreenImpl::LoadDocCallback(jpgBuff, jpgBuffSize, jpgWidth, jpgHeight, tm); 5307c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocTimeStamp = 0; 5317c804472Sopenharmony_ci EXPECT_FALSE(ret); 5327c804472Sopenharmony_ci // GetLoadDocFlag is VirtualScreen::LoadDocType::FINISHED && length = 0 5337c804472Sopenharmony_ci VirtualScreen::LoadDocType temp = VirtualScreenImpl::GetInstance().startLoadDoc; 5347c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().startLoadDoc = VirtualScreen::LoadDocType::FINISHED; 5357c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().loadDocTempBuffer = new uint8_t[1]; 5367c804472Sopenharmony_ci ret = VirtualScreenImpl::LoadDocCallback(jpgBuff, 0, jpgWidth, jpgHeight, tm); 5377c804472Sopenharmony_ci EXPECT_FALSE(ret); 5387c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().startLoadDoc = temp; 5397c804472Sopenharmony_ci delete[] jpgBuff; 5407c804472Sopenharmony_ci jpgBuff = nullptr; 5417c804472Sopenharmony_ci } 5427c804472Sopenharmony_ci 5437c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, StartTimerTest) 5447c804472Sopenharmony_ci { 5457c804472Sopenharmony_ci g_writeData = false; 5467c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().isFlushEmpty = false; 5477c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().StartTimer(); 5487c804472Sopenharmony_ci EXPECT_FALSE(g_writeData); 5497c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().isFlushEmpty = true; 5507c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().StartTimer(); 5517c804472Sopenharmony_ci EXPECT_FALSE(g_writeData); 5527c804472Sopenharmony_ci } 5537c804472Sopenharmony_ci 5547c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, NoFlushEmptyFuncTest) 5557c804472Sopenharmony_ci { 5567c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().onRenderTime = std::chrono::system_clock::now(); 5577c804472Sopenharmony_ci bool ret = VirtualScreenImpl::GetInstance().NoFlushEmptyFunc(300); 5587c804472Sopenharmony_ci EXPECT_TRUE(ret); 5597c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().onRenderTime = std::chrono::system_clock::time_point::min(); 5607c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().NoFlushEmptyFunc(10000); 5617c804472Sopenharmony_ci EXPECT_TRUE(ret); 5627c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().NoFlushEmptyFunc(1); 5637c804472Sopenharmony_ci EXPECT_FALSE(ret); 5647c804472Sopenharmony_ci } 5657c804472Sopenharmony_ci 5667c804472Sopenharmony_ci TEST_F(VirtualScreenImplTest, FlushEmptyFuncTest) 5677c804472Sopenharmony_ci { 5687c804472Sopenharmony_ci std::time_t timestamp = 1719273600; // 这个时间戳代表2024年7月25日00:00:00 UTC 5697c804472Sopenharmony_ci std::time_t gap = 100; 5707c804472Sopenharmony_ci int64_t timePassed = 9000; 5717c804472Sopenharmony_ci int64_t time = 8000; 5727c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().onRenderTime = std::chrono::system_clock::from_time_t(timestamp); 5737c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().flushEmptyTime = std::chrono::system_clock::from_time_t(timestamp - gap); 5747c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().flushEmptyTimeStamp = 200; 5757c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().timeStampTemp = 100; 5767c804472Sopenharmony_ci bool ret = VirtualScreenImpl::GetInstance().FlushEmptyFunc(std::chrono::system_clock::from_time_t( 5777c804472Sopenharmony_ci timestamp + gap), timePassed); 5787c804472Sopenharmony_ci EXPECT_TRUE(ret); 5797c804472Sopenharmony_ci 5807c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().timeStampTemp = 300; 5817c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().FlushEmptyFunc(std::chrono::system_clock::from_time_t( 5827c804472Sopenharmony_ci timestamp + gap), time); 5837c804472Sopenharmony_ci EXPECT_FALSE(ret); 5847c804472Sopenharmony_ci 5857c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().timeStampTemp = 100; 5867c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().flushEmptyTime = std::chrono::system_clock::from_time_t( 5877c804472Sopenharmony_ci timestamp + gap); 5887c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().FlushEmptyFunc(std::chrono::system_clock::from_time_t( 5897c804472Sopenharmony_ci timestamp + gap + gap + gap), timePassed); 5907c804472Sopenharmony_ci EXPECT_TRUE(ret); 5917c804472Sopenharmony_ci 5927c804472Sopenharmony_ci VirtualScreenImpl::GetInstance().timeStampTemp = 300; 5937c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().FlushEmptyFunc(std::chrono::system_clock::from_time_t( 5947c804472Sopenharmony_ci timestamp + gap), timePassed); 5957c804472Sopenharmony_ci EXPECT_TRUE(ret); 5967c804472Sopenharmony_ci 5977c804472Sopenharmony_ci ret = VirtualScreenImpl::GetInstance().FlushEmptyFunc(std::chrono::system_clock::from_time_t( 5987c804472Sopenharmony_ci timestamp + gap), time); 5997c804472Sopenharmony_ci EXPECT_FALSE(ret); 6007c804472Sopenharmony_ci } 6017c804472Sopenharmony_ci}