public void GetWidgetByNameTestNoRegionSingleWindow()
		{
			// single system window
			{
				int leftClickCount = 0;

				Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
				{
					AutomationRunner testRunner = new AutomationRunner();
					testRunner.ClickByName("left");
					testRunner.Wait(.5);

					resultsHarness.AddTestResult(leftClickCount == 1, "Got left button click");
				};

				SystemWindow buttonContainer = new SystemWindow(300, 200);

				Button leftButton = new Button("left", 10, 40);
				leftButton.Name = "left";
				leftButton.Click += (sender, e) => { leftClickCount++; };
				buttonContainer.AddChild(leftButton);

				AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(buttonContainer, testToRun, 10);

				Assert.IsTrue(testHarness.AllTestsPassed);
				Assert.IsTrue(testHarness.TestCount == 1); // make sure we can all our tests
			}
		}
Example #2
0
        public void SheetEditorNavigationTests()
        {
            var systemWindow = new SystemWindow(800, 600)
            {
                Name = "Main Window",
            };

            Application.AddTextWidgetRightClickMenu();

            AutomationRunner.TimeToMoveMouse = .1;

            var theme     = ApplicationController.Instance.Theme;
            var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                VAnchor = VAnchor.Stretch,
            };

            systemWindow.AddChild(container);

            var sheetData         = new SheetData(5, 5);
            var undoBuffer        = new UndoBuffer();
            var sheetEditorWidget = new SheetEditorWidget(sheetData, undoBuffer, theme);

            container.AddChild(sheetEditorWidget);

            systemWindow.RunTest(testRunner =>
            {
                testRunner.Delay(60);
                return(Task.CompletedTask);
            },
                                 2000);
        }
