Browse Source

New IO Test (╯°□°)╯︵ ┻━┻

Martin Edlund 5 years ago
parent
commit
4f3a515444

+ 0 - 49
SketchAssistant/SketchAssistantWPF/MVP_Presenter.cs

@@ -45,7 +45,6 @@ namespace SketchAssistantWPF
 
         public enum MouseAction
         {
-            Click,
             Down,
             Up,
             Up_Invalid,
@@ -87,49 +86,6 @@ namespace SketchAssistantWPF
             programModel.ResizeEvent(CanvasSizeLeft, CanvasSizeRight);
         }
 
-        /// <summary>
-        /// Display a new FileDialog to load a collection of lines.
-        /// </summary>
-        /// <returns>True if loading was a success</returns>
-        public bool ExamplePictureToolStripMenuItemClick()
-        {
-            var okToContinue = true; bool returnval = false;
-            if (programModel.HasUnsavedProgress())
-            {
-                okToContinue = programView.ShowWarning("You have unsaved progress. Continue?");
-            }
-            if (okToContinue)
-            {
-                var fileNameTup = programView.openNewDialog("Interactive Sketch-Assistant Drawing|*.isad");
-                if (!fileNameTup.Item1.Equals("") && !fileNameTup.Item2.Equals(""))
-                {
-                    programView.SetToolStripLoadStatus(fileNameTup.Item2);
-                    try
-                    {
-                        Tuple<int, int, List<InternalLine>> values = fileImporter.ParseISADInputFile(fileNameTup.Item1);
-                        values.Item3.ForEach(line => line.MakePermanent(0)); //Make all lines permanent
-                        programModel.SetLeftLineList(values.Item1, values.Item2, values.Item3);
-
-                        programModel.ResetRightImage();
-                        programModel.CanvasActivated();
-                        programModel.ChangeState(true);
-                        programView.EnableTimer();
-                        ClearRightLines();
-                        returnval = true;
-                    }
-                    catch (FileImporterException ex)
-                    {
-                        programView.ShowInfoMessage(ex.ToString());
-                    }
-                    catch (Exception ex)
-                    {
-                        programView.ShowInfoMessage("exception occured while trying to load interactive sketch-assistant drawing file:\n\n" + ex.ToString() + "\n\n" + ex.StackTrace);
-                    }
-                }
-            }
-            return returnval;
-        }
-
         /// <summary>
         /// Display a new FileDialog to a svg drawing.
         /// </summary>
@@ -253,11 +209,6 @@ namespace SketchAssistantWPF
 
             switch (mouseAction)
             {
-                case MouseAction.Click:
-                    programModel.MouseDown();
-                    programModel.Tick();
-                    programModel.MouseUp(true);
-                    break;
                 case MouseAction.Down:
                     programModel.MouseDown();
                     break;

+ 0 - 1
SketchAssistant/SketchAssistantWPF/MainWindow.xaml

@@ -22,7 +22,6 @@
         <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Background="LightGray">
             <Menu Background="LightGray"   VerticalAlignment="Center" Padding="5,0,0,0">
                 <MenuItem x:Name="LoadMenuButton" Header="Load">
-                    <MenuItem x:Name="ISADMenuButton" Header="Load .isad Drawing" Click="ISADMenuItem_Click"/>
                     <MenuItem x:Name="SVGMenuButton" Header="Import SVG File" Click="SVGMenuItem_Click"/>
                 </MenuItem>
                 <MenuItem x:Name="EditMenuButton" Header="Edit">

+ 0 - 9
SketchAssistant/SketchAssistantWPF/MainWindow.xaml.cs

@@ -227,15 +227,6 @@ namespace SketchAssistantWPF
             ProgramPresenter.Tick();
         }
 
-        /// <summary>
-        /// Import button for .isad drawing, will open an OpenFileDialog
-        /// </summary>
-        private void ISADMenuItem_Click(object sender, RoutedEventArgs e)
-        {
-            if(ProgramPresenter.ExamplePictureToolStripMenuItemClick())
-                RightCanvas.EditingMode = InkCanvasEditingMode.Ink;
-        }
-
         /// <summary>
         /// Import button for .svg file, will open an OpenFileDialog
         /// </summary>

+ 58 - 111
SketchAssistant/WhiteTests/UITest.cs

@@ -95,6 +95,28 @@ namespace WhiteTests
             return application.GetWindow("Sketch Assistant");
         }
 
