public IEnumerator OperationWithGameObject_AddChildOperation_OperationHasChild() { var operation1 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation1GameObject = operation1.gameObject; var plainGameObject = TestUtility.CreateGameObject(); plainGameObject.transform.parent = operation1.transform; var operation2 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation2GameObject = operation2.gameObject; operation2.transform.parent = plainGameObject.transform; Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(operation2); Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation1.Node.Count); Assert.AreEqual(operation2.Node.NodeID, operation1.Node[0].NodeID); }
public IEnumerator DisabledOperationWithPassThroughEnabled_EnableOperationComponent_OperationDoesNotExist() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; operation.enabled = false; operation.PassThrough = true; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); operation.enabled = true; yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.AreEqual(operation.Node, (CSGTreeBranch)CSGTreeNode.InvalidNode); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene)); }
public IEnumerator OperationWithChildBrush_DisableAndEnableOperationComponent_ChildHasOperationAsParent() { var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation.transform; yield return(null); operation.enabled = false; yield return(null); operation.enabled = true; yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation.Node.Count); Assert.AreEqual(operation.Node.NodeID, brush.TopNode.Parent.NodeID); }
public IEnumerator OperationWithPassThroughEnabled_DisablePassThrough_OperationExists() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; operation.PassThrough = true; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.True(operationGameObject); Assert.True(operation); operation.PassThrough = false; yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.AreNotEqual(operation.Node, (CSGTreeBranch)CSGTreeNode.InvalidNode); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene)); }
public IEnumerator OperationWithPassThroughEnabled_DestroyOperationComponent_OperationDoesNotExist() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; operation.PassThrough = true; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.True(operationGameObject); Assert.True(operation); Undo.DestroyObjectImmediate(operation); yield return(null); Assert.True(operationGameObject); Assert.False(operation); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene)); }
public IEnumerator CreateOperation_AddChildBrush_ChildHasOperationAsParent() { var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.Parent.NodeID); brush.transform.parent = operation.transform; yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation.Node.Count); Assert.AreEqual(operation.Node.NodeID, brush.TopNode.Parent.NodeID); }
public IEnumerator OperationWithWithGameObjectWithBrush_BrushHasOperationAsParent() { var operation = TestUtility.CreateUndoableGameObjectWithOperation("operation"); var operationGameObject = operation.gameObject; var plainGameObject = TestUtility.CreateGameObject("gameObject"); plainGameObject.transform.parent = operationGameObject.transform; var brush = TestUtility.CreateUndoableGameObjectWithBrush("brush"); var brushGameObject = brush.gameObject; brush.transform.parent = plainGameObject.transform; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.True(plainGameObject); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation.Node.Count); Assert.AreEqual(operation.Node.NodeID, brush.TopNode.Parent.NodeID); }
public IEnumerator Operation1WithDisabledOperation2_AddChildOperation_ChildHasParentOfOperationAsParent() { var operation1 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation1GameObject = operation1.gameObject; var operation2 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation2GameObject = operation2.gameObject; operation2.transform.parent = operation1.transform; operation2.enabled = false; var operation3 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation3GameObject = operation3.gameObject; operation3.transform.parent = operation2.transform; Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(operation2); Assert.True(operation3GameObject); Assert.True(operation3); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation1.Node.Count); Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, operation2.Node.NodeID); Assert.AreEqual(operation1.Node.NodeID, operation3.Node.Parent.NodeID); }
public IEnumerator OperationInScene1_MoveToScene2_OperationOnlyExistsInScene2() { var scene2 = TestUtility.defaultScene; EditorSceneManager.SaveScene(scene2, TestUtility.tempFilename); var scene1 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive); EditorSceneManager.SetActiveScene(scene1); var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(scene1, operation.hierarchyItem.Scene); Undo.MoveGameObjectToScene(operationGameObject, scene2, "Move gameObject to different scene"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(scene2, operation.gameObject.scene, "Operation is not part of expected scene"); Assert.AreEqual(scene2, operation.hierarchyItem.Scene, "Operation is not registered to expected scene"); Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene1)); Assert.AreEqual(1, CSGNodeHierarchyManager.RootCount(scene2)); // make sure test runner doesn't puke on its own bugs EditorSceneManager.NewScene(NewSceneSetup.EmptyScene); }
public IEnumerator CreateOperation_UndoCreateGameObject_DoesNotDirtyAnyScene() { var currentScene = SceneManager.GetActiveScene(); var newScene = TestUtility.CreateAdditionalSceneAndActivate(); Assert.False(currentScene.isDirty); Assert.False(newScene.isDirty); Undo.FlushUndoRecordObjects(); Undo.IncrementCurrentGroup(); yield return(null); var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(operationGameObject.scene, newScene); Assert.True(newScene.isDirty); Assert.False(currentScene.isDirty); Undo.PerformUndo(); yield return(null); Assert.False(operationGameObject); Assert.False(operation); Assert.False(newScene.isDirty); Assert.False(currentScene.isDirty); }
public IEnumerator Model_AddChildOperation_ModelHasChild() { var model = TestUtility.CreateUndoableGameObjectWithModel(); var modelGameObject = model.gameObject; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; operation.transform.parent = model.transform; Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.True(modelGameObject); Assert.True(model); Assert.True(operationGameObject); Assert.True(operation); Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist"); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(1, model.Node.Count); Assert.AreEqual(operation.Node.NodeID, model.Node[0].NodeID); }
public IEnumerator CreateAndDestroyOperationGameObject_Undo_OperationExists() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Undo.FlushUndoRecordObjects(); Undo.IncrementCurrentGroup(); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Undo.DestroyObjectImmediate(operationGameObject); yield return(null); Assert.False(operationGameObject); Assert.False(operation); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene)); Undo.PerformUndo(); operation = Object.FindObjectsOfType <ChiselOperation>()[0]; operationGameObject = operation.gameObject; yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene)); }
public IEnumerator Operation1WithDisabledOperation2WithChildBrush_EnableOperation2_ChildHasOperation2AsParent() { var operation1 = TestUtility.CreateUndoableGameObjectWithOperation("operation1"); var operation1GameObject = operation1.gameObject; var operation2 = TestUtility.CreateUndoableGameObjectWithOperation("operation2"); var operation2GameObject = operation2.gameObject; operation2.transform.parent = operation1.transform; operation2.enabled = false; var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation2.transform; Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(operation2); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation1.Node.Count); Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID); Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, operation2.Node.NodeID); Assert.AreEqual(operation1.Node.NodeID, brush.TopNode.Parent.NodeID); operation2.enabled = true; yield return(null); Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist"); Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, operation2.Node.NodeID); Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID); Assert.AreEqual(operation2.Node.NodeID, brush.TopNode.Parent.NodeID); Assert.AreEqual(operation1.Node.NodeID, operation2.Node.Parent.NodeID); Assert.AreEqual(1, operation1.Node.Count); Assert.AreEqual(1, operation2.Node.Count); }
public IEnumerator OperationWithChildInScene1_MoveToScene2_OperationWithChildOnlyExistsInScene2() { var scene2 = TestUtility.defaultScene; EditorSceneManager.SaveScene(scene2, TestUtility.tempFilename); var scene1 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive); EditorSceneManager.SetActiveScene(scene1); var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation.transform; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(scene1, operation.gameObject.scene); Assert.AreEqual(scene1, operation.hierarchyItem.Scene); Undo.MoveGameObjectToScene(operationGameObject, scene2, "Move gameObject to different scene"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(operation.hierarchyItem, brush.hierarchyItem.Parent); Assert.AreEqual(operation.NodeID, brush.hierarchyItem.Parent.Component.NodeID); Assert.AreEqual(operation.NodeID, brush.TopNode.Parent.NodeID); Assert.AreEqual(scene2, operation.gameObject.scene, "Operation is not part of expected scene"); Assert.AreEqual(scene2, operation.hierarchyItem.Scene, "Operation is not registered to expected scene"); Assert.AreEqual(scene2, brush.gameObject.scene, "Brush is not part of expected scene"); Assert.AreEqual(scene2, brush.hierarchyItem.Scene, "Brush is not registered to expected scene"); Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene1)); Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene2)); // make sure test runner doesn't puke on its own bugs EditorSceneManager.NewScene(NewSceneSetup.EmptyScene); }
public IEnumerator Operation1WithChildBrush_MoveBrushToNoneCSGNodeChildOfOperation2_ChildHasOperation2AsParent() { var operation1 = TestUtility.CreateUndoableGameObjectWithOperation("operation1"); var operation1GameObject = operation1.gameObject; var operation2 = TestUtility.CreateUndoableGameObjectWithOperation("operation2"); var operation2GameObject = operation2.gameObject; var plainGameObject = TestUtility.CreateGameObject("gameObject"); plainGameObject.transform.parent = operation2.transform; var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation1.transform; Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(operation2); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist"); Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, operation2.Node.NodeID); Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, operation1.Node.NodeID); Assert.AreNotEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID); Assert.AreEqual(operation1.Node.NodeID, brush.TopNode.Parent.NodeID); Assert.AreEqual(1, operation1.Node.Count); Assert.AreEqual(0, operation2.Node.Count); brush.transform.parent = plainGameObject.transform; yield return(null); Assert.AreEqual(operation2.Node.NodeID, brush.TopNode.Parent.NodeID); Assert.AreEqual(0, operation1.Node.Count); Assert.AreEqual(1, operation2.Node.Count); }
public IEnumerator Operation1WithWithGameObjectWithBrush_AddOperation2ToGameObject_BrushHasOperation2AsParent() { var operation1 = TestUtility.CreateUndoableGameObjectWithOperation("operation1"); var operation1GameObject = operation1.gameObject; var operation2GameObject = TestUtility.CreateGameObject("operation2"); operation2GameObject.transform.parent = operation1GameObject.transform; var brush = TestUtility.CreateUndoableGameObjectWithBrush("brush"); var brushGameObject = brush.gameObject; brush.transform.parent = operation2GameObject.transform; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation1.Node.Count); Assert.AreEqual(operation1.Node.NodeID, brush.TopNode.Parent.NodeID); var operation2 = TestUtility.CreateUndoableOperationComponent(operation2GameObject); yield return(null); Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(operation2); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist"); Assert.AreEqual(1, operation2.Node.Count); Assert.AreEqual(1, operation1.Node.Count); Assert.AreEqual(operation1.Node.NodeID, operation2.Node.Parent.NodeID); Assert.AreEqual(operation2.Node.NodeID, brush.TopNode.Parent.NodeID); }
public void CreateOperation_OnlyDirtiesSceneOfOperation() { var currentScene = SceneManager.GetActiveScene(); var newScene = TestUtility.CreateAdditionalSceneAndActivate(); Assert.False(currentScene.isDirty); Assert.False(newScene.isDirty); var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(newScene, operationGameObject.scene); Assert.True(newScene.isDirty); Assert.False(currentScene.isDirty); }
public IEnumerator Operation1WithOperation2WithChildBrush_DestroyOperationComponent2_ChildHasOperation1AsParent() { var operation1 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation1GameObject = operation1.gameObject; var operation2 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation2GameObject = operation2.gameObject; operation2.transform.parent = operation1.transform; var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation2.transform; Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(operation2); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(2, CSGManager.TreeBranchCount, "Expected 2 TreeBranches to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist"); Assert.AreEqual(1, operation1.Node.Count); Assert.AreEqual(1, operation2.Node.Count); Assert.AreEqual(operation2.Node.NodeID, brush.TopNode.Parent.NodeID); Assert.AreEqual(operation1.Node.NodeID, operation2.Node.Parent.NodeID); Undo.DestroyObjectImmediate(operation2); yield return(null); Assert.False(operation2); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation1.Node.Count); Assert.AreEqual(operation1.Node.NodeID, brush.TopNode.Parent.NodeID); }
public IEnumerator OperationWithTwoChildBrushes_SwapOrder_OperationHasChildrenInOrder() { var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; var brush1 = TestUtility.CreateUndoableGameObjectWithBrush(); var brush1GameObject = brush1.gameObject; brush1.transform.parent = operation.transform; var brush2 = TestUtility.CreateUndoableGameObjectWithBrush(); var brush2GameObject = brush2.gameObject; brush2.transform.parent = operation.transform; Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.True(operationGameObject); Assert.True(operation); Assert.True(brush1GameObject); Assert.True(brush1); Assert.True(brush2GameObject); Assert.True(brush2); Assert.AreEqual(operation.transform.GetChild(0), brush1.transform); Assert.AreEqual(operation.transform.GetChild(1), brush2.transform); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeBrushCount, "Expected 2 TreeBrushes to Exist"); Assert.AreEqual(4, CSGManager.TreeNodeCount, "Expected 4 TreeNodes to Exist"); Assert.AreEqual(2, operation.Node.Count); brush2.transform.SetSiblingIndex(0); Assert.AreEqual(operation.transform.GetChild(0), brush2.transform); Assert.AreEqual(operation.transform.GetChild(1), brush1.transform); yield return(null); Assert.AreEqual(brush2.TopNode.NodeID, operation.Node[0].NodeID); Assert.AreEqual(brush1.TopNode.NodeID, operation.Node[1].NodeID); }
public IEnumerator OperationWithChildBrush_DestroyOperation_ChildIsDestroyed() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation.transform; Assert.True(operationGameObject); Assert.True(operation); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation.Node.Count, 1); Assert.AreEqual(operation.Node.NodeID, brush.TopNode.Parent.NodeID); Undo.DestroyObjectImmediate(operationGameObject); yield return(null); Assert.False(operationGameObject); Assert.False(operation); Assert.False(brushGameObject); Assert.False(brush); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene)); }
public IEnumerator CreateOperation_DisableOperationComponent_OperationDoesNotExist() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); operation.enabled = false; yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene)); }
public IEnumerator OperationWithChildBrush_DeactivateChildGameObject_OperationHasNoChildren() { var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation.transform; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(1, operation.Node.Count); Assert.AreEqual(operation.Node.NodeID, brush.TopNode.Parent.NodeID); brushGameObject.SetActive(false); yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(0, operation.Node.Count); }
public IEnumerator ModelWithChildOperation_DestroyChildComponent_ModelHasNoChildren() { var model = TestUtility.CreateUndoableGameObjectWithModel(); var modelGameObject = model.gameObject; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; operation.transform.parent = model.transform; Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist"); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.True(modelGameObject); Assert.True(model); Assert.True(operationGameObject); Assert.True(operation); Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist"); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(1, model.Node.Count); Assert.AreEqual(model.Node.NodeID, operation.Node.Tree.NodeID); Undo.DestroyObjectImmediate(operation); yield return(null); Assert.True(modelGameObject); Assert.True(model); Assert.True(operationGameObject); Assert.False(operation); Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist"); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist"); Assert.AreEqual(0, model.Node.Count); }
public IEnumerator CreateOperation_DestroyOperationGameObject_OperationDoesNotExist() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Undo.DestroyObjectImmediate(operationGameObject); yield return(null); Assert.False(operationGameObject); Assert.False(operation); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene)); }
public IEnumerator Operation1WithOperation2WithChildBrush_DeactivateOperation2GameObject_ChildIsAlsoDeactivated() { var scene = TestUtility.defaultScene; var operation1 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation1GameObject = operation1.gameObject; var operation2 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation2GameObject = operation2.gameObject; operation2.transform.parent = operation1.transform; operation2GameObject.SetActive(false); var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation2.transform; Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(operation2); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(0, operation1.Node.Count); Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID); Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, operation2.Node.NodeID); Assert.AreEqual(1, CSGNodeHierarchyManager.RootCount(scene)); }
public IEnumerator CreateOperation_DestroyOperationComponent_OnlyDirtiesSceneOfOperation() { var currentScene = SceneManager.GetActiveScene(); var newScene = TestUtility.CreateAdditionalSceneAndActivate(); Assert.False(currentScene.isDirty); Assert.False(newScene.isDirty); var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(newScene, operationGameObject.scene); Assert.True(newScene.isDirty); Assert.False(currentScene.isDirty); Undo.DestroyObjectImmediate(operation); yield return(null); Assert.True(operationGameObject); Assert.False(operation); Assert.True(newScene.isDirty); Assert.False(currentScene.isDirty); }
public IEnumerator SaveOperationInScene_LoadScene_OperationTreeNodeIsGenerated() { var scene1 = TestUtility.defaultScene; { TestUtility.CreateUndoableGameObjectWithOperation(); EditorSceneManager.SaveScene(scene1, TestUtility.tempFilename); } var scene2 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene); yield return(null); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene2)); var scene3 = EditorSceneManager.OpenScene(TestUtility.tempFilename); var operations = Object.FindObjectsOfType <CSGOperation>(); yield return(null); Assert.NotNull(operations); Assert.AreEqual(1, operations.Length); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(scene3, operations[0].gameObject.scene, "Operation is not part of expected scene"); Assert.AreEqual(scene3, operations[0].hierarchyItem.Scene, "Operation is not registered to expected scene"); Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene1)); // unloaded, so should be unknown to us Assert.AreEqual(0, CSGNodeHierarchyManager.RootCount(scene2)); // unloaded, so should be unknown to us Assert.AreEqual(1, CSGNodeHierarchyManager.RootCount(scene3)); // make sure test runner doesn't puke on its own bugs EditorSceneManager.NewScene(NewSceneSetup.EmptyScene); }
public IEnumerator CreateOperation_UndoCreateGameObject_OperationDoesNotExist() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Undo.FlushUndoRecordObjects(); Undo.IncrementCurrentGroup(); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Undo.PerformUndo(); yield return(null); Assert.False(operationGameObject); Assert.False(operation); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene)); }
public IEnumerator CreateOperation_ActivateOperationGameObject_OperationExists() { var scene = TestUtility.defaultScene; var operation = TestUtility.CreateUndoableGameObjectWithOperation(); var operationGameObject = operation.gameObject; operationGameObject.SetActive(false); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); operationGameObject.SetActive(true); yield return(null); Assert.True(operationGameObject); Assert.True(operation); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist"); Assert.AreEqual(1, CSGNodeHierarchyManager.RootCount(scene)); }
public IEnumerator Operation1WithPassthroughOperation2_AddChild_ChildHasOperation1AsParent() { var operation1 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation1GameObject = operation1.gameObject; var operation2 = TestUtility.CreateUndoableGameObjectWithOperation(); var operation2GameObject = operation2.gameObject; operation2.transform.parent = operation1.transform; operation2.PassThrough = true; var brush = TestUtility.CreateUndoableGameObjectWithBrush(); var brushGameObject = brush.gameObject; brush.transform.parent = operation2.transform; Assert.True(operation1GameObject); Assert.True(operation1); Assert.True(operation2GameObject); Assert.True(operation2); Assert.True(brushGameObject); Assert.True(brush); Assert.AreEqual(0, CSGManager.TreeBranchCount, "Expected 0 TreeBranches to Exist"); Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist"); Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist"); yield return(null); Assert.AreEqual(1, CSGManager.TreeBranchCount, "Expected 1 TreeBranch to Exist"); Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist"); Assert.AreEqual(3, CSGManager.TreeNodeCount, "Expected 3 TreeNodes to Exist"); Assert.AreEqual(brush.TopNode.Parent, operation1.Node); Assert.AreEqual(operation1.Node.Count, 1); Assert.AreEqual(operation2.Node, (CSGTreeBranch)CSGTreeNode.InvalidNode); }