Example #3
0
        public static void Main(string[] args)
        {
            var demoWidget = new PolygonClippingDemo();

            var systemWindow = new SystemWindow(640, 520);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #4
0
        public static void Main(string[] args)
        {
            var demoWidget = new line_patterns_application();

            var systemWindow = new SystemWindow(500, 450);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #5
0
        public static void Main(string[] args)
        {
            var demoWidget = new image_resample();

            var systemWindow = new SystemWindow(600, 600);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #6
0
        public static void Main(string[] args)
        {
            var demoWidget = new alpha_mask2_application();

            var systemWindow = new SystemWindow(512, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #7
0
        public static void Main(string[] args)
        {
            var demoWidget = new MomsSolitaire();

            var systemWindow = new SystemWindow(691, 390);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #8
0
        public static void Main(string[] args)
        {
            Clipboard.SetSystemClipboard(new WindowsFormsClipboard());

            var systemWindow = new SystemWindow(640, 480);

            systemWindow.Title = "Demo Runner";
            systemWindow.AddChild(new DemoRunner());
            systemWindow.ShowAsSystemWindow();
        }
Example #9
0
        public static void Main(string[] args)
        {
            var demoWidget = new FloodFillDemo();

            var systemWindow = new SystemWindow(600, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #10
0
        public static void Main(string[] args)
        {
            var demoWidget = new Gradients();

            var systemWindow = new SystemWindow(512, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #11
0
        public static void Main(string[] args)
        {
            var demoWidget = new trans_curve1_application();

            var systemWindow = new SystemWindow(600, 600);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #12
0
        public static void Main(string[] args)
        {
            var demoWidget = new rounded_rect_application();

            var systemWindow = new SystemWindow(600, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #13
0
        public static void Main(string[] args)
        {
            var demoWidget = new blur();

            var systemWindow = new SystemWindow(440, 330);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
        public static void Main(string[] args)
        {
            var demoWidget = new image_filters();

            var systemWindow = new SystemWindow(305, 325);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #15
0
        public static void Main(string[] args)
        {
            var demoWidget = new gouraud_application();

            var systemWindow = new SystemWindow(400, 300);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #16
0
        public void ToolTipsShow()
        {
            SystemWindow buttonContainer = new SystemWindow(300, 200)
            {
                BackgroundColor = RGBA_Bytes.White,
            };

            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner("C:/TestImages");
                testRunner.Wait(1);

                // Now do the actions specific to this test. (replace this for new tests)
                {
                    testRunner.MoveToByName("ButtonWithToolTip");
                    testRunner.Wait(1.5);
                    GuiWidget toolTipWidget = buttonContainer.FindNamedChildRecursive("ToolTipWidget");
                    resultsHarness.AddTestResult(toolTipWidget != null, "Tool tip is showing");
                    testRunner.MoveToByName("right");
                    toolTipWidget = buttonContainer.FindNamedChildRecursive("ToolTipWidget");
                    resultsHarness.AddTestResult(toolTipWidget == null, "Tool tip is not showing");
                }

                testRunner.Wait(1);
                buttonContainer.CloseOnIdle();
            };

            Button leftButton = new Button("left", 10, 40);

            leftButton.Name        = "ButtonWithToolTip";
            leftButton.ToolTipText = "Left Tool Tip";
            buttonContainer.AddChild(leftButton);
            Button rightButton = new Button("right", 110, 40);

            rightButton.Name = "right";
            buttonContainer.AddChild(rightButton);

            AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(buttonContainer, testToRun, 10000);

            Assert.IsTrue(testHarness.AllTestsPassed);
            Assert.IsTrue(testHarness.TestCount == 2);             // make sure we can all our tests
        }
		public void DoClickButtonInWindow()
		{
			int leftClickCount = 0;
			int rightClickCount = 0;

			Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
			{
				AutomationRunner testRunner = new AutomationRunner();

				// Now do the actions specific to this test. (replace this for new tests)
				testRunner.ClickByName("left", 1);
				testRunner.Wait(.5);

				resultsHarness.AddTestResult(leftClickCount == 1, "Got left button click");

				testRunner.ClickByName("right", 1);
				testRunner.Wait(.5);

				resultsHarness.AddTestResult(rightClickCount == 1, "Got right button click");

				testRunner.DragDropByName("left", "right", offsetDrag: new Point2D(1, 0));
				testRunner.Wait(.5);

				resultsHarness.AddTestResult(leftClickCount == 1, "Mouse down not a click");
			};

			SystemWindow buttonContainer = new SystemWindow(300, 200);

			Button leftButton = new Button("left", 10, 40);
			leftButton.Name = "left";
			leftButton.Click += (sender, e) => { leftClickCount++; };
			buttonContainer.AddChild(leftButton);
			Button rightButton = new Button("right", 110, 40);
			rightButton.Click += (sender, e) => { rightClickCount++; };
			rightButton.Name = "right";
			buttonContainer.AddChild(rightButton);

			AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(buttonContainer, testToRun, 10);

			Assert.IsTrue(testHarness.AllTestsPassed);
			Assert.IsTrue(testHarness.TestCount == 3); // make sure we can all our tests
		}
Example #18
0
        public static void Main(string[] args)
        {
            var demoWidget = new FontHinter();

            var systemWindow = new SystemWindow(440, 330);

            systemWindow.PixelType = SystemWindow.PixelTypes.Depth24;
            systemWindow.Title     = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #19
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.InvokePendingActions();
            Assert.IsTrue(systemWindow.Children.Count == 2);

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

            return(systemWindow);
        }
Example #20
0
        public static void Main(string[] args)
        {
            Clipboard.SetSystemClipboard(new WindowsFormsClipboard());

            var demoWidget = new RenderTriangles();

            var systemWindow = new SystemWindow(800, 600);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #21
0
        public static void Main(string[] args)
        {
            //AggContext.Init(embeddedResourceName: "lion_outline.config.json");

            var demoWidget = new lion_outline();

            var systemWindow = new SystemWindow(512, 512);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #22
0
        public static void Main(string[] args)
        {
            MatterHackers.Agg.Tests.AggDrawingTests.RunAllTests();

            var demoWidget = new ComponentRendering();

            var systemWindow = new SystemWindow(320, 320);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #23
0
		public void CreateWidgetAndRunInWindow(SystemWindow.PixelTypes bitDepth = SystemWindow.PixelTypes.Depth32, RenderSurface surfaceType = RenderSurface.Bitmap)
		{
			AppWidgetInfo appWidgetInfo = GetAppParameters();
			SystemWindow systemWindow = new SystemWindow(appWidgetInfo.width, appWidgetInfo.height);
			systemWindow.PixelType = bitDepth;
			systemWindow.Title = appWidgetInfo.title;
			if (surfaceType == RenderSurface.OpenGL)
			{
				systemWindow.UseOpenGL = true;
			}
			systemWindow.AddChild(NewWidget());
			systemWindow.ShowAsSystemWindow();
		}
Example #24
0
        public static void Main(string[] args)
        {
            // Init agg with our OpenGL window definition
            //AggContext.Init(embeddedResourceName: "lion.config.json");

            var demoWidget = new Lion();

            var systemWindow = new SystemWindow(512, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #25
0
        public AboutWidget()
        {
            this.HAnchor = HAnchor.ParentLeftRight;
            this.VAnchor = VAnchor.ParentTop;

            this.Padding         = new BorderDouble(5);
            this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            FlowLayoutWidget customInfoTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            customInfoTopToBottom.Name    = "AboutPageCustomInfo";
            customInfoTopToBottom.HAnchor = HAnchor.ParentLeftRight;
            customInfoTopToBottom.VAnchor = VAnchor.Max_FitToChildren_ParentHeight;
            customInfoTopToBottom.Padding = new BorderDouble(5, 10, 5, 0);

            if (UserSettings.Instance.IsTouchScreen)
            {
                customInfoTopToBottom.AddChild(new UpdateControlView());
            }

            //AddMatterHackersInfo(customInfoTopToBottom);
            customInfoTopToBottom.AddChild(new GuiWidget(1, 10));

            string aboutHtmlFile = Path.Combine("OEMSettings", "AboutPage.html");
            string htmlContent   = StaticData.Instance.ReadAllText(aboutHtmlFile);

#if false // test
            {
                SystemWindow releaseNotes        = new SystemWindow(640, 480);
                string       releaseNotesFile    = Path.Combine("OEMSettings", "ReleaseNotes.html");
                string       releaseNotesContent = StaticData.Instance.ReadAllText(releaseNotesFile);
                HtmlWidget   content             = new HtmlWidget(releaseNotesContent, RGBA_Bytes.Black);
                content.AddChild(new GuiWidget(HAnchor.AbsolutePosition, VAnchor.ParentBottomTop));
                content.VAnchor        |= VAnchor.ParentTop;
                content.BackgroundColor = RGBA_Bytes.White;
                releaseNotes.AddChild(content);
                releaseNotes.BackgroundColor = RGBA_Bytes.Cyan;
                UiThread.RunOnIdle((state) =>
                {
                    releaseNotes.ShowAsSystemWindow();
                }, 1);
            }
#endif

            HtmlWidget htmlWidget = new HtmlWidget(htmlContent, ActiveTheme.Instance.PrimaryTextColor);

            customInfoTopToBottom.AddChild(htmlWidget);

            this.AddChild(customInfoTopToBottom);
        }
Example #26
0
        public void ShowContentInWindow()
        {
            if (PopedOutSystemWindow == null)
            {
                // So the window is open now only change this is we close it.
                UserSettings.Instance.Fields.SetBool(WindowLeftOpenKey, true);

                string windowSize = UserSettings.Instance.get(WindowSizeKey);
                int    width      = 600;
                int    height     = 400;
                if (windowSize != null && windowSize != "")
                {
                    string[] sizes = windowSize.Split(',');
                    width  = Math.Max(int.Parse(sizes[0]), (int)minSize.x);
                    height = Math.Max(int.Parse(sizes[1]), (int)minSize.y);
                }

                PopedOutSystemWindow                   = new SystemWindow(width, height);
                PopedOutSystemWindow.Padding           = new BorderDouble(3);
                PopedOutSystemWindow.Title             = windowTitle;
                PopedOutSystemWindow.AlwaysOnTopOfMain = true;
                PopedOutSystemWindow.BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;
                PopedOutSystemWindow.Closing          += SystemWindow_Closing;
                if (widgetWhosContentsPopOut.Children.Count == 1)
                {
                    GuiWidget child = widgetWhosContentsPopOut.Children[0];
                    widgetWhosContentsPopOut.RemoveChild(child);
                    child.ClearRemovedFlag();
                    widgetWhosContentsPopOut.AddChild(CreateContentForEmptyControl());
                    PopedOutSystemWindow.AddChild(child);
                }
                PopedOutSystemWindow.ShowAsSystemWindow();

                PopedOutSystemWindow.MinimumSize = minSize;
                string desktopPosition = UserSettings.Instance.get(PositionKey);
                if (desktopPosition != null && desktopPosition != "")
                {
                    string[] sizes = desktopPosition.Split(',');

                    //If the desktop position is less than -10,-10, override
                    int xpos = Math.Max(int.Parse(sizes[0]), -10);
                    int ypos = Math.Max(int.Parse(sizes[1]), -10);
                    PopedOutSystemWindow.DesktopPosition = new Point2D(xpos, ypos);
                }
            }
            else
            {
                PopedOutSystemWindow.BringToFront();
            }
        }
Example #27
0
        public static void Main(string[] args)
        {
            // Init agg with our OpenGL window definition
            //AggContext.Init(embeddedResourceName: "lion.config.json");
            AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.OpenGLWinformsWindowProvider, agg_platform_win32";

            var demoWidget = new Lion();

            var systemWindow = new SystemWindow(512, 400);

            systemWindow.Title = demoWidget.Title;
            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
        public void CreateWidgetAndRunInWindow(SystemWindow.PixelTypes bitDepth = SystemWindow.PixelTypes.Depth32, RenderSurface surfaceType = RenderSurface.Bitmap)
        {
            AppWidgetInfo appWidgetInfo = GetAppParameters();
            SystemWindow  systemWindow  = new SystemWindow(appWidgetInfo.width, appWidgetInfo.height);

            systemWindow.PixelType = bitDepth;
            systemWindow.Title     = appWidgetInfo.title;
            if (surfaceType == RenderSurface.OpenGL)
            {
                systemWindow.UseOpenGL = true;
            }
            systemWindow.AddChild(NewWidget());
            systemWindow.ShowAsSystemWindow();
        }
Example #29
0
        public async Task ToolTipsShow()
        {
            SystemWindow buttonContainer = new SystemWindow(300, 200)
            {
                BackgroundColor = RGBA_Bytes.White,
            };

            AutomationTest testToRun = (testRunner) =>
            {
                testRunner.Delay(1);

                testRunner.MoveToByName("ButtonWithToolTip");
                testRunner.Delay(1.5);
                GuiWidget toolTipWidget = buttonContainer.FindNamedChildRecursive("ToolTipWidget");
                Assert.IsTrue(toolTipWidget != null, "Tool tip is showing");
                testRunner.MoveToByName("right");
                toolTipWidget = buttonContainer.FindNamedChildRecursive("ToolTipWidget");
                Assert.IsTrue(toolTipWidget == null, "Tool tip is not showing");

                testRunner.Delay(1);
                buttonContainer.CloseOnIdle();

                return(Task.FromResult(0));
            };

            Button leftButton = new Button("left", 10, 40);

            leftButton.Name        = "ButtonWithToolTip";
            leftButton.ToolTipText = "Left Tool Tip";
            buttonContainer.AddChild(leftButton);
            Button rightButton = new Button("right", 110, 40);

            rightButton.Name = "right";
            buttonContainer.AddChild(rightButton);

            await AutomationRunner.ShowWindowAndExecuteTests(buttonContainer, testToRun, 10000);
        }
Example #30
0
        public async Task GetWidgetByNameTestRegionSingleWindow()
        {
            int leftClickCount = 0;

            var buttonContainer = new SystemWindow(300, 200);

            var leftButton = new Button("left", 10, 40);

            leftButton.Name   = "left";
            leftButton.Click += (sender, e) => { leftClickCount++; };
            buttonContainer.AddChild(leftButton);

            var rightButton = new Button("right", 110, 40);

            rightButton.Name = "right";
            buttonContainer.AddChild(rightButton);

            await AutomationRunner.ShowWindowAndExecuteTests(buttonContainer, (testRunner) =>
            {
                testRunner.ClickByName("left");
                testRunner.Delay(.5);
                Assert.AreEqual(1, leftClickCount, "Should have one left click count after click");

                Assert.IsTrue(testRunner.NameExists("left"), "Left button should exist");

                var widget = testRunner.GetWidgetByName(
                    "left",
                    out _,
                    5,
                    testRunner.GetRegionByName("right"));

                Assert.IsNull(widget, "Left button should not exist in the right button region");

                return(Task.CompletedTask);
            });
        }
        private static void ShowFileDialog(Action <string> dialogClosedHandler)
        {
            var systemWindow = new SystemWindow(600, 200)
            {
                Title           = "TestAutomation File Input",
                BackgroundColor = Color.DarkGray
            };

            var warningLabel = new TextWidget("This dialog should not appear outside of automation tests.\nNotify technical support if visible", pointSize: 15, textColor: Color.Pink)
            {
                Margin  = new BorderDouble(20),
                VAnchor = VAnchor.Top,
                HAnchor = HAnchor.Stretch
            };

            systemWindow.AddChild(warningLabel);

            var fileNameInput = new TextEditWidget(pixelWidth: 400)
            {
                VAnchor = VAnchor.Center,
                HAnchor = HAnchor.Stretch,
                Margin  = new BorderDouble(30, 15),
                Name    = "Automation Dialog TextEdit"
            };

            fileNameInput.EnterPressed += (s, e) => systemWindow.CloseOnIdle();
            systemWindow.AddChild(fileNameInput);

            systemWindow.Load   += (s, e) => fileNameInput.Focus();
            systemWindow.Closed += (s, e) =>
            {
                dialogClosedHandler(fileNameInput.Text);
            };

            systemWindow.ShowAsSystemWindow();
        }
Example #32
0
        public static void Main(string[] args)
        {
            //AggContext.Init(embeddedResourceName: "lion_outline.config.json");
            AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.OpenGLWinformsWindowProvider, agg_platform_win32";

            var demoWidget = new lion_outline();

            var systemWindow = new SystemWindow(512, 512)
            {
                Title = demoWidget.Title
            };

            systemWindow.AddChild(demoWidget);
            systemWindow.ShowAsSystemWindow();
        }
Example #33
0
        public void GetWidgetByNameTestRegionSingleWindow()
        {
            int leftClickCount = 0;

            Action <AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
            {
                AutomationRunner testRunner = new AutomationRunner();
                testRunner.ClickByName("left");
                testRunner.Wait(.5);
                resultsHarness.AddTestResult(leftClickCount == 1, "Got left button click");

                SearchRegion rightButtonRegion = testRunner.GetRegionByName("right");

                testRunner.ClickByName("left", searchRegion: rightButtonRegion);
                testRunner.Wait(.5);

                resultsHarness.AddTestResult(leftClickCount == 1, "Did not get left button click");
            };

            SystemWindow buttonContainer = new SystemWindow(300, 200);

            Button leftButton = new Button("left", 10, 40);

            leftButton.Name   = "left";
            leftButton.Click += (sender, e) => { leftClickCount++; };
            buttonContainer.AddChild(leftButton);
            Button rightButton = new Button("right", 110, 40);

            rightButton.Name = "right";
            buttonContainer.AddChild(rightButton);

            AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(buttonContainer, testToRun, 10);

            Assert.IsTrue(testHarness.AllTestsPassed);
            Assert.IsTrue(testHarness.TestCount == 2);             // make sure we can all our tests
        }
Example #34
0
		public void ToolTipsShow()
		{
			SystemWindow buttonContainer = new SystemWindow(300, 200)
			{
				BackgroundColor = RGBA_Bytes.White,
			};

			Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
			{
				AutomationRunner testRunner = new AutomationRunner("C:/TestImages");
				testRunner.Wait(1);

				// Now do the actions specific to this test. (replace this for new tests)
				{
					testRunner.MoveToByName("ButtonWithToolTip");
					testRunner.Wait(1.5);
					GuiWidget toolTipWidget = buttonContainer.FindNamedChildRecursive("ToolTipWidget");
					resultsHarness.AddTestResult(toolTipWidget != null, "Tool tip is showing");
					testRunner.MoveToByName("right");
					toolTipWidget = buttonContainer.FindNamedChildRecursive("ToolTipWidget");
					resultsHarness.AddTestResult(toolTipWidget == null, "Tool tip is not showing");
				}

				testRunner.Wait(1);
				buttonContainer.CloseOnIdle();
			};

			Button leftButton = new Button("left", 10, 40);
			leftButton.Name = "ButtonWithToolTip";
			leftButton.ToolTipText = "Left Tool Tip";
			buttonContainer.AddChild(leftButton);
			Button rightButton = new Button("right", 110, 40);
			rightButton.Name = "right";
			buttonContainer.AddChild(rightButton);

			AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(buttonContainer, testToRun, 10);

			Assert.IsTrue(testHarness.AllTestsPassed);
			Assert.IsTrue(testHarness.TestCount == 2); // make sure we can all our tests
		}
		public void ValidateEnterLeaveOnWidgetBoundsChange()
		{
			GuiWidget container = new SystemWindow(200, 200);
			container.Name = "container";

			GuiWidget regionA = new GuiWidget();
			regionA.Name = "regionA";
			regionA.BoundsRelativeToParent = new RectangleDouble(10, 10, 190, 190);
			int gotEnter = 0;
			int gotLeave = 0;
			regionA.MouseEnter += (sender, e) => { if (regionA.UnderMouseState == UnderMouseState.NotUnderMouse) throw new Exception("It must be under the mouse."); gotEnter++; };
			regionA.MouseLeave += (sender, e) => { if (regionA.UnderMouseState == UnderMouseState.FirstUnderMouse) throw new Exception("It must not be under the mouse."); gotLeave++; };
			int gotEnterBounds = 0;
			int gotLeaveBounds = 0;
			regionA.MouseEnterBounds += (sender, e) => { if (regionA.UnderMouseState == UnderMouseState.NotUnderMouse) throw new Exception("It must be under the mouse."); gotEnterBounds++; };
			regionA.MouseLeaveBounds += (sender, e) => { if (regionA.UnderMouseState != UnderMouseState.NotUnderMouse) throw new Exception("It must not be under the mouse."); gotLeaveBounds++; };
			container.AddChild(regionA);

			Assert.IsTrue(gotLeave == 0);
			Assert.IsTrue(gotEnter == 0);
			Assert.IsTrue(gotLeaveBounds == 0);
			Assert.IsTrue(gotEnterBounds == 0);

			// put the mouse into the widget but outside regionA
			container.OnMouseMove(new MouseEventArgs(MouseButtons.Left, 1, 5, 5, 0));
			Assert.IsTrue(regionA.UnderMouseState == UnderMouseState.NotUnderMouse);
			Assert.IsTrue(gotLeave == 0);
			Assert.IsTrue(gotEnter == 0);
			Assert.IsTrue(gotLeaveBounds == 0);
			Assert.IsTrue(gotEnterBounds == 0);
			// move regionA under mouse
			regionA.BoundsRelativeToParent = new RectangleDouble(0, 0, 180, 180);
			Assert.IsTrue(regionA.UnderMouseState == UnderMouseState.FirstUnderMouse);
			Assert.IsTrue(gotLeave == 0);
			Assert.IsTrue(gotEnter == 1);
			Assert.IsTrue(gotLeaveBounds == 0);
			Assert.IsTrue(gotEnterBounds == 1);
			// now regionA and make sure it does not re-trigger either event
			gotEnter = 0;
			gotEnterBounds = 0;
			regionA.BoundsRelativeToParent = new RectangleDouble(1, 1, 181, 181);
			Assert.IsTrue(regionA.UnderMouseState == UnderMouseState.FirstUnderMouse);
			Assert.IsTrue(gotLeave == 0);
			Assert.IsTrue(gotEnter == 0);
			Assert.IsTrue(gotLeaveBounds == 0);
			Assert.IsTrue(gotEnterBounds == 0);

			// now move out from under mouse and make sure we see the leave
			regionA.BoundsRelativeToParent = new RectangleDouble(10, 10, 190, 190);
			Assert.IsTrue(gotLeave == 1);
			Assert.IsTrue(gotEnter == 0);
			Assert.IsTrue(gotLeaveBounds == 1);
			Assert.IsTrue(gotEnterBounds == 0);

			// move back under
			gotLeave = gotEnter = gotLeaveBounds = gotEnterBounds = 0;
			regionA.BoundsRelativeToParent = new RectangleDouble(0, 0, 180, 180);
			Assert.IsTrue(gotEnter == 1);
			Assert.IsTrue(gotLeave == 0);
			Assert.IsTrue(gotLeaveBounds == 0);
			Assert.IsTrue(gotEnterBounds == 1);
		}
Example #36
0
		public void SelectAllOnFocusCanStillClickAfterSelection()
		{
			TextEditWidget editField = null;
			SystemWindow systemWindow = new SystemWindow(300, 200)
			{
				BackgroundColor = RGBA_Bytes.Black,
			};

			Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
			{
				editField.SelectAllOnFocus = true;
				AutomationRunner testRunner = new AutomationRunner();
				testRunner.Wait(1);

				resultsHarness.AddTestResult(testRunner.ClickByName(editField.Name, 1));

				editField.SelectAllOnFocus = true;
				testRunner.Type("123");
				resultsHarness.AddTestResult(editField.Text == "123", "on enter we have selected all and replaced the text");

				resultsHarness.AddTestResult(testRunner.ClickByName(editField.Name, 1));
				testRunner.Type("123");
				resultsHarness.AddTestResult(editField.Text == "123123", "we already have the contol selected so don't select all again.");

				systemWindow.CloseOnIdle();
			};

			editField = new TextEditWidget(pixelWidth: 200)
			{
				Name = "editField",
				Text = "Some Text",
				HAnchor = HAnchor.ParentCenter,
				VAnchor = VAnchor.ParentCenter,
			};
			systemWindow.AddChild(editField);

			AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(systemWindow, testToRun, 15);

			Assert.IsTrue(testHarness.AllTestsPassed);
			Assert.IsTrue(testHarness.TestCount == 4); // make sure we can all our tests
		}
Example #37
0
		public void VerifyFocusMakesTextWidgetEditable()
		{
			TextEditWidget editField = null;
			SystemWindow systemWindow = new SystemWindow(300, 200)
			{
				BackgroundColor = RGBA_Bytes.Black,
			};

			bool firstDraw = true;
			Stopwatch testDiedTimer = Stopwatch.StartNew();
			Action<AutomationTesterHarness> testToRun = (AutomationTesterHarness resultsHarness) =>
			{
				UiThread.RunOnIdle(editField.Focus);
				AutomationRunner testRunner = new AutomationRunner();
				testRunner.Wait(1);

				// Now do the actions specific to this test. (replace this for new tests)
				testRunner.Type("Test Text");

				resultsHarness.AddTestResult(editField.Text == "Test Text", "validate text is typed");

				systemWindow.CloseOnIdle();
			};

			editField = new TextEditWidget(pixelWidth: 200)
			{
				HAnchor = HAnchor.ParentCenter,
				VAnchor = VAnchor.ParentCenter,
			};
			systemWindow.AddChild(editField);

			AutomationTesterHarness testHarness = AutomationTesterHarness.ShowWindowAndExectueTests(systemWindow, testToRun, 10);

			Assert.IsTrue(testHarness.AllTestsPassed);
			Assert.IsTrue(testHarness.TestCount == 1); // make sure we can all our tests
		}
Example #38
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;
		}