public void TestConstructor() { //WindowControlから作成。 { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); Assert.AreEqual((NativeMethods.IsWindowUnicode(testDlg.Handle)) ? 101 : 100, listBox.Count); } //ハンドルから作成。 { NativeListBox listBox = new NativeListBox(app, testDlg.IdentifyFromDialogId(1037).Handle); Assert.AreEqual((NativeMethods.IsWindowUnicode(testDlg.Handle)) ? 101 : 100, listBox.Count); } }
public void TestCurrentSelectedIndexValue() { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); listBox.EmulateChangeCurrentSelectedIndex(1); Assert.AreEqual(1, listBox.CurrentSelectedIndex); //非同期でも正常に動作することを確認。 Async a = new Async(); listBox.EmulateChangeCurrentSelectedIndex(2, a); while (!a.IsCompleted) { Thread.Sleep(10); } Assert.AreEqual(2, listBox.CurrentSelectedIndex); }
public void TestCount() { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); Assert.AreEqual((NativeMethods.IsWindowUnicode(testDlg.Handle)) ? 101 : 100, listBox.Count); }
public void TestFindItem() { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); Assert.AreEqual(2, listBox.FindItem(0, "2")); Assert.AreEqual(2, listBox.FindItem(2, "2")); Assert.AreEqual(-1, listBox.FindItem(3, "2")); }
public void TestUnicode() { if (!NativeMethods.IsWindowUnicode(testDlg.Handle)) { return; } NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); Assert.AreEqual("𩸽", listBox.GetItemText(100)); Assert.AreEqual(100, listBox.FindItem(0, "𩸽")); }
public void TestEmulateChangeSelectEvent() { //LBN_SELCHANGEが発生していることを確認。 NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1035)); listBox.EmulateChangeSelect(0, false); Assert.IsTrue(EventChecker.IsSameTestEvent(testDlg, delegate { listBox.EmulateChangeSelect(0, true); }, new CodeInfo(1035, NativeMethods.WM_COMMAND, LBN_SELCHANGE))); }
public void TestEmulateChangeSelectEventAsync() { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1036)); Async async = new Async(); listBox.EmulateChangeSelect(1, true, async); Assert.IsTrue(0 < MessageBoxUtility.CloseAll(testDlg, async)); }
public void TestItemRect() { if (!OSUtility.Is7or8()) { //矩形は環境によって変わるので7のみ。しかし、7なら常に同じ矩形とも限らない。 //このテストデータが使えるOSの設定は限られる。 return; } NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); listBox.SetTopIndex(0); Assert.AreEqual(new Rectangle(0, 39, 63, 14), listBox.GetItemRect(3)); }
public void TestItemText() { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); Assert.AreEqual("10", listBox.GetItemText(10)); }
public void TestItemData() { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); Assert.AreEqual(new IntPtr(5), listBox.GetItemData(5)); }
public void TestTopIndex() { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1037)); listBox.SetTopIndex(30); Assert.AreEqual(30, listBox.TopIndex); //先頭になれない場合は表示領域に入ること。 if (NativeMethods.IsWindowUnicode(testDlg.Handle)) { listBox.SetTopIndex(100); Assert.AreEqual(93, listBox.TopIndex); } else { listBox.SetTopIndex(99); Assert.AreEqual(92, listBox.TopIndex); } }
public void TestSelectedIndices() { NativeListBox listBox = new NativeListBox(testDlg.IdentifyFromDialogId(1035)); listBox.EmulateChangeSelect(0, true); listBox.EmulateChangeSelect(1, false); listBox.EmulateChangeSelect(2, true); AssertEx.AreEqual(new int[] { 0, 2 }, listBox.SelectedIndices); //非同期でも正常に動作することを確認。 Async a = new Async(); listBox.EmulateChangeSelect(2, false, a); while (!a.IsCompleted) { Thread.Sleep(10); } AssertEx.AreEqual(new int[] { 0 }, listBox.SelectedIndices); }