TDD整改

Signed-off-by: 张有康 <zhangyoukang1@h-partners.com>
This commit is contained in:
张有康 2025-01-22 16:12:09 +08:00
parent c937825a33
commit cfbb256f3d
4 changed files with 40 additions and 101 deletions

View File

@ -684,7 +684,7 @@ HWTEST_F(ScreenSceneConfigTest, GetCurvedCompressionAreaInLandscape03, Function
HWTEST_F(ScreenSceneConfigTest, ReadStringListConfigInfo01, Function | SmallTest | Level3) HWTEST_F(ScreenSceneConfigTest, ReadStringListConfigInfo01, Function | SmallTest | Level3)
{ {
xmlNodePtr rootNode = nullptr; xmlNodePtr rootNode = nullptr;
ScreenSceneConfig::ReadStringListConfigInfo(nullptr, ""); ScreenSceneConfig::ReadStringListConfigInfo(rootNode, "");
EXPECT_EQ(rootNode, nullptr); EXPECT_EQ(rootNode, nullptr);
} }

View File

@ -27,6 +27,7 @@
#include "display_manager_adapter.h" #include "display_manager_adapter.h"
#include "display_manager_agent_default.h" #include "display_manager_agent_default.h"
#include "scene_board_judgement.h" #include "scene_board_judgement.h"
#include "screen_session_manager/include/screen_session_manager.h"
using namespace testing; using namespace testing;
using namespace testing::ext; using namespace testing::ext;
@ -1179,16 +1180,10 @@ HWTEST_F(ScreenSessionManagerProxyTest, RemoveVirtualScreenFromGroup, Function |
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
int resultValue = 0;
std::vector<ScreenId> screens = {1002, 1003, 1004}; std::vector<ScreenId> screens = {1002, 1003, 1004};
std::function<void()> func = [&]() screenSessionManagerProxy->RemoveVirtualScreenFromGroup(screens);
{ auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000);
screenSessionManagerProxy->RemoveVirtualScreenFromGroup(screens); EXPECT_EQ(screenSession, nullptr);
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1594,16 +1589,10 @@ HWTEST_F(ScreenSessionManagerProxyTest, ConvertScreenIdToRsScreenId, Function |
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
int resultValue = 0;
ScreenId screenId = 1001; ScreenId screenId = 1001;
ScreenId rsScreenId = 1002; ScreenId rsScreenId = 1002;
std::function<void()> func = [&]() auto ret = screenSessionManagerProxy->ConvertScreenIdToRsScreenId(screenId, rsScreenId);
{ EXPECT_EQ(ret, false);
screenSessionManagerProxy->ConvertScreenIdToRsScreenId(screenId, rsScreenId);
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1639,15 +1628,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, DumpAllScreensInfo, Function | SmallTest
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
int resultValue = 0;
std::string dumpInfo; std::string dumpInfo;
std::function<void()> func = [&]() screenSessionManagerProxy->DumpAllScreensInfo(dumpInfo);
{ EXPECT_NE(dumpInfo, "");
screenSessionManagerProxy->DumpAllScreensInfo(dumpInfo);
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1661,16 +1644,10 @@ HWTEST_F(ScreenSessionManagerProxyTest, DumpSpecialScreenInfo, Function | SmallT
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
int resultValue = 0;
ScreenId id = 1001; ScreenId id = 1001;
std::string dumpInfo; std::string dumpInfo;
std::function<void()> func = [&]() screenSessionManagerProxy->DumpSpecialScreenInfo(id, dumpInfo);
{ EXPECT_NE(dumpInfo, "");
screenSessionManagerProxy->DumpSpecialScreenInfo(id, dumpInfo);
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1684,15 +1661,13 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldDisplayMode, Function | SmallTest
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
int resultValue = 0;
const FoldDisplayMode displayMode {0}; const FoldDisplayMode displayMode {0};
std::function<void()> func = [&]() screenSessionManagerProxy->SetFoldDisplayMode(displayMode);
{ if (screenSessionManagerProxy->IsFoldable()) {
screenSessionManagerProxy->SetFoldDisplayMode(displayMode); EXPECT_NE(ScreenSessionManager::GetInstance().foldScreenController_, nullptr);
resultValue = 1; } else {
}; EXPECT_EQ(ScreenSessionManager::GetInstance().foldScreenController_, nullptr);
func(); }
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1728,15 +1703,13 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetFoldStatusLocked, Function | SmallTes
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
int resultValue = 0;
bool locked = true; bool locked = true;
std::function<void()> func = [&]() screenSessionManagerProxy->SetFoldStatusLocked(locked);
{ if (screenSessionManagerProxy->IsFoldable()) {
screenSessionManagerProxy->SetFoldStatusLocked(locked); EXPECT_NE(ScreenSessionManager::GetInstance().foldScreenController_, nullptr);
resultValue = 1; } else {
}; EXPECT_EQ(ScreenSessionManager::GetInstance().foldScreenController_, nullptr);
func(); }
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1786,15 +1759,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, IsFoldable, Function | SmallTest | Level
SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy(); SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
screenSessionManagerProxy->IsFoldable();
int resultValue = 0; auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000);
std::function<void()> func = [&]() EXPECT_EQ(screenSession, nullptr);
{
screenSessionManagerProxy->IsFoldable();
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1807,15 +1774,8 @@ HWTEST_F(ScreenSessionManagerProxyTest, IsCaptured, Function | SmallTest | Level
SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy(); SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
auto ret = screenSessionManagerProxy->IsCaptured();
int resultValue = 0; EXPECT_EQ(ret, false);
std::function<void()> func = [&]()
{
screenSessionManagerProxy->IsCaptured();
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1895,15 +1855,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SetClient, Function | SmallTest | Level1
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
int resultValue = 0;
const sptr<IScreenSessionManagerClient> client = nullptr; const sptr<IScreenSessionManagerClient> client = nullptr;
std::function<void()> func = [&]() screenSessionManagerProxy->SetClient(client);
{ EXPECT_EQ(client, nullptr);
screenSessionManagerProxy->SetClient(client);
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1916,15 +1870,9 @@ HWTEST_F(ScreenSessionManagerProxyTest, SwitchUser, Function | SmallTest | Level
SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy(); SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
screenSessionManagerProxy->SwitchUser();
int resultValue = 0; auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000);
std::function<void()> func = [&]() EXPECT_EQ(screenSession, nullptr);
{
screenSessionManagerProxy->SwitchUser();
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**
@ -1937,16 +1885,10 @@ HWTEST_F(ScreenSessionManagerProxyTest, GetScreenProperty, Function | SmallTest
SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy(); SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject(); sptr<IRemoteObject> impl = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl); sptr<ScreenSessionManagerProxy> screenSessionManagerProxy = new ScreenSessionManagerProxy(impl);
int resultValue = 0;
ScreenId screenId = 1001; ScreenId screenId = 1001;
std::function<void()> func = [&]() screenSessionManagerProxy->GetScreenProperty(screenId);
{ auto screenSession = ScreenSessionManager::GetInstance().GetScreenSession(2000);
screenSessionManagerProxy->GetScreenProperty(screenId); EXPECT_EQ(screenSession, nullptr);
resultValue = 1;
};
func();
EXPECT_EQ(resultValue, 1);
} }
/** /**

View File

@ -215,9 +215,8 @@ HWTEST_F(ScreenSnapshotPickerConnectionTest, GetScreenSnapshotInfo03, Function |
*/ */
HWTEST_F(ScreenSnapshotPickerConnectionTest, SnapshotPickerDisconnectExtension01, Function | SmallTest | Level1) HWTEST_F(ScreenSnapshotPickerConnectionTest, SnapshotPickerDisconnectExtension01, Function | SmallTest | Level1)
{ {
std::unique_ptr<ScreenSessionAbilityConnection> abilityConnection_ = nullptr;
ScreenSnapshotPickerConnection::GetInstance().SnapshotPickerDisconnectExtension(); ScreenSnapshotPickerConnection::GetInstance().SnapshotPickerDisconnectExtension();
EXPECT_EQ(abilityConnection_, nullptr); EXPECT_EQ(ScreenSnapshotPickerConnection::GetInstance().abilityConnection_, nullptr);
} }
/** /**

View File

@ -22,6 +22,7 @@
#include "session_manager.h" #include "session_manager.h"
#include "session_display_power_controller.h" #include "session_display_power_controller.h"
#include "zidl/window_manager_agent_interface.h" #include "zidl/window_manager_agent_interface.h"
#include "screen_session_manager/include/screen_session_manager.h"
using namespace testing; using namespace testing;
using namespace testing::ext; using namespace testing::ext;
@ -166,11 +167,8 @@ HWTEST_F(SessionDisplayPowerControllerTest, SuspendBegin, Function | SmallTest |
HWTEST_F(SessionDisplayPowerControllerTest, WaitScreenOffNotify, Function | SmallTest | Level1) HWTEST_F(SessionDisplayPowerControllerTest, WaitScreenOffNotify, Function | SmallTest | Level1)
{ {
DisplayState state = DisplayState::ON_SUSPEND; DisplayState state = DisplayState::ON_SUSPEND;
SessionDisplayPowerController controller([](DisplayId id, sptr<DisplayInfo> info, const std::map<DisplayId, ScreenSessionManager::GetInstance().sessionDisplayPowerController_->WaitScreenOffNotify(state);
sptr<DisplayInfo>>& infos, DisplayStateChangeType type) { EXPECT_NE(state, DisplayState::UNKNOWN);
EXPECT_TRUE(true);
});
EXPECT_EQ(state, DisplayState::ON_SUSPEND);
} }
} }