private void RunCommand(TreeNode <Command> node) { GetImageAndTimeout(node, out Guid imageGuid, out int timeout); if (Logger.AssertIf(imageGuid.IsDefault(), "Command does not have valid image referenced: " + node.ToString())) { return; } var image = RuntimeAssetManager.GetAsset <Bitmap>(imageGuid); if (image == null) { TestData.ShouldFailTest = true; return; } var points = FeatureDetectionThread.FindImageSync(image, timeout); if (points == null || points.Length == 0) { TestData.ShouldFailTest = true; return; } foreach (var p in points) { TestData.CommandRunningCallback?.Invoke(node.value); node.value.Run(TestData); foreach (var childNode in node) { if (TestData.ShouldCancelRun) { return; } OverrideCommandPropertiesIfExist(childNode.value, p.X, "X"); OverrideCommandPropertiesIfExist(childNode.value, p.Y, "Y"); var runner = TestData.RunnerFactory.GetFor(childNode.value.GetType()); runner.Run(childNode.value); } } }
public void Run(IRunnable runnable) { if (!TestData.RunnerFactory.DoesRunnerSupportType(this.GetType(), runnable.GetType())) { Logger.Log(LogType.Error, "This runner '" + this + "' is not compatible with this type: '" + runnable.GetType()); return; } if (runnable is CommandRunScript command) { TestData.CommandRunningCallback?.Invoke(command); var runner = TestData.RunnerFactory.GetFor(typeof(LightScript)); var oldScript = TestData.TestFixture; var script = RuntimeAssetManager.GetAsset <LightScript>(command.Asset); runner.Run(script); TestData.TestFixture = oldScript; } }
public void Run(IRunnable runnable) { if (!TestData.RunnerFactory.DoesRunnerSupportType(this.GetType(), runnable.GetType())) { Logger.Logi(LogType.Error, "This runner '" + this + "' is not compatible with this type: '" + runnable.GetType()); return; } var command = runnable as CommandIfImageVisible; var commandNode = TestData.TestFixture.Commands.FirstOrDefault(n => n.value == command); if (Logger.AssertIf(command.Asset.IsDefault(), "Command does not have valid image referenced: " + command.ToString())) { return; } var image = RuntimeAssetManager.GetAsset <Bitmap>(command.Asset); if (image == null) { TestData.ShouldFailTest = true; return; } TestData.CommandRunningCallback?.Invoke(commandNode.value); var points = FeatureDetectionThread.FindImageSync(image, command.Timeout); // Image was not found if (points == null || points.Length == 0) { if (command.ExpectTrue) { return; } foreach (var childNode in commandNode) { if (TestData.ShouldCancelRun) { return; } var runner = TestData.RunnerFactory.GetFor(childNode.value.GetType()); runner.Run(childNode.value); } } else // Image was found { if (!command.ExpectTrue) { return; } foreach (var p in points) { command.Run(TestData); foreach (var childNode in commandNode) { if (TestData.ShouldCancelRun) { return; } OverrideCommandPropertiesIfExist(childNode.value, p.X, "X"); OverrideCommandPropertiesIfExist(childNode.value, p.Y, "Y"); var runner = TestData.RunnerFactory.GetFor(childNode.value.GetType()); runner.Run(childNode.value); } } } }