public void TestUniCode()
 {
     if (!isUni)
     {
         return;
     }
     NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
     tree.EmulateEdit(tree.Nodes[0], "𩸽");
     Assert.AreEqual("𩸽", tree.GetItemText(tree.Nodes[0]));
 }
 public void TestConstructor()
 {
     //WindowControlから作成。
     {
         NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
         Assert.AreEqual("0", tree.GetItemText(tree.Nodes[0]));
     }
     //ハンドルから作成。
     {
         NativeTree tree = new NativeTree(app, testDlg.IdentifyFromDialogId(1041).Handle);
         Assert.AreEqual("0", tree.GetItemText(tree.Nodes[0]));
     }
 }
        public void TestEdit()
        {
            NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
            tree.EmulateEdit(tree.Nodes[0], "test");
            Assert.AreEqual("test", tree.GetItemText(tree.Nodes[0]));

            //非同期でも同様の効果があることの確認。
            Async a = new Async();
            tree.EmulateEdit(tree.Nodes[0], "test2", a);
            while (!a.IsCompleted)
            {
                Thread.Sleep(10);
            }
            Assert.AreEqual("test2", tree.GetItemText(tree.Nodes[0]));
        }
        public void TestCancelEdit()
        {
            NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));

            //編集状態にする。
            NativeMethods.SetFocus(tree.Handle);
            int TVM_EDITLABEL = isUni ? TVM_EDITLABELW : TVM_EDITLABELA;
            tree.SendMessage(TVM_EDITLABEL, IntPtr.Zero, tree.Nodes[0]);
            new WindowControl(tree.App, tree.SendMessage(TVM_GETEDITCONTROL, IntPtr.Zero, IntPtr.Zero)).SetWindowText("test");

            //キャンセル。
            tree.EmulateCancelEdit();
            Assert.AreEqual("0", tree.GetItemText(tree.Nodes[0]));
        }
 public void TestGetParentNode()
 {
     NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
     IntPtr[] children = tree.GetChildNodes(tree.Nodes[0]);
     Assert.AreEqual("0", tree.GetItemText(tree.GetParentNode(children[0])));
 }
 public void TestGetItemTextOver256()
 {
     NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
     StringBuilder overText = new StringBuilder();
     for (int i = 0; i < 259; i++)//ツリーの文字数最大がデフォルトで259。
     {
         overText.Append((i % 10).ToString());
     }
     tree.EmulateEdit(tree.Nodes[0], overText.ToString());
     Assert.AreEqual(overText.ToString(), tree.GetItemText(tree.Nodes[0]));
 }
        public void TestGetBrotherNodes()
        {
            NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
            AssertEx.AreEqual(tree.Nodes, tree.GetBrotherNodes(tree.Nodes[0]));
            IntPtr[] brother = tree.GetBrotherNodes(tree.FindNode(0, 0));
            Assert.AreEqual("1", tree.GetItemText(brother[0]));
            Assert.AreEqual("2", tree.GetItemText(brother[1]));

            //途中から取得してもすべて列挙されること
            brother = tree.GetBrotherNodes(tree.FindNode(0, 1));
            Assert.AreEqual("1", tree.GetItemText(brother[0]));
            Assert.AreEqual("2", tree.GetItemText(brother[1]));
        }
 public void TestFindNode()
 {
     NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
     Assert.AreEqual("2", tree.GetItemText(tree.FindNode(0, 1)));
     Assert.AreEqual("1", tree.GetItemText(tree.FindNode("0", "1")));
 }
        public void TestSelectedItem()
        {
            NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
            tree.EmulateSelectItem(tree.FindNode(0, 1));
            Assert.AreEqual("2", tree.GetItemText(tree.SelectedItem));

            //非同期でも同様の効果があることの確認。
            Async a = new Async();
            tree.EmulateSelectItem(tree.FindNode(1, 0), a);
            while (!a.IsCompleted)
            {
                Thread.Sleep(10);
            }
            Assert.AreEqual("0", tree.GetItemText(tree.SelectedItem));
        }
 public void TestNodes()
 {
     NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
     IntPtr[] nodes = tree.Nodes;
     Assert.AreEqual(2, nodes.Length);
     Assert.AreEqual("0", tree.GetItemText(nodes[0]));
     Assert.AreEqual("10", tree.GetItemText(nodes[1]));
 }
 public void TestGetItemText()
 {
     NativeTree tree = new NativeTree(testDlg.IdentifyFromDialogId(1041));
     Assert.AreEqual("0", tree.GetItemText(tree.Nodes[0]));
 }