Exemplo n.º 1
0
 public void Invoke(ArgType args)
 {
     if (EventFired != null)
     {
         EventFired.Invoke(this, args);
     }
 }
Exemplo n.º 2
0
 private void OnElapsedTime(object source, ElapsedEventArgs e)
 {
     EventFired?.Invoke(source, new DictionaryEventArgs()
     {
         Values = new Dictionary <string, object>()
         {
             { "Time", System.DateTime.Now }
         }
     });
 }
Exemplo n.º 3
0
        /// <summary>
        /// Event invocator for the <see cref="EventFired"/> event
        /// </summary>
        /// <param name="triggerTime">The event's time in UTC</param>
        protected void OnEventFired(DateTime triggerTime)
        {
            // don't fire the event if we're turned off
            if (!Enabled)
            {
                return;
            }

            _callback?.Invoke(Name, _orderedEventUtcTimes.Current);
            EventFired?.Invoke(Name, triggerTime);
        }
Exemplo n.º 4
0
        /// -------------------------------------------------------------------
        ///<summary></summary>
        /// -------------------------------------------------------------------
        void TS_IsInvokeEventAppropriateOnObject(AutomationElement element)
        {
            // if element is content
            //      if element supports{specific pattern}
            //          don't support Invoke
            // else
            //      don't support Invoke

            bool content = (bool)element.GetCurrentPropertyValue(AutomationElement.IsContentElementProperty);

            _eventAppropriate = EventFired.True;

            if (content)
            {
                if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports ExpandCollapsePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsValuePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports ValuePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsRangeValuePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports RangeValuePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsSelectionItemPatternAvailableProperty))
                {
                    Comment("Element is content element, and supports SelectionItemPattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsTogglePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports TogglePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsValuePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports ValuePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
            }
            else
            {
                Comment("AutomationElement.IsContentElementProperty is false, so Invoke event is not required as the control should have a higher pattern that supports the same operation such as ExpandCollapse");
                _eventAppropriate = EventFired.Undetermined;
            }

            m_TestStep++;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Event invocator for the <see cref="EventFired"/> event
        /// </summary>
        /// <param name="triggerTime">The event's time in UTC</param>
        protected void OnEventFired(DateTime triggerTime)
        {
            try
            {
                // don't fire the event if we're turned off
                if (!Enabled)
                {
                    return;
                }

                _callback?.Invoke(Name, _orderedEventUtcTimes.Current);
                EventFired?.Invoke(Name, triggerTime);
            }
            catch (Exception ex)
            {
                Log.Error($"ScheduledEvent.Scan(): Exception was thrown in OnEventFired: {ex}");

                // This scheduled event failed, so don't repeat the same event
                _needsMoveNext = true;
                throw new ScheduledEventException(Name, ex.Message, ex);
            }
        }
Exemplo n.º 6
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        void TestToggle1(ToggleState expectedState, EventFired eventShouldFire, bool usingKeyboard)
        {
            ToggleState orgState = pToggleState;

            // "Precondition: ToggleStateProperty == expectedState",
            TS_VerifyToggleState(orgState, true, CheckType.IncorrectElementConfiguration);

            // "SetFocus to the element",
            TS_SetFocus(m_le, null, CheckType.IncorrectElementConfiguration);

            //    "Step: Setup a StateProperty PropertyChange event",
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { TogglePattern.ToggleStateProperty }, CheckType.Verification);

            //    "Verify: Successful call TogglePattern.Toggle()",
            if (!usingKeyboard)
            {
                TS_Toggle(null, CheckType.Verification);
            }
            else
            {
                TS_PressKeys(true, System.Windows.Input.Key.Space);
            }

            // "Step: Wait for 1 event to occur
            TSC_WaitForEvents(1);

            // "Verify: The StateProperty PropertyChange event is fired",
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { eventShouldFire }, new AutomationProperty[] { TogglePattern.ToggleStateProperty }, CheckType.Verification);

            // "Verify: The StateProperty has changed",
            TS_VerifyToggleState(orgState, false, CheckType.Verification);

            // "Cleanup: Call Toggle() until ToggleStateProperty == original state(Off)"
            //TS_ToggleTo(orgState, null, CheckType.Verification);

            m_TestStep++;
        }
Exemplo n.º 7
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        void SetValue_SetToSameValue(ObjectTypes dataType, object Value, EventFired eventFired)
        {
            object val;

            // Precondition: Verify that this control is not ReadOnly
            TS_VerifyReadOnly(false, CheckType.IncorrectElementConfiguration);

            // Precondition: Verify that this control supports #### types
            TS_VerifyObjectType(pattern_Value, dataType, true, CheckType.IncorrectElementConfiguration);

            // Get the current value
            TS_GetValue(out val, CheckType.Verification);

            // Add event that will catch PropertyChangeEvent
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification);

            // Set the value of the pattern to the random string
            TS_SetValue(Value, true, null, CheckType.Verification);

            TSC_WaitForEvents(1);

            // Verify that the PropertyChangeEvent event is fired and the random string is passed into the event
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { eventFired }, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification);
        }
