public override void TickTest()
        {
            base.TickTest();

            // Handle device screenshot update
            TimeSpan      Delta  = DateTime.Now - ScreenshotTime;
            ITargetDevice Device = TestInstance.ClientApps[0].Device;

            string ImageFilename;

            if (!String.IsNullOrEmpty(ScreenshotDirectory) && Delta >= ScreenshotInterval && Device != null && PGOPlatform.TakeScreenshot(Device, ScreenshotDirectory, out ImageFilename))
            {
                ScreenshotTime = DateTime.Now;

                try
                {
                    TimeSpan ImageTimestamp  = DateTime.UtcNow - ScreenshotStartTime;
                    string   ImageOutputPath = Path.Combine(ScreenshotDirectory, ImageTimestamp.ToString().Replace(':', '-') + ".jpg");
                    ImageUtils.ResaveImageAsJpgWithScaleAndQuality(Path.Combine(ScreenshotDirectory, ImageFilename), ImageOutputPath, ScreenshotScale, ScreenshotQuality);
                }
                catch
                {
                    // Just ignore errors.
                }
                finally
                {
                    // Delete the temporary image file
                    try { File.Delete(Path.Combine(ScreenshotDirectory, ImageFilename)); }
                    catch { }
                }
            }
        }
Exemple #2
0
        protected void CleanDevice(ITargetDevice Device)
        {
            Gauntlet.Log.Info("Cleaning {0}", Device.Name);

            if (Device.IsOn == false)
            {
                Device.PowerOn();
            }

            if (Device.IsAvailable == false)
            {
                Gauntlet.Log.Info("{0} is not available, skipping", Device.Name);
                return;
            }

            Device.Connect();

            if (Device.IsConnected == false)
            {
                Gauntlet.Log.Warning("Failed to connect to {0}", Device.Name);
                return;
            }

            /*if (Device is TargetDevicePS4)
             * {
             *      CleanPS4(Device as TargetDevicePS4);
             * }*/

            // disconnect and power down
            Gauntlet.Log.Info("Powering down and disconnecting from {0}", Device.Name);
            Device.Disconnect();
            // turns out this may be a bad idea.. sorry environment.
            //Device.PowerOff();
        }
Exemple #3
0
 public void OnFileDeployed(ITargetDevice Device, string SourceFile)
 {
     if (WinForm != null && DeviceView != null)
     {
         ThreadHelperClass.UpdateDeviceDeploymentProgress(WinForm, DeviceView, Device);
     }
 }
        public static string GetLogFile(ITargetDevice DeviceConfig)
        {
            string LogPath = GetLogFilePath();

            string LogFileName = GetLogFileName(DeviceConfig);

            return(Path.Combine(LogPath, LogFileName));
        }
 void ILayoutManager.Initialize(IReportItem forReportItem, ITargetDevice targetDevice)
 {
     _calendar = forReportItem as CalendarDataRegion;
     if (_calendar == null)
     {
         throw new ArgumentException("The argument has wrong type.", "forReportItem");
     }
 }
        private static ITargetDevice buildVorzeDevice(BluetoothLEDevice device)
        {
            string vorzeServiceUuidStr          = "40ee1111-63ec-4b7f-8ce7-712efd55b90e";
            string vorzeCharactersticUuidStr    = "40ee2222-63ec-4b7f-8ce7-712efd55b90e";
            string charactersticDescriptionName = "nls_command";

            IDictionary <string, Type> deviceMap = new Dictionary <string, Type>()
            {
                { "VorzePiston", typeof(VorzeA10Piston) },
                { "CycSA", typeof(VorzeA10Cyclone) },
                { "UFOSA", typeof(VorzeUFOSA) },
            };


            ITargetDevice concreateDevice = null;


            if (device == null)
            {
                return(null);
            }



            GattDeviceServicesResult services = device.GetGattServicesForUuidAsync(new Guid(vorzeServiceUuidStr)).GetResults();

            var service = services != null && services.Services.Count > 0 ? services.Services[0] : null;

            if (service == null)
            {
                return(null);
            }

            Logger.log($"DeviceName: {service.Device.Name}");

            var characteristics = service.GetCharacteristicsForUuidAsync(new Guid(vorzeCharactersticUuidStr)).GetResults();

            if (characteristics == null || characteristics.Characteristics.Count < 1)
            {
                return(null);
            }

            var characterstic = characteristics.Characteristics[0];

            if (characterstic != null)
            {
                foreach (var key in deviceMap.Keys)
                {
                    if (service.Device.Name.Contains(key))
                    {
                        concreateDevice = Activator.CreateInstance(deviceMap[key]) as ITargetDevice;
                        concreateDevice.init(characterstic);
                        break;
                    }
                }
            }
            return(concreateDevice);
        }
        public void Initialize(IReportItem forReportItem, ITargetDevice targetDevice)
        {
            _item         = forReportItem;
            _control      = _item as RtfControl;
            _computedSize = new SizeF(_item.Width.ToTwips(), _item.Height.ToTwips());

            ProcessGrow();
            ProcessShrink();
        }
 public TextInputPopupViewModel(ITargetDevice targetDevice)
 {
     if (targetDevice == null)
     {
         throw new ArgumentNullException("targetDevice");
     }
     this.targetDevice    = targetDevice;
     this.EndInputCommand = new AsyncCommand((object arg) => this.targetDevice.EndInputAsync());
 }
