Skip to content

Commit 2e600ef

Browse files
Bring back test : Generation TestGraphAsIs
1 parent 1951e6a commit 2e600ef

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

com.unity.sg2/Tests/Generation/GenerationTests.cs

+25-29
Original file line numberDiff line numberDiff line change
@@ -86,35 +86,31 @@ private static Texture2D DrawToTex(Material material, int width = 4, int height
8686

8787
}
8888

89-
// TODO (Brett) This is disabled because of Generation errors with the Dec.
90-
// TODO (Brett) branch update.
91-
// TODO (Brett) Re-enable ASAP.
92-
93-
// static object[] testAsIsSource =
94-
// {
95-
// ("Add1", new Color(1,0,0,1)), //Colors with Alpha 1 since target is opaque
96-
// ("Add2", new Color(0,1,0,1)),
97-
// ("Add3", new Color(1,1,0,1)),
98-
// };
99-
//
100-
// [Test]
101-
// [TestCaseSource("testAsIsSource")]
102-
// public static void TestGraphAsIs((string nodeToCompile, Color expectedColor) input)
103-
// {
104-
// var shaderString = Interpreter.GetShaderForNode(graph.GetNodeReader(input.nodeToCompile), graph, registry, out _);
105-
// var shader = MakeShader(shaderString);
106-
// var rt = DrawToTex(shader);
107-
// try
108-
// {
109-
// var pixelColor = rt.GetPixel(0,0);
110-
// Assert.AreEqual(pixelColor, input.expectedColor);
111-
// }
112-
// catch(Exception e)
113-
// {
114-
// File.WriteAllBytes($"Assets/FailureImage{input.nodeToCompile}.jpg", rt.EncodeToJPG());
115-
// throw e;
116-
// }
117-
// }
89+
static object[] testAsIsSource =
90+
{
91+
("Add1", new Color(1,0,0,1)), //Colors with Alpha 1 since target is opaque
92+
("Add2", new Color(0,1,0,1)),
93+
("Add3", new Color(1,1,0,1)),
94+
};
95+
96+
[Test]
97+
[TestCaseSource("testAsIsSource")]
98+
public static void TestGraphAsIs((string nodeToCompile, Color expectedColor) input)
99+
{
100+
var shaderString = Interpreter.GetShaderForNode(graph.GetNodeReader(input.nodeToCompile), graph, registry, out _);
101+
var shader = MakeShader(shaderString);
102+
var rt = DrawToTex(shader);
103+
try
104+
{
105+
var pixelColor = rt.GetPixel(0,0);
106+
Assert.AreEqual(pixelColor, input.expectedColor);
107+
}
108+
catch(Exception e)
109+
{
110+
File.WriteAllBytes($"Assets/FailureImage{input.nodeToCompile}.jpg", rt.EncodeToJPG());
111+
throw e;
112+
}
113+
}
118114

119115
[Test]
120116
public static void TestGraphReferenceNode()

0 commit comments

Comments
 (0)