[tests] Add editor test with example tests for now
This commit is contained in:
Родитель
3d748f156a
Коммит
212e141edb
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: db91a525414eed845a7f8efa1070a218
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e4c186e2d570110b48de95a1c5fecc03
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,101 @@
|
|||
using NUnit.Framework;
|
||||
using System.Linq;
|
||||
using UnityEngine.Playables;
|
||||
|
||||
class GraphVisualizerClientTest
|
||||
{
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
// Clear graphs between tests, otherwise graphs are still referenced across tests.
|
||||
GraphVisualizerClient.ClearGraphs();
|
||||
}
|
||||
|
||||
private static PlayableGraph CreatePlayableGraph(string name)
|
||||
{
|
||||
var graph = PlayableGraph.Create(name);
|
||||
ScriptPlayableOutput.Create(graph, "output");
|
||||
return graph;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanShowGraph()
|
||||
{
|
||||
var graph1 = CreatePlayableGraph("test1");
|
||||
var graph2 = CreatePlayableGraph("test2");
|
||||
|
||||
GraphVisualizerClient.Show(graph1);
|
||||
var graphs = GraphVisualizerClient.GetGraphs().ToArray();
|
||||
|
||||
Assert.That(graphs.Length, Is.EqualTo(1));
|
||||
Assert.That(graphs[0].GetEditorName(), Is.EqualTo(graph1.GetEditorName()));
|
||||
|
||||
GraphVisualizerClient.Show(graph2);
|
||||
graphs = GraphVisualizerClient.GetGraphs().ToArray();
|
||||
|
||||
Assert.That(graphs.Length, Is.EqualTo(2));
|
||||
Assert.That(graphs[0].GetEditorName(), Is.EqualTo(graph1.GetEditorName()));
|
||||
Assert.That(graphs[1].GetEditorName(), Is.EqualTo(graph2.GetEditorName()));
|
||||
|
||||
graph1.Destroy();
|
||||
graph2.Destroy();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CannotShowSameGraphTwice()
|
||||
{
|
||||
var graph1 = CreatePlayableGraph("test1");
|
||||
|
||||
GraphVisualizerClient.Show(graph1);
|
||||
var graphs = GraphVisualizerClient.GetGraphs().ToArray();
|
||||
|
||||
Assert.That(graphs.Length, Is.EqualTo(1));
|
||||
|
||||
graph1.Destroy();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanHideGraph()
|
||||
{
|
||||
var graph1 = CreatePlayableGraph("test1");
|
||||
var graph2 = CreatePlayableGraph("test2");
|
||||
|
||||
GraphVisualizerClient.Show(graph1);
|
||||
GraphVisualizerClient.Show(graph2);
|
||||
var graphs = GraphVisualizerClient.GetGraphs().ToArray();
|
||||
|
||||
Assert.That(graphs.Length, Is.EqualTo(2));
|
||||
Assert.That(graphs[0].GetEditorName(), Is.EqualTo(graph1.GetEditorName()));
|
||||
Assert.That(graphs[1].GetEditorName(), Is.EqualTo(graph2.GetEditorName()));
|
||||
|
||||
GraphVisualizerClient.Hide(graph1);
|
||||
graphs = GraphVisualizerClient.GetGraphs().ToArray();
|
||||
|
||||
Assert.That(graphs.Length, Is.EqualTo(1));
|
||||
Assert.That(graphs[0].GetEditorName(), Is.EqualTo(graph2.GetEditorName()));
|
||||
|
||||
graph1.Destroy();
|
||||
graph2.Destroy();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanClearGraphs()
|
||||
{
|
||||
var graph1 = CreatePlayableGraph("test1");
|
||||
var graph2 = CreatePlayableGraph("test2");
|
||||
|
||||
GraphVisualizerClient.Show(graph1);
|
||||
GraphVisualizerClient.Show(graph2);
|
||||
var graphs = GraphVisualizerClient.GetGraphs().ToArray();
|
||||
|
||||
Assert.That(graphs.Length, Is.EqualTo(2));
|
||||
|
||||
GraphVisualizerClient.ClearGraphs();
|
||||
graphs = GraphVisualizerClient.GetGraphs().ToArray();
|
||||
|
||||
Assert.That(graphs.Length, Is.EqualTo(0));
|
||||
|
||||
graph1.Destroy();
|
||||
graph2.Destroy();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 76f082e5010cb366e9639d3b6f99834e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "Unity.PlayableGraphVisualizer.Tests",
|
||||
"references": [
|
||||
"Unity.PlayableGraphVisualizer"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": []
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 24b367a1e8631110f924a62b35bba83d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Загрузка…
Ссылка в новой задаче