コード例 #1
0
        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();
        }
コード例 #2
0
		public void TestCellActivateAsync()
		{
			var async = new Async();

			_grid.Rows[ 0 ].Cells[ 1 ].EmulateActivate( async );
			async.WaitForCompletion();
			_grid.Rows[ 0 ].Cells[ 1 ].IsActive.IsTrue();
		}
コード例 #3
0
 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);
 }
コード例 #4
0
 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");
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 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();
 }
コード例 #7
0
 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();
 }
コード例 #8
0
 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();
 }
コード例 #10
0
 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);
 }
コード例 #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();
 }
コード例 #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);
 }
コード例 #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;
 }
コード例 #15
0
ファイル: AppFriend.cs プロジェクト: Codeer-Software/Friendly
 public FriendlyOperation this[string staticOperation, Async async]
 {
     get
     {
         if (async == null)
         {
             throw new ArgumentNullException("async");
         }
         return CreateFullNameFriendlyOperation(staticOperation, null, async);
     }
 }
コード例 #16
0
 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);
 }
コード例 #17
0
        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");
     }
 }
コード例 #19
0
 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();
 }
コード例 #20
0
 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);
 }
コード例 #21
0
        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();
        }
コード例 #22
0
 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();
        }
コード例 #24
0
 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();
 }
コード例 #25
0
 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);
 }
コード例 #26
0
 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);
 }
コード例 #27
0
 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);
 }
コード例 #28
0
 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);
 }
コード例 #29
0
 public void EmulateEdit(string text, Async async)
 {
     Static.EmulateEdit(Grid, CellData, text, async);
 }
コード例 #30
0
 public void EmulateEdit(int index, Async async)
 {
     Static.EmulateEdit(Grid, CellData, index, async);
 }