public void TestCellActivateAsync()
		{
			var async = new Async();

			_grid.Rows[ 0 ].Cells[ 1 ].EmulateActivate( async );
			async.WaitForCompletion();
			_grid.Rows[ 0 ].Cells[ 1 ].IsActive.IsTrue();
		}
 public void TestActivateAsync()
 {
     var panes = _dock.GetPanes();
     panes[0].EmulateActivate();
     var async = new Async();
     panes[1].EmulateActivate(async);
     async.WaitForCompletion();
     _dock.ActivePane.HeaderText.Is("Pane2");
 }
 public void EmulteClickTestAsync()
 {
     WPFMenuItem item = new WPFMenuItem(_ctrl._menuItemMessage);
     Async async = new Async();
     WindowControl windowControl = WindowControl.FromZTop(_app);
     item.EmulateClick(async);
     new NativeMessageBox(windowControl.WaitForNextModal()).EmulateButtonClick("OK");
     async.WaitForCompletion();
 }
 public void TestEmulateClickAsync()
 {
     var item = _ribbon.ApplicationMenu.GetItem("b", "b-1", "b-1-1");
     ((bool)_dlg.Dynamic().b_1_1_clicked).IsFalse();
     Async a = new Async();
     item.EmulateClick(a);
     a.WaitForCompletion();
     ((bool)_dlg.Dynamic().b_1_1_clicked).IsTrue();
 }
 public void EmulteChangeSelectedAsyncTest()
 {
     WPFTreeViewItem item = new WPFTreeViewItem(_ctrl._item1);
     Async async = new Async();
     WindowControl windowControl = WindowControl.FromZTop(_app);
     item.EmulateChangeSelected(true, async);
     new NativeMessageBox(windowControl.WaitForNextModal()).EmulateButtonClick("OK");
     async.WaitForCompletion();
 }
 public void TestNet()
 {
     Async async = new Async();
     app[typeof(MessageBox), "Show", async]("Message", "Title", MessageBoxButtons.OK, MessageBoxIcon.Information);
     NativeMessageBox msg = new NativeMessageBox(main.WaitForNextModal());
     Assert.AreEqual("Title", msg.Title);
     Assert.AreEqual("Message", msg.Message);
     msg.EmulateButtonClick("OK");
     async.WaitForCompletion();
 }
 public string ButtonEntry_EmulateClickAndGetMessage()
 {
     Async async = new Async();
     ButtonEntry.EmulateClick(async);
     var msgBox = new NativeMessageBox(Window.WaitForNextModal());
     var msg = msgBox.Message;
     msgBox.EmulateButtonClick("OK");
     async.WaitForCompletion();
     return msg;
 }
 public void TestEmulateCheckAsync()
 {
     _app.Type<WPFToggleButtonTest>().AddToggleEvent(_toggle.AppVar);
     Async async = new Async();
     WindowControl main = WindowControl.FromZTop(_app);
     _toggle.EmulateCheck(true, async);
     new NativeMessageBox(main.WaitForNextModal()).EmulateButtonClick("OK");
     async.WaitForCompletion();
     Assert.IsTrue((bool)_toggle.IsChecked);
 }
 public void TestNative()
 {
     Async async = new Async();
     app[GetType(), "MessageBoxA", async](0, "Message", "Title", 0);
     NativeMessageBox msg = new NativeMessageBox(WindowControl.WaitForIdentifyFromWindowText(app, "Title"));
     Assert.AreEqual("Title", msg.Title);
     Assert.AreEqual("Message", msg.Message);
     msg.EmulateButtonClick("OK");
     async.WaitForCompletion();
 }
        public void TestEmulateChangeValueAsync()
        {
            var slider = new WPFSlider(_target);

            _app[GetType(), "ChangeValueEvent"](slider.AppVar);
            var async = new Async();
            slider.EmulateChangeValue(TestValue, async);
            new NativeMessageBox(_mainWindow.WaitForNextModal()).EmulateButtonClick("OK");
            async.WaitForCompletion();
            Assert.AreEqual(TestValue, slider.Value);
        }
 public void SelectedIndexAsync()
 {
     app.Type<WPFListBoxTest>().AddSelectionEvent(listBox.AppVar);
     Async async = new Async();
     WindowControl main = WindowControl.FromZTop(app);
     listBox.EmulateChangeSelectedIndex(3, async);
     new NativeMessageBox(main.WaitForNextModal()).EmulateButtonClick("OK");
     async.WaitForCompletion();
     int index = listBox.SelectedIndex;
     Assert.AreEqual(3, index);
 }
        public void Wpf()
        {
            var app = new WindowsAppFriend(Process.Start("Wpf.exe"));
            AppVar window = app.Type().System.Windows.Application.Current.MainWindow;
            var logicalTree = window.LogicalTree();
            var buttonModal = new WPFButtonBase(logicalTree.ByBinding("CommandModal").Single());
            var buttonModeless = new WPFButtonBase(logicalTree.ByBinding("CommandModeless").Single());

            //モーダレスは通常はそのままでOK
            buttonModeless.EmulateClick();
            var next = app.Type().System.Windows.Application.Current.Windows[1];
            next.Title = "aaa";

            //でもたまに変なことしているやつがいれば注意
            //まあ、こっち使った方が無難
            var nextW = WindowControl.WaitForIdentifyFromWindowText(app, "aaa");
            nextW.Dynamic().Close();

            //モーダルは要注意
            var current = new WindowControl(window);

            {
                var a = new Async();
                buttonModal.EmulateClick(a);
                var modal = current.WaitForNextModal();
                modal.Dynamic().Close();
                a.WaitForCompletion();
            }

            //連続で出るやつはもっと注意
            var buttonModalSequential = new WPFButtonBase(logicalTree.ByBinding("CommandModalSequential").Single());
            {
                var a = new Async();
                buttonModalSequential.EmulateClick(a);

                var modal1 = current.WaitForNextModal();
                modal1.Dynamic().Close();
                modal1.WaitForDestroy();

                var modal2 = current.WaitForNextModal();
                modal2.Dynamic().Close();
                modal2.WaitForDestroy();

                a.WaitForCompletion();
            }

            Process.GetProcessById(app.ProcessId).Kill();
        }
        public void Friendlyなめんなよ()
        {
            var app = new WindowsAppFriend(Process.Start("WinForms.exe"));
            var form = app.Type().System.Windows.Forms.Application.OpenForms[0];
            WindowsAppExpander.LoadAssembly(app, GetType().Assembly);

            var button = new FormsButton(form._buttonFile);
            var a = new Async();
            button.EmulateClick(a);
            var dlg = new WindowControl(form).WaitForNextModal();

            OpenFile(dlg, @"c:\TestData\data.txt");

            a.WaitForCompletion();
            Process.GetProcessById(app.ProcessId).Kill();
        }
        public void TestExecutingExceptionNotComplate()
        {
            WindowControl window = WindowControl.FromZTop(app);
            Async async = new Async();
            app[typeof(MessageBox), "Show", async]("");
            Assert.IsNull(async.ExecutingException);
            WindowControl next = window.WaitForNextModal();

            next.IdentifyFromZIndex(1).SetFocus();
            next.IdentifyFromZIndex(1).SequentialMessage(
                new MessageInfo(0x0201, 0x0001, 0),
                new MessageInfo(0x0202, 0x0000, 0));

            async.WaitForCompletion();
        }
 public void GetItemEmulateChangeSelectedAsync()
 {
     WindowControl windowControl = WindowControl.FromZTop(app);
     var item = listBox.GetItem(99);
     app.Type(GetType()).MessageBoxEvent(item);
     var a = new Async();
     item.EmulateChangeSelected(true, a);
     Assert.IsTrue(item.IsSelected);
     new NativeMessageBox(windowControl.WaitForNextModal()).EmulateButtonClick("OK");
     a.WaitForCompletion();
 }
 public void TestEmulateCellCheckAsync()
 {
     app.Type<WPFDataGridTest>().AddEditEvent(dataGrid.AppVar);
     Async async = new Async();
     WindowControl main = WindowControl.FromZTop(app);
     dataGrid.EmulateCellCheck(0, 2, true, async);
     new NativeMessageBox(main.WaitForNextModal()).EmulateButtonClick("OK");
     async.WaitForCompletion();
     Assert.AreEqual(true, (bool)dataGrid.Dynamic().ItemsSource[0].IsActive);
 }
 public void GetCellEmulateChangeSelectedAsync()
 {
     dataGrid.Dynamic().SelectionUnit = DataGridSelectionUnit.Cell;
     WindowControl windowControl = WindowControl.FromZTop(app);
     var item = dataGrid.GetCell(99, 1);
     app.Type(GetType()).MessageBoxEvent(item);
     var a = new Async();
     item.EmulateChangeSelected(true, a);
     Assert.IsTrue(item.IsSelected);
     new NativeMessageBox(windowControl.WaitForNextModal()).EmulateButtonClick("OK");
     a.WaitForCompletion();
 }
 public void TestEmulateChangeCellTextAsync()
 {
     app.Type<WPFDataGridTest>().AddEditEvent(dataGrid.AppVar);
     Async async = new Async();
     WindowControl main = WindowControl.FromZTop(app);
     dataGrid.EmulateChangeCellText(0, 0, "xxx", async);
     new NativeMessageBox(main.WaitForNextModal()).EmulateButtonClick("OK");
     async.WaitForCompletion();
     Assert.AreEqual("xxx", (string)dataGrid.Dynamic().ItemsSource[0].Name);
 }
 public void TestEmulateChangeCellComboSelectAsync()
 {
     app.Type<WPFDataGridTest>().AddEditEvent(dataGrid.AppVar);
     Async async = new Async();
     WindowControl main = WindowControl.FromZTop(app);
     dataGrid.EmulateChangeCellComboSelect(0, 1, 2, async);
     new NativeMessageBox(main.WaitForNextModal()).EmulateButtonClick("OK");
     async.WaitForCompletion();
     Assert.AreEqual(ProgramingLanguage.CSP, (ProgramingLanguage)dataGrid.Dynamic().ItemsSource[0].Language);
 }
 public void ApplicationMenu2010SelectTabAsync()
 {
     var menu = _ribbon.ApplicationMenu2010;
     menu.EmulateOpen();
     menu.SelectedTabIndex.Is(1);
     var a = new Async();
     menu.EmulateSelectTab(2, a);
     a.WaitForCompletion();
     menu.SelectedTabIndex.Is(2);
 }
 public void TestEmulateChangeCurrentCellAsync()
 {
     app.Type<WPFDataGridTest>().AddCurrentCellEvent(dataGrid.AppVar);
     Async async = new Async();
     WindowControl main = WindowControl.FromZTop(app);
     dataGrid.EmulateChangeCurrentCell(2, 1, async);
     new NativeMessageBox(main.WaitForNextModal()).EmulateButtonClick("OK");
     async.WaitForCompletion();
     Assert.AreEqual(2, dataGrid.CurrentItemIndex);
     Assert.AreEqual(1, dataGrid.CurrentColIndex);
 }
 public void TestEmulateChangeTextAsync()
 {
     var a = new Async();
     _numeric.EmulateChangeText("1234", a);
     a.WaitForCompletion();
     _numeric.Text.Is("1,234");
 }
 public void TestSetCompleted()
 {
     Async a = new Async();
     a.SetCompleted();
     Assert.IsTrue(a.IsCompleted);
     a.WaitForCompletion();
 }
 public void TestWaitForCompletion()
 {
     AppVar arg = app.Dim();
     WindowControl window = WindowControl.FromZTop(app);
     Async async = new Async();
     AppVar ret = window.AppVar["AsyncValueTest", async](arg);
     WindowControl next = window.WaitForNextModal();
     WindowsAppExpander.LoadAssemblyFromFile(app, GetType().Assembly.Location);
     app[GetType(), "ClickByTimer"](next.IdentifyFromZIndex(1).Handle);
     Stopwatch watch = new Stopwatch();
     watch.Start();
     async.WaitForCompletion();
     watch.Stop();
     Assert.IsTrue(1000 < watch.ElapsedMilliseconds);//1秒以上待っていること
     Assert.AreEqual((int)arg.Core, 1);
     Assert.AreEqual((int)ret.Core, 2);
 }
 public void TestExecutingExceptionNonThrow()
 {
     Async async = new Async();
     app[typeof(OperationTestClassPublic), "PublicIntValueStatic", async](1);
     async.WaitForCompletion();
     Assert.IsNull(async.ExecutingException);
 }
        public void ButtonClickAsyncTest()
        {
            // Arrenge
            dynamic main = _app.Type<Application>().Current.MainWindow;
            AppVar buttonCore = _app.Type<Button>()();
            main._grid.Children.Add(buttonCore);
            dynamic checker = _app.Type<ButtonEventCheck>()(buttonCore, true);
            WindowControl windowControl = WindowControl.FromZTop(_app);
            WPFButtonBase ButtonBase = new WPFButtonBase(buttonCore);

            // Act
            Async async = new Async();
            ButtonBase.EmulateClick(async);

            // Assert
            WindowControl messageBoxControl = windowControl.WaitForNextModal();
            NativeMessageBox messageBox = new NativeMessageBox(messageBoxControl);
            Assert.AreEqual("TestMessageWindow", messageBox.Message);
            Assert.IsTrue((bool)checker.ButtonClickCalled);

            // Teardown
            messageBox.EmulateButtonClick("OK");
            messageBoxControl.WaitForDestroy();
            async.WaitForCompletion();
        }
 public void TestVisibilityAndCloseAsync()
 {
     var panes = _dock.GetPanes();
     var async = new Async();
     panes[0].EmulateClose(async);
     async.WaitForCompletion();
     panes[0].Visibility.Is(Visibility.Collapsed);
 }
        public void TestState()
        {
            NativeListControl list = new NativeListControl(testDlg.IdentifyFromDialogId(1037));
            list.EmulateChangeItemState(3, LVIS.FOCUSED, LVIS.FOCUSED);
            Assert.AreEqual(list.GetItemState(3, LVIS.FOCUSED), LVIS.FOCUSED);

            //非同期でも同様の効果があることを確認。
            Async a = new Async();
            list.EmulateChangeItemState(5, LVIS.FOCUSED, LVIS.FOCUSED, a);
            a.WaitForCompletion();
            Assert.AreEqual(list.GetItemState(5, LVIS.FOCUSED), LVIS.FOCUSED);
        }