Exemplo n.º 8
0
        void TestScroll(bool HScrollable,
            bool VScrollable,
            double PreConitionHPercent,
            double PreConitionVPercent,
            ScrollAmount arg_HScrollAmount,
            ScrollAmount arg_VScrollAmount,
            bool expectedMethReturn,
            object ExpectedHPercent,
            object ExpectedVPercent,
            EventFired HEventFire,
            EventFired VEventFire)
        {
            //Precondition: Verify that the ScrollAmount values are valid for this AutomationElement (ie. Tab does not support ScrollAmount.LargeIncrement or ScrollAmount.LargeDecrement)
            TS_ControlsSupportsLargeIncrementOrDecrement(m_le, arg_HScrollAmount, arg_VScrollAmount, CheckType.IncorrectElementConfiguration);

            //2 "Step: Set HorizontalPercent = PreConitionHPercent",
            TSC_ScrollPercent(PreConitionHPercent, ScrollDirection.Horizontal, CheckType.IncorrectElementConfiguration);

            //3 "Step: Verify that it was set correctly",
            TSC_VerifyScrollPercent(PreConitionHPercent, ScrollDirection.Horizontal, CheckType.Verification);

            //4 "Step: Set VerticalPercent = 0",
            TSC_ScrollPercent(PreConitionVPercent, ScrollDirection.Vertical, CheckType.IncorrectElementConfiguration);

            //5 "Step: Verify that it was set correctly",
            TSC_VerifyScrollPercent(PreConitionVPercent, ScrollDirection.Vertical, CheckType.Verification);

            //6 "Step: Add a property changed listener for HorizontalScrollPercentProperty",
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ScrollPattern.HorizontalScrollPercentProperty }, CheckType.Verification);

            //7 "Step: Add a property changed listener for VerticalScrollPercentProperty",
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ScrollPattern.VerticalScrollPercentProperty }, CheckType.Verification);

            //8 "Call SetScrollPercent (NoScroll,0) and verify that method returns true",
            TSC_Scroll(arg_HScrollAmount, arg_VScrollAmount, CheckType.Verification);

            //9 "Verify that HorizontalPercent = *",
            TSC_VerifyScrollPercent(ExpectedHPercent, ScrollDirection.Horizontal, CheckType.Verification);

            //10 "Verify that VerticalPercent = *",
            TSC_VerifyScrollPercent(ExpectedVPercent, ScrollDirection.Vertical, CheckType.Verification);

            // 11 "Step: Wait for events",
            TSC_WaitForEvents(1);

            //11 "Verify that the firing of the event listener HorizontalScrollPercentProperty is Undetermined",
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { HEventFire }, new AutomationProperty[] { ScrollPattern.HorizontalScrollPercentProperty }, CheckType.Verification);

            //12 "Verify that the firing of the event listener VerticalScrollPercentProperty is false",
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { VEventFire }, new AutomationProperty[] { ScrollPattern.VerticalScrollPercentProperty }, CheckType.Verification);
        }
Exemplo n.º 9
0
        void TestC_SetScrollPercent(bool HScrollable, bool VScrollable, double PreConitionHPercent, double PreConitionVPercent,
            double newHPercent,
            double newVPercent,
            double expectedHPercent,
            double expectedVPercent,
            EventFired HEventFire,
            EventFired VEventFire,
            Type exceptionExpected
            )
        {
            Comment("HScrollable({0}), VScrollable({1}), PreConitionHPercent({2}), PreConitionVPercent({3}), newHPercent({4}), newVPercent({5}), expectedHPercent({6}), expectedVPercent({7}), HEventFire({8}), VEventFire({9}), exceptionExpected({0})",
            HScrollable, VScrollable, PreConitionHPercent, PreConitionVPercent, newHPercent, newVPercent, expectedHPercent, expectedVPercent, HEventFire, VEventFire, exceptionExpected);

            //"5 Step: Add a property changed listener for HorizontalScrollPercentProperty",
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ScrollPattern.HorizontalScrollPercentProperty }, CheckType.Verification);

            //"6 Step: Add a property changed listener for VerticalScrollPercentProperty",
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ScrollPattern.VerticalScrollPercentProperty }, CheckType.Verification);

            //"7 Step: Set HorizontalPercent = *",
            TSC_ScrollPercent(PreConitionHPercent, ScrollDirection.Horizontal, CheckType.IncorrectElementConfiguration);

            //"8 Step: Verify that it was set correctly",
            TSC_VerifyScrollPercent(PreConitionHPercent, ScrollDirection.Horizontal, CheckType.Verification);

            //"9 Step: Set VerticalPercent = 0",
            TSC_ScrollPercent(PreConitionVPercent, ScrollDirection.Vertical, CheckType.IncorrectElementConfiguration);

            //"10 Step: Verify that it was set correctly",
            TSC_VerifyScrollPercent(PreConitionVPercent, ScrollDirection.Vertical, CheckType.Verification);

            //"11 Wait and eat 2 possible events before we actually start the test
            TSC_WaitForEvents(2);

            //"12 Removing all events fired");
            TS_RemoveAllEventsFired();

            Comment("".PadRight(50, '-'));

            //"13 Call SetScrollPercent (NoScroll,0) and verify that method returns true",
            TSC_SetScrollPercent(newHPercent, newVPercent, exceptionExpected, CheckType.Verification);

            // 14 Now wait for 2 events tested events",
            TSC_WaitForEvents(2);

            //"15 Verify that HorizontalPercent = expectedHPercent",
            TSC_VerifyScrollPercent(expectedHPercent, ScrollDirection.Horizontal, CheckType.Verification);

            //"16 Verify that VerticalPercent = expectedVPercent",
            TSC_VerifyScrollPercent(expectedVPercent, ScrollDirection.Vertical, CheckType.Verification);

            //"17 Verify that the firing of the event listener HorizontalScrollPercentProperty is Undetermined",
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { HEventFire }, new AutomationProperty[] { ScrollPattern.HorizontalScrollPercentProperty }, CheckType.Verification);

            //"1 Verify that the firing of the event listener VerticalScrollPercentProperty is false",
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { VEventFire }, new AutomationProperty[] { ScrollPattern.VerticalScrollPercentProperty }, CheckType.Verification);
        }
Exemplo n.º 10
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        void SetValue_SetToRandomValue(ObjectTypes dataType, bool CanBeNull, bool ShouldBeReadOnly, bool MethodReturnValue, bool DoesValueChange, bool RandomValDifferentFromCurrentValue, EventFired eventFired, Type expectedException)
        {
            object val = pattern_Value;

            // Verify that control is not read only
            TS_VerifyReadOnly(ShouldBeReadOnly, CheckType.IncorrectElementConfiguration);

            // Verify that this control supports ######### types
            TS_VerifyObjectType(pattern_Value, dataType, CanBeNull, CheckType.IncorrectElementConfiguration);

            // Get a random valid value
            TS_GetRandomValue(out val, pattern_Value, dataType, true, RandomValDifferentFromCurrentValue, CheckType.Verification);

            // Add event that will catch PropertyChangeEvent 
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification);

            // Set the pattern to this value
            TS_SetValue(val, MethodReturnValue, expectedException, CheckType.Verification);

            // Wait for event
            TSC_WaitForEvents(1);

            // Verify the pattern is set to this value
            TS_VerifyValue(val, DoesValueChange, CheckType.Verification);

            // Verify that the PropertyChangeEvent event is *
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { eventFired }, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification);
        }
Exemplo n.º 11
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        void TestToggle1(ToggleState expectedState, EventFired eventShouldFire, bool usingKeyboard)
        {
            ToggleState orgState = pToggleState;

            // "Precondition: ToggleStateProperty == expectedState",
            TS_VerifyToggleState(orgState, true, CheckType.IncorrectElementConfiguration);

            // "SetFocus to the element",
            TS_SetFocus(m_le, null, CheckType.IncorrectElementConfiguration);

            //    "Step: Setup a StateProperty PropertyChange event", 
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { TogglePattern.ToggleStateProperty }, CheckType.Verification);

            //    "Verify: Successful call TogglePattern.Toggle()", 
            if (!usingKeyboard)
                TS_Toggle(null, CheckType.Verification);
            else
                TS_PressKeys(true, System.Windows.Input.Key.Space);

            // "Step: Wait for 1 event to occur 
            TSC_WaitForEvents(1);

            // "Verify: The StateProperty PropertyChange event is fired", 
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { eventShouldFire }, new AutomationProperty[] { TogglePattern.ToggleStateProperty }, CheckType.Verification);

            // "Verify: The StateProperty has changed",
            TS_VerifyToggleState(orgState, false, CheckType.Verification);

            // "Cleanup: Call Toggle() until ToggleStateProperty == original state(Off)"        
            //TS_ToggleTo(orgState, null, CheckType.Verification);

            m_TestStep++;
        }
Exemplo n.º 12
0
        /// -------------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------------
        void AddElementToSelectionTest2(bool required, bool canSelectMultiple, EventFired eventFired) // ***
        {
            AutomationElement le;
            ArrayList selected = new ArrayList();
#if NATIVE_UIA
            Type expectedException = canSelectMultiple ? null : typeof(ArgumentException);
#else
            Type expectedException = canSelectMultiple ? null : typeof(InvalidOperationException);
#endif
            selected.Add(m_le);

            // "Precondition: There is a selection container (ie. Win32 radio buttons do not have a selection container",
            TSC_VerifyPropertyEqual(_pattern.Current.SelectionContainer != null, true, SelectionItemPattern.SelectionContainerProperty, CheckType.IncorrectElementConfiguration);

            //"Precondition: There is at least 2 element in the selection container",
            TS_AtLeastSelectableChildCount(_selectionContainer, 2, CheckType.IncorrectElementConfiguration);

            //"Precondition: IsSelectionRequired = #1",
            TS_AtLeastOneSelectionRequired(_selectionPattern, required, CheckType.IncorrectElementConfiguration);

            //"Precondition: SupportsMulitpleSelection = #2",
            TS_SupportsMultipleSelection(this._selectionPattern, canSelectMultiple, CheckType.IncorrectElementConfiguration);

            // "Precondition: Select element",
            TS_Select(CheckType.Verification);

            // "Find a random unselected element",
            TS_GetOtherSelectionItem(m_le, out le, false, 10, CheckType.IncorrectElementConfiguration);

            // "Setup ElementAddedToSelectionEvent event",
            TSC_AddEventListener(le, SelectionItemPattern.ElementAddedToSelectionEvent, TreeScope.Element, CheckType.Verification);

            // "Call AddElementToSelection() with this element and verify that AddElementToSelection() returns true",
            TS_AddElementToSelection(le, expectedException, CheckType.Verification);

            // "Wait for events",
            TSC_WaitForEvents(1);

            // "Verify ElementAddedToSelection event * happen",
            TSC_VerifyEventListener(le, SelectionItemPattern.ElementAddedToSelectionEvent, eventFired, CheckType.Verification);

        }
Exemplo n.º 13
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        private void TestDriverAddToSelection2(bool isSelectionRequired, bool canSelectMultiple)
        {
            // "Precondition: There is a selection container (ie. Win32 radio buttons do not have a selection container",
            TSC_VerifyPropertyEqual(_pattern.Current.SelectionContainer != null, true, SelectionItemPattern.SelectionContainerProperty, CheckType.IncorrectElementConfiguration);

            ArrayList allElements = HelperGetContainersSelectableItems(_selectionContainer);

            ArrayList listElement = new ArrayList();
            listElement.Add(m_le);

            AutomationProperty[] propertiesFired = new AutomationProperty[] { SelectionItemPattern.IsSelectedProperty };
            EventFired[] fireState = new EventFired[] { EventFired.True };

            // Precondition: Selection container's SelectionPattern.IsSelectionRequired should be *
            TS_SelectionRequired(isSelectionRequired, CheckType.IncorrectElementConfiguration);

            // Precondition: Selection container's SelectionPattern.CanSelectMultiple should be *
            TS_CanSelectMultiple(canSelectMultiple, CheckType.IncorrectElementConfiguration);

            //"Step: Select the element",
            TS_Select(m_le, null, CheckType.Verification);

            //"Step: Add a SelectionItemPattern.IsSelectedProperty property change event",
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, propertiesFired, CheckType.Verification);

            //"Step: Call AddToSelection on the same element",
            TS_AddElementToSelection(m_le, null, CheckType.Verification);

            // Step: Wait for two events max
            TSC_WaitForEvents(2);

            //"Verification: Verify that the SelectionItemPattern.IsSelectedProperty was fired",
            TSC_VerifyPropertyChangedListener(m_le, fireState, propertiesFired, CheckType.Verification);

            //"Verify element is selected",
            TS_VerifyElementsAreSelected(listElement, CheckType.Verification);

        }
Exemplo n.º 14
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Tests and displays the correct error/comment
        /// </summary>
        /// -------------------------------------------------------------------
        void TestIfEventShouldFire(EventFired shouldFire, EventFired actualFired, object eventId, CheckType checkType)
        {
            if (!shouldFire.Equals(EventFired.Undetermined))
            {
                string eventName;
                if (eventId == null)
                {
                    eventName = "Focus";
                }
                else
                {
                    // Property change event
                    eventName = ((AutomationIdentifier)(eventId)).ProgrammaticName;
                }

                if (!actualFired.Equals(shouldFire))
                {
                    if (actualFired.Equals(EventFired.False))
                    {
                        ThrowMe(checkType, eventName + " event was not fired and was expected to be fired");
                    }
                    else
                    {
                        // Was fired and should not have been
                        ThrowMe(checkType, eventName + " event did get fired and was not expected to be fired");
                    }
                }
                else
                {
                    if (actualFired.Equals(EventFired.False))
                    {
                        Comment(eventName + " event was not fired and was not expected to be fired");
                    }
                    else
                    {
                        Comment(eventName + " change event did get fired and was expected to be fired");
                    }
                }
            }
            else
            {
                if (actualFired.Equals(EventFired.False))
                    Comment("The test spec'd firing of " + eventId + " event is Undetermined. The event was not fired");
                else
                    Comment("The test spec'd firing of " + eventId + " event is Undetermined. The event was fired");
            }
        }
Exemplo n.º 15
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        private void TestDriverAddToSelection3(bool isSelectionRequired, bool canSelectMultiple)
        {
            // "Precondition: There is a selection container (ie. Win32 radio buttons do not have a selection container",
            TSC_VerifyPropertyEqual(_pattern.Current.SelectionContainer != null, true, SelectionItemPattern.SelectionContainerProperty, CheckType.IncorrectElementConfiguration);

            ArrayList selectableList = HelperSubtract(HelperGetContainersSelectableItems(_selectionContainer), new object[] { m_le });
            ArrayList multiSelectList = new ArrayList();
            ArrayList singleSelectList = new ArrayList();

            multiSelectList.Add((AutomationElement)selectableList[0]);
            multiSelectList.Add(m_le);

            singleSelectList.Add((AutomationElement)selectableList[0]); ;

            AutomationProperty[] propertiesFired = new AutomationProperty[] { SelectionItemPattern.IsSelectedProperty };
            EventFired[] fireState;
            if (canSelectMultiple)
                fireState = new EventFired[] { EventFired.True };
            else
                fireState = new EventFired[] { EventFired.False };

            // Precondition: Selection container's SelectionPattern.IsSelectionRequired should be *
            TS_SelectionRequired(isSelectionRequired, CheckType.IncorrectElementConfiguration);

            // Precondition: Selection container's SelectionPattern.CanSelectMultiple should be *
            TS_CanSelectMultiple(canSelectMultiple, CheckType.IncorrectElementConfiguration);

            // Step: Select some other element incase selection required
            TS_Select((AutomationElement)multiSelectList[0], null, CheckType.IncorrectElementConfiguration);

            // Step: Add a SelectionItemPattern.IsSelectedProperty property change event
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, propertiesFired, CheckType.Verification);

            // Step: Call AddToSelection on the element
            if (canSelectMultiple)
                TS_AddElementToSelection(m_le, null, CheckType.Verification);
            else
                TS_AddElementToSelection(m_le, typeof(InvalidOperationException), CheckType.Verification);

            // Step: Wait for one event to occur
            TSC_WaitForEvents(1);

            // Verification: Verify that the SelectionItemPattern.IsSelectedProperty was fired
            TSC_VerifyPropertyChangedListener(m_le, fireState, propertiesFired, CheckType.Verification);

            // Verify correct elements are selected
            if (canSelectMultiple)
                TS_VerifyElementsAreSelected(multiSelectList, CheckType.Verification);
            else
                TS_VerifyElementsAreSelected(singleSelectList, CheckType.Verification);

        }
Exemplo n.º 16
0
        /// <summary>
        /// Normally a <pre>video</pre> element doesn't have a <pre>change</pre> event.
        /// We force one and a use it as a proxy for all the Media Events.
        /// </summary>
        /// <param name="args">The event args - Value contains our JSON</param>
        protected virtual void OnChange(ChangeEventArgs args)
        {
            var            ThisEvent = args?.Value?.ToString();
            VideoEventData videoData = new VideoEventData();

            try
            {
                videoData = JsonSerializer.Deserialize <VideoEventData>(ThisEvent, serializationOptions);
            }
            catch (Exception ex)
            {
                LoggerFactory
                .CreateLogger(nameof(VideoExComponentBase))
                .LogError(ex, "Failed to convert the JSON: {0}", ThisEvent);
            }

            switch (videoData.EventName)
            {
            case VideoEvents.Abort:
                Abort?.Invoke(videoData.State);
                AbortEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.CanPlay:
                CanPlay?.Invoke(videoData.State);
                CanPlayEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.CanPlayThrough:
                CanPlayThrough?.Invoke(videoData.State);
                CanPlayThroughEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.DurationChange:
                DurationChange?.Invoke(videoData.State);
                DurationChangeEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Emptied:
                Emptied?.Invoke(videoData.State);
                EmptiedEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Ended:
                Ended?.Invoke(videoData.State);
                EndedEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Error:
                Error?.Invoke(videoData.State);
                ErrorEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.LoadedData:
                LoadedData?.Invoke(videoData.State);
                LoadedDataEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.LoadedMetadata:
                LoadedMetadata?.Invoke(videoData.State);
                LoadedMetadataEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.LoadStart:
                LoadStart?.Invoke(videoData.State);
                LoadStartEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Pause:
                Pause?.Invoke(videoData.State);
                PauseEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Play:
                Play?.Invoke(videoData.State);
                PlayEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Playing:
                Playing?.Invoke(videoData.State);
                PlayingEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Progress:
                Progress?.Invoke(videoData.State);
                ProgressEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.RateChange:
                RateChange?.Invoke(videoData.State);
                RateChangeEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Seeked:
                Seeking?.Invoke(videoData.State);
                SeekingEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Seeking:
                Seeking?.Invoke(videoData.State);
                SeekingEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Stalled:
                Stalled?.Invoke(videoData.State);
                StalledEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Suspend:
                Suspend?.Invoke(videoData.State);
                SuspendEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.TimeUpdate:
                TimeUpdate?.Invoke(videoData.State);
                TimeUpdateEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.VolumeChange:
                VolumeChange?.Invoke(videoData.State);
                VolumeChangeEvent.InvokeAsync(videoData.State);
                break;

            case VideoEvents.Waiting:
                Waiting?.Invoke(videoData.State);
                WaitingEvent.InvokeAsync(videoData.State);
                break;

            default:
                break;
            }
            // Here is our catch-all event handler call!
            EventFired?.Invoke(videoData);
        }
