Exemplo n.º 1
0
        public IEnumerator CreateAndDestroyCompositeComponent_Undo_CompositeExists()
        {
            var scene               = TestUtility.defaultScene;
            var composite           = TestUtility.CreateGameObjectWithUndoableCompositeComponent();
            var compositeGameObject = composite.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(composite);
            yield return(null);

            Assert.True(compositeGameObject);
            Assert.False(composite);
            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();
            composite = compositeGameObject.GetComponent <ChiselComposite>();
            yield return(null);

            Assert.True(compositeGameObject);
            Assert.True(composite);
            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));
        }
Exemplo n.º 2
0
        public IEnumerator CompositeWithPassThroughEnabled_DestroyCompositeGameObject_CompositeDoesNotExist()
        {
            var scene               = TestUtility.defaultScene;
            var composite           = TestUtility.CreateUndoableGameObjectWithComposite();
            var compositeGameObject = composite.gameObject;

            composite.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(compositeGameObject);
            Assert.True(composite);

            Undo.DestroyObjectImmediate(compositeGameObject);
            yield return(null);

            Assert.False(compositeGameObject);
            Assert.False(composite);
            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));
        }
Exemplo n.º 3
0
        public IEnumerator DisabledCompositeWithPassThroughEnabled_EnableCompositeComponent_CompositeDoesNotExist()
        {
            var scene               = TestUtility.defaultScene;
            var composite           = TestUtility.CreateUndoableGameObjectWithComposite();
            var compositeGameObject = composite.gameObject;

            composite.enabled     = false;
            composite.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");

            composite.enabled = true;
            yield return(null);

            Assert.True(compositeGameObject);
            Assert.True(composite);
            Assert.AreEqual(composite.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, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 6
0
        public IEnumerator CreateAndDestroyModelGameObject_Undo_ModelExist()
        {
            var scene           = TestUtility.defaultScene;
            var model           = TestUtility.CreateUndoableGameObjectWithModel();
            var modelGameObject = model.gameObject;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Undo.FlushUndoRecordObjects();
            Undo.IncrementCurrentGroup();
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");

            Undo.DestroyObjectImmediate(modelGameObject);
            yield return(null);

            Assert.False(modelGameObject);
            Assert.False(model);
            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            Undo.PerformUndo();
            yield return(null);

            model = modelGameObject.GetComponent <ChiselModel>();
            yield return(null);

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 7
0
        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, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 8
0
        public IEnumerator CreateBrushInScene1_MoveToScene2_BrushOnlyExistsInScene2()
        {
            var scene2 = TestUtility.defaultScene;

            EditorSceneManager.SaveScene(scene2, TestUtility.tempFilename);
            var scene1 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);

            EditorSceneManager.SetActiveScene(scene1);

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            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.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(scene1, brush.hierarchyItem.Scene);
            Undo.MoveGameObjectToScene(brushGameObject, scene2, "Move gameObject to different scene");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            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);
        }
Exemplo n.º 9
0
        public IEnumerator CreateBrush_DeactivateBrushGameObject_BrushDoesNotExist()
        {
            var scene           = TestUtility.defaultScene;
            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");       // default model
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            brushGameObject.SetActive(false);
            yield return(null);

            Assert.True(brushGameObject);
            Assert.True(brush);
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 10
0
        public IEnumerator CompositeWithChildInScene1_MoveToScene2_CompositeWithChildOnlyExistsInScene2()
        {
            var scene2 = TestUtility.defaultScene;

            EditorSceneManager.SaveScene(scene2, TestUtility.tempFilename);
            var scene1 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);

            EditorSceneManager.SetActiveScene(scene1);

            var composite           = TestUtility.CreateUndoableGameObjectWithComposite();
            var compositeGameObject = composite.gameObject;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = composite.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, composite.gameObject.scene);
            Assert.AreEqual(scene1, composite.hierarchyItem.Scene);

            Undo.MoveGameObjectToScene(compositeGameObject, 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(composite.hierarchyItem, brush.hierarchyItem.Parent);
            Assert.AreEqual(composite.NodeID, brush.hierarchyItem.Parent.Component.NodeID);
            Assert.AreEqual(composite.NodeID, brush.TopNode.Parent.NodeID);

            Assert.AreEqual(scene2, composite.gameObject.scene, "Composite is not part of expected scene");
            Assert.AreEqual(scene2, composite.hierarchyItem.Scene, "Composite 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);
        }
Exemplo n.º 11
0
        public IEnumerator GameObjectInScene1WithModel_MoveModelToGameObjectInScene2_ModelOnlyExistsInScene2()
        {
            var scene2           = TestUtility.defaultScene;
            var scene2GameObject = new GameObject();

            EditorSceneManager.SaveScene(scene2, TestUtility.tempFilename);

            var scene1 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);

            EditorSceneManager.SetActiveScene(scene1);
            var scene1GameObject = new GameObject();

            var model           = TestUtility.CreateUndoableGameObjectWithModel();
            var modelGameObject = model.gameObject;

            model.transform.parent = scene1GameObject.transform;
            EditorSceneManager.SaveScene(scene2, TestUtility.tempFilename2);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");
            Assert.AreEqual(scene1, model.hierarchyItem.Scene);


            model.transform.parent = scene2GameObject.transform;
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");

            Assert.AreEqual(scene2, model.gameObject.scene, "Model is not part of expected scene");
            Assert.AreEqual(scene2, model.hierarchyItem.Scene, "Model 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);
        }
Exemplo n.º 12
0
        public IEnumerator ModelWithChildBrush_DestroyModel_ChildIsAlsoDestroyed()
        {
            var scene           = TestUtility.defaultScene;
            var model           = TestUtility.CreateUndoableGameObjectWithModel();
            var modelGameObject = model.gameObject;

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model.transform;

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.True(brushGameObject);
            Assert.True(brush);

            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");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Assert.AreEqual(1, model.Node.Count, 1);
            Assert.AreEqual(model.Node.NodeID, brush.TopNode.Tree.NodeID);

            Undo.DestroyObjectImmediate(modelGameObject);
            yield return(null);

            Assert.False(modelGameObject);
            Assert.False(model);
            Assert.False(brushGameObject);
            Assert.False(brush);

            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.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 13
0
        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, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 14
0
        public IEnumerator CreateBrush_DestroyBrushComponent_BrushDoesNotExist()
        {
            var scene           = TestUtility.defaultScene;
            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            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.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Undo.DestroyObjectImmediate(brush);
            yield return(null);

            Assert.True(brushGameObject);
            Assert.False(brush);
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 15
0
        public IEnumerator GameObjectInScene1WithOperation_MoveGameObjectToScene2_OperationOnlyExistsInScene2()
        {
            var scene2 = TestUtility.defaultScene;

            EditorSceneManager.SaveScene(scene2, TestUtility.tempFilename);
            var scene1 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Additive);

            EditorSceneManager.SetActiveScene(scene1);
            var scene1GameObject = new GameObject();

            var operation           = TestUtility.CreateUndoableGameObjectWithOperation();
            var operationGameObject = operation.gameObject;

            operation.transform.parent = scene1GameObject.transform;

            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(scene1GameObject, 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, ChiselNodeHierarchyManager.RootCount(scene1));
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene2));

            // make sure test runner doesn't puke on its own bugs
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
        }
Exemplo n.º 16
0
        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, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 17
0
        public IEnumerator CreateComposite_DisableCompositeComponent_CompositeDoesNotExist()
        {
            var scene               = TestUtility.defaultScene;
            var composite           = TestUtility.CreateUndoableGameObjectWithComposite();
            var compositeGameObject = composite.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");

            composite.enabled = false;
            yield return(null);

            Assert.True(compositeGameObject);
            Assert.True(composite);
            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));
        }
