public override void Body() { ActualResult = QAliber.RemotingModel.TestCaseResult.Passed; UIControlBase c = UIControlBase.FindControlByPath(control); if (!c.Exists) { ActualResult = QAliber.RemotingModel.TestCaseResult.Failed; throw new InvalidOperationException("Control not found"); } IWindowPattern window = c.GetControlInterface <IWindowPattern>(); if (window == null) { ActualResult = QAliber.RemotingModel.TestCaseResult.Failed; throw new InvalidOperationException("Control doesn't appear to be a window"); } switch (opType) { case WindowOperationType.Close: window.Close(); break; case WindowOperationType.Maximize: if (!window.CanMaximize) { Log.Error("Window does not support maximizing.", string.Empty, EntryVerbosity.Internal); return; } window.SetState(WindowVisualState.Maximized); break; case WindowOperationType.Minimize: if (!window.CanMinimize) { Log.Error("Window does not support maximizing.", string.Empty, EntryVerbosity.Internal); return; } window.SetState(WindowVisualState.Minimized); break; case WindowOperationType.Restore: window.SetState(WindowVisualState.Normal); break; case WindowOperationType.SetFocus: window.SetState(WindowVisualState.Normal); c.SetFocus(); break; } }
protected override void ProcessRecord() { base.ProcessRecord(); // 20140312 // if (InputObject.Current.ControlType == classic.ControlType.Window) if (InputObject.GetCurrent().ControlType == classic.ControlType.Window) { // 20131208 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // WindowPattern windowPattern = InputObject.GetCurrentPattern(classic.WindowPattern.Pattern) as WindowPattern; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! IWindowPattern windowPattern = InputObject.GetCurrentPattern <IWindowPattern>(classic.WindowPattern.Pattern); try { switch (PatternName.ToLower()) { case "close": windowPattern.Close(); break; case "maximize": windowPattern.SetWindowVisualState(classic.WindowVisualState.Maximized); break; case "minimize": windowPattern.SetWindowVisualState(classic.WindowVisualState.Minimized); break; case "restore": windowPattern.SetWindowVisualState(classic.WindowVisualState.Normal); break; } } catch (InvalidOperationException) { ArgumentException ex = new ArgumentException("Target window doesn't support '" + PatternName + "' pattern."); ThrowTerminatingError(new ErrorRecord(ex, "WrongInputObject", ErrorCategory.InvalidArgument, null)); } } else { ArgumentException ex = new ArgumentException("Cannot call WindowPattern on object that is not a Window."); ThrowTerminatingError(new ErrorRecord(ex, "WrongInputObject", ErrorCategory.InvalidArgument, null)); } }