Exemplo n.º 17
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Verify that the property changed
        /// </summary>
        /// -------------------------------------------------------------------
        internal void TSC_VerifyPropertyChangedListener(AutomationElement element, EventFired[] eventFired, AutomationProperty[] properties, CheckType checkType)
        {
            int counter = 0;

            for (int i = 0; i < properties.Length; i++)
            {
                Comment("Verifying property change \"{0}\" event firing was {1})", properties[i].ProgrammaticName, eventFired[i]);
            }

            foreach (AutomationProperty prop in properties)
                if (_testEvents && element.Current.IsContentElement)
                {
                    foreach (EventFired ShouldFire in eventFired)
                    {
                        if (!ShouldFire.Equals(EventFired.Undetermined))
                        {
                            Comment("Start: Looking for event that might have been fired");

                            EventFired ActualFired = m_PropertyChangeEvents.WasEventFired(element, properties[counter]);

                            Comment("End : Looking for event that might have been fired");
                            TestIfEventShouldFire(ShouldFire, ActualFired, properties[counter], checkType);
                        }
                        else
                        {
                            Comment("Test spec stated that firing of the event is " + ShouldFire.ToString());
                        }
                    }
                }
                else
                {
                    /* If the element's (ControlView == true && ContentView == false), events
                    // are not required to be fired since the element has some other mechanism
                    // through patterns on the elements containing element that does the same
                    // characteristic.  Example, Lists ScrollBar does not have to fire a 
                    // RangeValue change event since the ListView supports ScrollPattern and the 
                    // user would set events on the ScrollPattern. */
                    if (!element.Current.IsContentElement)
                    {
                        Comment(IDS_NO_EVENT_TESTING_ON_CONTROLVIEW);
                    }
                    else
                    {
                        Comment("Not testing for events");
                    }
                }
            m_TestStep++;
        }
        public void Publish_WhenProvidedMessageIsNotINServiceBusEventFired_ArgumentExceptionMustBeThrown()
        {
            var eventFired = new EventFired();

            Assert.Throws<ArgumentException>(() => this.testee.Publish(eventFired));
        }
Exemplo n.º 19
0
        /// -------------------------------------------------------------------
        ///<summary></summary>
        /// -------------------------------------------------------------------
        void TS_IsInvokeEventAppropriateOnObject(AutomationElement element)
        {
            // if element is content
            //      if element supports{specific pattern}
            //          don't support Invoke
            // else
            //      don't support Invoke

            bool content = (bool)element.GetCurrentPropertyValue(AutomationElement.IsContentElementProperty);
            _eventAppropriate = EventFired.True;

            if (content)
            {
                if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsExpandCollapsePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports ExpandCollapsePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsValuePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports ValuePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsRangeValuePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports RangeValuePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsSelectionItemPatternAvailableProperty))
                {
                    Comment("Element is content element, and supports SelectionItemPattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsTogglePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports TogglePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
                else if ((bool)element.GetCurrentPropertyValue(AutomationElement.IsValuePatternAvailableProperty))
                {
                    Comment("Element is content element, and supports ValuePattern, so Invoke event is not required");
                    _eventAppropriate = EventFired.Undetermined;
                }
            }
            else
            {
                Comment("AutomationElement.IsContentElementProperty is false, so Invoke event is not required as the control should have a higher pattern that supports the same operation such as ExpandCollapse");
                _eventAppropriate = EventFired.Undetermined;
            }

            m_TestStep++;
        }
Exemplo n.º 20
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        private void TestDriverSelect0(bool currentlySelected)
        {
            // "Precondition: There is a selection container (ie. Win32 radio buttons do not have a selection container",
            TSC_VerifyPropertyEqual(_pattern.Current.SelectionContainer != null, true, SelectionItemPattern.SelectionContainerProperty, CheckType.IncorrectElementConfiguration);

            EventFired[] fireState = new EventFired[] { currentlySelected == true ? EventFired.Undetermined : EventFired.True };
            AutomationProperty[] propertiesFired = new AutomationProperty[] { SelectionItemPattern.IsSelectedProperty };
            ArrayList elementsSelected = new ArrayList();
            elementsSelected.Add(m_le);

            //"Precondition: Element is X selected"
            TSC_VerifyPropertyEqual(_pattern.Current.IsSelected, currentlySelected, SelectionItemPattern.SelectionContainerProperty, CheckType.IncorrectElementConfiguration);

            //  Step: Add a SelectionItemPattern.IsSelectedProperty property change event
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, propertiesFired, CheckType.Verification);

            // Step: Select the element
            TS_Select(m_le, null, CheckType.Verification);

            // Step: Wait for one event to fire
            TSC_WaitForEvents(2);

            // Verification: Verify that the SelectionItemPattern.IsSelectedProperty was fired
            TSC_VerifyPropertyChangedListener(m_le, fireState, propertiesFired, CheckType.Verification);

            // Verify element is selected
            TS_VerifyElementsAreSelected(elementsSelected, CheckType.Verification);
        }
Exemplo n.º 21
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Verify that the event was fired
        /// </summary>        
        /// -------------------------------------------------------------------
        internal void TSC_VerifyEventListener(AutomationElement element, AutomationEvent eventId, EventFired shouldFire, CheckType checkType)
        {
            // Element == null means we are looking for WindowCloseEvent
            if (_testEvents && (element == null || element.Current.IsContentElement))
            {
                Comment("Start: Looking for event that might have been fired");

                EventFired ActualFired = m_AutomationEvents.WasEventFired(element, eventId);

                Comment("End : Looking for event that might have been fired");
                TestIfEventShouldFire(shouldFire, ActualFired, eventId, checkType);
            }
            else
            {
                Comment("Not testing for events");
            }

            m_TestStep++;
        }
Exemplo n.º 22
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        private void TestDriverAbleToRemoveFromSelection(bool canSelectMultiple)
        {
            // "Precondition: There is a selection container (ie. Win32 radio buttons do not have a selection container",
            TSC_VerifyPropertyEqual(_pattern.Current.SelectionContainer != null, true, SelectionItemPattern.SelectionContainerProperty, CheckType.IncorrectElementConfiguration);

            ArrayList listElement = new ArrayList();
            listElement.Add(m_le);

            AutomationProperty[] propertiesFired = new AutomationProperty[] { SelectionItemPattern.IsSelectedProperty };
            EventFired[] fireState = new EventFired[] { EventFired.True };

            // Precondition: Selection container's SelectionPattern.IsSelectionRequired should be *
            TS_SelectionRequired(false, CheckType.IncorrectElementConfiguration);

            // Precondition: Selection container's SelectionPattern.CanSelectMultiple should be *
            TS_CanSelectMultiple(canSelectMultiple, CheckType.IncorrectElementConfiguration);

            // "Step: Select the element",
            TS_Select(CheckType.Verification);

            // Step: Add a SelectionItemPattern.IsSelectedProperty property change event
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, propertiesFired, CheckType.Verification);

            // Step: Select the element
            TS_RemoveElementFromSelection(m_le, null, CheckType.Verification);

            // Step: Wait for event to occur
            TSC_WaitForEvents(1);

            // Verification: Verify that the SelectionItemPattern.IsSelectedProperty was fired
            TSC_VerifyPropertyChangedListener(m_le, fireState, propertiesFired, CheckType.Verification);

            // Verify element are not selected
            TS_VerifyElementsAreNotSelected(listElement, CheckType.Verification);

        }
