Esempio n. 1
0
        public void MyTestInitialize()
        {
            // Find the Start button, which will be our target
            AutomationElement trueStartButton = AutomationElementTest.GetTaskbar();

            this.startButtonHwnd = (IntPtr)trueStartButton.Current.NativeWindowHandle;
        }
Esempio n. 2
0
        public void MyTestInitialize()
        {
            // Find the taskbar, which will be our target
            AutomationElement taskBar = AutomationElementTest.GetTaskbar();

            this.targetHwnd = (IntPtr)taskBar.Current.NativeWindowHandle;

            // Register a client side provider
            ClientSideProviderDescription provider = new ClientSideProviderDescription(
                new ClientSideProviderFactoryCallback(MockPatternProvider.MockPatternFactory), "Shell_TrayWnd");

            ClientSideProviderDescription[] providers = new ClientSideProviderDescription[1] {
                provider
            };
            ClientSettings.RegisterClientSideProviders(providers);

            // Get the overridden element
            this.mockObject = AutomationElement.FromHandle(this.targetHwnd);
            Assert.IsNotNull(this.mockObject);
        }
Esempio n. 3
0
        public void TestInvokeEvent()
        {
            AutomationElement  startButton = AutomationElementTest.GetStartButton();
            BasicChangeHandler handler     = new BasicChangeHandler();

            Automation.AddAutomationEventHandler(
                InvokePattern.InvokedEvent,
                startButton,
                TreeScope.Element,
                new AutomationEventHandler(handler.HandleEvent));
            handler.Start();
            InvokePattern invoke = (InvokePattern)startButton.GetCurrentPattern(InvokePattern.Pattern);

            invoke.Invoke();
            System.Windows.Forms.SendKeys.SendWait("{ESC}");
            Assert.IsTrue(handler.Confirm());
            Assert.IsNotNull(handler.EventSource);
            Automation.RemoveAutomationEventHandler(
                InvokePattern.InvokedEvent,
                startButton,
                new AutomationEventHandler(handler.HandleEvent));
        }