コード例 #1
0
        private void ShowTopLevel(Control control, object[] propertyObjects, bool modal, Action <Form> shownAction)
        {
            //if (TestContext.CurrentContext.Test.Properties["_CATEGORIES"])

            ThrowIfPropertyObjectsContainsActionDueToLikelyMisuse(propertyObjects);

            GuiTestHelper.Initialize();

            formShown = shownAction;

            if (control.TopLevelControl == control)
            {
                ShowTopLevelControl(control, modal);
            }
            else
            {
                ShowControlInTestForm(control, modal, propertyObjects);
            }

            // clear all controls shown as non-modal after modal control closes
            if (!modal)
            {
                var testName = TestContext.CurrentContext.Test.FullName;

                if (string.IsNullOrEmpty(nonModalControlsTestName))
                {
                    nonModalControlsTestName = testName;
                }
                else
                {
                    if (nonModalControlsTestName != testName)
                    {
                        var errorMessage = string.Format("Did you forget to call WindowsFormsTestHelper.CloseAll() at the end of the following test: {0}?", nonModalControlsTestName);
                        nonModalControlsTestName = testName; // reset for the next test
                        throw new InvalidOperationException(errorMessage);
                    }
                }

                nonModalControls.Add(this);
            }
            else
            {
                CloseAll();

                Close();
                Dispose();

                control.Dispose();
            }
        }
コード例 #2
0
        public WindowsFormsTestHelper()
        {
            AllowDrop = false; // prevent STA DragDrop exceptions

            System.Windows.Forms.Application.EnableVisualStyles();

            CheckForIllegalCrossThreadCalls = true;
            Application.EnableVisualStyles();
            SetStyle(
                ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw |
                ControlStyles.UserPaint, true);
            InitializeComponent();

            guiTestHelper = GuiTestHelper.Instance;
        }
コード例 #3
0
        public WindowsFormsTestHelper()
        {
            AllowDrop = false; // prevent STA DragDrop exceptions

            System.Windows.Forms.Application.EnableVisualStyles();

            CheckForIllegalCrossThreadCalls = true;
            Application.EnableVisualStyles();
            SetStyle(
                ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw |
                ControlStyles.UserPaint, true);
            InitializeComponent();

            guiTestHelper = GuiTestHelper.Instance;
        }
コード例 #4
0
        private void ShowTopLevel(Control control, object[] propertyObjects, bool modal, Action shownAction)
        {
            ThrowIfPropertyObjectsContainsActionDueToLikelyMisuse(propertyObjects);

            GuiTestHelper.Initialize();

            this.shownAction = shownAction;

            if (control is Window)
            {
                ShowTopLevelControl(control, modal);
            }
            else
            {
                ShowControlInTestForm(control, modal, propertyObjects);
            }

            // clear all controls shown as non-modal after modal control closes
            if (!modal)
            {
                throw new NotImplementedException();
            }
            else
            {
                WindowsFormsTestHelper.CloseAll(); // just in case, since we have mixed WPF / WF app

                Close();

                if (window != null)
                {
                    window.Closed += delegate { Console.WriteLine("Closed"); };

                    window.Close();
                    window.Close();

                    while (window.IsVisible)
                    {
                        System.Windows.Forms.Application.DoEvents();
                    }

                    window = null;
                }
            }
        }
コード例 #5
0
 public WpfTestHelper()
 {
     InitializeComponent();
     guiTestHelper = GuiTestHelper.Instance;
 }
コード例 #6
0
 public WpfTestHelper()
 {
     InitializeComponent();
     guiTestHelper = GuiTestHelper.Instance;
 }