Exemplo n.º 18
0
        public IEnumerator CreateModel_DeactivateModelGameObject_ModelDoesNotExist()
        {
            var scene           = TestUtility.defaultScene;
            var model           = TestUtility.CreateUndoableGameObjectWithModel();
            var modelGameObject = model.gameObject;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");

            modelGameObject.SetActive(false);
            yield return(null);

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 19
0
        public IEnumerator SaveBrushInScene_LoadScene_BrushTreeNodeIsGenerated()
        {
            var scene1 = TestUtility.defaultScene;
            {
                TestUtility.CreateUndoableGameObjectWithBrush();
                EditorSceneManager.SaveScene(scene1, TestUtility.tempFilename);
            }

            var scene2 = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);

            yield return(null);

            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene2));

            var scene3  = EditorSceneManager.OpenScene(TestUtility.tempFilename);
            var brushes = Object.FindObjectsOfType <ChiselBrush>();

            yield return(null);

            Assert.NotNull(brushes);
            Assert.AreEqual(1, brushes.Length);

            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene3));

            Assert.AreEqual(scene3, brushes[0].gameObject.scene, "Brush is not part of expected scene");
            Assert.AreEqual(scene3, brushes[0].hierarchyItem.Scene, "Brush is not registered to expected scene");

            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene1)); // unloaded, so should be unknown to us
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene2)); // unloaded, so should be unknown to us
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene3));

            // make sure test runner doesn't puke on its own bugs
            EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
        }
