Advertisement
JevgeniD

ApplicationManager

Jun 8th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using NUnit.Framework;
  7. using TestStack.White;
  8. using TestStack.White.UIItems;
  9. using System.Threading;
  10. using TestStack.White.UIItems.WindowItems;
  11. using TestStack.White.UIItems.Finders;
  12.  
  13. namespace indicorecorder_tests_whitefromzero
  14. {
  15.     public class ApplicationManager
  16.     {
  17.         protected LoginHelper loginHelper;
  18.         protected BriefReportHelper briefreportHelper;
  19.         protected RecordingHelper recodingHelper;
  20.         protected PreferencesHelper preferencesHelper;
  21.         protected Application IndicoRecorderApplication = null;
  22.         protected Application IndicoLauncherApplication = null;
  23.  
  24.         public static string IndicoLauncherTitle = "Indico Launcher";
  25.         public static string IndicoRecorderTitle = "Indico Recorder";
  26.  
  27.         public ApplicationManager()
  28.         {
  29.             Application app = Application.Launch(@"C:\Program Files (x86)\Indico Systems\Indico Recorder\Indico Launcher.exe");
  30.             LauncherWindow = app.GetWindow(IndicoLauncherTitle);
  31.             loginHelper = new LoginHelper(this);
  32.             briefreportHelper = new BriefReportHelper(this);
  33.             recodingHelper = new RecordingHelper(this);
  34. //            RecorderWindow = IndicoRecorderWindow();
  35.         }
  36.  
  37.         public void Stop()
  38.         {
  39.             if (IsLoggingIn())
  40.             {
  41.                 RecorderWindow.Get<Button>("btnCancel").Click();
  42.                 RecorderWindow.Get<Button>("Close").Click();
  43.                 RecorderWindow.Get<Button>("btnOK").Click();
  44.             }
  45.             if (LauncherWindow.IsCurrentlyActive)
  46.             {
  47.                 LauncherWindow.Get<Button>("Close").Click();
  48.             }
  49.         }
  50.  
  51.         // Запускаю Launcher и открываю через него Indico Recorder
  52.         public Application OpenIndicoRecorder()
  53.         {
  54.             if (IndicoRecorderApplication == null)
  55.             {
  56.                 LauncherWindow.Get<Image>(SearchCriteria.ByAutomationId("img").AndIndex(0)).Click();
  57.                 Application Recorder = Application.Attach("Indico Recorder");
  58.                 return Recorder;
  59.             }
  60.                 return IndicoRecorderApplication;
  61.         }
  62.  
  63.         public Window IndicoRecorderWindow()
  64.         {
  65.             if (IndicoRecorderApplication == null)
  66.             {
  67.                 IndicoRecorderApplication = OpenIndicoRecorder();
  68.             }
  69.             IndicoRecorderApplication = OpenIndicoRecorder();
  70.             Window IndicoRecorder = IndicoRecorderApplication.GetWindow(IndicoRecorderTitle);
  71.             return IndicoRecorder;
  72.         }
  73.  
  74.         public bool IsLoggingIn()
  75.         {
  76.             return RecorderWindow.Exists<Button>("btnCancel");
  77.         }
  78.  
  79.         public Window LauncherWindow { get; set; }
  80.         public Window RecorderWindow { get; set; }
  81.         public Window PreferencesWindow { get; set; }
  82.  
  83.         public LoginHelper Auth
  84.         {
  85.             get
  86.             {
  87.                 return loginHelper;
  88.             }
  89.         }
  90.  
  91.         public BriefReportHelper BriefReport
  92.         {
  93.             get
  94.             {
  95.                 return briefreportHelper;
  96.             }
  97.         }
  98.  
  99.         public RecordingHelper Recording
  100.         {
  101.             get
  102.             {
  103.                 return recodingHelper;
  104.             }
  105.         }
  106.  
  107.         public PreferencesHelper Preferences
  108.         {
  109.             get
  110.             {
  111.                 return preferencesHelper;
  112.             }
  113.         }
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement