/// <summary> /// Tests to determine if the current platform is supported /// based on a platform attribute. /// </summary> /// <param name="testCaseAttribute">The attribute to examine</param> /// <returns></returns> public bool IsPlatformSupported(TestCaseAttribute testCaseAttribute) { string include = testCaseAttribute.IncludePlatform; string exclude = testCaseAttribute.ExcludePlatform; return(IsPlatformSupported(include, exclude)); }
public void TestExpandS15(TestCaseAttribute checkType) { HeaderComment(checkType); //"Precondition: Verify that this is not a leaf node", TSC_VerifyProperty(pattern_getExpandCollapseState, ExpandCollapseState.LeafNode, false, ExpandCollapsePattern.ExpandCollapseStateProperty.ToString(), CheckType.IncorrectElementConfiguration); //"Step: Call Expand()", TS_Collapse(null, CheckType.IncorrectElementConfiguration); //"Step: Call Expand() twice in case of ExpandCollapseState = PartialExpanded", TS_Collapse(null, CheckType.IncorrectElementConfiguration); // "Step: Verify that the ExpandCollapseState = Collapsed", TS_VerifyState(new object[] { ExpandCollapseState.LeafNode, ExpandCollapseState.Collapsed }, true, CheckType.Verification); //"Step: Add StatePropertyChange event", TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { ExpandCollapsePattern.ExpandCollapseStateProperty }, CheckType.Verification); //"Step: Call Expand() and verify that Expand() returns true", TS_Expand(null, CheckType.Verification); // Wait for events TSC_WaitForEvents(1); //"Step: Verify that the ExpandCollapseState != Collapsed", TS_VerifyState(new object[] { ExpandCollapseState.Collapsed }, false, CheckType.Verification); //"Step: Verify that the StatePropertyChange event was fired" TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { EventFired.True }, new AutomationProperty[] { ExpandCollapsePattern.ExpandCollapseStateProperty }, CheckType.Verification); }
public static void ExecuteTest(MethodInfo method) { Game.LogTrivial($"START EXECUTING TEST: {method.Name}"); TestCaseAttribute att = method.GetCustomAttribute <TestCaseAttribute>(); if (att == null) { Game.LogTrivial($"FAILED TO EXECUTE TEST: {method.Name}"); Game.LogTrivial($" The method {method.Name} doesn't have the {nameof(TestCaseAttribute)}"); Game.Console.Print(); return; } try { method.Invoke(null, null); Game.LogTrivial($"FINISHED EXECUTING TEST: {method.Name}"); } catch (Exception ex) { Game.LogTrivial($"FAILED TO EXECUTE TEST: {method.Name}"); Game.LogTrivial($" Exception:{Environment.NewLine}{ex}"); Game.Console.Print(); Game.DisplayHelp($"~r~Test {method.Name} failed!"); } }
public void TestTableItemContainingGridPropertyS13(TestCaseAttribute checkType) { HeaderComment(checkType); int col; int row; AutomationElement cell = null; //"Step: Get the AutomationElement's col", TS_GetColumn(out col, CheckType.Verification); //"Step: Get the AutomationElement's row", TS_GetRow(out row, CheckType.Verification); //"Step: Add and event listener for ContainingGridProperty property change event", TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { TableItemPattern.ContainingGridProperty }, CheckType.Verification); //"Step: Call containing table's GetCell(row, col)", TS_GetCell(row, col, out cell, CheckType.Verification); // "Step: Wait for event to occur", TSC_WaitForEvents(1); //"Step: Verify that listener for ContainingGridProperty property change event did not fire", TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { EventFired.False }, new AutomationProperty[] { TableItemPattern.ContainingGridProperty }, CheckType.Verification); //"Step: Verify that AutomationElement and one from GetCell() are the same" TS_AreTheseTheSame(m_le, cell, true, CheckType.Verification); }
public void Toggle21(TestCaseAttribute testCase, object[] argument) { try { HeaderComment(testCase); if (argument == null) { throw new ArgumentException(); } if (argument[0] == null) { throw new ArgumentException(); } if (argument.Length != 1) { throw new ArgumentException(); } // Get the value passed into the test case ToggleState expectedValue = (ToggleState)(argument[0]); TS_VerifyToggleState(expectedValue, true, CheckType.Verification); } catch (Exception e) { throw e; /* amd64fre does not include this function (1st called in assembly?) in the trace unless we do this */ } }
public void InvokeWithKeyboard(TestCaseAttribute testCaseAtrribute) { HeaderComment(testCaseAtrribute); //"Precondition: Verify that Invoke event will get fired for this element", TS_IsInvokeEventAppropriateOnObject(m_le); //"Precondtion: user can set focus to the element", TSC_VerifyPropertyEqual(m_le.Current.IsKeyboardFocusable, true, AutomationElement.IsKeyboardFocusableProperty, CheckType.IncorrectElementConfiguration); //"Precondition: Verify that invoking this element is not a know desctructive action such as a Close button TS_InvokeIsDestructive(m_le, CheckType.IncorrectElementConfiguration); //"Step: Add InvokePattern.InvokedEvent event on the AutomationElement", TSC_AddEventListener(m_le, InvokePattern.InvokedEvent, TreeScope.Element, CheckType.Verification); //"Step: Set focus to the element, if that can be done TS_SetFocus(m_le, null, CheckType.Verification); //"Step: Press whatever key is needed to invoke the element TS_InvokeWithKeyboard(m_le, CheckType.Verification); // Step: Wait for event", TSC_WaitForEvents(2); //"Step: Verify that AutomationElement fired a FocusChange event TSC_VerifyEventListener(m_le, InvokePattern.InvokedEvent, _eventAppropriate, CheckType.Verification); }
public void InvokeS12(TestCaseAttribute testCaseAtrribute) { HeaderComment(testCaseAtrribute); //"Precondition: Verify that this control supports SetFocus tests", TS_VerifySetFocusIsOK(m_le, CheckType.IncorrectElementConfiguration); //"Step: Verify that Invoke event will get fired for this element", TS_IsInvokeEventAppropriateOnObject(m_le); //"Precondition: Verify that invoking this element is not a know desctructive action such as a Close button TS_InvokeIsDestructive(m_le, CheckType.IncorrectElementConfiguration); //"Step: Add InvokePattern.InvokedEvent event on the AutomationElement", TSC_AddEventListener(m_le, InvokePattern.InvokedEvent, TreeScope.Element, CheckType.Verification); //"Step: Call and verify that SetFocus(AutomationElement) returns true" TSC_MouseClick(m_le, CheckType.IncorrectElementConfiguration); // Step: Wait for event", TSC_WaitForEvents(1); //"Step: Verify that AutomationElement fired a FocusChange event TSC_VerifyEventListener(m_le, InvokePattern.InvokedEvent, _eventAppropriate, CheckType.Verification); }
public void InvokeS11b(TestCaseAttribute testCaseAtrribute) { HeaderComment(testCaseAtrribute); //"Step: Verify that Invoke event will get fired for this element", TS_IsInvokeEventAppropriateOnObject(m_le); // "Precondition: Verify that the element is enabled", TS_ElementEnabled(m_le, true, CheckType.IncorrectElementConfiguration); //"Precondition: Verify that invoking this element is not a know desctructive action such as a Close button TS_InvokeIsDestructive(m_le, CheckType.IncorrectElementConfiguration); //"Step: Add InvokePattern.InvokedEvent event on the AutomationElement", TSC_AddEventListener(m_le, InvokePattern.InvokedEvent, TreeScope.Element, CheckType.Verification); //"Verify: Call Invoke()", TSC_Invoke(CheckType.Verification); // Step: Wait for event", TSC_WaitForEvents(1); //"Step: Verify that AutomationElement fired a FocusChange event TSC_VerifyEventListener(m_le, InvokePattern.InvokedEvent, _eventAppropriate, CheckType.Verification); }
public void TestSetValue119(TestCaseAttribute testCase) { HeaderComment(testCase); ControlType ct = m_le.Current.ControlType; if (ct == null) { ThrowMe(CheckType.IncorrectElementConfiguration, "Cannot determine if control will accept '' since AutomationElement.ControlTypeProperty returns null"); } if (ct == ControlType.Custom) { ThrowMe(CheckType.IncorrectElementConfiguration, "Cannot determine if control will accept '' since AutomationElement.ControlTypeProperty returns ControlType.Custom"); } // Which controls support value??? if ((ct != ControlType.Edit) && (ct != ControlType.ListItem) && (ct != ControlType.TreeItem) ) { ThrowMe(CheckType.IncorrectElementConfiguration, Helpers.GetProgrammaticName(ct) + " do not support ''"); } SetValue_Test1(false, "", testCase); }
public void GetRowOrColumnMajor(TestCaseAttribute testCaseAtrribute) { HeaderComment(testCaseAtrribute); RowOrColumnMajor retrievedRowOrColumnMajor; //Step: Get the RowOrColumnMajor TS_GetRowOrColumnMajor(out retrievedRowOrColumnMajor, CheckType.Verification); if (retrievedRowOrColumnMajor == RowOrColumnMajor.RowMajor) { Comment("RowOrColumnMajor is RowMajor"); } else if (retrievedRowOrColumnMajor == RowOrColumnMajor.ColumnMajor) { Comment("RowOrColumnMajor is ColumnMajor"); } else if (retrievedRowOrColumnMajor == RowOrColumnMajor.Indeterminate) { Comment("RowOrColumnMajor is Indeterminate"); } else { ThrowMe(CheckType.Verification, "{0} : returned for RowOrColumnMajor", retrievedRowOrColumnMajor); } }
public void TestWindowModalS101(TestCaseAttribute testCase) { HeaderComment(testCase); // Precondition: Resizable = false TSC_VerifyPropertyEqual(pattern_getIsModal, true, WindowPattern.IsModalProperty, CheckType.IncorrectElementConfiguration); }
public void AvalonScenario2(TestCaseAttribute testCase, object[] arguments) { // Validate arguments passed to test if (arguments == null) { throw new ArgumentException("arguments is null"); } if (arguments[0] == null) { throw new ArgumentException("arguments[0] is null"); } if (arguments[1] == null) { throw new ArgumentException("arguments[1] is null"); } if (arguments.Length != 2) { throw new ArgumentException("arguments is wrong length"); } if (!(arguments[0] is string) || !(arguments[1] is string)) { throw new ArgumentException("arguments are of wrong type"); } // cast arguments to local variables string string1 = (string)arguments[0]; string string2 = (string)arguments[1]; HeaderComment(testCase); // Pre-condition: Get Scenario Pre-Conditions TS_ScenarioPreConditions(true, CheckType.IncorrectElementConfiguration); // Cause test to suceed or fail based on value of second string argument Comment("string1 = " + string1); Comment("string2 = " + string2); if (string2 == "IncorrectElementConfiguration") { ThrowMe(CheckType.IncorrectElementConfiguration, "Some condition required for the test to actually be performed wasn't met. " + "Exit gracefully without setting a failure condition for this scenario"); } else if (string2 == "Verification") { ThrowMe(CheckType.Verification, "Test failed, call ThrowMe with CheckType.Verification to log this test scenario as a failure"); } else { Comment("This test has passed"); } m_TestStep++; // increment counter as a best practice }
public TestNode(XmlDocument document, int step, string message, string methodName, bool isClientSideProvider, TestCaseAttribute testCaseAttribute, string verificationMethod, string controlPath) { Document = document; Step = step; MethodName = methodName; IsClientSideProvider = isClientSideProvider.ToString().Substring(0, 1).ToUpper(); Attribute = testCaseAttribute; VerificationMethod = verificationMethod; ControlPath = controlPath; Message = message; }
private static TestCaseAttribute ToTestCaseAttribute(TestAttribute testAttr) { var testCaseAttr = new TestCaseAttribute(); testAttr.Author?.With(x => testCaseAttr.Author = x); testAttr.Description?.With(x => testCaseAttr.Description = x); testAttr.ExpectedResult?.With(x => testCaseAttr.ExpectedResult = x); testAttr.TestOf?.With(x => testCaseAttr.TestOf = x); return(testCaseAttr); }
/// <summary> /// /// </summary> /// <param name="xmlNodeObjectID">XmlNode that idetifies the object to test. This can be as simple as the name of the control, to a node that represents the path</param> /// <param name="testCaseAttribute"></param> /// <param name="methodInfo">MethodInfo of the method of the test</param> public StartTestInfo(XmlNode xmlNodeObjectID, TestCaseAttribute testCaseAttribute, MethodInfo methodInfo) { this.XmlNodeObjectID = xmlNodeObjectID; this.TestAttribute = testCaseAttribute; this.MethodInfo = methodInfo; StringBuilder possibleIssuesMessageBuilder = new StringBuilder(); this.PossibleIssuesMessage = possibleIssuesMessageBuilder.ToString(); }
public void StaticsDontHaveLabels(TestCaseAttribute testCaseAttribute) { HeaderComment(testCaseAttribute); //"Precondition: Classname is 'Static'", TSC_VerifyPropertyEqual(m_le.Current.ClassName.ToLower(), "static", AutomationElement.ClassNameProperty, CheckType.IncorrectElementConfiguration); //"Verify: LabeledBy == null", TSC_VerifyPropertyEqual(m_le.Current.LabeledBy, null, AutomationElement.LabeledByProperty, CheckType.Verification); }
public void AccessOneCharacter(TestCaseAttribute testCaseAttribute) { HeaderComment(testCaseAttribute); //"Precondition: There is an access key character", TSC_VerifyProperty(m_le.Current.AccessKey.Length, 0, false, AutomationElement.AcceleratorKeyProperty, CheckType.IncorrectElementConfiguration); //"Verify: AccessKey length must be one character in length", TSC_VerifyProperty(m_le.Current.AccessKey.Length, 1, true, AutomationElement.AcceleratorKeyProperty, CheckType.Verification); }
public void TestSetValue12(TestCaseAttribute testCase) { HeaderComment(testCase); if (m_le.Current.ControlType != ControlType.Edit) { ThrowMe(CheckType.IncorrectElementConfiguration, "Test is designed for edit control"); } SetValue_Test1(false, "", testCase); }
public void Layout1(TestCaseAttribute testCaseAttribute) { HeaderComment(testCaseAttribute); // "Precondition: This is a vertical scrollbar", TSC_VerifyPropertyEqual(m_le.GetCurrentPropertyValue(AutomationElement.OrientationProperty), OrientationType.Vertical, AutomationElement.OrientationProperty, CheckType.IncorrectElementConfiguration); // "If this is a non Right to Left layout, the bounding rectangle will be on the right side, if Right to Left, bounding rectangle will be on the left side of the parent control", TS_VerifyLayout(m_le, CheckType.Verification); }
public void AvalonScenario1(TestCaseAttribute testCase) { HeaderComment(testCase); // Pre-condition: Get Scenario Pre-Conditions TS_ScenarioPreConditions(true, CheckType.IncorrectElementConfiguration); // TBD Comment("This test has passed"); m_TestStep++; }
public void TestSetValue11(TestCaseAttribute testCase) { try { HeaderComment(testCase); SetValue_Test1(false, Helpers.GetRandomValidValue(m_le, null), testCase); } catch (Exception e) { throw e; /* amd64fre does not include this function (1st called in assembly?) in the trace unless we do this */ } }
public void TestValuePropertyS21(TestCaseAttribute checkType) { HeaderComment(checkType); // Verify Minimum is less than Maximum TSC_VerifyMinLessThanMax(CheckType.Verification); object i = pattern_Value; // Verify that Minimum <= Value <= Maximium TS_VerifyMinimumLessThanEqualValueAsObjectLessThanEqualMaximum(patternMinimum, pattern_Value, patternMaximum, CheckType.Verification); }
public void GetColumnSpanValue(TestCaseAttribute testCaseAtrribute) { HeaderComment(testCaseAtrribute); int retrievedColumnSpanVal; TS_GetColumnSpan(out retrievedColumnSpanVal, CheckType.Verification); Comment("ColumnSpan Value is {0}", retrievedColumnSpanVal); if (retrievedColumnSpanVal < 0) { ThrowMe(CheckType.Verification, "{0} : negative value returned for ColumnSpan value on the Table Item", retrievedColumnSpanVal); } }
public void Toggle14(TestCaseAttribute testCase) { try { HeaderComment(testCase); TestToggle1(ToggleState.Off, EventFired.True, true); } catch (Exception e) { throw e; /* amd64fre does not include this function (1st called in assembly?) in the trace unless we do this */ } }
public void TestMinimizePropertyS72(TestCaseAttribute testCase) { HeaderComment(testCase); // "Precondition: Minimizable property is false",, TSC_VerifyPropertyEqual(pattern_getCanMinimize, false, WindowPattern.CanMinimizeProperty, CheckType.IncorrectElementConfiguration); // "Verify that you cannot set the VisualState property to WindowVisualState.Minimizable", TS_VerifySetVisualState(WindowVisualState.Minimized, typeof(InvalidOperationException), CheckType.Verification); // "Verify that the WindowVisualState is not WindowVisualState.Minimizable after setting the property" TS_VerifyVisualState(WindowVisualState.Minimized, false, CheckType.Verification); }
public void GetColumnNumber(TestCaseAttribute testCaseAtrribute) { HeaderComment(testCaseAtrribute); int retrievedColumnNum; TS_GetColumn(out retrievedColumnNum, CheckType.Verification); Comment("Column Number is {0}", retrievedColumnNum); if (retrievedColumnNum < 0) { ThrowMe(CheckType.Verification, "{0} : negative value returned for Column number on the Table Item", retrievedColumnNum); } }
public void IsTextPatternAvailableProperty1(TestCaseAttribute testCaseAttribute) { HeaderComment(testCaseAttribute); // "Precondition: Element has a valid hwnd", TSC_VerifyProperty(m_le.Current.NativeWindowHandle, 0, false, AutomationElement.NativeWindowHandleProperty, CheckType.IncorrectElementConfiguration); // "Verification: HelpTextProeprty != null", TSC_VerifyProperty(m_le.Current.FrameworkId, "Win32", true, AutomationElement.FrameworkIdProperty, CheckType.IncorrectElementConfiguration); // "Verification: HelpTextProeprty != \"\"", TSC_VerifyPropertyEqual((bool)m_le.GetCurrentPropertyValue(AutomationElement.IsTextPatternAvailableProperty), false, AutomationElement.IsTextPatternAvailableProperty, CheckType.Verification); }
// No controlled environment test cases #endregion ValueProperty #region IsReadOnlyProperty // No controlled environment test cases #endregion IsReadOnlyProperty #endregion Tests #region Test Wrappers /// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- void SetValue_Test1(bool readOnly, object newValue, TestCaseAttribute testCaseAttribute) { object oldValue; ControlType ct = m_le.Current.ControlType; if (m_le.Current.IsPassword) { ThrowMe(CheckType.IncorrectElementConfiguration, "Cannot verify setting Password controls"); } if (ct == ControlType.Custom) { ThrowMe(CheckType.IncorrectElementConfiguration, "Cannot verify setting ControlType.Custom is correct"); } if (m_le.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty) == ControlType.ScrollBar) { ThrowMe(CheckType.IncorrectElementConfiguration, "Cannot verify correctness of setting the scrollbar's value since we do not know valid values that can be set"); } // Verify ReadOnly = false TS_VerifyReadOnly(readOnly, CheckType.IncorrectElementConfiguration); if (ct == null) { ThrowMe(CheckType.IncorrectElementConfiguration, "Cannot determine specific control since AutomationElement.ControlTypeProperty returns null"); } Comment("DataType: " + newValue.GetType() + "; New Value: " + newValue); // Get the value of the current Value TS_GetValue(out oldValue, CheckType.IncorrectElementConfiguration); // Verify that the old value does not equal the new random value TS_VerifyObjectNotEqual(newValue, oldValue, CheckType.IncorrectElementConfiguration); // 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(newValue, true, null, CheckType.Verification); // Wait for event 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.True }, new AutomationProperty[] { ValuePattern.ValueProperty }, CheckType.Verification); // Verify that Value is set correctly to the new value TS_VerifyValue(newValue, true, CheckType.Verification); }
public void GetColumnCount(TestCaseAttribute testCaseAtrribute) { HeaderComment(testCaseAtrribute); int retrievedColumnCount; //Step: Get the ColumnCount TS_GetColumnCount(out retrievedColumnCount, CheckType.Verification); Comment("ColumnCount is {0}", retrievedColumnCount); if (retrievedColumnCount < 0) { ThrowMe(CheckType.Verification, "{0} : negative value returned for ColumnCount", retrievedColumnCount); } }
public void GetRowNumber(TestCaseAttribute testCaseAtrribute) { HeaderComment(testCaseAtrribute); int retrievedRowNum; //"Step: Get the AutomationElement's row", TS_GetRow(out retrievedRowNum, CheckType.Verification); Comment("Row Number is {0}", retrievedRowNum); if (retrievedRowNum < 0) { ThrowMe(CheckType.Verification, "{0} : negative value returned for Row number on the Table Item", retrievedRowNum); } }
/// <summary> /// Tests to determine if the current platform is supported /// based on a platform attribute. /// </summary> /// <param name="testCaseAttribute">The attribute to examine</param> /// <returns></returns> public bool IsPlatformSupported(TestCaseAttribute testCaseAttribute) { string include = testCaseAttribute.IncludePlatform; string exclude = testCaseAttribute.ExcludePlatform; return IsPlatformSupported(include, exclude); }
public StandaloneTest (Type testType, TestCaseAttribute info) { if (testType == null) throw new ArgumentNullException ("testType"); if (info == null) throw new ArgumentNullException ("info"); TestType = testType; Info = info; }