예제 #1
0
        public void RunTest()
        {
            var frameworksToRun = SupportedFrameworks();

            foreach (var framework in frameworksToRun)
            {
                currentFramework = framework;
                using (SetMainWindow(framework))
                {
                    try
                    {
                        RunTest(framework);
                    }
                    catch (TestFailedException)
                    {
                        throw;
                    }
                    catch (Exception ex)
                    {
                        throw new TestFailedException(string.Format("Failed to run test for {0}", framework), ex);
                    }
                }
            }
            currentFramework = null;
        }
예제 #2
0
        private void GetMultipleButtons(WindowsFramework framework)
        {
            MainWindow.Get<Button>("GetMultipleButton").Click();
            var window = MainWindow.ModalWindow("GetMultiple");

            try
            {
                var buttons = window.GetMultiple(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "Button")).OfType<Button>();
                Assert.AreEqual(3, buttons.Count());

                if (framework == WindowsFramework.Wpf)
                {
                    buttons = window.GetMultiple(SearchCriteria.ByAutomationId("Test")).OfType<Button>();
                    Assert.AreEqual(3, buttons.Count());
                }

                var checkboxes = window.GetMultiple(SearchCriteria.ByControlType(ControlType.CheckBox)).OfType<CheckBox>();
                Assert.AreEqual(3, checkboxes.Count());

                checkboxes = window.GetMultiple(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "Checkbox")).OfType<CheckBox>();
                Assert.AreEqual(3, checkboxes.Count());

                if (framework == WindowsFramework.Wpf)
                {
                    checkboxes = window.GetMultiple(SearchCriteria.ByAutomationId("Test2")).OfType<CheckBox>();
                    Assert.AreEqual(3, checkboxes.Count());
                }
            }
            finally
            {
                window.Close();
            }
        }
예제 #3
0
 protected override void RunTest(WindowsFramework framework)
 {
     listBoxUnderTest = MainWindow.Get<ListBox>("CheckedListBox");
     RunTest(CanCheckItem);
     RunTest(CheckSelectedItem);
     RunTest(CheckUncheckItem);
 }
예제 #4
0
 protected override void RunTest(WindowsFramework framework)
 {
     var window = OpenVerticalSliderWindow();
     using (new DelegateDisposable(() => CloseSliderWindow(window)))
     {
         RunTest(() => Find(window));
         RunTest(() => Slide(window));
     }
 }
예제 #5
0
        protected override void RunTest(WindowsFramework framework)
        {
            DataGridUnderTest = MainWindow.Get<ListView>(SearchCriteria.ByAutomationId("DataGridControl"));
            var customControl = MainWindow.Get(SearchCriteria.ByAutomationId("CustomDataGridControl")) as UIItem;
            DataGridFromCustomControlUnderTest = customControl.Get<ListView>(SearchCriteria.ByAutomationId("DataGridControl"));

            RunTest(() => CanGetAllItems(DataGridUnderTest));
            RunTest(() => CanGetAllItems(DataGridFromCustomControlUnderTest));
            RunTest(() => CanGetCell(DataGridUnderTest));
            RunTest(() => CanGetCell(DataGridFromCustomControlUnderTest));
        }
예제 #6
0
 protected override void RunTest(WindowsFramework framework)
 {
     CoreAppXmlConfiguration.Instance.LoggerFactory = new ConsoleFactory(LoggerLevel.Debug);
     ComboBoxUnderTest = MainWindow.Get<ComboBox>(SearchCriteria.ByAutomationId("AComboBox"));
     RunTest(ListItemInComboBoxWithoutTextAvailableInitially, WindowsFramework.Wpf);
     RunTest(CanSelectItemAtTopOfList);
     RunTest(CanGetAllItems);
     RunTest(CanSelectItemAtBottomOfList);
     RunTest(CanSelectItemAtTopOfList); // Once an item is selected at the bottom of the list, White couldn't select at the top again
     RunTest(CanSelectByIndex);
     RunTest(CanSelectReallyLongText);
     RunTest(SetValue);
 }
        internal static Window Create(AutomationElement element, InitializeOption option, WindowSession windowSession)
        {
            SpecializedWindowFactory specializedWindowFactory = specializedWindowFactories.Find(factory => factory.DoesSpecializedThis(element));
            if (specializedWindowFactory != null)
            {
                return specializedWindowFactory.Create(element, option, windowSession);
            }

            var windowsFramework = new WindowsFramework(element.Current.FrameworkId);
            if (windowsFramework.WinForm) return new WinFormWindow(element, option, windowSession);
            if (windowsFramework.WPF) return new WPFWindow(element, WindowFactory.Desktop, option, windowSession);
            if (windowsFramework.Win32) return new Win32Window(element, WindowFactory.Desktop, option, windowSession);
            if (windowsFramework.UIAutomationBug) return null;
            throw new UIItemSearchException(string.Format("{0} is not supported yet.", windowsFramework));
        }
