protected override void BeginProcessing() { var command = AutomationFactory.GetCommand <GetDesktopCommand>(this); command.Execute(); }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { if (!CheckAndPrepareInput(this)) { return; } // foreach (IUiElement inputObject in InputObject) { // // try { // var resultElement = inputObject.InvokeContextMenu(this, X, Y); // // return the context menu window // WriteObject(this, resultElement); // } catch { // WriteError( // this, // "Failed to invoke context menu on this element", // "couldNotClick", // ErrorCategory.InvalidResult, // true); // } // // } var command = AutomationFactory.GetCommand <InvokeControlContextMenuCommand>(this); command.Execute(); }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { CheckCmdletParameters(); var command = AutomationFactory.GetCommand <GetWindowCommand>(this); command.Execute(); }
protected override void BeginProcessing() { // UiaHelper.ShowBanner(Message); var command = AutomationFactory.GetCommand <ShowBannerCommand>(this); command.Execute(); }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { if (!CheckAndPrepareInput(this)) { return; } // foreach (IUiElement inputObject in InputObject) { // // //System.Windows.Automation.AutomationElement _control = null; // // if (!Equals(ControlType, inputObject.Current.ControlType)) { // // WriteError( // this, // "Control is not of " + // ControlType.ProgrammaticName + // " type", // "WrongControlType", // ErrorCategory.InvalidArgument, // true); // } // // /* // if (this.ControlType != inputObject.Current.ControlType) { // // this.WriteError( // this, // "Control is not of " + // this.ControlType.ProgrammaticName + // " type", // "WrongControlType", // ErrorCategory.InvalidArgument, // true); // } // */ // // //this.WaitIfCondition(_control, false); // // 20120823 // //this.WaitIfCondition(this.InputObject, false); // WaitIfCondition(inputObject, false); // // //WriteObject(this, _control); // // 20130105 // //WriteObject(this, this.InputObject); // WriteObject(this, inputObject); // // } // 20120823 var command = AutomationFactory.GetCommand <WaitControlIsVisibleCommand>(this); command.Execute(); }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { if (!CheckAndPrepareInput(this)) { return; } var command = AutomationFactory.GetCommand <WaitControlIsEnabledCommand>(this); command.Execute(); }
protected override void BeginProcessing() { // IUiElement element = // GetActiveWindow(); // // CurrentData.CurrentWindow = element; // WriteObject(this, element); var command = AutomationFactory.GetCommand <GetActiveWindowCommand>(this); command.Execute(); }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { CheckCmdletParameters(); if (!CheckAndPrepareInput(this)) { return; } var command = AutomationFactory.GetCommand <GetControlCommand>(this); command.Execute(); }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { if (!CheckAndPrepareInput(this)) { return; } var command = AutomationFactory.GetCommand <WaitControlStateCommand>(this); command.Execute(); // bool result = false; // do { // result = // TestControlByPropertiesFromHashtable( // // 20130315 // InputObject, // SearchCriteria, // Timeout); // if (result) { // WriteObject(this, true); // return; // } else { // SleepAndRunScriptBlocks(this); // // wait until timeout expires or the state will be confirmed as valid // DateTime nowDate = // DateTime.Now; // if ((nowDate - StartDate).TotalSeconds > Timeout / 1000) { // //WriteObject(this, false); // result = true; // //write // //return; // } // } // } while (!result); // //WriteObject(this, false); // // // 20130316 // // graceful fail // WriteObject(this, false); // //// this.WriteError( //// this, //// "Timeout expired", //// "TimeoutExpired", //// ErrorCategory.OperationTimeout, //// true); }
/// <summary> /// Processes the pipeline. /// </summary> protected override void ProcessRecord() { if (!CheckAndPrepareInput(this)) { return; } // foreach (IUiElement inputObject in InputObject) { // // ClickControl( // this, // inputObject, // new ClickSettings { // RightClick = this.RightClick, // MidClick = this.MidClick, // Alt = this.Alt, // Shift = this.Shift, // Ctrl = this.Ctrl, // // inSequence = this.ins // DoubleClick = this.DoubleClick, // DoubleClickInterval = this.DoubleClickInterval, // RelativeX = this.X, // RelativeY = this.Y // }); // // if (PassThru) { // // WriteObject(this, inputObject); // } else { // WriteObject(this, true); // } // // } var command = AutomationFactory.GetCommand <InvokeControlClickCommand>(this); command.Execute(); }
private void TestParametersAgainstCollection( Hashtable[] inputData, IEnumerable <IUiElement> collection, bool expectedResult) { // Arrange var data = new ControlSearcherData { SearchCriteria = inputData }; Condition condition = ControlSearcher.GetWildcardSearchCondition(data); IUiElement element = FakeFactory.GetElement_ForFindAll( collection, condition); var cmdlet = new TestUiaControlStateCommand { SearchCriteria = inputData, InputObject = new[] { element } }; // Act var command = AutomationFactory.GetCommand <TestControlStateCommand>(cmdlet); command.Execute(); // Assert MbUnit.Framework.Assert.AreEqual <bool>( expectedResult, (bool)PSTestLib.UnitTestOutput.LastOutput[0]); Assert.Equal <bool>( expectedResult, (bool)PSTestLib.UnitTestOutput.LastOutput[0]); }
protected override void ProcessRecord() { var command = AutomationFactory.GetCommand <WaitEventRaisedCommand>(this); command.Execute(); // bool notFoundYet = true; // // // TODO: move to SearchTemplate // do { //WriteTrace(this, "do"); // if (CurrentData.LastEventInfoAdded) { //WriteTrace(this, "if (CurrentData.LastEventInfoAdded)"); // string name = string.Empty; // string automationId = string.Empty; // string controlType = string.Empty; // string eventId = string.Empty; // // try { //WriteTrace(this, "name 1"); // name = CurrentData.LastEventSource.Cached.Name; //WriteTrace(this, "name 2"); // } // catch {} // // try { //WriteTrace(this, "auId 1"); // automationId = CurrentData.LastEventSource.Cached.AutomationId; //WriteTrace(this, "auId 2"); // } // catch {} // // try { //WriteTrace(this, "type 1"); // controlType = CurrentData.LastEventSource.Cached.ControlType.ProgrammaticName; //WriteTrace(this, "type 2"); // controlType = controlType.Substring(12); //WriteTrace(this, "type 3"); // } // catch {} // // try { //WriteTrace(this, "eventId 1"); // eventId = CurrentData.LastEventType; //WriteTrace(this, eventId); //WriteTrace(this, "eventId 2"); // } // catch {} // //System.Windows.Automation.Peers.AutomationEvents. // //System.Windows.Automation.Peers.PatternInterface.Dock // if (Name != null && // Name.Length > 0) { //WriteTrace(this, "name 001"); // notFoundYet = !IsInArray(name, Name); //WriteTrace(this, "name 002"); // } // // if (AutomationId != null && // AutomationId.Length > 0) { //WriteTrace(this, "auId 001"); // notFoundYet = !IsInArray(automationId, AutomationId); //WriteTrace(this, "auId 002"); // } // // if (ControlType != null && // ControlType.Length > 0) { //WriteTrace(this, "type 001"); // notFoundYet = !IsInArray(controlType, ControlType); //WriteTrace(this, "type 002"); // } // // if (EventId != null && // EventId.Length > 0) { //WriteTrace(this, "eventId 001"); // notFoundYet = !IsInArray(eventId, EventId); //WriteTrace(this, "eventId 002"); // } // } // // //System.Threading.Thread.Sleep(100); // SleepAndRunScriptBlocks(this); // DateTime nowDate = DateTime.Now; // // if ((nowDate - StartDate).TotalSeconds > Timeout / 1000) // { // this.WriteError( // this, // "Failed to catch the event", // "NoEventFound", // ErrorCategory.ObjectNotFound, // true); // } // // if (notFoundYet) continue; // CurrentData.LastEventInfoAdded = false; // WriteObject(this, CurrentData.LastEventSource); // // } while (notFoundYet); }
void TestEvent(EventCmdletBase cmdlet, params AutomationProperty[] properties) { // Arrange IAutomation automation = Substitute.For <IAutomation>(); automation.RawViewCondition.Returns(Condition.TrueCondition); cmdlet.UiaAutomation = automation; var command = AutomationFactory.GetCommand <EventCommand>(cmdlet); // Act command.Execute(); // Assert foreach (var element in cmdlet.InputObject) { switch (cmdlet.GetType().Name) { case "RegisterUiaFocusChangedEventCommand": automation.Received(1).AddAutomationFocusChangedEventHandler( new AutomationFocusChangedEventHandler(cmdlet.AutomationEventHandler)); break; case "RegisterUiaInvokedEventCommand": automation.Received(1).AddAutomationEventHandler( InvokePattern.InvokedEvent, Arg.Any <IUiElement>(), TreeScope.Element, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; case "RegisterUiaMenuClosedEventCommand": automation.Received(1).AddAutomationEventHandler( AutomationElement.MenuClosedEvent, Arg.Any <IUiElement>(), TreeScope.Subtree, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; case "RegisterUiaMenuOpenedEventCommand": automation.Received(1).AddAutomationEventHandler( AutomationElement.MenuOpenedEvent, Arg.Any <IUiElement>(), TreeScope.Subtree, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; // case "RegisterUiaPropertyChangedEventCommand": // case "RegisterUiaGridRowCountChangedEventCommand": // case "RegisterUiaGridColumnCountChangedEventCommand": // case "RegisterUiaRangeValueChangedEventCommand": // case "RegisterUiaTableColumnCountChangedEventCommand": // case "RegisterUiaTableRowCountChangedEventCommand": // case "RegisterUiaValueChangedEventCommand": // automation.Received(1).AddAutomationPropertyChangedEventHandler( // Arg.Any<IUiElement>(), // TreeScope.Subtree, // new AutomationPropertyChangedEventHandler(cmdlet.AutomationPropertyChangedEventHandler), // cmdlet.AutomationProperty); ////if (null == properties) { //// Console.WriteLine("null == properties"); ////} else { //// Console.WriteLine("null != properties"); //// Console.WriteLine(properties.All(p => { Console.WriteLine("expected: {0}", p.ProgrammaticName); return true; } )); ////} ////if (null == cmdlet.AutomationProperty) { //// Console.WriteLine("null == cmdlet.AutomationProperty"); ////} else { //// Console.WriteLine("null != cmdlet.AutomationProperty"); //// Console.WriteLine(cmdlet.AutomationProperty.All(p => { Console.WriteLine("actual: {0}", p.ProgrammaticName); return true; } )); ////} // MbUnit.Framework.Assert.AreEqual<AutomationProperty[]>(properties, cmdlet.AutomationProperty); // Xunit.Assert.Equal<AutomationProperty[]>(properties, cmdlet.AutomationProperty); // break; case "RegisterUiaStructureChangedEventCommand": automation.Received(1).AddStructureChangedEventHandler( Arg.Any <IUiElement>(), TreeScope.Subtree, new StructureChangedEventHandler(cmdlet.StructureChangedEventHandler)); break; case "RegisterUiaTextChangedEventCommand": automation.Received(1).AddAutomationEventHandler( TextPattern.TextChangedEvent, Arg.Any <IUiElement>(), TreeScope.Element, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; case "RegisterUiaTextSelectionChangedEventCommand": automation.Received(1).AddAutomationEventHandler( TextPattern.TextSelectionChangedEvent, Arg.Any <IUiElement>(), TreeScope.Element, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; case "RegisterUiaToolTipClosedEventCommand": automation.Received(1).AddAutomationEventHandler( AutomationElement.ToolTipClosedEvent, Arg.Any <IUiElement>(), TreeScope.Subtree, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; case "RegisterUiaToolTipOpenedEventCommand": automation.Received(1).AddAutomationEventHandler( AutomationElement.ToolTipOpenedEvent, Arg.Any <IUiElement>(), TreeScope.Subtree, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; case "RegisterUiaWindowClosedEventCommand": automation.Received(1).AddAutomationEventHandler( WindowPattern.WindowClosedEvent, Arg.Any <IUiElement>(), TreeScope.Subtree, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; case "RegisterUiaWindowOpenedEventCommand": automation.Received(1).AddAutomationEventHandler( WindowPattern.WindowOpenedEvent, Arg.Any <IUiElement>(), TreeScope.Subtree, new AutomationEventHandler(cmdlet.AutomationEventHandler)); break; default: automation.Received(1).AddAutomationPropertyChangedEventHandler( Arg.Any <IUiElement>(), TreeScope.Subtree, new AutomationPropertyChangedEventHandler(cmdlet.AutomationPropertyChangedEventHandler), cmdlet.AutomationProperty); MbUnit.Framework.Assert.AreEqual <AutomationProperty[]>(properties, cmdlet.AutomationProperty); Assert.Equal <AutomationProperty[]>(properties, cmdlet.AutomationProperty); break; } } }