Exemple #9
0
        public UnrealTargetConstraint GetConstraint(ITargetDevice Device)
        {
            if (!Constraints.ContainsKey(Device))
            {
                throw new AutomationException("Device pool has no contstaint for {0} (device was likely released)", Device);
            }

            return(Constraints[Device]);
        }
        private static ILayoutTree GenerateLayoutTree(IReport report,
                                                      ITargetDevice targetDevice,
                                                      ITextMetricsProvider metricsProvider)
        {
            var layoutInfo = new LayoutInfo(report, targetDevice, metricsProvider);
            var engine     = GetLayoutEngine(report);

            return(engine.BuildLayout(layoutInfo));
        }
Exemple #11
0
            private static ILayoutTree GetLayoutTree(IReport report, ITargetDevice targetDevice, LayoutNotificationCallback callback)
            {
                LayoutInfo           layoutInfo = new LayoutInfo(report, targetDevice, new TextMetricsProvider(), callback);
                ILayoutEngineFactory factory    = report.GetService(typeof(ILayoutEngineFactory)) as ILayoutEngineFactory;

                Assert.IsNotNull(factory);

                ILayoutEngine engine = factory.GetLayoutEngine();

                return(engine.BuildLayout(layoutInfo));
            }
        public void OnBuildDeployedAborted(ITargetDevice Device, BuildNode Build)
        {
            ThreadHelperClass.SetDeviceDeploymentResult(WinForm, DeviceView, Device, BuildDeploymentResult.Aborted);

            DeployedDeviceCount++;

            if (Devices.Count == DeployedDeviceCount)
            {
                Callback.OnDeploymentDone(this);
            }
        }
        public void OnBuildDeployedError(ITargetDevice Device, BuildNode Build, string ErrorMessage)
        {
            ThreadHelperClass.SetDeviceDeploymentResult(WinForm, DeviceView, Device, BuildDeploymentResult.Failure);

            DeployedDeviceCount++;

            if (Devices.Count == DeployedDeviceCount)
            {
                Callback.OnDeploymentDone(this);
            }
        }
        void MarkProblemDevice(ITargetDevice Device)
        {
            if (ProblemDevices.Where(D => D.Name == Device.Name && D.Platform == Device.Platform).Count() > 0)
            {
                return;
            }

            // @todo Notify service of problem (reboot device, notify email, etc)
            // also, pass problem devices to service when asking for reservation, so don't get that device back
            ProblemDevices.Add(new ProblemDevice(Device.Name, Device.Platform));
        }
Exemple #15
0
        /// <summary>
        /// Report target device issue to service with given error message
        /// </summary>
        public void ReportDeviceError(ITargetDevice Device, string ErrorMessage)
        {
            DeviceDefinition Def = null;

            if (!ServiceDeviceInfo.TryGetValue(Device, out Def))
            {
                return;
            }

            ReportDeviceError(Def.Name, ErrorMessage);
        }