예제 #8
0
 private static SearchCriteria SearchCondition(FieldInfo fieldInfo, WindowsFramework framework)
 {
     SearchCriteria defaultCriteria = SearchCriteria.ByAutomationId(fieldInfo.Name).AndControlType(fieldInfo.FieldType, framework);
     SearchCriteria searchCriteria = null;
     object[] customAttributes = fieldInfo.GetCustomAttributes(false);
     foreach (Attribute customAttribute in customAttributes)
     {
         var searchCriteriaAttribute = customAttribute as SearchCriteriaAttribute;
         if (searchCriteriaAttribute != null)
         {
             if (searchCriteria == null) searchCriteria = SearchCriteria.ByControlType(fieldInfo.FieldType, framework);
             searchCriteriaAttribute.Apply(searchCriteria);
         }
     }
     return searchCriteria ?? defaultCriteria;
 }
예제 #9
0
 public static TestConfiguration Create(WindowsFramework framework)
 {
     switch (framework.FrameworkId)
     {
         case Constants.WPFFrameworkId:
             return new WpfTestConfiguration();
         case Constants.WinFormFrameworkId:
             return new WinformsTestConfiguration();
         case Constants.SilverlightFrameworkId:
             return new SilverlightTestConfiguration();
         case Constants.Win32FrameworkId:
         case Constants.SWT:
         //case Constants.WinRT:
         default:
             throw new ArgumentOutOfRangeException("framework");
     }
 }
예제 #10
0
파일: UIItemTests.cs 프로젝트: ritro/White
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(can_click_on_elements_located_by_searching_through_several_containers);
 }
예제 #11
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(SelectUnselect);
     RunTest(CheckAndUncheckCheckbox);
 }
예제 #12
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(() => GetMultipleButtons(framework));
 }
예제 #13
0
 protected abstract void RunTest(WindowsFramework framework);
예제 #14
0
 protected WindowsConfiguration(WindowsFramework framework)
 {
     this.framework = framework;
 }
예제 #15
0
        private IDisposable SetMainWindow(WindowsFramework framework)
        {
            try
            {
                Keyboard = Keyboard.Instance;
                var configuration = TestConfigurationFactory.Create(framework);
                Application = configuration.LaunchApplication();
                MainWindow = configuration.GetMainWindow(Application);

                return new ShutdownApplicationDisposable(this);
            }
            catch (Exception e)
            {
                logger.Error("Failed to launch application and get main window", e);
                if (Application != null)
                    Application.Close();
                throw;
            }
        }
예제 #16
0
 protected override void RunTest(WindowsFramework framework)
 {
     ComboBoxUnderTest = MainWindow.Get<ComboBox>("DataBoundComboBox");
     RunTest(CanSelectDataboundItems);
 }
예제 #17
0
 public FrameworkIdAttribute(WindowsFramework framework)
 {
     this.framework = framework;
 }
예제 #18
0
 protected override void RunTest(WindowsFramework framework)
 {
     ComboBoxUnderTest = MainWindow.Get<ComboBox>("EditableComboBox");
     RunTest(SetValueInEditableComboBox);
     RunTest(SelectItemInEditableComboBox);
 }
예제 #19
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(ClickTitleBarClose);
 }
예제 #20
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(() => GetDate(DateTime.Today), WindowsFramework.WinForms);
     RunTest(() => GetDate(null), WindowsFramework.Wpf, WindowsFramework.Silverlight);
     RunTest(SetDate);
 }
예제 #21
0
 protected override void RunTest(WindowsFramework framework)
 {
     RunTest(CanGetTooltip);
 }
예제 #22
0
 public FrameworkIdAttribute(string id)
 {
     framework = new WindowsFramework(id);
 }