FastNoiseEditorTest.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzTest/AzTest.h>
  9. #include <AzCore/Component/Entity.h>
  10. #include <AzCore/UnitTest/TestTypes.h>
  11. #include <EditorFastNoiseGradientComponent.h>
  12. #include <FastNoiseTest.h>
  13. class FastNoiseEditorTestApp : public ::testing::Test
  14. {
  15. };
  16. TEST_F(FastNoiseEditorTestApp, FastNoise_EditorCreateGameEntity)
  17. {
  18. AZStd::unique_ptr<AZ::Entity> noiseEntity(aznew AZ::Entity("editor_noise_entity"));
  19. ASSERT_TRUE(noiseEntity != nullptr);
  20. FastNoiseGem::EditorFastNoiseGradientComponent editor;
  21. auto* editorBase = static_cast<AzToolsFramework::Components::EditorComponentBase*>(&editor);
  22. editorBase->BuildGameEntity(noiseEntity.get());
  23. // the new game entity's FastNoise component should look like the default one
  24. FastNoiseGem::FastNoiseGradientConfig defaultConfig;
  25. FastNoiseGem::FastNoiseGradientConfig gameComponentConfig;
  26. FastNoiseGem::FastNoiseGradientComponent* noiseComp = noiseEntity->FindComponent<FastNoiseGem::FastNoiseGradientComponent>();
  27. ASSERT_TRUE(noiseComp != nullptr);
  28. // Change a value in the gameComponentConfig just to verify that it got overwritten instead of simply matching the default.
  29. gameComponentConfig.m_seed++;
  30. noiseComp->WriteOutConfig(&gameComponentConfig);
  31. ASSERT_EQ(defaultConfig, gameComponentConfig);
  32. }
  33. // This uses custom test / benchmark hooks so that we can load LmbrCentral and GradientSignal Gems.
  34. AZ_UNIT_TEST_HOOK(new UnitTest::FastNoiseTestEnvironment, UnitTest::FastNoiseBenchmarkEnvironment);