PropertyChunkTests.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using UnityEngine;
  2. namespace UnityEditor.ShaderGraph.UnitTests
  3. {
  4. /* [TestFixture]
  5. public class PropertyChunkTests
  6. {
  7. class TestPropertyChunch : PropertyChunk
  8. {
  9. public TestPropertyChunch(string propertyName, string propertyDescription, HideState hideState)
  10. : base(propertyName, propertyDescription, hideState)
  11. {}
  12. public override string GetPropertyString()
  13. {
  14. return propertyName;
  15. }
  16. }
  17. [TestFixtureSetUp]
  18. public void RunBeforeAnyTests()
  19. {
  20. Debug.unityLogger.logHandler = new ConsoleLogHandler();
  21. }
  22. [SetUp]
  23. public void TestSetUp()
  24. {
  25. }
  26. private const string kPropertyName = "ThePropertyName";
  27. private const string kPropertyDescription = "ThePropertyDescription";
  28. [Test]
  29. public void TestSimplePropertyChunkIsConstructedProperly()
  30. {
  31. var chunk = new TestPropertyChunch(kPropertyName, kPropertyDescription, PropertyChunk.HideState.Visible);
  32. Assert.AreEqual(kPropertyName, chunk.propertyName);
  33. Assert.AreEqual(kPropertyDescription, chunk.propertyDescription);
  34. Assert.AreEqual(kPropertyName, chunk.GetPropertyString());
  35. Assert.AreEqual(PropertyChunk.HideState.Visible, chunk.hideState);
  36. }
  37. [Test]
  38. public void TestColorChunkReturnsValidValues()
  39. {
  40. var expectedPropertyString = "ThePropertyName(\"ThePropertyDescription\", Color) = (1,0,0,1)";
  41. var chunk = new ColorPropertyChunk(kPropertyName, kPropertyDescription, Color.red, ColorPropertyChunk.ColorType.Default, PropertyChunk.HideState.Visible);
  42. Assert.AreEqual(kPropertyName, chunk.propertyName);
  43. Assert.AreEqual(kPropertyDescription, chunk.propertyDescription);
  44. Assert.AreEqual(expectedPropertyString, chunk.GetPropertyString());
  45. Assert.AreEqual(Color.red, chunk.defaultColor);
  46. Assert.AreEqual(PropertyChunk.HideState.Visible, chunk.hideState);
  47. }
  48. [Test]
  49. public void TestFloatChunkReturnsValidValues()
  50. {
  51. var expectedPropertyString = "ThePropertyName(\"ThePropertyDescription\", Float) = 0.5";
  52. var chunk = new FloatPropertyChunk(kPropertyName, kPropertyDescription, 0.5f, PropertyChunk.HideState.Visible);
  53. Assert.AreEqual(kPropertyName, chunk.propertyName);
  54. Assert.AreEqual(kPropertyDescription, chunk.propertyDescription);
  55. Assert.AreEqual(expectedPropertyString, chunk.GetPropertyString());
  56. Assert.AreEqual(0.5f, chunk.defaultValue);
  57. Assert.AreEqual(PropertyChunk.HideState.Visible, chunk.hideState);
  58. }
  59. [Test]
  60. public void TestVectorChunkReturnsValidValues()
  61. {
  62. var vector = new Vector4(0.2f, 0.4f, 0.66f, 1.0f);
  63. var expectedPropertyString = "ThePropertyName(\"ThePropertyDescription\", Vector) = (0.2,0.4,0.66,1)";
  64. var chunk = new VectorPropertyChunk(kPropertyName, kPropertyDescription, vector, PropertyChunk.HideState.Visible);
  65. Assert.AreEqual(kPropertyName, chunk.propertyName);
  66. Assert.AreEqual(kPropertyDescription, chunk.propertyDescription);
  67. Assert.AreEqual(expectedPropertyString, chunk.GetPropertyString());
  68. Assert.AreEqual(vector, chunk.defaultValue);
  69. Assert.AreEqual(PropertyChunk.HideState.Visible, chunk.hideState);
  70. }
  71. [Test]
  72. public void TestTextureChunkReturnsValidValues()
  73. {
  74. var expectedPropertyString = "ThePropertyName(\"ThePropertyDescription\", 2D) = \"bump\" {}";
  75. var chunk = new TexturePropertyChunk(kPropertyName, kPropertyDescription, null, TextureType.Bump, PropertyChunk.HideState.Visible, TexturePropertyChunk.ModifiableState.Modifiable);
  76. Assert.AreEqual(kPropertyName, chunk.propertyName);
  77. Assert.AreEqual(kPropertyDescription, chunk.propertyDescription);
  78. Assert.AreEqual(expectedPropertyString, chunk.GetPropertyString());
  79. Assert.AreEqual(null, chunk.defaultTexture);
  80. Assert.AreEqual(PropertyChunk.HideState.Visible, chunk.hideState);
  81. }
  82. [Test]
  83. public void TestTexturePropertyChunkGeneratesValidPropertyStringVisibleNotModifiable()
  84. {
  85. var expectedPropertyString = "[NonModifiableTextureData] ThePropertyName(\"ThePropertyDescription\", 2D) = \"gray\" {}";
  86. var chunk = new TexturePropertyChunk(kPropertyName, kPropertyDescription, null, TextureType.Gray, PropertyChunk.HideState.Visible, TexturePropertyChunk.ModifiableState.NonModifiable);
  87. Assert.AreEqual(expectedPropertyString, chunk.GetPropertyString());
  88. Assert.AreEqual(TexturePropertyChunk.ModifiableState.NonModifiable, chunk.modifiableState);
  89. Assert.AreEqual(PropertyChunk.HideState.Visible, chunk.hideState);
  90. }
  91. [Test]
  92. public void TestTexturePropertyChunkGeneratesValidPropertyStringHiddenNotModifiable()
  93. {
  94. var expectedPropertyString = "[HideInInspector] [NonModifiableTextureData] ThePropertyName(\"ThePropertyDescription\", 2D) = \"white\" {}";
  95. var chunk = new TexturePropertyChunk(kPropertyName, kPropertyDescription, null, TextureType.White, PropertyChunk.HideState.Hidden, TexturePropertyChunk.ModifiableState.NonModifiable);
  96. Assert.AreEqual(expectedPropertyString, chunk.GetPropertyString());
  97. Assert.AreEqual(TexturePropertyChunk.ModifiableState.NonModifiable, chunk.modifiableState);
  98. Assert.AreEqual(PropertyChunk.HideState.Hidden, chunk.hideState);
  99. }
  100. }*/
  101. }