Polish shared editor tree context behavior
This commit is contained in:
@@ -307,6 +307,22 @@ TEST_F(EditorActionRoutingTest, HierarchyRouterRenameHelpersPublishAndCommit) {
|
||||
m_context.GetEventBus().Unsubscribe<EntityRenameRequestedEvent>(renameSubscription);
|
||||
}
|
||||
|
||||
TEST_F(EditorActionRoutingTest, HierarchyItemContextRequestSelectsEntityAndStoresPopupTarget) {
|
||||
auto* entity = Commands::CreateEmptyEntity(m_context, nullptr, "Create Entity", "ContextTarget");
|
||||
ASSERT_NE(entity, nullptr);
|
||||
|
||||
UI::TargetedPopupState<::XCEngine::Components::GameObject*> popupState;
|
||||
EXPECT_FALSE(popupState.HasTarget());
|
||||
EXPECT_FALSE(popupState.HasPendingOpenRequest());
|
||||
|
||||
Actions::HandleHierarchyItemContextRequest(m_context, entity, popupState);
|
||||
|
||||
EXPECT_EQ(m_context.GetSelectionManager().GetSelectedEntity(), entity->GetID());
|
||||
ASSERT_TRUE(popupState.HasTarget());
|
||||
EXPECT_EQ(popupState.TargetValue(), entity);
|
||||
EXPECT_TRUE(popupState.HasPendingOpenRequest());
|
||||
}
|
||||
|
||||
TEST_F(EditorActionRoutingTest, ProjectCommandsCreateFolderMoveAssetAndOpenFolderHelper) {
|
||||
const fs::path assetsDir = m_projectRoot / "Assets";
|
||||
const fs::path sourceFilePath = assetsDir / "MoveMe.txt";
|
||||
@@ -328,6 +344,27 @@ TEST_F(EditorActionRoutingTest, ProjectCommandsCreateFolderMoveAssetAndOpenFolde
|
||||
EXPECT_EQ(m_context.GetProjectManager().GetCurrentPath(), "Assets/MovedFolder");
|
||||
}
|
||||
|
||||
TEST_F(EditorActionRoutingTest, ProjectItemContextRequestSelectsAssetAndStoresPopupTarget) {
|
||||
const fs::path assetsDir = m_projectRoot / "Assets";
|
||||
const fs::path filePath = assetsDir / "ContextAsset.txt";
|
||||
std::ofstream(filePath.string()) << "context asset";
|
||||
|
||||
m_context.GetProjectManager().RefreshCurrentFolder();
|
||||
const AssetItemPtr item = FindCurrentItemByName("ContextAsset.txt");
|
||||
ASSERT_NE(item, nullptr);
|
||||
|
||||
UI::TargetedPopupState<AssetItemPtr> popupState;
|
||||
EXPECT_FALSE(popupState.HasTarget());
|
||||
EXPECT_FALSE(popupState.HasPendingOpenRequest());
|
||||
|
||||
Actions::HandleProjectItemContextRequest(m_context.GetProjectManager(), item, popupState);
|
||||
|
||||
EXPECT_EQ(m_context.GetProjectManager().GetSelectedItemPath(), item->fullPath);
|
||||
ASSERT_TRUE(popupState.HasTarget());
|
||||
EXPECT_EQ(popupState.TargetValue(), item);
|
||||
EXPECT_TRUE(popupState.HasPendingOpenRequest());
|
||||
}
|
||||
|
||||
TEST_F(EditorActionRoutingTest, ProjectCommandsRejectInvalidMoveTargets) {
|
||||
const fs::path assetsDir = m_projectRoot / "Assets";
|
||||
const fs::path sourceFilePath = assetsDir / "MoveSource.txt";
|
||||
@@ -353,5 +390,54 @@ TEST_F(EditorActionRoutingTest, ProjectCommandsRejectInvalidMoveTargets) {
|
||||
EXPECT_TRUE(fs::exists(sourceFilePath));
|
||||
}
|
||||
|
||||
TEST_F(EditorActionRoutingTest, ProjectSelectionSurvivesRefreshWhenItemOrderChanges) {
|
||||
const fs::path assetsDir = m_projectRoot / "Assets";
|
||||
const fs::path selectedPath = assetsDir / "Selected.txt";
|
||||
const fs::path earlierPath = assetsDir / "Earlier.txt";
|
||||
|
||||
std::ofstream(selectedPath.string()) << "selected";
|
||||
m_context.GetProjectManager().RefreshCurrentFolder();
|
||||
|
||||
const int selectedIndex = FindCurrentItemIndexByName("Selected.txt");
|
||||
ASSERT_GE(selectedIndex, 0);
|
||||
m_context.GetProjectManager().SetSelectedIndex(selectedIndex);
|
||||
|
||||
AssetItemPtr selectedItem = Actions::GetSelectedAssetItem(m_context);
|
||||
ASSERT_NE(selectedItem, nullptr);
|
||||
EXPECT_EQ(selectedItem->name, "Selected.txt");
|
||||
|
||||
std::ofstream(earlierPath.string()) << "earlier";
|
||||
m_context.GetProjectManager().RefreshCurrentFolder();
|
||||
|
||||
selectedItem = Actions::GetSelectedAssetItem(m_context);
|
||||
ASSERT_NE(selectedItem, nullptr);
|
||||
EXPECT_EQ(selectedItem->name, "Selected.txt");
|
||||
EXPECT_EQ(
|
||||
m_context.GetProjectManager().GetSelectedIndex(),
|
||||
FindCurrentItemIndexByName("Selected.txt"));
|
||||
}
|
||||
|
||||
TEST_F(EditorActionRoutingTest, ProjectCommandsRejectMovingFolderIntoItsDescendant) {
|
||||
const fs::path assetsDir = m_projectRoot / "Assets";
|
||||
const fs::path parentPath = assetsDir / "Parent";
|
||||
const fs::path childPath = parentPath / "Child";
|
||||
|
||||
fs::create_directories(childPath);
|
||||
m_context.GetProjectManager().RefreshCurrentFolder();
|
||||
|
||||
const AssetItemPtr parentFolder = FindCurrentItemByName("Parent");
|
||||
ASSERT_NE(parentFolder, nullptr);
|
||||
ASSERT_TRUE(parentFolder->isFolder);
|
||||
|
||||
m_context.GetProjectManager().NavigateToFolder(parentFolder);
|
||||
const AssetItemPtr childFolder = FindCurrentItemByName("Child");
|
||||
ASSERT_NE(childFolder, nullptr);
|
||||
ASSERT_TRUE(childFolder->isFolder);
|
||||
|
||||
EXPECT_FALSE(Commands::MoveAssetToFolder(m_context.GetProjectManager(), parentFolder->fullPath, childFolder));
|
||||
EXPECT_TRUE(fs::exists(parentPath));
|
||||
EXPECT_TRUE(fs::exists(childPath));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace XCEngine::Editor
|
||||
|
||||
Reference in New Issue
Block a user