|
@@ -17,10 +17,11 @@ using System.Text.RegularExpressions;
|
|
using WindowsInput;
|
|
using WindowsInput;
|
|
using WindowsInput.Native;
|
|
using WindowsInput.Native;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
|
+using System.Linq;
|
|
|
|
|
|
namespace WhiteTests
|
|
namespace WhiteTests
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
[TestClass]
|
|
[TestClass]
|
|
public class UITest
|
|
public class UITest
|
|
{
|
|
{
|
|
@@ -209,7 +210,7 @@ namespace WhiteTests
|
|
}
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
[TestMethod]
|
|
- public void DrawSeveralLines()
|
|
|
|
|
|
+ public void DrawSeveralLinesTest()
|
|
{
|
|
{
|
|
Window mainWindow = setupapp();
|
|
Window mainWindow = setupapp();
|
|
Thread.Sleep(20);
|
|
Thread.Sleep(20);
|
|
@@ -237,7 +238,7 @@ namespace WhiteTests
|
|
}
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
[TestMethod]
|
|
- public void DeleteSeveralLines()
|
|
|
|
|
|
+ public void DeleteSeveralLinesTest()
|
|
{
|
|
{
|
|
Window mainWindow = setupapp();
|
|
Window mainWindow = setupapp();
|
|
Thread.Sleep(20);
|
|
Thread.Sleep(20);
|
|
@@ -276,7 +277,7 @@ namespace WhiteTests
|
|
}
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
[TestMethod]
|
|
- public void UndoSeveralLines()
|
|
|
|
|
|
+ public void UndoSeveralLinesTest()
|
|
{
|
|
{
|
|
Window mainWindow = setupapp();
|
|
Window mainWindow = setupapp();
|
|
Thread.Sleep(20);
|
|
Thread.Sleep(20);
|
|
@@ -312,7 +313,7 @@ namespace WhiteTests
|
|
}
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
[TestMethod]
|
|
- public void RedoSeveralLines()
|
|
|
|
|
|
+ public void RedoSeveralLinesTest()
|
|
{
|
|
{
|
|
Window mainWindow = setupapp();
|
|
Window mainWindow = setupapp();
|
|
Thread.Sleep(20);
|
|
Thread.Sleep(20);
|
|
@@ -356,7 +357,7 @@ namespace WhiteTests
|
|
}
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
[TestMethod]
|
|
- public void UndoAndRedoTests()
|
|
|
|
|
|
+ public void UndoAndRedoTest()
|
|
{
|
|
{
|
|
Window mainWindow = setupapp();
|
|
Window mainWindow = setupapp();
|
|
Thread.Sleep(20);
|
|
Thread.Sleep(20);
|
|
@@ -414,7 +415,39 @@ namespace WhiteTests
|
|
}
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
[TestMethod]
|
|
- public void PointDraw()
|
|
|
|
|
|
+ public void UndoAndDrawTest()
|
|
|
|
+ {
|
|
|
|
+ Window mainWindow = setupapp();
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ Assert.AreEqual("none", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
|
|
|
|
+ mainWindow.Get<Button>(SearchCriteria.ByAutomationId("CanvasButton")).Click();
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
|
|
|
|
+ mainWindow.Get<Menu>(SearchCriteria.ByAutomationId("EditMenuButton")).Click();
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ mainWindow.Get<Menu>(SearchCriteria.ByAutomationId("DebugMode")).Click();
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ mainWindow.Get<Menu>(SearchCriteria.ByAutomationId("DebugFour")).Click();
|
|
|
|
+ Thread.Sleep(2000);
|
|
|
|
+ Assert.AreEqual("Last Action: Line number 0 was drawn.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ mainWindow.Get<Button>(SearchCriteria.ByAutomationId("UndoButton")).Click();
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ mainWindow.Get<Menu>(SearchCriteria.ByAutomationId("EditMenuButton")).Click();
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ mainWindow.Get<Menu>(SearchCriteria.ByAutomationId("DebugMode")).Click();
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ mainWindow.Get<Menu>(SearchCriteria.ByAutomationId("DebugFour")).Click();
|
|
|
|
+ Thread.Sleep(2000);
|
|
|
|
+ Assert.AreEqual("Last Action: Line number 1 was drawn.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
|
|
|
|
+ Thread.Sleep(20);
|
|
|
|
+ mainWindow.Close();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void PointDrawTest()
|
|
{
|
|
{
|
|
Window mainWindow = setupapp();
|
|
Window mainWindow = setupapp();
|
|
Thread.Sleep(20);
|
|
Thread.Sleep(20);
|
|
@@ -434,7 +467,7 @@ namespace WhiteTests
|
|
}
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
[TestMethod]
|
|
- public void NewCanvasAfterDraw()
|
|
|
|
|
|
+ public void NewCanvasAfterDrawTest()
|
|
{
|
|
{
|
|
Window mainWindow = setupapp();
|
|
Window mainWindow = setupapp();
|
|
Thread.Sleep(20);
|
|
Thread.Sleep(20);
|
|
@@ -479,7 +512,6 @@ namespace WhiteTests
|
|
}
|
|
}
|
|
|
|
|
|
[TestClass]
|
|
[TestClass]
|
|
- //[DeploymentItem(@"WhiteTests\test_input_files\")]
|
|
|
|
public class FileImporterTests
|
|
public class FileImporterTests
|
|
{
|
|
{
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -516,7 +548,7 @@ namespace WhiteTests
|
|
Regex rx = new Regex(@"^(.*\\SketchAssistant\\)");
|
|
Regex rx = new Regex(@"^(.*\\SketchAssistant\\)");
|
|
Match match = rx.Match(TestContext.DeploymentDirectory);
|
|
Match match = rx.Match(TestContext.DeploymentDirectory);
|
|
String SketchAssistDir = match.Groups[1].Value;
|
|
String SketchAssistDir = match.Groups[1].Value;
|
|
- if(input_file_dir == null)
|
|
|
|
|
|
+ if (input_file_dir == null)
|
|
{
|
|
{
|
|
if (Directory.Exists(SketchAssistDir + @"\WhiteTests\test_input_files\"))
|
|
if (Directory.Exists(SketchAssistDir + @"\WhiteTests\test_input_files\"))
|
|
{
|
|
{
|
|
@@ -586,7 +618,7 @@ namespace WhiteTests
|
|
/// <param name="file">the input file represented as an array of lines</param>
|
|
/// <param name="file">the input file represented as an array of lines</param>
|
|
[DataTestMethod]
|
|
[DataTestMethod]
|
|
[TestCategory("bla")]
|
|
[TestCategory("bla")]
|
|
- [DataRow(new String[] {})]
|
|
|
|
|
|
+ [DataRow(new String[] { })]
|
|
[DataRow(new String[] { "begindrawing", "300x300", "line", "50;50", "100;50", "endline", "enddrawing" })]
|
|
[DataRow(new String[] { "begindrawing", "300x300", "line", "50;50", "100;50", "endline", "enddrawing" })]
|
|
[DataRow(new String[] { "drawing", "300;300", "line", "50;50", "100;50", "endline", "enddrawing" })]
|
|
[DataRow(new String[] { "drawing", "300;300", "line", "50;50", "100;50", "endline", "enddrawing" })]
|
|
[DataRow(new String[] { "drawing", "30.5x300", "line", "50;50", "100;50", "endline", "enddrawing" })]
|
|
[DataRow(new String[] { "drawing", "30.5x300", "line", "50;50", "100;50", "endline", "enddrawing" })]
|
|
@@ -611,10 +643,11 @@ namespace WhiteTests
|
|
//try to initialize the left image with an invalid isad drawing
|
|
//try to initialize the left image with an invalid isad drawing
|
|
Tuple<int, int, List<InternalLine>> values1 = uut.ParseISADInputForTesting(file);
|
|
Tuple<int, int, List<InternalLine>> values1 = uut.ParseISADInputForTesting(file);
|
|
}
|
|
}
|
|
- catch (FileImporterException)
|
|
|
|
|
|
+ catch (FileImporterException e)
|
|
{
|
|
{
|
|
//save the occurence of an exception
|
|
//save the occurence of an exception
|
|
correctExceptionThrown = true;
|
|
correctExceptionThrown = true;
|
|
|
|
+ System.Diagnostics.Debug.WriteLine(e.ToString());
|
|
}
|
|
}
|
|
catch (Exception)
|
|
catch (Exception)
|
|
{
|
|
{
|
|
@@ -633,7 +666,7 @@ namespace WhiteTests
|
|
{
|
|
{
|
|
FileImporter uut = new FileImporter();
|
|
FileImporter uut = new FileImporter();
|
|
string[] files = Directory.GetFiles(getSketchAssistantDirectory() + @"\whitelisted", "*.svg", SearchOption.AllDirectories);
|
|
string[] files = Directory.GetFiles(getSketchAssistantDirectory() + @"\whitelisted", "*.svg", SearchOption.AllDirectories);
|
|
-
|
|
|
|
|
|
+
|
|
Assert.IsTrue(files.Length > 0);
|
|
Assert.IsTrue(files.Length > 0);
|
|
|
|
|
|
foreach (string s in files) //parse each of the whitelisted files
|
|
foreach (string s in files) //parse each of the whitelisted files
|
|
@@ -670,8 +703,9 @@ namespace WhiteTests
|
|
{
|
|
{
|
|
uut.ParseSVGInputFile(s, 10000, 10000);
|
|
uut.ParseSVGInputFile(s, 10000, 10000);
|
|
}
|
|
}
|
|
- catch (FileImporterException)
|
|
|
|
|
|
+ catch (FileImporterException e)
|
|
{
|
|
{
|
|
|
|
+ System.Diagnostics.Debug.WriteLine(e.ToString());
|
|
correctExceptionThrown = true;
|
|
correctExceptionThrown = true;
|
|
}
|
|
}
|
|
catch (Exception)
|
|
catch (Exception)
|
|
@@ -689,7 +723,7 @@ namespace WhiteTests
|
|
/// The debug data element used to generate random lines.
|
|
/// The debug data element used to generate random lines.
|
|
/// </summary>
|
|
/// </summary>
|
|
private DebugData DebugData = new DebugData();
|
|
private DebugData DebugData = new DebugData();
|
|
-
|
|
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Generates random lines and tests how similar they are.
|
|
/// Generates random lines and tests how similar they are.
|
|
/// To test the similarity score always stays between 0 and 1.
|
|
/// To test the similarity score always stays between 0 and 1.
|
|
@@ -697,15 +731,15 @@ namespace WhiteTests
|
|
[TestMethod]
|
|
[TestMethod]
|
|
public void StaysWithinParameters()
|
|
public void StaysWithinParameters()
|
|
{
|
|
{
|
|
- Parallel.For(1,100,
|
|
|
|
|
|
+ Parallel.For(1, 100,
|
|
i =>
|
|
i =>
|
|
{
|
|
{
|
|
- InternalLine l0 = DebugData.GetRandomLine(1, (uint) i);
|
|
|
|
|
|
+ InternalLine l0 = DebugData.GetRandomLine(1, (uint)i);
|
|
InternalLine l1 = DebugData.GetRandomLine(1, (uint)i);
|
|
InternalLine l1 = DebugData.GetRandomLine(1, (uint)i);
|
|
var sim = GeometryCalculator.CalculateSimilarity(l0, l1);
|
|
var sim = GeometryCalculator.CalculateSimilarity(l0, l1);
|
|
Assert.IsTrue((sim >= 0));
|
|
Assert.IsTrue((sim >= 0));
|
|
Assert.IsTrue((sim <= 1));
|
|
Assert.IsTrue((sim <= 1));
|
|
- } );
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
[TestMethod]
|
|
[TestMethod]
|
|
@@ -720,6 +754,62 @@ namespace WhiteTests
|
|
Assert.AreEqual(tup.Item3, sim, 0.00000001);
|
|
Assert.AreEqual(tup.Item3, sim, 0.00000001);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [TestClass]
|
|
|
|
+ public class InternalLineUnitTests
|
|
|
|
+ {
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// The debug data element used to generate random lines.
|
|
|
|
+ /// </summary>
|
|
|
|
+ private DebugData DebugData = new DebugData();
|
|
|
|
+
|
|
|
|
+ [TestMethod]
|
|
|
|
+ public void MakePermanentTest()
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ List<Point> points = new List<Point>();
|
|
|
|
+ points.AddRange(DebugData.debugPoints4);
|
|
|
|
+ InternalLine uut = new InternalLine(points);
|
|
|
|
+ Assert.AreEqual(false, uut.isPoint);
|
|
|
|
+ uut.MakePermanent(5);
|
|
|
|
+ Assert.AreEqual(true, uut.isPoint);
|
|
|
|
+ Assert.AreEqual(5, uut.GetID());
|
|
|
|
+ Assert.AreEqual(0, uut.GetLength());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [DataTestMethod]
|
|
|
|
+ [DataRow(new int[] { 1 ,1, 3, 3 }, new int[] { 1, 1, 2, 2, 3, 3 }, false, 2.828427125)]
|
|
|
|
+ [DataRow(new int[] { 1, 1, 3, 3 }, new int[] { 1, 1, 2, 2, 3, 3 }, true, 2.828427125)]
|
|
|
|
+ [DataRow(new int[] { 1, 1, 1, 4 ,3, 4 }, new int[] { 1, 1, 1, 2, 1, 3, 1, 4, 2, 4, 3, 4 }, false, 5)]
|
|
|
|
+ [DataRow(new int[] { 1, 1, 1, 4, 3, 4 }, new int[] { 1, 1, 1, 2, 1, 3, 1, 4, 2, 4, 3, 4 }, true, 5)]
|
|
|
|
+ public void PermanentLineTest(int[] inPoints, int[] outPoints, bool isTemp, double len)
|
|
|
|
+ {
|
|
|
|
+ List<Point> inLine = new List<Point>(); List<Point> outLine = new List<Point>();
|
|
|
|
+ for (int i = 0; i < inPoints.Length;i += 2) inLine.Add(new Point(inPoints[i], inPoints[i + 1]));
|
|
|
|
+ for (int i = 0; i < outPoints.Length; i += 2) outLine.Add(new Point(outPoints[i], outPoints[i + 1]));
|
|
|
|
+ InternalLine uut;
|
|
|
|
+ if (isTemp)
|
|
|
|
+ {
|
|
|
|
+ uut = new InternalLine(inLine);
|
|
|
|
+ var zip = inLine.Zip(uut.GetPoints(), (a,b) => new Tuple<Point, Point>(a, b));
|
|
|
|
+ foreach (Tuple < Point, Point> tup in zip)
|
|
|
|
+ {
|
|
|
|
+ Assert.AreEqual(tup.Item1, tup.Item2);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ uut = new InternalLine(inLine,0);
|
|
|
|
+ var zip = outLine.Zip(uut.GetPoints(), (a, b) => new Tuple<Point, Point>(a, b));
|
|
|
|
+ foreach (Tuple<Point, Point> tup in zip)
|
|
|
|
+ {
|
|
|
|
+ Assert.AreEqual(tup.Item1, tup.Item2);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Assert.AreEqual(len, uut.GetLength(), 0.000001);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|