Skip to content

Commit b5c9a69

Browse files
committed
Run pre-commit / dotnet-format once to reformat everything
1 parent b07c07a commit b5c9a69

File tree

350 files changed

+75942
-67311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

350 files changed

+75942
-67311
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,3 @@ jobs:
483483
target_commitish: ${{ needs.configuration.outputs.currentrelease }}
484484
tag_name: ${{ needs.configuration.outputs.version }}
485485
files: releases/*
486-

Assets/Editor/tests/model/controller/TouchPadLocationTest.cs

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,44 @@
1515
using NUnit.Framework;
1616
using UnityEngine;
1717

18-
namespace com.google.apps.peltzer.client.model.controller {
18+
namespace com.google.apps.peltzer.client.model.controller
19+
{
1920

20-
[TestFixture]
21-
// Tests for TouchpadLocation.
22-
public class TouchpadLocationTest {
23-
[Test]
24-
public void TestBasicQuadrants() {
25-
NUnit.Framework.Assert.IsTrue(
26-
TouchpadLocation.RIGHT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.5f, 0))));
27-
NUnit.Framework.Assert.IsTrue(
28-
TouchpadLocation.TOP.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, .5f))));
29-
NUnit.Framework.Assert.IsTrue(
30-
TouchpadLocation.LEFT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.5f, 0))));
31-
NUnit.Framework.Assert.IsTrue(
32-
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, -.5f))));
33-
}
21+
[TestFixture]
22+
// Tests for TouchpadLocation.
23+
public class TouchpadLocationTest
24+
{
25+
[Test]
26+
public void TestBasicQuadrants()
27+
{
28+
NUnit.Framework.Assert.IsTrue(
29+
TouchpadLocation.RIGHT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.5f, 0))));
30+
NUnit.Framework.Assert.IsTrue(
31+
TouchpadLocation.TOP.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, .5f))));
32+
NUnit.Framework.Assert.IsTrue(
33+
TouchpadLocation.LEFT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.5f, 0))));
34+
NUnit.Framework.Assert.IsTrue(
35+
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, -.5f))));
36+
}
3437

35-
[Test]
36-
public void TestCenter() {
37-
NUnit.Framework.Assert.IsTrue(
38-
TouchpadLocation.CENTER.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, 0))));
39-
}
38+
[Test]
39+
public void TestCenter()
40+
{
41+
NUnit.Framework.Assert.IsTrue(
42+
TouchpadLocation.CENTER.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(0, 0))));
43+
}
4044

41-
[Test]
42-
public void TestXYCombinations() {
43-
NUnit.Framework.Assert.IsTrue(
44-
TouchpadLocation.TOP.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.1f, .5f))));
45-
NUnit.Framework.Assert.IsTrue(
46-
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.1f, -.5f))));
47-
NUnit.Framework.Assert.IsTrue(
48-
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.1f, -.5f))));
49-
NUnit.Framework.Assert.IsTrue(
50-
TouchpadLocation.LEFT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.5f, 0))));
45+
[Test]
46+
public void TestXYCombinations()
47+
{
48+
NUnit.Framework.Assert.IsTrue(
49+
TouchpadLocation.TOP.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.1f, .5f))));
50+
NUnit.Framework.Assert.IsTrue(
51+
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(.1f, -.5f))));
52+
NUnit.Framework.Assert.IsTrue(
53+
TouchpadLocation.BOTTOM.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.1f, -.5f))));
54+
NUnit.Framework.Assert.IsTrue(
55+
TouchpadLocation.LEFT.Equals(TouchpadLocationHelper.GetTouchpadLocation(new Vector2(-.5f, 0))));
56+
}
5157
}
52-
}
5358
}

Assets/Editor/tests/model/core/CommandTest.cs

Lines changed: 151 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -18,149 +18,156 @@
1818
using NUnit.Framework;
1919
using UnityEngine;
2020

21-
namespace com.google.apps.peltzer.client.model.core {
22-
23-
[TestFixture]
24-
// Tests for Command and implementations.
25-
public class CommandTest {
26-
27-
[Test]
28-
public void TestCompositeMove() {
29-
int meshOne = 1;
30-
int meshTwo = 2;
31-
32-
Model model = new Model(new Bounds(Vector3.zero, Vector3.one * 10));
33-
34-
// Add two meshes.
35-
model.ApplyCommand(new AddMeshCommand(Primitives.AxisAlignedBox(
36-
meshOne, Vector3.zero, Vector3.one, /* materialId */ 3)));
37-
model.ApplyCommand(new AddMeshCommand(Primitives.AxisAlignedBox(
38-
meshTwo, Vector3.one, Vector3.one, /* materialId */ 4)));
39-
40-
// Check the meshes are where we think they are.
41-
NUnit.Framework.Assert.Less(
42-
Vector3.Distance(model.GetMesh(meshOne).offset,
43-
new Vector3(0, 0, 0)), 0.001f);
44-
NUnit.Framework.Assert.Less(
45-
Vector3.Distance(model.GetMesh(meshTwo).offset,
46-
new Vector3(1, 1, 1)), 0.001f);
47-
48-
// Make and apply a CompositeCommand that moves both of them.
49-
MoveMeshCommand move1 = new MoveMeshCommand(
50-
meshOne, new Vector3(1, 0, 0), Quaternion.identity);
51-
MoveMeshCommand move2 = new MoveMeshCommand(
52-
meshTwo, new Vector3(0, 1, 0), Quaternion.identity);
53-
List<Command> commands = new List<Command>();
54-
commands.Add(move1);
55-
commands.Add(move2);
56-
57-
model.ApplyCommand(new CompositeCommand(commands));
58-
59-
// Check the meshes' new locations.
60-
NUnit.Framework.Assert.Less(
61-
Vector3.Distance(model.GetMesh(meshOne).offset,
62-
new Vector3(1, 0, 0)), 0.001f);
63-
NUnit.Framework.Assert.Less(
64-
Vector3.Distance(model.GetMesh(meshTwo).offset,
65-
new Vector3(1, 2, 1)), 0.001f);
66-
67-
// Undo and make sure they are back.
68-
model.Undo();
69-
NUnit.Framework.Assert.Less(
70-
Vector3.Distance(model.GetMesh(meshOne).offset,
71-
new Vector3(0, 0, 0)), 0.001f);
72-
NUnit.Framework.Assert.Less(
73-
Vector3.Distance(model.GetMesh(meshTwo).offset,
74-
new Vector3(1, 1, 1)), 0.001f);
21+
namespace com.google.apps.peltzer.client.model.core
22+
{
23+
24+
[TestFixture]
25+
// Tests for Command and implementations.
26+
public class CommandTest
27+
{
28+
29+
[Test]
30+
public void TestCompositeMove()
31+
{
32+
int meshOne = 1;
33+
int meshTwo = 2;
34+
35+
Model model = new Model(new Bounds(Vector3.zero, Vector3.one * 10));
36+
37+
// Add two meshes.
38+
model.ApplyCommand(new AddMeshCommand(Primitives.AxisAlignedBox(
39+
meshOne, Vector3.zero, Vector3.one, /* materialId */ 3)));
40+
model.ApplyCommand(new AddMeshCommand(Primitives.AxisAlignedBox(
41+
meshTwo, Vector3.one, Vector3.one, /* materialId */ 4)));
42+
43+
// Check the meshes are where we think they are.
44+
NUnit.Framework.Assert.Less(
45+
Vector3.Distance(model.GetMesh(meshOne).offset,
46+
new Vector3(0, 0, 0)), 0.001f);
47+
NUnit.Framework.Assert.Less(
48+
Vector3.Distance(model.GetMesh(meshTwo).offset,
49+
new Vector3(1, 1, 1)), 0.001f);
50+
51+
// Make and apply a CompositeCommand that moves both of them.
52+
MoveMeshCommand move1 = new MoveMeshCommand(
53+
meshOne, new Vector3(1, 0, 0), Quaternion.identity);
54+
MoveMeshCommand move2 = new MoveMeshCommand(
55+
meshTwo, new Vector3(0, 1, 0), Quaternion.identity);
56+
List<Command> commands = new List<Command>();
57+
commands.Add(move1);
58+
commands.Add(move2);
59+
60+
model.ApplyCommand(new CompositeCommand(commands));
61+
62+
// Check the meshes' new locations.
63+
NUnit.Framework.Assert.Less(
64+
Vector3.Distance(model.GetMesh(meshOne).offset,
65+
new Vector3(1, 0, 0)), 0.001f);
66+
NUnit.Framework.Assert.Less(
67+
Vector3.Distance(model.GetMesh(meshTwo).offset,
68+
new Vector3(1, 2, 1)), 0.001f);
69+
70+
// Undo and make sure they are back.
71+
model.Undo();
72+
NUnit.Framework.Assert.Less(
73+
Vector3.Distance(model.GetMesh(meshOne).offset,
74+
new Vector3(0, 0, 0)), 0.001f);
75+
NUnit.Framework.Assert.Less(
76+
Vector3.Distance(model.GetMesh(meshTwo).offset,
77+
new Vector3(1, 1, 1)), 0.001f);
78+
}
79+
80+
[Test]
81+
public void TestCompositeUndo()
82+
{
83+
int meshOne = 1;
84+
85+
Model model = new Model(new Bounds(Vector3.zero, Vector3.one * 10));
86+
87+
// Add a Mesh.
88+
model.ApplyCommand(new AddMeshCommand(Primitives.AxisAlignedBox(
89+
meshOne, Vector3.zero, Vector3.one, /* materialId */ 3)));
90+
91+
// Create a CompositeCommand that deletes and adds the same mesh.
92+
List<Command> commands = new List<Command>();
93+
commands.Add(new DeleteMeshCommand(meshOne));
94+
commands.Add(new AddMeshCommand(Primitives.AxisAlignedBox(
95+
meshOne, Vector3.zero, Vector3.one, /* materialId */ 3)));
96+
97+
CompositeCommand composite = new CompositeCommand(commands);
98+
99+
CompositeCommand undoCommand =
100+
(CompositeCommand)composite.GetUndoCommand(model);
101+
102+
List<Command> undoList = undoCommand.GetCommands();
103+
104+
// The order of commands should be the same, we invert the commands
105+
// *and* invert the order.
106+
NUnit.Framework.Assert.NotNull(undoList[1] as AddMeshCommand);
107+
NUnit.Framework.Assert.NotNull(undoList[0] as DeleteMeshCommand);
108+
}
109+
110+
[Test]
111+
public void TestRotation()
112+
{
113+
Model model = new Model(new Bounds(Vector3.zero, Vector3.one * 10));
114+
115+
MMesh mesh = Primitives.AxisAlignedBox(1, Vector3.zero, Vector3.one, /* materialId */ 2);
116+
model.AddMesh(mesh);
117+
118+
CheckBounds(model.GetMesh(1).bounds, new Bounds(Vector3.zero, Vector3.one * 2.0f));
119+
120+
MoveMeshCommand cmd = new MoveMeshCommand(1, Vector3.zero, Quaternion.AngleAxis(45, Vector3.up));
121+
model.ApplyCommand(cmd);
122+
// Bounds should have grown, since the box is no longer axis-aligned.
123+
float extends = 2.0f * Mathf.Sqrt(2);
124+
CheckBounds(model.GetMesh(1).bounds, new Bounds(Vector3.zero, new Vector3(extends, 2.0f, extends)));
125+
126+
model.Undo();
127+
// Make sure we are back:
128+
CheckBounds(model.GetMesh(1).bounds, new Bounds(Vector3.zero, Vector3.one * 2.0f));
129+
}
130+
131+
private void CheckBounds(Bounds left, Bounds right)
132+
{
133+
NUnit.Framework.Assert.Less(Vector3.Distance(left.center, right.center), 0.0001);
134+
NUnit.Framework.Assert.Less(Vector3.Distance(left.extents, right.extents), 0.0001);
135+
}
136+
137+
[Test]
138+
public void TestChangeFacePropertiesCommand()
139+
{
140+
Model model = new Model(new Bounds(Vector3.zero, Vector3.one * 10));
141+
142+
int baseMaterialId = 2;
143+
int newMaterial1 = 3;
144+
int newMaterial2 = 4;
145+
MMesh mesh = Primitives.AxisAlignedBox(1, Vector3.zero, Vector3.one, baseMaterialId);
146+
model.AddMesh(mesh);
147+
148+
Dictionary<int, FaceProperties> props = new Dictionary<int, FaceProperties>();
149+
props[1] = new FaceProperties(newMaterial1);
150+
props[2] = new FaceProperties(newMaterial2);
151+
152+
ChangeFacePropertiesCommand command = new ChangeFacePropertiesCommand(1, props);
153+
154+
// Apply the command, ensure the mesh was updated.
155+
model.ApplyCommand(command);
156+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(0).properties.materialId, baseMaterialId);
157+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(1).properties.materialId, newMaterial1);
158+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(2).properties.materialId, newMaterial2);
159+
160+
// Undo, faces should be back to normal.
161+
model.Undo();
162+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(0).properties.materialId, baseMaterialId);
163+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(1).properties.materialId, baseMaterialId);
164+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(2).properties.materialId, baseMaterialId);
165+
166+
// Redo, changes should be applied again.
167+
model.Redo();
168+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(0).properties.materialId, baseMaterialId);
169+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(1).properties.materialId, newMaterial1);
170+
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(2).properties.materialId, newMaterial2);
171+
}
75172
}
76-
77-
[Test]
78-
public void TestCompositeUndo() {
79-
int meshOne = 1;
80-
81-
Model model = new Model(new Bounds(Vector3.zero, Vector3.one * 10));
82-
83-
// Add a Mesh.
84-
model.ApplyCommand(new AddMeshCommand(Primitives.AxisAlignedBox(
85-
meshOne, Vector3.zero, Vector3.one, /* materialId */ 3)));
86-
87-
// Create a CompositeCommand that deletes and adds the same mesh.
88-
List<Command> commands = new List<Command>();
89-
commands.Add(new DeleteMeshCommand(meshOne));
90-
commands.Add(new AddMeshCommand(Primitives.AxisAlignedBox(
91-
meshOne, Vector3.zero, Vector3.one, /* materialId */ 3)));
92-
93-
CompositeCommand composite = new CompositeCommand(commands);
94-
95-
CompositeCommand undoCommand =
96-
(CompositeCommand) composite.GetUndoCommand(model);
97-
98-
List<Command> undoList = undoCommand.GetCommands();
99-
100-
// The order of commands should be the same, we invert the commands
101-
// *and* invert the order.
102-
NUnit.Framework.Assert.NotNull(undoList[1] as AddMeshCommand);
103-
NUnit.Framework.Assert.NotNull(undoList[0] as DeleteMeshCommand);
104-
}
105-
106-
[Test]
107-
public void TestRotation() {
108-
Model model = new Model(new Bounds(Vector3.zero, Vector3.one * 10));
109-
110-
MMesh mesh = Primitives.AxisAlignedBox(1, Vector3.zero, Vector3.one, /* materialId */ 2);
111-
model.AddMesh(mesh);
112-
113-
CheckBounds(model.GetMesh(1).bounds, new Bounds(Vector3.zero, Vector3.one * 2.0f));
114-
115-
MoveMeshCommand cmd = new MoveMeshCommand(1, Vector3.zero, Quaternion.AngleAxis(45, Vector3.up));
116-
model.ApplyCommand(cmd);
117-
// Bounds should have grown, since the box is no longer axis-aligned.
118-
float extends = 2.0f * Mathf.Sqrt(2);
119-
CheckBounds(model.GetMesh(1).bounds, new Bounds(Vector3.zero, new Vector3(extends, 2.0f, extends)));
120-
121-
model.Undo();
122-
// Make sure we are back:
123-
CheckBounds(model.GetMesh(1).bounds, new Bounds(Vector3.zero, Vector3.one * 2.0f));
124-
}
125-
126-
private void CheckBounds(Bounds left, Bounds right) {
127-
NUnit.Framework.Assert.Less(Vector3.Distance(left.center, right.center), 0.0001);
128-
NUnit.Framework.Assert.Less(Vector3.Distance(left.extents, right.extents), 0.0001);
129-
}
130-
131-
[Test]
132-
public void TestChangeFacePropertiesCommand() {
133-
Model model = new Model(new Bounds(Vector3.zero, Vector3.one * 10));
134-
135-
int baseMaterialId = 2;
136-
int newMaterial1 = 3;
137-
int newMaterial2 = 4;
138-
MMesh mesh = Primitives.AxisAlignedBox(1, Vector3.zero, Vector3.one, baseMaterialId);
139-
model.AddMesh(mesh);
140-
141-
Dictionary<int, FaceProperties> props = new Dictionary<int, FaceProperties>();
142-
props[1] = new FaceProperties(newMaterial1);
143-
props[2] = new FaceProperties(newMaterial2);
144-
145-
ChangeFacePropertiesCommand command = new ChangeFacePropertiesCommand(1, props);
146-
147-
// Apply the command, ensure the mesh was updated.
148-
model.ApplyCommand(command);
149-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(0).properties.materialId, baseMaterialId);
150-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(1).properties.materialId, newMaterial1);
151-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(2).properties.materialId, newMaterial2);
152-
153-
// Undo, faces should be back to normal.
154-
model.Undo();
155-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(0).properties.materialId, baseMaterialId);
156-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(1).properties.materialId, baseMaterialId);
157-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(2).properties.materialId, baseMaterialId);
158-
159-
// Redo, changes should be applied again.
160-
model.Redo();
161-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(0).properties.materialId, baseMaterialId);
162-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(1).properties.materialId, newMaterial1);
163-
NUnit.Framework.Assert.AreEqual(model.GetMesh(1).GetFace(2).properties.materialId, newMaterial2);
164-
}
165-
}
166173
}

0 commit comments

Comments
 (0)