assetBuilderSDKTest.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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 "assetBuilderSDKTest.h"
  9. namespace AssetProcessor
  10. {
  11. #if defined(ENABLE_LEGACY_PLATFORMFLAGS_SUPPORT)
  12. TEST_F(AssetBuilderSDKTest, GetEnabledPlatformsCountUnitTest)
  13. {
  14. AssetBuilderSDK::CreateJobsRequest createJobsRequest;
  15. ASSERT_EQ(createJobsRequest.GetEnabledPlatformsCount(), 0);
  16. createJobsRequest.m_enabledPlatforms = {
  17. { "pc", {}
  18. }
  19. };
  20. ASSERT_EQ(createJobsRequest.GetEnabledPlatformsCount(), 1);
  21. createJobsRequest.m_enabledPlatforms = {
  22. { "pc", {}
  23. }, { "android", {}
  24. }
  25. };
  26. ASSERT_EQ(createJobsRequest.GetEnabledPlatformsCount(), 2);
  27. }
  28. TEST_F(AssetBuilderSDKTest, GetEnabledPlatformAtUnitTest)
  29. {
  30. UnitTestUtils::AssertAbsorber absorb;
  31. AssetBuilderSDK::CreateJobsRequest createJobsRequest;
  32. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(0), AssetBuilderSDK::Platform_NONE);
  33. createJobsRequest.m_enabledPlatforms = {
  34. { "pc", { }
  35. }
  36. };
  37. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(0), AssetBuilderSDK::Platform_PC);
  38. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(1), AssetBuilderSDK::Platform_NONE);
  39. createJobsRequest.m_enabledPlatforms = {
  40. { "android", {}
  41. }
  42. };
  43. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(0), AssetBuilderSDK::Platform_ANDROID);
  44. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(1), AssetBuilderSDK::Platform_NONE);
  45. createJobsRequest.m_enabledPlatforms = {
  46. { "pc", {}
  47. }, { "android", {}
  48. }
  49. };
  50. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(0), AssetBuilderSDK::Platform_PC);
  51. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(1), AssetBuilderSDK::Platform_ANDROID);
  52. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(2), AssetBuilderSDK::Platform_NONE);
  53. createJobsRequest.m_enabledPlatforms = {
  54. { "ios", {}
  55. }
  56. };
  57. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(0), AssetBuilderSDK::Platform_IOS);
  58. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(1), AssetBuilderSDK::Platform_NONE);
  59. createJobsRequest.m_enabledPlatforms = {
  60. { "pc", {}
  61. }, { "android", {}
  62. }, { "ios", {}
  63. }, { "mac", {}
  64. }
  65. };
  66. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(0), AssetBuilderSDK::Platform_PC);
  67. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(1), AssetBuilderSDK::Platform_ANDROID);
  68. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(2), AssetBuilderSDK::Platform_IOS);
  69. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(3), AssetBuilderSDK::Platform_MAC);
  70. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(4), AssetBuilderSDK::Platform_NONE);
  71. createJobsRequest.m_enabledPlatforms = {
  72. { "pc", {}
  73. }, { "android", {}
  74. }
  75. };
  76. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(0), AssetBuilderSDK::Platform_PC);
  77. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(1), AssetBuilderSDK::Platform_ANDROID);
  78. ASSERT_EQ(createJobsRequest.GetEnabledPlatformAt(2), AssetBuilderSDK::Platform_NONE);
  79. // using a deprecated API should have generated warnings.
  80. // but we can't test for it because these warnings are WarningOnce and some other unit test might have already triggered it
  81. }
  82. TEST_F(AssetBuilderSDKTest, IsPlatformEnabledUnitTest)
  83. {
  84. UnitTestUtils::AssertAbsorber absorb;
  85. AssetBuilderSDK::CreateJobsRequest createJobsRequest;
  86. ASSERT_FALSE(createJobsRequest.IsPlatformEnabled(AssetBuilderSDK::Platform_PC));
  87. createJobsRequest.m_enabledPlatforms = {
  88. { "pc", {}
  89. }
  90. };
  91. ASSERT_TRUE(createJobsRequest.IsPlatformEnabled(AssetBuilderSDK::Platform_PC));
  92. ASSERT_FALSE(createJobsRequest.IsPlatformEnabled(AssetBuilderSDK::Platform_ANDROID));
  93. createJobsRequest.m_enabledPlatforms = {
  94. { "pc", {}
  95. }, { "android", {}
  96. }
  97. };
  98. ASSERT_TRUE(createJobsRequest.IsPlatformEnabled(AssetBuilderSDK::Platform_PC));
  99. ASSERT_TRUE(createJobsRequest.IsPlatformEnabled(AssetBuilderSDK::Platform_ANDROID));
  100. createJobsRequest.m_enabledPlatforms = {
  101. { "pc", {}
  102. }, { "android", {}
  103. }
  104. };
  105. ASSERT_TRUE(createJobsRequest.IsPlatformEnabled(AssetBuilderSDK::Platform_PC));
  106. ASSERT_TRUE(createJobsRequest.IsPlatformEnabled(AssetBuilderSDK::Platform_ANDROID));
  107. // using a deprecated API should have generated warnings.
  108. // but we can't test for it because these warnings are WarningOnce and some other unit test might have already triggered it
  109. }
  110. TEST_F(AssetBuilderSDKTest, IsPlatformValidUnitTest)
  111. {
  112. AssetBuilderSDK::CreateJobsRequest createJobsRequest;
  113. UnitTestUtils::AssertAbsorber absorb;
  114. ASSERT_TRUE(createJobsRequest.IsPlatformValid(AssetBuilderSDK::Platform_PC));
  115. ASSERT_TRUE(createJobsRequest.IsPlatformValid(AssetBuilderSDK::Platform_ANDROID));
  116. ASSERT_TRUE(createJobsRequest.IsPlatformValid(AssetBuilderSDK::Platform_IOS));
  117. ASSERT_TRUE(createJobsRequest.IsPlatformValid(AssetBuilderSDK::Platform_MAC));
  118. ASSERT_TRUE(createJobsRequest.IsPlatformValid(AssetBuilderSDK::Platform_PROVO));
  119. ASSERT_TRUE(createJobsRequest.IsPlatformValid(AssetBuilderSDK::Platform_SALEM));
  120. ASSERT_TRUE(createJobsRequest.IsPlatformValid(AssetBuilderSDK::Platform_JASPER));
  121. //64 is 0x040 which currently is the next valid platform value which is invalid as of now, if we ever add a new platform entry to the Platform enum
  122. //we will have to update this failure unit test
  123. ASSERT_FALSE(createJobsRequest.IsPlatformValid(static_cast<AssetBuilderSDK::Platform>(256)));
  124. // using a deprecated API should have generated warnings.
  125. // but we can't test for it because these warnings are WarningOnce and some other unit test might have already triggered it
  126. }
  127. #endif // defined(ENABLE_LEGACY_PLATFORMFLAGS_SUPPORT)
  128. };