Пример #1
0
        public void ToolTipCloseOnLeave()
        {
            TempData     tempData     = new TempData();
            SystemWindow systemWindow = CreateTwoChildWindow(tempData);

            // move into the first widget
            systemWindow.OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, 11, 11, 0));
            UiThread.DoRunAllPending();

            // sleep long enough to show the tool tip
            Thread.Sleep((int)(systemWindow.ToolTipManager.InitialDelay * 1000 + minMsToBias));
            UiThread.DoRunAllPending();

            // make sure the tool tip came up
            Assert.IsTrue(systemWindow.Children.Count == 3);
            Assert.IsTrue(tempData.showCount == 1);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == toolTip1Text);

            // move off the first widget
            systemWindow.OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, 9, 9, 0));
            Thread.Sleep(minMsTimeToRespond);             // sleep enough for the tool tip to want to respond
            UiThread.DoRunAllPending();

            // make sure the tool tip went away
            Assert.IsTrue(systemWindow.Children.Count == 2);
            Assert.IsTrue(tempData.popCount == 1);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == "");
        }
Пример #2
0
        public void ToolTipInitialOpenTests()
        {
            TempData tempData = new TempData();
            // test simple open then wait for pop
            SystemWindow systemWindow = CreateTwoChildWindow(tempData);

            // move into the first widget
            systemWindow.OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, 11, 11, 0));
            UiThread.DoRunAllPending();

            // show that initialy we don't have a tooltip
            Assert.IsTrue(systemWindow.Children.Count == 2);

            // sleep 1/2 long enough to show the tool tip
            Thread.Sleep((int)(systemWindow.ToolTipManager.InitialDelay / 2 * 1000 + minMsToBias));
            UiThread.DoRunAllPending();

            // make sure it is still not up
            Assert.IsTrue(systemWindow.Children.Count == 2);
            Assert.IsTrue(tempData.showCount == 0);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == "");

            // sleep 1/2 long enough to show the tool tip
            Thread.Sleep((int)(systemWindow.ToolTipManager.InitialDelay / 2 * 1000 + minMsToBias));
            UiThread.DoRunAllPending();

            // make sure the tool tip came up
            Assert.IsTrue(systemWindow.Children.Count == 3);
            Assert.IsTrue(tempData.showCount == 1);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == toolTip1Text);

            // wait 1/2 long enough for the tool tip to go away
            Thread.Sleep((int)(systemWindow.ToolTipManager.AutoPopDelay * 1000 / 2 + minMsToBias));
            UiThread.DoRunAllPending();

            // make sure the tool did not go away
            Assert.IsTrue(systemWindow.Children.Count == 3);
            Assert.IsTrue(tempData.popCount == 0);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == toolTip1Text);

            // wait 1/2 long enough for the tool tip to go away
            Thread.Sleep((int)(systemWindow.ToolTipManager.AutoPopDelay * 1000 / 2 + minMsToBias));
            UiThread.DoRunAllPending();

            // make sure the tool tip went away
            Assert.IsTrue(systemWindow.Children.Count == 2);
            Assert.IsTrue(tempData.popCount == 1);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == "");
        }
Пример #3
0
        private static SystemWindow CreateTwoChildWindow(TempData tempData)
        {
            SystemWindow systemWindow = new SystemWindow(200, 200);
            GuiWidget    toolTip1     = new GuiWidget()
            {
                LocalBounds = new RectangleDouble(10, 10, 20, 20),
                ToolTipText = toolTip1Text,
            };
            GuiWidget toolTip2 = new GuiWidget()
            {
                LocalBounds = new RectangleDouble(30, 30, 40, 40),
                ToolTipText = toolTip2Text,
            };

            systemWindow.ToolTipManager.ToolTipShown += (sender, stringEvent) =>
            {
                tempData.showCount++;
                tempData.lastShownText = stringEvent.Data;
            };

            systemWindow.ToolTipManager.ToolTipPop += (sender, e) =>
            {
                tempData.popCount++;
            };

            systemWindow.AddChild(toolTip1);
            systemWindow.AddChild(toolTip2);

            Assert.IsTrue(systemWindow.Children.Count == 2);

            // make sure we start out with only the widgets (no tool tip)
            systemWindow.OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, 0, 0, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(systemWindow.Children.Count == 2);

            tempData.lastShownText = "";
            tempData.showCount     = 0;
            tempData.popCount      = 0;

            return(systemWindow);
        }
Пример #4
0
        public void MoveFastFromToolTipToToolTip()
        {
            TempData     tempData     = new TempData();
            SystemWindow systemWindow = CreateTwoChildWindow(tempData);

            // move into the first widget
            systemWindow.OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, 11, 11, 0));
            UiThread.DoRunAllPending();

            // sleep long enough to show the tool tip
            Thread.Sleep((int)(systemWindow.ToolTipManager.InitialDelay * 1000 + minMsToBias));
            UiThread.DoRunAllPending();

            // make sure the tool tip came up
            Assert.IsTrue(systemWindow.Children.Count == 3);
            Assert.IsTrue(tempData.showCount == 1);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == toolTip1Text);

            // wait 1/2 long enough for the tool tip to go away
            Thread.Sleep((int)(systemWindow.ToolTipManager.AutoPopDelay * 1000 / 2 + minMsToBias));
            UiThread.DoRunAllPending();

            // move onto the other widget
            systemWindow.OnMouseMove(new MouseEventArgs(MouseButtons.None, 0, 31, 31, 0));
            Thread.Sleep(minMsTimeToRespond);             // sleep enough for the tool tip to want to respond
            UiThread.DoRunAllPending();

            // make sure the first tool tip went away
            Assert.IsTrue(systemWindow.Children.Count == 2);
            Assert.IsTrue(tempData.popCount == 1);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == "");

            // wait long enough for the second tool tip to come up
            Thread.Sleep((int)(systemWindow.ToolTipManager.ReshowDelay * 1000 + minMsToBias));
            UiThread.DoRunAllPending();

            // make sure the tool tip 2 came up
            Assert.IsTrue(systemWindow.Children.Count == 3);
            Assert.IsTrue(tempData.showCount == 2);
            Assert.IsTrue(systemWindow.ToolTipManager.CurrentText == toolTip2Text);
        }