Exemplo n.º 23
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Verify that the property changed
        /// </summary>
        /// -------------------------------------------------------------------
        internal void TS_VerifyLogicalStructureChangedEventArgs(AutomationElement element, EventFired shouldFire, StructureChangeType properties, CheckType checkType)
        {
            if (_testEvents)
            {
                Comment("Start: Looking for event that might have been fired");

                EventFired ActualFired = m_StructureChangedEvents.WasEventFired(element, properties);

                Comment("End : Looking for event that might have been fired");
                TestIfEventShouldFire(shouldFire, ActualFired, properties, checkType);
            }
            else
            {
                Comment("Not testing for events");
            }

            m_TestStep++;
        }
Exemplo n.º 24
0
 internal void Notify(NetworkEvent netEvent)
 {
     EventFired?.Invoke(netEvent);
 }
Exemplo n.º 25
0
        /// -------------------------------------------------------------------
        /// <summary>
        /// Verify focus changed
        /// </summary>
        /// -------------------------------------------------------------------
        internal void TSC_VerifyFocusedChangeEvent(AutomationElement element, EventFired shouldFire, string eventHandlerVar, CheckType checkType)
        {
            if (_testEvents)
            {
                Comment("Start: Looking for event that might have been fired");

                EventFired ActualFired = m_AutomationFocusChangedEvents.WasEventFired(element);

                Comment("End : Looking for event that might have been fired");
                TestIfEventShouldFire(shouldFire, ActualFired, null, checkType);
            }
            else
            {
                Comment("Not testing for events");
            }

            m_TestStep++;
        }
Exemplo n.º 26
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        void TestMove1(bool canMove, CheckType checkType, Type expectedException, WindowPosition placement, EventFired eventFired, Point point, bool moveWindowBackToOriginalPostion, HasFocus hasFocus)
        {
            Point oldPoint = new Point(m_le.Current.BoundingRectangle.Left, m_le.Current.BoundingRectangle.Top);

            try
            {
                //"Precondition: TransformPattern.CanMove == true", 
                TSC_VerifyPropertyEqual(pCanMove, canMove, TransformPattern.CanMoveProperty, CheckType.IncorrectElementConfiguration);

                //"Step: Ensure the AutomationElement does not have focus by calling SetFocus(AutomationElement.RootElement.FirstChild) - "OS's Start Button"",
                switch (hasFocus)
                {
                    case HasFocus.No:
                        TSC_SetFocusVerifyWithEvent(ControlFirstChild(AutomationElement.RootElement), CheckType.Verification);
                        break;

                    case HasFocus.DontCare:
                        break;

                    default:
                        throw new ArgumentException("Need to handle a HasFocus enum");
                }

                //"Step: Setup a BoundingRectangle PropertyChange event", 
                TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }, CheckType.Verification);

                //"Step: Verify that Move with the random point is called successfully", 
                TS_Move(point, expectedException, CheckType.Verification);

                //"Step: Wait for event to get fired",
                TSC_WaitForEvents(2);

                if (placement == WindowPosition.Exact)
                {
                    //"Verify: The BoundingRectangle PropertyChange event is fired",
                    TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { eventFired }, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }, CheckType.Verification);
                    if (eventFired == EventFired.True)
                    {
                        // Verify element was moved to the correct position by validating the BoundingRectangle
                        TS_VerifyBoundingRect(new Rect(point.X, point.Y, m_le.Current.BoundingRectangle.Width, m_le.Current.BoundingRectangle.Height), m_le.Current.BoundingRectangle, CheckType.Verification);
                    }
                    else
                    {
                        // Verify element was not moved to the correct position by validating the BoundingRectangle
                        TS_VerifyBoundingRect(new Rect(oldPoint.X, oldPoint.Y, m_le.Current.BoundingRectangle.Width, m_le.Current.BoundingRectangle.Height), m_le.Current.BoundingRectangle, CheckType.Verification);
                    }
                }
                else if (placement == WindowPosition.Within)
                {
                    // "Verify: The BoundingRectangle PropertyChange event is fired if the element is moved",
                    if (m_le.Current.BoundingRectangle.Left == point.X && m_le.Current.BoundingRectangle.Top == point.Y)
                    {
                        TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { EventFired.False }, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }, CheckType.Verification);
                    }
                    else
                    {
                        TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { EventFired.True }, new AutomationProperty[] { AutomationElement.BoundingRectangleProperty }, CheckType.Verification);
                    }

                    // OS does not allow off the screen so will move it back to a good location
                    TS_VerifyPlacedWithinScreen(CheckType.Verification);

                }

            }
            finally // incase we throw expection, come back and clean up
            {
                if (moveWindowBackToOriginalPostion)
                {
                    //"Step: Move the window back to it's original position",
                    Comment("Moving window back to it's original position");
                    if (oldPoint != new Point(m_le.Current.BoundingRectangle.Left, m_le.Current.BoundingRectangle.Top))
                        TS_Move(oldPoint, null, CheckType.Verification);
                    else
                        m_TestStep++;
                }
            }
        }
Exemplo n.º 27
0
        public void Publish_WhenProvidedMessageIsNotINServiceBusEventFired_ArgumentExceptionMustBeThrown()
        {
            var eventFired = new EventFired();

            Assert.Throws <ArgumentException>(() => this.testee.Publish(eventFired));
        }
Exemplo n.º 28
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        private void TestDriverNotAbleToRemoveFromSelection(bool canSelectMultiple)
        {
            // "Precondition: There is a selection container (ie. Win32 radio buttons do not have a selection container",
            TSC_VerifyPropertyEqual(_pattern.Current.SelectionContainer != null, true, SelectionItemPattern.SelectionContainerProperty, CheckType.IncorrectElementConfiguration);

            ArrayList otherElements = HelperSubtract(HelperGetContainersSelectableItems(_selectionContainer), new object[] { m_le });
            ArrayList listElement = new ArrayList();
            listElement.Add(otherElements[0]);

            AutomationProperty[] propertiesFired = new AutomationProperty[] { SelectionItemPattern.IsSelectedProperty };
            EventFired[] fireState = new EventFired[] { EventFired.False };

            // Precondition: Selection container's SelectionPattern.IsSelectionRequired should be *
            TS_SelectionRequired(true, CheckType.IncorrectElementConfiguration);

            // Precondition: Selection container's SelectionPattern.CanSelectMultiple should be *
            TS_CanSelectMultiple(canSelectMultiple, CheckType.IncorrectElementConfiguration);

            // "Step: Select some other element",
            TS_Select((AutomationElement)otherElements[0], null, CheckType.Verification);

            // Step: Add a SelectionItemPattern.IsSelectedProperty property change event
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, propertiesFired, CheckType.Verification);

            // Step: Remove element from selection and expect no exception
            TS_RemoveElementFromSelection(m_le, null, CheckType.Verification);

            // Verification: Verify that the SelectionItemPattern.IsSelectedProperty was not fired
            TSC_VerifyPropertyChangedListener(m_le, fireState, propertiesFired, CheckType.Verification);

            // Verify element is selected
            TS_VerifyElementsAreSelected(listElement, CheckType.Verification);

        }
Exemplo n.º 29
0
        public void PropertyChangeIsOffScreen1(TestCaseAttribute testCase)
        {
            HeaderComment(testCase);
            Rect originalRect = Rect.Empty;
            AutomationElement windowElement = null;
            Exception tempException = null;

            AutomationProperty[] properties = new AutomationProperty[] { AutomationElement.IsOffscreenProperty };
            EventFired[] eventsFired = new EventFired[] { EventFired.True };

            try
            {
                // Move the element to position 0,0 on the screen
                TS_MoveElementsWindow(m_le, 0, 0, out originalRect, out windowElement, CheckType.IncorrectElementConfiguration);

                // "Step: Add Property Change Listener",
                TSC_AddPropertyChangedListener(m_le, TreeScope.Element, properties, CheckType.Verification);

                // Move the element to position off the screen
                TS_MoveElementsWindow(windowElement, int.MaxValue / 2, int.MaxValue / 2, CheckType.IncorrectElementConfiguration);

                // "Step: Wait for 1 event",
                TSC_WaitForEvents(1);

                // "Verify: That a property change event was fired"
                TSC_VerifyPropertyChangedListener(m_le, eventsFired, properties, CheckType.Verification);

                // Move the element back onto the screen to position 0,0 on the screen
                TS_MoveElementsWindow(windowElement, 0, 0, CheckType.IncorrectElementConfiguration);

                // "Step: Wait for 1 event",
                TSC_WaitForEvents(1);

                // "Verify: That a property change event was fired"
                TSC_VerifyPropertyChangedListener(m_le, eventsFired, properties, CheckType.Verification);

                // Move the element to original location
                TS_MoveElementsWindow(windowElement, originalRect.X, originalRect.Y, CheckType.IncorrectElementConfiguration);
            }
            catch (TestErrorException exception)
            {
                tempException = exception;
            }
            finally
            {
                // Something might have failed the test, so let's make sure we put the window back to the original location
                if (windowElement != null && originalRect != Rect.Empty)
                {
                    TS_MoveElementsWindow(windowElement, originalRect.X, originalRect.Y, CheckType.IncorrectElementConfiguration);
                }
                if (tempException != null)
                    throw tempException;
            }

        }
Exemplo n.º 30
0
        public void PropertyChangeEnabled1(TestCaseAttribute testCaseAttribute)
        {
            HeaderComment(testCaseAttribute);

            Exception caughtException = null;

            try
            {

                AutomationProperty[] properties = new AutomationProperty[] { AutomationElement.NameProperty };
                EventFired[] eventsFired = new EventFired[] { EventFired.True };

                // "Precondition: Verify that this control supports testing PropertyChanges",
                TS_SupportsPropertyChangeEvents(CheckType.IncorrectElementConfiguration);

                // "Step: Reset the control to it's original state",
                TS_ResetControlToInitialState(m_le, CheckType.Verification);

                //"Step: Display the current AutomationElement.IsEnabledProperty",
                TSC_VerifyPropertyEqual(m_le.Current.IsEnabled, true, AutomationElement.IsEnabledProperty, CheckType.Verification);

                // "Step: Add Property Change Listener",
                TSC_AddPropertyChangedListener(m_le, TreeScope.Element, properties, CheckType.Verification);

                // "Step: Change the AutomationElement.IsEnabledProperty of the element",
                TS_CausePropertyChange(m_le, AutomationElement.IsEnabledProperty, CheckType.Verification);

                // "Step: Wait for 1 event",
                TSC_WaitForEvents(1);

                //"Step: Display the current AutomationElement.IsEnabledProperty",
                TSC_VerifyPropertyEqual(m_le.Current.IsEnabled, false, AutomationElement.IsEnabledProperty, CheckType.Verification);

                // "Verify: That a property change event was fired"
                TSC_VerifyPropertyChangedListener(m_le, eventsFired, properties, CheckType.Verification);
            }
            catch (Exception error)
            {
                caughtException = error;
            }
            finally
            {
                if (!(caughtException is IncorrectElementConfigurationForTestException))
                {

                    // Step: Reset the control to it's initial state
                    TS_ResetControlToInitialState(m_le, CheckType.Verification);

                    //"Step: Display the current AutomationElement.IsEnabledProperty",
                    TS_LogProperty(m_le, AutomationElement.IsEnabledProperty, CheckType.Verification);
                }

                if (caughtException != null)
                    throw caughtException;
            }

        }
