Procházet zdrojové kódy

added some UITests

TiReischl před 5 roky
rodič
revize
0dac9ed43d

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 0
SketchAssistant/SketchAssistantWPF/DebugData.cs


+ 1 - 0
SketchAssistant/SketchAssistantWPF/MainWindow.xaml

@@ -35,6 +35,7 @@
                     <MenuItem x:Name="DebugMode" Header="Debug Input">
                         <MenuItem x:Name="DebugOne" Header="Debug 1" Click="DebugOne_Click"/>
                         <MenuItem x:Name="DebugTwo" Header="Debug 2" Click="DebugTwo_Click"/>
+                        <MenuItem x:Name="DebugThree" Header="Debug 3" Click="DebugThree_Click"/>
                     </MenuItem>
                 </MenuItem>
             </Menu>

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

@@ -204,6 +204,15 @@ namespace SketchAssistantWPF
             Debug(2);
         }
 
+        /// <summary>
+        /// Sends inputs to the presenter simulating drawing, used for testing and debugging.
+        /// Takes 7000ms
+        /// </summary>
+        private void DebugThree_Click(object sender, RoutedEventArgs e)
+        {
+            Debug(3);
+        }
+
         /// <summary>
         /// Ticks the Presenter.
         /// </summary>

+ 79 - 0
SketchAssistant/WhiteTests/UITest.cs

@@ -60,5 +60,84 @@ namespace WhiteTests
             Assert.AreEqual("Last Action: Line number 0 was drawn.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
             mainWindow.Close();
         }
+
+        /*[TestMethod]
+ public void DeleteLineTest()
+ {
+     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("DebugOne")).Click();
+     Thread.Sleep(7000);
+     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("DeleteButton")).Click();
+     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("DebugThree")).Click();
+     Thread.Sleep(24000);
+     Assert.AreEqual("Last Action: Line number 0 was deleted", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
+     mainWindow.Close();
+ }*/
+
+        [TestMethod]
+        public void UndoTest()
+        {
+            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("DebugOne")).Click();
+            Thread.Sleep(7000);
+            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());
+            mainWindow.Close();
+        }
+
+        [TestMethod]
+        public void RedoTest()
+        {
+            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("DebugOne")).Click();
+            Thread.Sleep(7000);
+            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<Button>(SearchCriteria.ByAutomationId("RedoButton")).Click();
+            Thread.Sleep(20);
+            Assert.AreEqual("Last Action: Line number 0 was drawn.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
+            mainWindow.Close();
+        }
     }
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů