Tim Cooper
9 年前
当前提交
2630ebd1
共有 7 个文件被更改,包括 138 次插入 和 40 次删除
-
18UnityProject/Assets/UnityShaderEditor/Editor/Source/AbstractMaterialGraph.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialGraphDataSource.cs
-
12UnityProject/Assets/UnityShaderEditor/Editor/Source/MaterialGraph.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/AbstractMaterialNode.cs
-
6UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PixelShaderNode.cs
-
25UnityProject/Assets/UnityShaderEditor/Editor/Source/PixelGraph.cs
-
113UnityProject/Assets/UnityShaderEditor/Editor/Testing/UnitTests/AbstractMaterialGraphTests.cs
|
|||
using System.Linq; |
|||
using NUnit.Framework; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Tests |
|||
{ |
|||
[TestFixture] |
|||
public class AbstractMaterialGraphTests |
|||
{ |
|||
private class TestableMGraph : AbstractMaterialGraph |
|||
{} |
|||
|
|||
private class TestableMNode : AbstractMaterialNode |
|||
{ |
|||
public TestableMNode(AbstractMaterialGraph theOwner) : base(theOwner) |
|||
{} |
|||
} |
|||
private class TimeTestableMNode : AbstractMaterialNode, IRequiresTime |
|||
{ |
|||
public TimeTestableMNode(AbstractMaterialGraph theOwner) : base(theOwner) |
|||
{} |
|||
} |
|||
|
|||
[Test] |
|||
public void TestCanCreateMaterialGraph() |
|||
{ |
|||
TestableMGraph graph = new TestableMGraph(); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(0, graph.nodes.Count()); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestCanAddMaterialNodeToMaterialGraph() |
|||
{ |
|||
TestableMGraph graph = new TestableMGraph(); |
|||
|
|||
var node = new TestableMNode(graph); |
|||
graph.AddNode(node); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(1, graph.nodes.Count()); |
|||
Assert.AreEqual(1, graph.materialNodes.Count()); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestCanNotAddSerializableNodeToMaterialGraph() |
|||
{ |
|||
TestableMGraph graph = new TestableMGraph(); |
|||
|
|||
var node = new SerializableNode(graph); |
|||
graph.AddNode(node); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(0, graph.nodes.Count()); |
|||
Assert.AreEqual(0, graph.materialNodes.Count()); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestCanGetMaterialNodeFromMaterialGraph() |
|||
{ |
|||
TestableMGraph graph = new TestableMGraph(); |
|||
|
|||
var node = new TestableMNode(graph); |
|||
graph.AddNode(node); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(1, graph.nodes.Count()); |
|||
|
|||
Assert.AreEqual(node, graph.GetMaterialNodeFromGuid(node.guid)); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestMaterialGraphNeedsRepaintWhenTimeNodePresent() |
|||
{ |
|||
TestableMGraph graph = new TestableMGraph(); |
|||
graph.AddNode(new TestableMNode(graph)); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(1, graph.nodes.Count()); |
|||
Assert.IsFalse(graph.requiresRepaint); |
|||
|
|||
graph.AddNode(new TimeTestableMNode(graph)); |
|||
Assert.IsTrue(graph.requiresRepaint); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestCreatePixelShaderGraphWorks() |
|||
{ |
|||
var graph = new PixelGraph(); |
|||
Assert.AreEqual(0, graph.nodes.Count()); |
|||
|
|||
var psn = new PixelShaderNode(graph); |
|||
graph.AddNode(psn); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(1, graph.nodes.Count()); |
|||
Assert.IsInstanceOf(typeof(PixelShaderNode), graph.nodes.FirstOrDefault()); |
|||
Assert.IsNotNull(graph.pixelMasterNode); |
|||
Assert.AreEqual(1, graph.activeNodes.Count()); |
|||
} |
|||
|
|||
[Test] |
|||
public void TestCanOnlyAddOnePixelShaderNode() |
|||
{ |
|||
var graph = new PixelGraph(); |
|||
Assert.AreEqual(0, graph.nodes.Count()); |
|||
|
|||
var psn = new PixelShaderNode(graph); |
|||
graph.AddNode(psn); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(1, graph.nodes.Count()); |
|||
|
|||
var psn2 = new PixelShaderNode(graph); |
|||
graph.AddNode(psn2); |
|||
Assert.AreEqual(0, graph.edges.Count()); |
|||
Assert.AreEqual(1, graph.nodes.Count()); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue