Beispiel #1
0
        public static AutomationTesterHarness RunTest(
            Action <AutomationTesterHarness> testToRun,
            string staticDataPathOverride      = null,
            double maxTimeToRun                = 60,
            QueueTemplate queueItemFolderToAdd = QueueTemplate.None,
            int overrideWidth = -1, int overrideHeight = -1)
        {
            if (staticDataPathOverride == null)
            {
                // Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
                staticDataPathOverride = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "StaticData");
            }

#if !__ANDROID__
            // Set the static data to point to the directory of MatterControl
            StaticData.Instance = new FileSystemStaticData(staticDataPathOverride);
#endif
            // Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl"));

            if (queueItemFolderToAdd != QueueTemplate.None)
            {
                string queueTemplateDirectory = queueItemFolderToAdd.ToString();
                MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory);
            }

            MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(overrideWidth, overrideHeight);
            return(AutomationTesterHarness.ShowWindowAndExecuteTests(matterControlWindow, testToRun, maxTimeToRun));
        }
Beispiel #2
0
        public static AutomationTesterHarness RunTest(
            Action <AutomationTesterHarness> testToRun,
            string staticDataPathOverride      = null,
            double maxTimeToRun                = 60,
            QueueTemplate queueItemFolderToAdd = QueueTemplate.None)
        {
            // Walk back a step in the stack and output the callers name
            StackTrace st = new StackTrace(false);

            Console.WriteLine("\r\nRunning automation test: " + st.GetFrames().Skip(1).First().GetMethod().Name);

            if (staticDataPathOverride == null)
            {
                staticDataPathOverride = Path.Combine("..", "..", "..", "..", "StaticData");
            }

#if !__ANDROID__
            // Set the static data to point to the directory of MatterControl
            StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(staticDataPathOverride);
#endif
            MatterControlUtilities.OverrideAppDataLocation();

            if (queueItemFolderToAdd != QueueTemplate.None)
            {
                string queueTemplateDirectory = queueItemFolderToAdd.ToString();
                MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory);
            }

            MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance();
            return(AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, maxTimeToRun));
        }
        public static async Task RunTest(
            AutomationTest testMethod,
            string staticDataPathOverride      = null,
            double maxTimeToRun                = 60,
            QueueTemplate queueItemFolderToAdd = QueueTemplate.None,
            int overrideWidth        = -1,
            int overrideHeight       = -1,
            string defaultTestImages = null)
        {
            // Walk back a step in the stack and output the callers name
            StackTrace st = new StackTrace(false);

            Debug.WriteLine("\r\n ***** Running automation test: {0} {1} ", st.GetFrames().Skip(1).First().GetMethod().Name, DateTime.Now);

            if (staticDataPathOverride == null)
            {
                // Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
                staticDataPathOverride = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "StaticData");
            }

#if DEBUG
            string outputDirectory = "Debug";
#else
            string outputDirectory = "Release";
#endif

            Environment.CurrentDirectory = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "bin", outputDirectory);

#if !__ANDROID__
            // Set the static data to point to the directory of MatterControl
            StaticData.Instance = new FileSystemStaticData(staticDataPathOverride);
#endif
            // Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl"));

            if (queueItemFolderToAdd != QueueTemplate.None)
            {
                string queueTemplateDirectory = queueItemFolderToAdd.ToString();
                MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory);
            }

            if (defaultTestImages == null)
            {
                defaultTestImages = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestImages");
            }

            UserSettings.Instance.set(UserSettingsKey.ThumbnailRenderingMode, "orthographic");
            //GL.HardwareAvailable = false;
            MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(overrideWidth, overrideHeight);

            var config = TestAutomationConfig.Load();

            // Extract mouse speed from config
            AutomationRunner.TimeToMoveMouse = config.TimeToMoveMouse;

            await AutomationRunner.ShowWindowAndExecuteTests(matterControlWindow, testMethod, maxTimeToRun, defaultTestImages, config.AutomationInputType);
        }
		public static AutomationTesterHarness RunTest(
			Action<AutomationTesterHarness> testToRun, 
			string staticDataPathOverride = null, 
			double maxTimeToRun = 60, 
			QueueTemplate queueItemFolderToAdd = QueueTemplate.None)
		{
			// Walk back a step in the stack and output the callers name
			StackTrace st = new StackTrace(false);
			Console.WriteLine("\r\nRunning automation test: " + st.GetFrames().Skip(1).First().GetMethod().Name);

			if (staticDataPathOverride == null)
			{
				staticDataPathOverride = Path.Combine("..", "..", "..", "..", "StaticData");
			}

#if !__ANDROID__
			// Set the static data to point to the directory of MatterControl
			StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(staticDataPathOverride);
#endif
			MatterControlUtilities.OverrideAppDataLocation();

			if (queueItemFolderToAdd != QueueTemplate.None)
			{
				string queueTemplateDirectory = queueItemFolderToAdd.ToString();
				MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory);
			}

			MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance();
			return AutomationTesterHarness.ShowWindowAndExectueTests(matterControlWindow, testToRun, maxTimeToRun);
		}
Beispiel #5
0
        public static async Task RunTest(
            AutomationTest testMethod,
            string staticDataPathOverride      = null,
            double maxTimeToRun                = 60,
            QueueTemplate queueItemFolderToAdd = QueueTemplate.None,
            int overrideWidth        = -1,
            int overrideHeight       = -1,
            string defaultTestImages = null)
        {
            // Walk back a step in the stack and output the callers name
            //StackTrace st = new StackTrace(false);
            //Debug.WriteLine("\r\n ***** Running automation test: {0} {1} ", st.GetFrames().Skip(1).First().GetMethod().Name, DateTime.Now);

            if (staticDataPathOverride == null)
            {
                // Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
                staticDataPathOverride = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "StaticData");
            }

#if DEBUG
            string outputDirectory = "Debug";
#else
            string outputDirectory = "Release";
#endif

            Environment.CurrentDirectory = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "bin", outputDirectory);

            // Override the default SystemWindow type without config.json
            AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.OpenGLWinformsWindowProvider, agg_platform_win32";

#if !__ANDROID__
            // Set the static data to point to the directory of MatterControl
            AggContext.StaticData = new FileSystemStaticData(staticDataPathOverride);
#endif
            // Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
            MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl"));

            if (queueItemFolderToAdd != QueueTemplate.None)
            {
                MatterControlUtilities.AddItemsToQueue(queueItemFolderToAdd.ToString());
            }

            if (defaultTestImages == null)
            {
                defaultTestImages = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestImages");
            }

            UserSettings.Instance.set(UserSettingsKey.ThumbnailRenderingMode, "orthographic");
            //GL.HardwareAvailable = false;

            var config = TestAutomationConfig.Load();
            if (config.UseAutomationDialogs)
            {
                AggContext.Config.ProviderTypes.DialogProvider = "MatterHackers.Agg.Platform.AutomationDialogProvider, GuiAutomation";
            }

            // Extract mouse speed from config
            AutomationRunner.TimeToMoveMouse = config.TimeToMoveMouse;
            AutomationRunner.UpDelaySeconds  = config.MouseUpDelay;

            // Automation runner must do as much as program.cs to spin up platform
            string platformFeaturesProvider = "MatterHackers.MatterControl.WindowsPlatformsFeatures, MatterControl.Winforms";
            AppContext.Platform = AggContext.CreateInstanceFrom <INativePlatformFeatures>(platformFeaturesProvider);
            AppContext.Platform.ProcessCommandline();

            var(width, height) = RootSystemWindow.GetStartupBounds();

            rootSystemWindow = Application.LoadRootWindow(
                overrideWidth == -1 ? width : overrideWidth,
                overrideHeight == -1 ? height : overrideHeight);

            OemSettings.Instance.ShowShopButton = false;

            if (!config.UseAutomationMouse)
            {
                AutomationRunner.InputMethod = new WindowsInputMethods();
            }

            await AutomationRunner.ShowWindowAndExecuteTests(
                rootSystemWindow,
                testMethod,
                maxTimeToRun,
                defaultTestImages,
                closeWindow : () =>
            {
                if (ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Printing)
                {
                    ApplicationController.Instance.ActivePrinter.Connection.Disable();
                }

                rootSystemWindow.Close();
            });
        }
		public static AutomationTesterHarness RunTest(
			Action<AutomationTesterHarness> testToRun,
			string staticDataPathOverride = null,
			double maxTimeToRun = 60,
			QueueTemplate queueItemFolderToAdd = QueueTemplate.None,
			int overrideWidth = -1, int overrideHeight = -1)
		{
			if (staticDataPathOverride == null)
			{
				// Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
				staticDataPathOverride = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "StaticData");
			}