Exemple #16
0
        public override void TickTest()
        {
            base.TickTest();

            if (GetTestStatus() == TestStatus.Complete || ResultsGathered)
            {
                if (!ResultsGathered)
                {
                    ResultsGathered = true;

                    try
                    {
                        // Gather results and merge PGO data
                        Log.Info("Gathering profiling results to {0}", TestInstance.ClientApps[0].ArtifactPath);
                        PGOPlatform.GatherResults(TestInstance.ClientApps[0].ArtifactPath);
                    }
                    catch (Exception Ex)
                    {
                        ProcessPGODataFailed = true;
                        Log.Error("Error getting PGO results: {0}", Ex);
                    }
                }

                return;
            }

            // Handle device screenshot update
            TimeSpan      Delta  = DateTime.Now - ScreenshotTime;
            ITargetDevice Device = TestInstance.ClientApps[0].Device;

            string ImageFilename;

            if (!String.IsNullOrEmpty(ScreenshotDirectory) && Delta >= ScreenshotInterval && Device != null && PGOPlatform.TakeScreenshot(Device, ScreenshotDirectory, out ImageFilename))
            {
                ScreenshotTime = DateTime.Now;

                try
                {
                    TimeSpan ImageTimestamp  = DateTime.UtcNow - ScreenshotStartTime;
                    string   ImageOutputPath = Path.Combine(ScreenshotDirectory, ImageTimestamp.ToString().Replace(':', '-') + ".jpg");
                    ImageUtils.ResaveImageAsJpgWithScaleAndQuality(Path.Combine(ScreenshotDirectory, ImageFilename), ImageOutputPath, ScreenshotScale, ScreenshotQuality);
                }
                catch
                {
                    // Just ignore errors.
                }
                finally
                {
                    // Delete the temporary image file
                    try { File.Delete(Path.Combine(ScreenshotDirectory, ImageFilename)); }
                    catch { }
                }
            }
        }
Exemple #17
0
        private IFileLoader     CreateFileLoader(ITargetDevice targetDevice)
        {
            var fileLoader = Activator.CreateInstance(targetDevice.FileLoaderType) as IFileLoader;

            if (null != fileLoader)
            {
                fileLoader.Game           = CurrentGame;
                fileLoader.ContentManager = Kernel.Get <IContentManager>();
            }
            return(fileLoader);
        }
Exemple #18
0
 public RemoteControlViewModel(ITargetDevice targetDevice, DeviceController deviceController, IPageController parentController)
 {
     this.TargetDevice      = targetDevice;
     this.deviceController  = deviceController;
     this.parentController  = parentController;
     this.SetSourceCommand  = new Command(new Action <object>(this.OnSetSource));
     this.TvPowerCommand    = new Command(new Action <object>(this.OnTvPower));
     this.ShowKeypadCommand = new Command((object arg) => {
         this.lastText = string.Empty;
         this.OnShowTextInput();
     });
 }
 private void SetCurrentDevice(ITargetDevice device)
 {
     if (this.CurrentDevice != null)
     {
         this.CurrentDevice.Disconnecting -= new EventHandler <EventArgs>(this.CurrentDevice_Disconnecting);
     }
     this.CurrentDevice = device;
     if (this.CurrentDevice != null)
     {
         this.CurrentDevice.Disconnecting += new EventHandler <EventArgs>(this.CurrentDevice_Disconnecting);
     }
 }
Exemple #20
0
        void MarkProblemDevice(ITargetDevice Device)
        {
            if (ProblemDevices.Where(D => D.Name == Device.Name && D.Platform == Device.Platform).Count() > 0)
            {
                return;
            }

            // report device has a problem to the pool
            DevicePool.Instance.ReportDeviceError(Device, "MarkProblemDevice");

            ProblemDevices.Add(new ProblemDevice(Device.Name, Device.Platform));
        }
Exemple #21
0
 public void OnBuildDeployed(ITargetDevice Device, BuildNode Build)
 {
     if (WinForm != null && DeviceView != null)
     {
         ThreadHelperClass.SetDeviceDeploymentResult(WinForm, DeviceView, Device, BuildDeploymentResult.Success);
     }
     else
     {
         Console.WriteLine(string.Format("Build [{0}] has been successfully deployed on device [{1}]", Build.Number, Device.Name));
     }
     Callback.OnDeploymentDone(this);
 }
Exemple #22
0
        public static CommandResult ExecuteCommand(ILogger Logger, string Argument, ITargetDevice Device, out string ReturnValue, out string LogInfo, out string LogError, int TimeoutSeconds = 30)
        {
            ReturnValue = LogInfo = LogError = string.Empty;

            int RetryCount = 0;

            while (RetryCount < 3)
            {
                RetryCount++;

                try
                {
                    using (var Client = new SshClient(Device.Address, Device.Username, Device.Password))
                    {
                        Client.Connect();

                        if (!Client.IsConnected)
                        {
                            continue;
                        }

                        using (var Command = Client.CreateCommand(Argument))
                        {
                            Command.CommandTimeout = TimeSpan.FromSeconds(TimeoutSeconds);
                            Command.Execute();
                            ReturnValue = Command.Result;

                            var OutputStreamReader = new StreamReader(Command.OutputStream);
                            var ErrorStreamReader  = new StreamReader(Command.ExtendedOutputStream);

                            LogError = ErrorStreamReader.ReadToEnd();
                            LogInfo  = OutputStreamReader.ReadToEnd();
                        }

                        Client.Disconnect();
                    }

                    if (LogError.Length == 0)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    Logger.Warning(string.Format("Failed to run command '{0}' at device '{1}' retry count {2}. Ex: {3}. {4}. {5}. {6}", Argument, Device.Address, RetryCount, e.Message, ReturnValue, LogInfo, LogError));
                }

                Thread.Sleep(500);
            }

            return(LogError.Length > 0 ? CommandResult.Failure : CommandResult.Success);
        }
