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 TestCellActivateAsync()
		{
			var async = new Async();

			_grid.Rows[ 0 ].Cells[ 1 ].EmulateActivate( async );
			async.WaitForCompletion();
			_grid.Rows[ 0 ].Cells[ 1 ].IsActive.IsTrue();
		}
 public SearchFormDriver(WindowControl window, Async async)
 {
     Async = async;
     Window = window;
     ButtonExecute = new FormsButton(Window.Dynamic()._buttonExecute);
     TextBoxSearch = new FormsTextBox(Window.Dynamic()._textBoxSearch);
     ListBoxEmployee = new FormsListBox(Window.Dynamic()._listBoxEmployee);
 }
 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 TestInitialize()
 {
     _app = new WindowsAppFriend(Process.Start(Target.Path));
     var main = WindowControl.FromZTop(_app);
     var a = new Async();
     new WPFButtonBase(main.Dynamic()._buttonXamOutlookBar).EmulateClick(a);
     _dlg = main.WaitForNextModal();
     _outlook = new XamOutlookBarDriver(_dlg.Dynamic()._outlook);
 }
 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 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 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 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 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);
 }
Exemplo n.º 11
0
        public void TestInitialize()
        {
            _app = new WindowsAppFriend(Process.Start(Target.Path));
            var main = WindowControl.FromZTop(_app);
            var a = new Async();

            new FormsButton(main.Dynamic()._buttonFlexGrid).EmulateClick(a);
            _dlg = main.WaitForNextModal();
            _grid = new C1FlexGridDriver(_dlg.Dynamic()._grid);
        }
 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();
 }
Exemplo n.º 13
0
 public AddFormDriver(WindowControl window, Async async)
 {
     Window = window;
     Async = async;
     ButtonEntry = new FormsButton(Window.Dynamic()._buttonEntry);
     TextBoxName = new FormsTextBox(Window.Dynamic()._textBoxName);
     TextBoxAddress = new FormsTextBox(Window.Dynamic()._textBoxAddress);
     RadioButtonWoman = new FormsRadioButton(Window.Dynamic()._radioButtonWoman);
     RadioButtonMan = new FormsRadioButton(Window.Dynamic()._radioButtonMan);
 }
Exemplo n.º 14
0
 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;
 }
Exemplo n.º 15
0
 public FriendlyOperation this[string staticOperation, Async async]
 {
     get
     {
         if (async == null)
         {
             throw new ArgumentNullException("async");
         }
         return CreateFullNameFriendlyOperation(staticOperation, null, async);
     }
 }
 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 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);
        }
 /// <summary>
 /// すべて閉じる
 /// </summary>
 /// <param name="testDlg">ダイアログ</param>
 /// <param name="async">きっかけとなった非同期処理</param>
 /// <returns>閉じたダイアログの個数</returns>
 internal static int CloseAll(WindowControl testDlg, Async async)
 {
     for (int i = 0; true; i++)
     {
         WindowControl msg = testDlg.WaitForNextModal(async);
         if (msg == null)
         {
             return i;
         }
         new NativeMessageBox(msg).EmulateButtonClick("OK");
     }
 }
 public void GetItemEmulateChangeSelectedAsync()
 {
     var listView = new WPFListView(_ctrl.listView);
     WindowControl windowControl = WindowControl.FromZTop(_app);
     var item = listView.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 TestInitialize()
 {
     _app = new WindowsAppFriend(Process.Start(Target.Path));
     var main = WindowControl.FromZTop(_app);
     var a = new Async();
     new WPFButtonBase(main.Dynamic()._buttonXamEditors).EmulateClick(a);
     _dlg = main.WaitForNextModal();
     _combo = new XamComboEditorDriver(_dlg.Dynamic()._combo);
     _numeric = new XamValueEditorDriver(_dlg.Dynamic()._numeric);
     _dateTime = new XamValueEditorDriver(_dlg.Dynamic()._dateTime);
     _currency = new XamValueEditorDriver(_dlg.Dynamic()._currency);
     _masked = new XamValueEditorDriver(_dlg.Dynamic()._masked);
     _text = new XamValueEditorDriver(_dlg.Dynamic()._text);
 }
        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();
        }
 internal static FriendlyOperation GetFriendlyOperation(AppFriend target, string name, Async async, OperationTypeInfo typeInfo)
 {
     if (async != null && typeInfo != null)
     {
         return target[name, typeInfo, async];
     }
     else if (async != null)
     {
         return target[name, async];
     }
     else if (typeInfo != null)
     {
         return target[name, typeInfo];
     }
     return target[name];
 }
        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 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 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 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 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 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 EmulateEdit(string text, Async async)
 {
     Static.EmulateEdit(Grid, CellData, text, async);
 }
 public void EmulateEdit(int index, Async async)
 {
     Static.EmulateEdit(Grid, CellData, index, async);
 }