#if !__ANDROID__
			// Set the static data to point to the directory of MatterControl
			StaticData.Instance = new FileSystemStaticData(staticDataPathOverride);
#endif
			// Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
			MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl"));

			if (queueItemFolderToAdd != QueueTemplate.None)
			{
				string queueTemplateDirectory = queueItemFolderToAdd.ToString();
				MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory);
			}

			MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(overrideWidth, overrideHeight);
			return AutomationTesterHarness.ShowWindowAndExecuteTests(matterControlWindow, testToRun, maxTimeToRun);
		}
		public static async Task RunTest(
			AutomationTest testMethod,
			string staticDataPathOverride = null,
			double maxTimeToRun = 60,
			QueueTemplate queueItemFolderToAdd = QueueTemplate.None,
			int overrideWidth = -1, 
			int overrideHeight = -1,
			string defaultTestImages = null)
		{
			// Walk back a step in the stack and output the callers name
			StackTrace st = new StackTrace(false);
			Debug.WriteLine("\r\n ***** Running automation test: {0} {1} ", st.GetFrames().Skip(1).First().GetMethod().Name, DateTime.Now);

			if (staticDataPathOverride == null)
			{
				// Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
				staticDataPathOverride = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "StaticData");
			}

#if DEBUG
			string outputDirectory = "Debug";
#else
			string outputDirectory = "Release";
#endif

			Environment.CurrentDirectory = TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl", "bin", outputDirectory); 

#if !__ANDROID__
			// Set the static data to point to the directory of MatterControl
			StaticData.Instance = new FileSystemStaticData(staticDataPathOverride);
#endif
			// Popping one directory above MatterControl, then back down into MatterControl ensures this works in MCCentral as well and MatterControl
			MatterControlUtilities.OverrideAppDataLocation(TestContext.CurrentContext.ResolveProjectPath(5, "MatterControl"));

			if (queueItemFolderToAdd != QueueTemplate.None)
			{
				string queueTemplateDirectory = queueItemFolderToAdd.ToString();
				MatterControlUtilities.AddItemsToQueue(queueTemplateDirectory);
			}

			if (defaultTestImages == null)
			{
				defaultTestImages = TestContext.CurrentContext.ResolveProjectPath(4, "Tests", "TestData", "TestImages");
			}

			UserSettings.Instance.set(UserSettingsKey.ThumbnailRenderingMode, "orthographic");
			//GL.HardwareAvailable = false;
			MatterControlApplication matterControlWindow = MatterControlApplication.CreateInstance(overrideWidth, overrideHeight);

			var config = TestAutomationConfig.Load();

			// Extract mouse speed from config
			AutomationRunner.TimeToMoveMouse = config.TimeToMoveMouse;

			await AutomationRunner.ShowWindowAndExecuteTests(matterControlWindow, testMethod, maxTimeToRun, defaultTestImages, config.AutomationInputType);
		}