Exemplo n.º 31
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        void SetValue_SetToRandomValue(ObjectTypes dataType, bool CanBeNull, bool ShouldBeReadOnly, bool MethodReturnValue, bool DoesValueChange, bool RandomValDifferentFromCurrentValue, EventFired eventFired, Type expectedException)
        {
            object val = pattern_Value;

            // Verify that control is not read only
            TS_VerifyReadOnly(ShouldBeReadOnly, CheckType.IncorrectElementConfiguration);

            // Verify that this control supports ######### types
            TS_VerifyObjectType(pattern_Value, dataType, CanBeNull, CheckType.IncorrectElementConfiguration);

            // Get a random valid value
            TS_GetRandomValue(out val, pattern_Value, dataType, true, RandomValDifferentFromCurrentValue, CheckType.Verification);

            // Add event that will catch PropertyChangeEvent
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification);

            // Set the pattern to this value
            TS_SetValue(val, MethodReturnValue, expectedException, CheckType.Verification);

            // Wait for event
            TSC_WaitForEvents(1);

            // Verify the pattern is set to this value
            TS_VerifyValue(val, DoesValueChange, CheckType.Verification);

            // Verify that the PropertyChangeEvent event is *
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { eventFired }, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification);
        }
Exemplo n.º 32
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        void SetValue_SetToSameValue(ObjectTypes dataType, object Value, EventFired eventFired)
        {
            object val;
            // Precondition: Verify that this control is not ReadOnly
            TS_VerifyReadOnly(false, CheckType.IncorrectElementConfiguration);

            // Precondition: Verify that this control supports #### types
            TS_VerifyObjectType(pattern_Value, dataType, true, CheckType.IncorrectElementConfiguration);

            // Get the current value
            TS_GetValue(out val, CheckType.Verification);

            // Add event that will catch PropertyChangeEvent 
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification);

            // Set the value of the pattern to the random string
            TS_SetValue(Value, true, null, CheckType.Verification);

            TSC_WaitForEvents(1);

            // Verify that the PropertyChangeEvent event is fired and the random string is passed into the event
            TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { eventFired }, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification);
        }
Exemplo n.º 33
0
        private void TrayAgent_SpeechActionFired(SpeechEventArgs e)
        {
            SynthesizerState state = speech.State;

            if (e.Actions == Actions.ABOUT || e.Actions == Actions.RESTORE || e.Actions == Actions.EXIT)
            {
                EventFired?.Invoke(e);
                return;
            }


            if (e.Actions == Actions.HOTKEY_FIRED)
            {
                string lang   = "";
                string newMD5 = "";

                string textBeforeCopy = Clipboard.GetText(TextDataFormat.Text);
                Util.Delay(10);
                clipboardBackup.Backup();

                Util.Delay(5);
                Util.PressKey(Keys.ControlKey, false);
                Util.Delay(5);
                Util.PressKey(Keys.C, false);
                Util.Delay(20);
                Util.PressKey(Keys.C, true);
                Util.Delay(5);
                Util.PressKey(Keys.ControlKey, true);
                Util.Delay(400);

                string text = Clipboard.GetText(TextDataFormat.Text);

                clipboardBackup.Restore();



                if (string.IsNullOrEmpty(text) || textBeforeCopy.Equals(text))
                {
                    sound.Play();

                    if (state == SynthesizerState.Speaking)
                    {
                        SpeakPause();
                        return;
                    }
                    if (state == SynthesizerState.Paused)
                    {
                        SpeakResume();
                        return;
                    }
                }

                Parallel.Invoke(() =>
                {
                    Debug.WriteLine("Begin GetMd5Hash task...");
                    newMD5 = Util.GetMd5Hash(text);
                    Debug.WriteLine("End GetMd5Hash task...");
                }, () =>
                {
                    Debug.WriteLine("Begin languageDetection task...");
                    lang = languageDetection.Detect(text);
                    Debug.WriteLine("End languageDetection task...");
                }, () =>
                {
                    Debug.WriteLine("Begin Beep task...");
                    sound.Play();
                    Debug.WriteLine("End Beep task...");
                }
                                );

                //if the text is the same
                if (newMD5.Equals(md5))
                {
                    if (speech.State == SynthesizerState.Ready)
                    {
                        md5 = "";
                    }

                    if (state == SynthesizerState.Speaking)
                    {
                        SpeakPause();
                    }
                    if (state == SynthesizerState.Paused)
                    {
                        SpeakResume();
                    }
                }
                //if the text has changed
                if (!newMD5.Equals(md5))
                {
                    SpeakStop();
                    SpeakStart(text, lang);
                    md5 = newMD5;
                }
            }
        }
Exemplo n.º 34
0
        /// -------------------------------------------------------------------
        /// <summary></summary>
        /// -------------------------------------------------------------------
        private void TestDriverSelect2(bool isSelectionRequired, bool canSelectMultiple)
        {
            // "Precondition: There is a selection container (ie. Win32 radio buttons do not have a selection container",
            TSC_VerifyPropertyEqual(_pattern.Current.SelectionContainer != null, true, SelectionItemPattern.SelectionContainerProperty, CheckType.IncorrectElementConfiguration);

            ArrayList listOther = HelperSubtract(HelperGetContainersSelectableItems(_selectionContainer), new object[] { m_le });
            ArrayList listElement = new ArrayList();
            listElement.Add(m_le);

            AutomationProperty[] propertiesFired = new AutomationProperty[] { SelectionItemPattern.IsSelectedProperty };
            EventFired[] fireState = new EventFired[] { EventFired.True };

            // Precondition: Selection container's SelectionPattern.IsSelectionRequired should be *
            TS_SelectionRequired(isSelectionRequired, CheckType.IncorrectElementConfiguration);

            // Precondition: Selection container's SelectionPattern.CanSelectMultiple should be *
            TS_CanSelectMultiple(canSelectMultiple, CheckType.IncorrectElementConfiguration);

            // Step: Select some other element incase selection required
            TS_Select((AutomationElement)listOther[0], null, CheckType.IncorrectElementConfiguration);

            //  Step: Add a SelectionItemPattern.IsSelectedProperty property change event
            TSC_AddPropertyChangedListener(m_le, TreeScope.Element, propertiesFired, CheckType.Verification);

            // Step: Select the element
            TS_Select(m_le, null, CheckType.Verification);

            // Step: Wait for one event to fire
            TSC_WaitForEvents(1);

            // Verification: Verify that the SelectionItemPattern.IsSelectedProperty was fired
            TSC_VerifyPropertyChangedListener(m_le, fireState, propertiesFired, CheckType.Verification);

            // Verify element is selected
            TS_VerifyElementsAreSelected(listElement, CheckType.Verification);

        }