Пример #5
0
        public void ListMenuTests()
        {
            string menuSelected = "";

            GuiWidget  container = new GuiWidget(400, 400);
            TextWidget menueView = new TextWidget("Edit");
            Menu       listMenu  = new Menu(menueView);

            listMenu.OriginRelativeParent = new Vector2(10, 300);

            MenuItem cutMenuItem = new MenuItem(new TextWidget("Cut"));

            cutMenuItem.Selected += (sender, e) => { menuSelected = "Cut"; };
            listMenu.MenuItems.Add(cutMenuItem);

            MenuItem copyMenuItem = new MenuItem(new TextWidget("Copy"));

            copyMenuItem.Selected += (sender, e) => { menuSelected = "Copy"; };
            listMenu.MenuItems.Add(copyMenuItem);

            MenuItem pastMenuItem = new MenuItem(new TextWidget("Paste"));

            pastMenuItem.Selected += (sender, e) => { menuSelected = "Paste"; };
            listMenu.MenuItems.Add(pastMenuItem);

            container.AddChild(listMenu);

            Assert.IsTrue(!listMenu.IsOpen);

            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // all the menu itmes should be added to the open menu
            Assert.IsTrue(cutMenuItem.Parent != null);
            Assert.IsTrue(copyMenuItem.Parent != null);
            Assert.IsTrue(pastMenuItem.Parent != null);

            // click on menu again to close
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            // all the mune itmes should be removed from the closed menu
            Assert.IsTrue(cutMenuItem.Parent == null);
            Assert.IsTrue(copyMenuItem.Parent == null);
            Assert.IsTrue(pastMenuItem.Parent == null);

            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);

            // all the menu itmes should be removed from the closed menu
            Assert.IsTrue(cutMenuItem.Parent == null);
            Assert.IsTrue(copyMenuItem.Parent == null);
            Assert.IsTrue(pastMenuItem.Parent == null);

            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);
            // all the menu itmes should be added to the open menu
            Assert.IsTrue(cutMenuItem.Parent != null);
            Assert.IsTrue(copyMenuItem.Parent != null);
            Assert.IsTrue(pastMenuItem.Parent != null);

            // click off menu to close
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 5, 299, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            // all the mune itmes should be removed from the closed menu
            Assert.IsTrue(cutMenuItem.Parent == null);
            Assert.IsTrue(copyMenuItem.Parent == null);
            Assert.IsTrue(pastMenuItem.Parent == null);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 5, 299, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);

            // open the menu again
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // select the first item
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            Assert.IsTrue(menuSelected == "Cut");

            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // select the second item
            menuSelected = "";
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 275, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 275, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            Assert.IsTrue(menuSelected == "Copy");

            // make sure click down then move off item does not select it.
            menuSelected = "";
            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // click down on the first item
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);
            // move off of it
            container.OnMouseMove(new MouseEventArgs(MouseButtons.None, 1, 5, 290, 0));
            UiThread.DoRunAllPending();
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 5, 290, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            Assert.IsTrue(menuSelected == "");

            // make sure click down and then move to new items selects the new item.

            // click and draw down to item should work as well
        }
Пример #6
0
        public void DropDownListTests()
        {
            string menuSelected = "";

            GuiWidget    container = new GuiWidget(400, 400);
            DropDownList listMenu  = new DropDownList("- Select Something -", RGBA_Bytes.Black, RGBA_Bytes.Gray);

            listMenu.OriginRelativeParent = new Vector2(10, 300);

            MenuItem cutMenuItem = new MenuItem(new TextWidget("Cut"));

            cutMenuItem.Selected += (sender, e) => { menuSelected = "Cut"; };
            listMenu.MenuItems.Add(cutMenuItem);

            MenuItem copyMenuItem = new MenuItem(new TextWidget("Copy"));

            copyMenuItem.Selected += (sender, e) => { menuSelected = "Copy"; };
            listMenu.MenuItems.Add(copyMenuItem);

            MenuItem pastMenuItem = new MenuItem(new TextWidget("Paste"));

            pastMenuItem.Selected += (sender, e) => { menuSelected = "Paste"; };
            listMenu.MenuItems.Add(pastMenuItem);

            container.AddChild(listMenu);

            Assert.IsTrue(!listMenu.IsOpen);

            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // click on menu again to close
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);

            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // click off menu to close
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 5, 299, 0));
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 5, 299, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);

            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // select the first item
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            Assert.IsTrue(menuSelected == "Cut");

            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // select the second item
            menuSelected = "";
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 275, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 275, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            Assert.IsTrue(menuSelected == "Copy");

            // make sure click down then move off item does not select it.
            menuSelected = "";
            // open the menu
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 11, 300, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);

            // click down on the first item
            container.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 11, 290, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(listMenu.IsOpen);
            // move off of it
            container.OnMouseMove(new MouseEventArgs(MouseButtons.None, 1, 5, 290, 0));
            container.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 5, 290, 0));
            UiThread.DoRunAllPending();
            Assert.IsTrue(!listMenu.IsOpen);
            Assert.IsTrue(menuSelected == "");

            // make sure click down and then move to new items selects the new item.

            // click and draw down to item should work as well
        }