Exemple #23
0
        protected bool CheckEssentialFunctions(ITargetDevice TestDevice)
        {
            // Device should power on (or ignore this if it's already on);
            CheckResult(TestDevice.PowerOn() && TestDevice.IsOn, "Failed to power on device");

            // Device should reboot (or pretend it did)
            CheckResult(TestDevice.Reboot(), "Failed to reboot device");

            // Device should connect
            CheckResult(TestDevice.Connect() && TestDevice.IsConnected, "Failed to connect to device");

            return(TestFailures.Count == 0);
        }
Exemple #24
0
        public void OnBuildDeployedError(ITargetDevice Device, BuildNode Build, string ErrorMessage)
        {
            if (WinForm != null && DeviceView != null)
            {
                ThreadHelperClass.SetDeviceDeploymentResult(WinForm, DeviceView, Device, BuildDeploymentResult.Failure);
            }
            else
            {
                Console.WriteLine(string.Format("Following error happened while deploying build [{0}] to device [{1}] : {2}", Build.Number, Device.Name, ErrorMessage));
            }

            Callback.OnDeploymentDone(this);
        }
Exemple #25
0
 public void OnBuildDeployedAborted(ITargetDevice Device, BuildNode Build)
 {
     Build.Progress = 0;
     if (WinForm != null && DeviceView != null)
     {
         ThreadHelperClass.SetDeviceDeploymentResult(WinForm, DeviceView, Device, BuildDeploymentResult.Aborted);
     }
     else
     {
         Console.WriteLine(string.Format("Deployment of build [{0}] to device [{1}] has been aborted !", Build.Number, Device.Name));
     }
     Callback.OnDeploymentDone(this);
 }
Exemple #26
0
 public TvVideoViewModel(DeviceController deviceController, ITargetDevice targetDevice)
 {
     this.TargetDevice              = targetDevice;
     this.deviceController          = deviceController;
     this.channelListCommand        = new Command(new Action <object>(this.OnShowChannelList));
     this.selectChannelCommand      = new Command(new Action <object>(this.OnSetChannel));
     this.channelUpCommand          = new Command(new Action <object>(this.OnChannelUp));
     this.channelDownCommand        = new Command(new Action <object>(this.OnChannelDown));
     this.sendDeviceViewToTvCommand = new Command(new Action <object>(this.OnSendDeviceViewToTv));
     this.sendTvViewToDeviceCommand = new Command(new Action <object>(this.OnSendTvViewToDevice));
     this.selectSourceCommand       = new UICommand(new Action <object>(this.OnSetSource), new Predicate <object>(this.CanSetSource));
     this.ccDataCommand             = new Command(new Action <object>(this.OnCcDataClick));
     this.restartCommand            = new Command(new Action <object>(this.OnRestart));
 }
 public static void DeployBuild(Form form, TreeListView listView, ITargetDevice device)
 {
     if (form.InvokeRequired)
     {
         var d = new DeployBuildDelegate(DeployBuild);
         form.Invoke(d, new object[] { form, listView, device });
     }
     else
     {
         listView.SelectedObject = device;
         listView.Expand(device);
         listView.RefreshSelectedObjects(); // RefreshObject(device);
     }
 }
Exemple #28
0
        private StandardModule GetSpecificModule(ITargetDevice targetDevice)
        {
            var display = targetDevice.Display;

            var inlineModule = new InlineModule(
                (m) => m.Bind <IDisplay>().ToConstant(display),
                (m) => m.Bind <ITargetDevice>().ToConstant(targetDevice),
                (m) => m.Bind <IGeometryContext>().To(targetDevice.GeometryContextType),
                (m) => m.Bind <IImageContext>().To(targetDevice.ImageContextType),
                (m) => m.Bind <ISpriteContext>().To(targetDevice.SpriteContextType),
                (m) => m.Bind <IFileLoader>().ToMethod((c) => CreateFileLoader(targetDevice))
                );

            return(inlineModule);
        }