Exemplo n.º 20
0
        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, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 21
0
        public IEnumerator Model1WithModel2WithChildBrush_DeactivateModel2GameObject_ChildIsAlsoDeactivated()
        {
            var scene            = TestUtility.defaultScene;
            var model1           = TestUtility.CreateUndoableGameObjectWithModel();
            var model1GameObject = model1.gameObject;

            var model2           = TestUtility.CreateUndoableGameObjectWithModel();
            var model2GameObject = model2.gameObject;

            model2.transform.parent = model1.transform;
            model2GameObject.SetActive(false);

            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            brush.transform.parent = model2.transform;

            Assert.True(model1GameObject);
            Assert.True(model1);
            Assert.True(model2GameObject);
            Assert.True(model2);
            Assert.True(brushGameObject);
            Assert.True(brush);

            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");
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");

            Assert.AreEqual(0, model1.Node.Count);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, brush.TopNode.NodeID);
            Assert.AreEqual(CSGTreeNode.InvalidNode.NodeID, model2.Node.NodeID);
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 22
0
        public IEnumerator CreateBrush_UndoCreateGameObject_BrushDoesNotExist()
        {
            var scene           = TestUtility.defaultScene;
            var brush           = TestUtility.CreateUndoableGameObjectWithBrush();
            var brushGameObject = brush.gameObject;

            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Undo.FlushUndoRecordObjects();
            Undo.IncrementCurrentGroup();
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeBrushCount, "Expected 1 TreeBrush to Exist");
            Assert.AreEqual(2, CSGManager.TreeNodeCount, "Expected 2 TreeNodes to Exist");

            Undo.PerformUndo();
            yield return(null);

            Assert.False(brushGameObject);
            Assert.False(brush);
            Assert.AreEqual(0, CSGManager.TreeBrushCount, "Expected 0 TreeBrushes to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 23
0
        public IEnumerator CreateModel_EnableModelComponent_ModelExists()
        {
            var scene           = TestUtility.defaultScene;
            var model           = TestUtility.CreateUndoableGameObjectWithModel();
            var modelGameObject = model.gameObject;

            model.enabled = false;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            yield return(null);

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");

            model.enabled = true;
            yield return(null);

            Assert.True(modelGameObject);
            Assert.True(model);
            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");
            Assert.AreEqual(1, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 24
0
        public IEnumerator CreateModel_UndoCreateComponent_ModelDoesNotExist()
        {
            var scene           = TestUtility.defaultScene;
            var model           = TestUtility.CreateGameObjectWithUndoableModelComponent();
            var modelGameObject = model.gameObject;

            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Undo.FlushUndoRecordObjects();
            Undo.IncrementCurrentGroup();
            yield return(null);

            Assert.AreEqual(1, CSGManager.TreeCount, "Expected 1 Tree to Exist");
            Assert.AreEqual(1, CSGManager.TreeNodeCount, "Expected 1 TreeNode to Exist");

            Undo.PerformUndo();
            yield return(null);

            Assert.True(modelGameObject);
            Assert.False(model);
            Assert.AreEqual(0, CSGManager.TreeCount, "Expected 0 Trees to Exist");
            Assert.AreEqual(0, CSGManager.TreeNodeCount, "Expected 0 TreeNodes to Exist");
            Assert.AreEqual(0, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 25
0
        public IEnumerator CreateOperation_UndoCreateComponent_OperationDoesNotExist()
        {
            var scene               = TestUtility.defaultScene;
            var operation           = TestUtility.CreateGameObjectWithUndoableOperationComponent();
            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.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, ChiselNodeHierarchyManager.RootCount(scene));
        }
Exemplo n.º 26
0
        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, ChiselNodeHierarchyManager.RootCount(scene));
        }