static void OpenFile(WindowControl fileDialog, string path) { //ボタン取得 var buttonOpen = new NativeButton(fileDialog.IdentifyFromWindowText("開く(&O)")); //コンボボックスは二つある場合がある。 //下の方を採用。 var comboBoxPathSrc = fileDialog.GetFromWindowClass("ComboBoxEx32").OrderBy(e => { RECT rc; GetWindowRect(e.Handle, out rc); return rc.Top; }).Last(); var comboBoxPath = new NativeComboBox(comboBoxPathSrc); //パスを設定 comboBoxPath.EmulateChangeEditText(path); //開くボタンを押す buttonOpen.EmulateClick(); }
public void TestComboBoxDropDownVisibleEventAsync() { NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1008)); Async async = new Async(); combo.EmulateChangeDropDownVisible(true, async); Assert.IsTrue(0 < MessageBoxUtility.CloseAll(testDlg, async)); combo.EmulateChangeDropDownVisible(false); }
public void TestComboBoxEx32DropDownVisibleEventAsync() { //非同期実行ができること。CBN_DROPDOWNのイベントでメッセージボックスが表示されるのでそれを閉じる。 NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1009)); Async async = new Async(); combo.EmulateChangeDropDownVisible(true, async); Assert.IsTrue(0 < MessageBoxUtility.CloseAll(testDlg, async)); combo.EmulateChangeDropDownVisible(false); }
public void TestComboBoxEx32TextChangeEventAsync() { NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1009)); Async async = new Async(); combo.EmulateChangeEditText("abc", async); Assert.IsTrue(0 < MessageBoxUtility.CloseAll(testDlg, async)); }
public void TestComboBoxEx32DropDownVisibleEvent() { NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1007)); //イベント発生テスト。指定の状態と現在の状態が同じ場合はイベントの通知は発生しない。 //それ以外は開いたときにCBN_DROPDOWN、閉じたときにCBN_CLOSEUPが発生すること。 Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { combo.EmulateChangeDropDownVisible(true); }, CreateIgnorMessage(1007), new CodeInfo(1007, NativeMethods.WM_COMMAND, CBN_DROPDOWN))); Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { combo.EmulateChangeDropDownVisible(true); }, CreateIgnorMessage(1007), new CodeInfo[0])); Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { combo.EmulateChangeDropDownVisible(false); }, CreateIgnorMessage(1007), new CodeInfo(1007, NativeMethods.WM_COMMAND, CBN_SELENDCANCEL), new CodeInfo(1007, NativeMethods.WM_COMMAND, CBN_CLOSEUP))); Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { combo.EmulateChangeDropDownVisible(false); }, CreateIgnorMessage(1007), new CodeInfo[0])); }
public void TestComboBoxTextChangeEvent() { NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1006)); //イベント発生テスト。 //CBN_EDITCHANGEが発生すること。 //ComboBoxはCBN_EDITUPDATEも発生すること。 Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { combo.EmulateChangeEditText("abc"); }, CreateIgnorMessage(1006), new CodeInfo(1006, NativeMethods.WM_COMMAND, CBN_EDITCHANGE), new CodeInfo(1006, NativeMethods.WM_COMMAND, CBN_EDITUPDATE))); combo.EmulateChangeEditText(string.Empty); }
public void TestComboBoxEx32TextChangeEvent() { NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1007)); //イベント発生テスト。 //CBN_EDITCHANGEが発生すること。 combo.EmulateSelectItem(0); Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { combo.EmulateChangeEditText("abc"); }, //無視。 CreateIgnorMessage(1007, new CodeInfo(1007, NativeMethods.WM_COMMAND, CBN_SELENDCANCEL)), //期待値。 new CodeInfo(1007, NativeMethods.WM_COMMAND, CBN_EDITCHANGE))); combo.EmulateChangeEditText(string.Empty); }
public void TestComboBoxSelectItemEventAsync() { //非同期実行ができること。CBN_SELCHANGEのイベントでメッセージボックスが表示されるのでそれを閉じる。 NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1008)); Async async = new Async(); combo.EmulateSelectItem(1, async); Assert.IsTrue(0 < MessageBoxUtility.CloseAll(testDlg, async)); }
public void TestComboBoxEx32SelectItemEventAsync() { //ComboEx32 CBN_SELCHANGE、CBN_EDITCHANGEのイベントでメッセージボックスが出るのでそれを閉じる。 NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1009)); Async async = new Async(); combo.EmulateSelectItem(2, async); Assert.IsTrue(0 < MessageBoxUtility.CloseAll(testDlg, async)); }
public void TestItemData() { NativeComboBox[] combos = new NativeComboBox[]{ new NativeComboBox(testDlg.IdentifyFromDialogId(1006)), new NativeComboBox(testDlg.IdentifyFromDialogId(1007)) }; foreach (NativeComboBox combo in combos) { Assert.AreEqual(new IntPtr(0), combo.GetItemData(0)); Assert.AreEqual(new IntPtr(1), combo.GetItemData(1)); Assert.AreEqual(new IntPtr(2), combo.GetItemData(2)); } }
public void TestComboBoxEx32DropDownListSelectItemEvent() { NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1010)); //イベント発生テスト。指定の状態と現在の状態が同じ場合はイベントの通知は発生しない。 //それ以外はCBN_SELENDOK,CBN_SELCHANGEが発生すること。 combo.EmulateSelectItem(0); Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { combo.EmulateSelectItem(1); }, //無視。 CreateIgnorMessage(1010, new CodeInfo(1010, NativeMethods.WM_COMMAND, CBN_SELENDCANCEL)), //期待値。 new CodeInfo(1010, NativeMethods.WM_COMMAND, CBN_SELENDOK), new CodeInfo(1010, NativeMethods.WM_COMMAND, CBN_SELCHANGE))); Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { combo.EmulateSelectItem(1); }, //無視。 CreateIgnorMessage(1010, new CodeInfo(1010, NativeMethods.WM_COMMAND, CBN_SELENDCANCEL)), //期待値。 new CodeInfo[0] )); }
public void TestItemText() { NativeComboBox[] combos = new NativeComboBox[]{ new NativeComboBox(testDlg.IdentifyFromDialogId(1006)), new NativeComboBox(testDlg.IdentifyFromDialogId(1007)) }; foreach (NativeComboBox combo in combos) { Assert.AreEqual("あ", combo.GetItemText(0)); Assert.AreEqual("b", combo.GetItemText(1)); Assert.AreEqual("c", combo.GetItemText(2)); } }
public void TestText() { NativeComboBox[] combos = new NativeComboBox[]{ new NativeComboBox(testDlg.IdentifyFromDialogId(1006)), new NativeComboBox(testDlg.IdentifyFromDialogId(1007)) }; foreach (NativeComboBox combo in combos) { combo.EmulateChangeEditText("123"); Assert.AreEqual("123", combo.Text); //非同期でも同様の効果があることを確認。 Async a = new Async(); combo.EmulateChangeEditText("abcd", a); while (!a.IsCompleted) { Thread.Sleep(10); } Assert.AreEqual("abcd", combo.Text); } //ドロップダウン形式の場合。 NativeComboBox exDropDown = new NativeComboBox(testDlg.IdentifyFromDialogId(1010)); exDropDown.EmulateSelectItem(1); Assert.AreEqual("b", exDropDown.Text); }
public void TestSelectItem() { NativeComboBox[] combos = new NativeComboBox[]{ new NativeComboBox(testDlg.IdentifyFromDialogId(1006)), new NativeComboBox(testDlg.IdentifyFromDialogId(1007)) }; foreach (NativeComboBox combo in combos) { combo.EmulateSelectItem(1); Assert.AreEqual(1, combo.SelectedItemIndex); //非同期でも同様の効果があることを確認。 Async a = new Async(); combo.EmulateSelectItem(2, a); while (!a.IsCompleted) { Thread.Sleep(10); } Assert.AreEqual(2, combo.SelectedItemIndex); } }
public void TestItemCount() { NativeComboBox[] combos = new NativeComboBox[]{ new NativeComboBox(testDlg.IdentifyFromDialogId(1006)), new NativeComboBox(testDlg.IdentifyFromDialogId(1007)) }; foreach (NativeComboBox combo in combos) { Assert.AreEqual((NativeMethods.IsWindowUnicode(testDlg.Handle)) ? 4 : 3, combo.ItemCount); } }
public void TestConstructor() { //WindowControlから作成。 { NativeComboBox combo = new NativeComboBox(testDlg.IdentifyFromDialogId(1006)); combo.EmulateSelectItem(1); Assert.AreEqual(1, combo.SelectedItemIndex); } //ハンドルから作成。 { NativeComboBox combo = new NativeComboBox(app, testDlg.IdentifyFromDialogId(1006).Handle); combo.EmulateSelectItem(1); Assert.AreEqual(1, combo.SelectedItemIndex); } }