Project Manager Gem Dependencies (#4132)
* Fix engine API change and add gem dependencies Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Add GemCatalog dependency test Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Clarify display name and fix missing const Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Moving a couple helper functions into private scope Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Update gem count when unselecting a gem #4074 This addresses the following issue https://github.com/o3de/o3de/issues/4074 Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Active/Inactive filter and dependency tooltips Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Accessors for previously added and dependencies Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Cart displays gem dependency changes Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Shorten titles to fit in summary popup Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Remove QString::number Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Remove extra space Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Consolidate source model accesor helpers Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Addressing minor feedback Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com> * Remove unused local variable Signed-off-by: AMZN-alexpete <26804013+AMZN-alexpete@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzCore/UnitTest/TestTypes.h>
|
||||
#include <AzTest/Utils.h>
|
||||
#include <GemCatalog/GemModel.h>
|
||||
|
||||
|
||||
namespace O3DE::ProjectManager
|
||||
{
|
||||
class GemCatalogTests
|
||||
: public ::UnitTest::ScopedAllocatorSetupFixture
|
||||
{
|
||||
public:
|
||||
|
||||
GemCatalogTests() = default;
|
||||
};
|
||||
|
||||
TEST_F(GemCatalogTests, GemCatalog_Displays_But_Does_Not_Add_Dependencies)
|
||||
{
|
||||
GemModel* gemModel = new GemModel();
|
||||
|
||||
// given 3 gems a,b,c where a depends on b which depends on c
|
||||
GemInfo gemA, gemB, gemC;
|
||||
QModelIndex indexA, indexB, indexC;
|
||||
gemA.m_name = "a";
|
||||
gemB.m_name = "b";
|
||||
gemC.m_name = "c";
|
||||
|
||||
gemA.m_dependencies = QStringList({ "b" });
|
||||
gemB.m_dependencies = QStringList({ "c" });
|
||||
|
||||
gemModel->AddGem(gemA);
|
||||
indexA = gemModel->FindIndexByNameString(gemA.m_name);
|
||||
|
||||
gemModel->AddGem(gemB);
|
||||
indexB = gemModel->FindIndexByNameString(gemB.m_name);
|
||||
|
||||
gemModel->AddGem(gemC);
|
||||
indexC = gemModel->FindIndexByNameString(gemC.m_name);
|
||||
|
||||
gemModel->UpdateGemDependencies();
|
||||
|
||||
EXPECT_FALSE(GemModel::IsAdded(indexA));
|
||||
EXPECT_FALSE(GemModel::IsAddedDependency(indexB) || GemModel::IsAddedDependency(indexC));
|
||||
|
||||
// when a is added
|
||||
GemModel::SetIsAdded(*gemModel, indexA, true);
|
||||
|
||||
// expect b and c are now dependencies of an added gem but not themselves added
|
||||
// cmake will handle dependencies
|
||||
EXPECT_TRUE(GemModel::IsAddedDependency(indexB) && GemModel::IsAddedDependency(indexC));
|
||||
EXPECT_TRUE(!GemModel::IsAdded(indexB) && !GemModel::IsAdded(indexC));
|
||||
|
||||
QVector<QModelIndex> gemsToAdd = gemModel->GatherGemsToBeAdded();
|
||||
EXPECT_TRUE(gemsToAdd.size() == 1);
|
||||
EXPECT_EQ(GemModel::GetName(gemsToAdd.at(0)), gemA.m_name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user