+        [DataTestMethod]
+        [TestCategory("FileIO")]
+        [DataRow("line")]
+        public void LoadSVGFileTestAsync(String filename)
+        {
+            Window mainWindow = setupapp();
+            InputSimulator inputSimulator = new InputSimulator();
+            Thread.Sleep(20);
+            string[] files = Directory.GetFiles(getSketchAssistantDirectory() + @"\whitelisted", "*.svg", SearchOption.AllDirectories);
+            Thread.Sleep(20);
+            mainWindow.Get<Menu>(SearchCriteria.ByAutomationId("LoadMenuButton")).Click();
+            Thread.Sleep(20);
+            mainWindow.Get<Menu>(SearchCriteria.ByAutomationId("SVGMenuButton")).Click();
+            Thread.Sleep(1000);
+            inputSimulator.Keyboard.TextEntry(getSketchAssistantDirectory() + @"whitelisted\" + filename + ".svg");
+            Thread.Sleep(1000);
+            inputSimulator.Keyboard.KeyPress(VirtualKeyCode.RETURN);
+            Thread.Sleep(1000);
+            Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
+            mainWindow.Close();
+        }
+        /*
         [TestMethod]
         [TestCategory("DirectInput")]
         public void DrawLineOnCanvasTest()
@@ -121,7 +143,7 @@ namespace WhiteTests
 
         [TestMethod]
         [TestCategory("DirectInput")]
-        public void DeleteLineOnCanvasTest()
+        public void UndoLineOnCanvasTest()
         {
             Window mainWindow = setupapp();
             Thread.Sleep(20);
@@ -147,6 +169,40 @@ namespace WhiteTests
             mainWindow.Close();
         }
 
+        [TestMethod]
+        [TestCategory("DirectInput")]
+        public void InvalidLineTest()
+        {
+            Window mainWindow = setupapp();
+            Thread.Sleep(20);
+            InputSimulator inputSimulator = new InputSimulator();
+            MouseSimulator mouseSimulator = new MouseSimulator(inputSimulator);
+            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());
+            Thread.Sleep(20);
+            mainWindow.Get<Button>(SearchCriteria.ByAutomationId("DrawButton")).Click();
+            Thread.Sleep(20);
+            inputSimulator.Mouse.LeftButtonDown();
+            inputSimulator.Mouse.MoveMouseBy(0, 200);
+            Thread.Sleep(20);
+            inputSimulator.Mouse.MoveMouseBy(500, 300);
+            Thread.Sleep(20);
+            inputSimulator.Mouse.LeftButtonUp();
+            Thread.Sleep(20);
+            Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
+            Thread.Sleep(20);
+            inputSimulator.Mouse.MoveMouseBy(-1000, 0);
+            Thread.Sleep(20);
+            inputSimulator.Mouse.LeftButtonDown();
+            inputSimulator.Mouse.MoveMouseBy(1000, 0);
+            inputSimulator.Mouse.LeftButtonUp();
+            Thread.Sleep(20);
+            Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
+            mainWindow.Close();
+        }
+
         [TestMethod]
         [TestCategory("DirectInput")]
         public void PointsOnCanvasSimilarityTest()
@@ -951,115 +1007,6 @@ namespace WhiteTests
                 }
             }
             Assert.AreEqual(len, uut.GetLength(), 0.000001);
-        }
-    }
-
-    [TestClass]
-    public class FileIOIntegrationTests
-    {
-        public class DummyView : MVP_View
-        {
-
-
-            public DummyView()
-            {
-
-            }
-
-            void MVP_View.AddNewLineLeft(System.Windows.Shapes.Polyline newLine)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.AddNewLineRight(System.Windows.Shapes.Polyline newLine)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.AddNewPointLeft(System.Windows.Shapes.Ellipse newPoint)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.AddNewPointRight(System.Windows.Shapes.Ellipse newPoint, InternalLine line)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.DisplayCurrLine(System.Windows.Shapes.Polyline line)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.EnableTimer()
-            {
-                throw new NotImplementedException();
-            }
-
-            Point MVP_View.GetCursorPosition()
-            {
-                throw new NotImplementedException();
-            }
-
-            bool MVP_View.IsMousePressed()
-            {
-                throw new NotImplementedException();
-            }
-
-            Tuple<string, string> MVP_View.openNewDialog(string Filter)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.RemoveAllLeftLines()
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.RemoveAllRightLines()
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.RemoveCurrLine()
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.SetCanvasState(string canvasName, bool active)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.SetImageSimilarityText(string message)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.SetLastActionTakenText(string message)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.SetToolStripButtonStatus(string buttonName, MainWindow.ButtonState state)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.SetToolStripLoadStatus(string message)
-            {
-                throw new NotImplementedException();
-            }
-
-            void MVP_View.ShowInfoMessage(string message)
-            {
-                throw new NotImplementedException();
-            }
-
-            bool MVP_View.ShowWarning(string message)
-            {
-                throw new NotImplementedException();
-            }
-        }
+        }*/
     }
 }