aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs')
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs104
1 files changed, 99 insertions, 5 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs
index 7df8d59f9..827a41d80 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs
+++ b/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs
@@ -5,14 +5,25 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Tango.MachineStudio.Common.Automation;
using TestStack.White;
using TestStack.White.Factory;
using TestStack.White.UIItems;
using TestStack.White.UIItems.Finders;
+using TestStack.White.UIItems.ListBoxItems;
using TestStack.White.UIItems.WindowItems;
+using TestStack.White.WindowsAPI;
namespace Tango.UnitTesting
{
+ public static class AutomationExtensions
+ {
+ public static T GetByAutomationId<T>(this Window window, String id) where T : IUIItem
+ {
+ return window.Get<T>(SearchCriteria.ByAutomationId(id));
+ }
+ }
+
[TestClass]
[TestCategory("Machine Studio")]
public class MachineStudio_TST
@@ -24,14 +35,43 @@ namespace Tango.UnitTesting
return window;
}
+ private Window GetCurrentDialogWindow()
+ {
+ var app = Application.AttachOrLaunch(new System.Diagnostics.ProcessStartInfo() { FileName = Helper.GetMachineStudioPath() });
+ return app.GetWindows().LastOrDefault(x => x.IsModal);
+ }
+
+ private void Kill(int delay = 4000)
+ {
+ Thread.Sleep(delay);
+ var app = Application.AttachOrLaunch(new System.Diagnostics.ProcessStartInfo() { FileName = Helper.GetMachineStudioPath() });
+ app.Kill();
+ }
+
+ private void Wait(int delay = 1000)
+ {
+ Thread.Sleep(delay);
+ }
+
+ private void ConfirmMessageBox()
+ {
+ Wait();
+ var dialog = GetCurrentDialogWindow();
+
+ if (dialog != null)
+ {
+ dialog.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN);
+ }
+ }
+
[TestMethod]
public void Login()
{
var window = GetMachineStudioWindow();
- window.WaitTill(() => window.Get<Button>(SearchCriteria.ByText("LOGIN")) != null);
+ window.WaitTill(() => window.GetByAutomationId<Button>(UI.LoginButton) != null);
- var btnLogin = window.Get<Button>(SearchCriteria.ByText("LOGIN"));
+ var btnLogin = window.GetByAutomationId<Button>(UI.LoginButton);
Thread.Sleep(1000);
@@ -39,15 +79,69 @@ namespace Tango.UnitTesting
}
[TestMethod]
- public void Start_Developer_Module()
+ public void Start_Developer_Module_Create_And_Delete_Job()
{
+ Login();
+
var window = GetMachineStudioWindow();
window.WaitTill(() => window.Get<Button>(SearchCriteria.ByAutomationId("Developer")) != null);
- var btnDeveloper = window.Get<Button>(SearchCriteria.ByAutomationId("Developer"));
+ Wait(2000);
+
+ window.Get<Button>(SearchCriteria.ByAutomationId("Developer")).Click();
+
+ Wait();
+
+ window.GetByAutomationId<Button>(Developer.NewJobButton).Click();
+
+ Wait();
+
+ var jobsGrid = window.GetByAutomationId<ListView>(Developer.JobsDataGrid);
+ int jobsCount = jobsGrid.Items.Count;
+
+ var dialog = GetCurrentDialogWindow();
+
+ dialog.Keyboard.Enter("Unit Test Job");
+
+ Wait();
+
+ dialog.Keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN);
+
+ Assert.AreEqual(jobsCount, jobsGrid.Items.Count - 1);
+
+ Wait();
+
+ var segmentsListBox = window.GetByAutomationId<ListBox>(Developer.SegmentsListBox);
+ int segmentsCount = segmentsListBox.Items.Count;
+
+ window.GetByAutomationId<Button>(Developer.AddSegmentButton).Click();
+
+ Assert.AreEqual(segmentsCount, segmentsListBox.Items.Count - 1);
+
+ window.GetByAutomationId<ListBox>(Developer.SegmentsListBox).Items[1].Click();
+
+ window.GetByAutomationId<Button>(Developer.AddBrushStopButton).Click();
+
+ window.GetByAutomationId<Button>(Developer.AddBrushStopButton).Click();
+
+ window.GetByAutomationId<Button>(Developer.SaveJobButton).Click();
+
+ Wait(2000);
+
+ window.GetByAutomationId<Button>(Developer.ToJobsButton).Click();
+
+ ConfirmMessageBox();
+
+ Wait();
+
+ window.GetByAutomationId<Button>(Developer.DeleteJobButton).Click();
+
+ ConfirmMessageBox();
+
+ Assert.AreEqual(jobsCount, jobsGrid.Items.Count);
- btnDeveloper.Click();
+ Kill();
}
}
}