/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include #include #include #include #include #include #include #include #include #include namespace EMotionFX { TEST_F(PreviewMotionFixture, MotionCanBePlayed) { /* Test Case: C1797320 Motion playbacks with no corruption to animation Motion can be played in the open gl viewport. */ RecordProperty("test_case_id", "C1797320"); // Check motion exists in motions window. auto motionWindowPlugin = static_cast(EMStudio::GetPluginManager()->FindActivePlugin(EMStudio::MotionWindowPlugin::CLASS_ID)); ASSERT_TRUE(motionWindowPlugin != nullptr) << "Could not find the Motion Window Plugin"; QTableWidget* table = qobject_cast(FindTopLevelWidget("EMFX.MotionListWindow.MotionTable")); ASSERT_TRUE(table) << "Could not find the Motion Table"; EXPECT_EQ(GetMotionManager().GetNumMotions(), 1) << "Expected to have no motions for the Manager"; EXPECT_EQ(table->rowCount(), 1) << "Expected the table to have no rows yet"; // Create actor and actor instance. const AZStd::string actorFilename = "Gems/EMotionFX/Code/Tests/TestAssets/Rin/rin.actor"; AZStd::unique_ptr m_actor = EMotionFX::GetImporter().LoadActor(actorFilename); EXPECT_TRUE(m_actor.get() != nullptr) << "Actor not loaded."; EMotionFX::ActorInstance* m_actorInstance = ActorInstance::Create(m_actor.get()); EXPECT_TRUE(m_actorInstance != nullptr) << "Actor instance not created."; AZStd::string result; EXPECT_TRUE(CommandSystem::GetCommandManager()->ExecuteCommand(AZStd::string{ "Select -actorInstanceID " } + AZStd::to_string(m_actorInstance->GetID()), result)) << result.c_str(); // Double click on motion in motions window. QTableWidgetItem* item = table->item(0, 0); const auto rect = table->visualItemRect(item); QTest::mouseClick(table->viewport(), Qt::LeftButton, {}, rect.center()); QTest::mouseDClick(table->viewport(), Qt::LeftButton, {}, rect.center()); // Check motion has been selected in render window. EMStudio::EMStudioPlugin* plugin = EMStudio::GetPluginManager()->FindActivePlugin(static_cast(EMStudio::RenderPlugin::CLASS_ID)); EXPECT_TRUE(plugin != nullptr) << "Render plugin not found."; EMStudio::RenderPlugin* renderPlugin = static_cast(plugin); CommandSystem::SelectionList* renderPluginSelectionList = renderPlugin->GetCurrentSelection(); EXPECT_TRUE(renderPluginSelectionList->GetSingleMotion()) << "Motion not selected in render window."; EXPECT_TRUE(renderPluginSelectionList->GetSingleMotion()->GetFileName() == m_motionFileName) << "Motion file name does not match."; } }