Bladeren bron

Added check for com5

Martin Edlund 5 jaren geleden
bovenliggende
commit
d5158d679d
3 gewijzigde bestanden met toevoegingen van 28 en 9 verwijderingen
  1. 3 3
      .appveyor.yml
  2. 17 4
      SketchAssistant/SketchAssistantWPF/MVP_Model.cs
  3. 8 2
      SketchAssistant/WhiteTests/UITest.cs

+ 3 - 3
.appveyor.yml

@@ -21,6 +21,6 @@ before_test:
     - ps: "SketchAssistant/GenerateCoverageReport.bat"
 #test:
 #don't run tests depending on [DeploymentItem] and filesystem access
-#categories:
-#    except:
-#        - FileIO
+categories:
+    except:
+        - Local

+ 17 - 4
SketchAssistant/SketchAssistantWPF/MVP_Model.cs

@@ -10,6 +10,7 @@ using System.Windows.Media.Imaging;
 using OptiTrack;
 using System.Runtime.InteropServices;
 using System.IO;
+using System.IO.Ports;
 
 namespace SketchAssistantWPF
 {
@@ -171,13 +172,24 @@ namespace SketchAssistantWPF
         /// The line currently being drawin with optitrack.
         /// </summary>
         List<Point> currentLine = new List<Point>();
+        /// <summary>
+        /// If the COM5 port is available.
+        /// </summary>
+        bool comFiveAvailable = false;
 
         public MVP_Model(MVP_Presenter presenter)
         {
             //TODO remove
-            Console.WriteLine("trying to initialize Armband...");
-            int tmp= LocalArmbandInterface.SetupArmband();
-            Console.WriteLine("Armband initialization terminated, exit code: " + tmp);
+            var portName = "COM5";
+
+            var isValid = SerialPort.GetPortNames().Any(x => string.Compare(x, portName, true) == 0);
+            if (isValid)
+            {
+                Console.WriteLine("trying to initialize Armband...");
+                int tmp = LocalArmbandInterface.SetupArmband();
+                Console.WriteLine("Armband initialization terminated, exit code: " + tmp);
+            }
+
             programPresenter = presenter;
             historyOfActions = new ActionHistory();
             rightLineList = new List<Tuple<bool, InternalLine>>();
@@ -258,7 +270,8 @@ namespace SketchAssistantWPF
             if(PathTraveled > 15)
             {
                 PathTraveled = 0;
-                LocalArmbandInterface.Actuate(0, TACTILE_SURFACE_FEEDBACK_INTENSITY, TACTILE_SURFACE_FEEDBACK_DURATION);
+                if(comFiveAvailable)
+                    LocalArmbandInterface.Actuate(0, TACTILE_SURFACE_FEEDBACK_INTENSITY, TACTILE_SURFACE_FEEDBACK_DURATION);
             }
         }
 

+ 8 - 2
SketchAssistant/WhiteTests/UITest.cs

@@ -114,8 +114,14 @@ namespace WhiteTests
         }
 
         [DataTestMethod]
-        [TestCategory("FileIO")]
+        [TestCategory("Local")]
         [DataRow("line")]
+        [DataRow("all")]
+        [DataRow("circle_ellipse")]
+        [DataRow("path")]
+        [DataRow("polygon")]
+        [DataRow("polyline")]
+        [DataRow("rect")]
         public void LoadSVGFileTest(String filename)
         {
             Window mainWindow = setupapp();
@@ -131,7 +137,7 @@ namespace WhiteTests
             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());
+            Assert.AreEqual("Last Action: A new canvas was created.", mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId("LastActionBox")).Text.ToString());
             mainWindow.Close();
         }