Exemple #29
0
        /// <summary>
        /// Created and registered a device from the provided definition
        /// </summary>
        /// <param name="Def"></param>
        /// <returns></returns>
        protected ITargetDevice CreateAndRegisterDeviceFromDefinition(DeviceDefinition Def)
        {
            ITargetDevice NewDevice = null;

            IDeviceFactory Factory = Gauntlet.Utils.InterfaceHelpers.FindImplementations <IDeviceFactory>()
                                     .Where(F => F.CanSupportPlatform(Def.Platform))
                                     .FirstOrDefault();

            if (Factory == null)
            {
                throw new AutomationException("No IDeviceFactory implementation that supports {0}", Def.Platform);
            }

            try
            {
                bool IsDesktop = Def.Platform != null && UnrealBuildTool.Utils.GetPlatformsInClass(UnrealPlatformClass.Desktop).Contains(Def.Platform.Value);

                if (IsDesktop)
                {
                    string ClientTempDir = Path.Combine(LocalTempDir, "DeviceCache", Def.Platform.ToString());
                    int    DeviceCount   = AvailableDevices.Union(ReservedDevices).Where(D => D.Platform == Def.Platform).Count();

                    NewDevice = Factory.CreateDevice(Def.Name, ClientTempDir);
                }
                else
                {
                    NewDevice = Factory.CreateDevice(Def.Address, Def.DeviceData);
                }

                lock (LockObject)
                {
                    if (NewDevice != null)
                    {
                        RegisterDevice(NewDevice, new UnrealTargetConstraint(NewDevice.Platform, Def.PerfSpec, Def.Model));
                    }
                }
            }
            catch (Exception Ex)
            {
                Log.Info("Failed to create device {0}. {1}", Def.ToString(), Ex.Message);
            }

            return(NewDevice);
        }
        private async Task InitTargetDevice(DeviceInfo device)
        {
            Console.WriteLine("InitTargetDevice - started... ");
            Logger instance = Logger.Instance;

            object[] encryptionEnabled = new object[] { this.devicePairing.EncryptionEnabled };
            instance.LogMessageFormat("InitTargetDevice - EncryptionEnabled : {0}", encryptionEnabled);
            ISecondTvSecurityProvider noSecurityProvider = null;

            if (!this.devicePairing.EncryptionEnabled)
            {
                noSecurityProvider = new NoSecurityProvider();
            }
            else
            {
                noSecurityProvider = new AesSecurityProvider(this.devicePairing.SpcApi.GetKey(), this.devicePairing.SessionId);
            }
            Console.WriteLine("InitTargetDevice - Created Tv device.");

            ITargetDevice targetDevice = SmartTVRemoteControl.DeviceFactory.CreateTvDevice(device, this.notificationProvider, new DispatcherWrapper(Dispatcher.CurrentDispatcher), noSecurityProvider);

            Console.WriteLine("InitTargetDevice - Set current device.");
            this.SetCurrentDevice(targetDevice);
            try
            {
                Console.WriteLine("InitTargetDevice - Initialize Tv device.");
                AsyncContext.Run(() => targetDevice.InitializeAsync());
                //await targetDevice.InitializeAsync();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                Console.WriteLine("[ERROR]Catch exception when initialize TV.");
                Logger logger = Logger.Instance;
                logger.LogMessageFormat("Exception message: {0}", new object[] { exception.Message });
                Logger instance1 = Logger.Instance;
                instance1.LogMessageFormat("Exception stacktrace: {0}", new object[] { exception.StackTrace });
            }
            finally
            {
                Console.WriteLine("InitTargetDevice is complete");
            }
        }
        public bool SaveToWindowsPhone(TrackDescriptor tr, ITargetDevice targ)
        {
            SendItemProgressDelegate progress = SendItemProgress;
            string Path = tr.Path;

            try
            {
                if (!File.Exists(Path))
                {
                    _IIC.OnFactorisableError<FileBrokenCannotBeExported>(Path);
                    return false;
                }

                WindowsDictionaryDecorator wdd = new WindowsDictionaryDecorator();
                new DataExchanger<TrackDescriptor>(tr).Describe(DataExportImportType.WindowsPhone, wdd);

                Uri file = new Uri(Path, UriKind.Absolute);

                Dictionary OutputDictionary = new Dictionary();
                targ.SendMusicFile(file, file, wdd.Dictionary, progress, OutputDictionary);

                return true;
            }
            catch (Exception e)
            {
                Trace.WriteLine(string.Format("Unexpected error during export to Windows phone {0}", e));
                _IIC.OnFactorisableError<UnableToExportFileToWindowsPhone>(Path);
                return false;
            }
        }