/// <summary> /// This summary has not been prepared yet. NOSUMMARY - pantal07 /// </summary> public override void Init(Variation v) { base.Init(v); parameters = new UnitTestObjects(v); PrepareAnimation(v["ClassName"], v["Property"], v["From"], v["To"], v["DefaultValue"]); }
/// <summary> /// Test variation initialization /// </summary> /// <param name="v"></param> public override void Init(Variation v) { base.Init(v); string ml = v["matchlevel"]; colorTolerance = (ml == null) ? 2 : StringConverter.ToDouble(ml); if (Variation.NewWindowPerVariation) { if (window != null) { window.Dispose(); window = null; } window = RenderingWindow.Create(v); Log(""); Log("BitDepth detected: {0}", ColorOperations.BitDepth); } else { if (window == null) { window = RenderingWindow.Create(Variation.GlobalParameters); Log(""); Log("BitDepth detected: {0}", ColorOperations.BitDepth); } } // We need to change background color per variation. // Global Variation won't have the right value, so there's no sense in doing this in the constructor. window.SetBackgroundColor(v.BackgroundColor); }
/// <summary> /// This summary has not been prepared yet. NOSUMMARY - pantal07 /// </summary> public override void Init(Variation v) { base.Init(v); v.AssertExistenceOf("ClassName", "Property", "From", "To", "DefaultValue", "TestType"); testType = (TestType)Enum.Parse(typeof(TestType), v["TestType"]); }
private static Matrix3D MakeViewMatrix(Variation v) { return(MatrixUtils.MakeViewMatrix( StringConverter.ToPoint3D(v["CameraPosition"]), StringConverter.ToVector3D(v["CameraLookDirection"]), StringConverter.ToVector3D(v["CameraUp"]) )); }
private static void SetLocalLightParameters(PointLightBase light, Variation v) { light.Position = StringConverter.ToPoint3D(v["LightPosition"]); light.Range = StringConverter.ToDouble(v["LightRange"]); light.ConstantAttenuation = StringConverter.ToDouble(v["LightConstantAttenuation"]); light.LinearAttenuation = StringConverter.ToDouble(v["LightLinearAttenuation"]); light.QuadraticAttenuation = StringConverter.ToDouble(v["LightQuadraticAttenuation"]); }
/// <summary/> public override void Init(Variation v) { base.Init(v); v.AssertExistenceOf("ExpectedException", "Visual"); exceptionType = Type.GetType(v["ExpectedException"]); visual = VisualFactory.MakeVisual(v["Visual"]); }
/// <summary> /// Initializes the test with variation specific data /// </summary> public virtual void Init(Variation v) { variation = v; failures = 0; string max = v["MaxLogFails"]; maxLogFails = (max == null) ? 50 : StringConverter.ToInt(max); string pri = v["Priority"]; priority = (pri == null) ? 0 : StringConverter.ToInt(pri); failOnPurpose = (v["Fail"] == "true") ? true : false; string prefix = v["LogFilePrefix"]; if (prefix == null) { prefix = this.GetType().Name; } logPrefix = prefix + "_" + TwoDigitVariationID(v.ID); DateTime current = DateTime.Now; logger = Logger.Create("Variation " + TwoDigitVariationID(v.ID)); if (TestLauncher.LogTime) { if (!loggedFirst) { DateTime logCreateTime = DateTime.Now; Log("Test Starting..."); DateTime firstLogTime = DateTime.Now; Log(" BeginTime: {0:HH:mm:ss.fff}", TestLauncher.BeginTime); Log(" LogCreationTime: {0:HH:mm:ss.fff}", logCreateTime - current); Log(" FirstLogTime: {0:HH:mm:ss.fff}", firstLogTime - logCreateTime); loggedFirst = true; } current = DateTime.Now; Log(" TotalTestTime: {0:HH:mm:ss.fff}", current - TestLauncher.BeginTime); Log(""); } if (v["Description"] != null) { Log("Test Description:"); Log("-----------------"); Log(" " + v["Description"]); Log(""); } if (v["Expectation"] != null) { Log("Expected Output:"); Log("----------------"); Log(" " + v["Expectation"]); Log(""); } }
/// <summary/> public SceneTestObjects(Variation v) : base(v) { visual3Ds = FactoryParser.MakeScene(v); camera = FactoryParser.MakeCamera(v); camera.Transform = TransformFactory.MakeTransform(v["CameraTransform"]); ObjectUtils.NameObjects(visual3Ds); }
/// <summary/> public UnitTestObjects(Variation v) : base(v) { model = FactoryParser.MakeModel(v); camera = FactoryParser.MakeCamera(v); light = FactoryParser.MakeLight(v); transform = FactoryParser.MakeTransform3D(v); modelVisual = CreateModelVisual(v); }
/// <summary/> public static RenderingWindow Create(Variation v) { if (v.UseViewport3D) { return(new ViewportWindow(v)); } return(new VisualWindow(v)); }
private static Matrix3D MakeOrthoMatrix(Variation v) { return(MatrixUtils.MakeOrthographicProjection( StringConverter.ToDouble(v["CameraNearPlaneDistance"]), StringConverter.ToDouble(v["CameraFarPlaneDistance"]), StringConverter.ToDouble(v["CameraWidth"]), StringConverter.ToDouble(v["CameraHeight"]) )); }
private static Matrix3D MakePerspMatrix(Variation v) { return(MatrixUtils.MakePerspectiveProjection( StringConverter.ToDouble(v["CameraNearPlaneDistance"]), StringConverter.ToDouble(v["CameraFarPlaneDistance"]), StringConverter.ToDouble(v["CameraFieldOfViewX"]), StringConverter.ToDouble(v["CameraFieldOfViewY"]) )); }
private static Visual3D MakeModelUIElement3D(Variation v, string visualName) { Model3D model = MakeCustomModel3D(v, visualName); ModelUIElement3D visual = new ModelUIElement3D(); visual.Model = model; return(visual); }
/// <summary/> public static Camera MakeCamera(Variation v) { Camera camera = null; if (v["Camera"] != null) { v.AssertAbsenceOf("CameraType", "CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraWidth", "CameraFieldOfView", "CameraViewMatrix", "CameraProjectionMatrix"); camera = CameraFactory.MakeCamera(v["Camera"]); } else { v.AssertExistenceOf("CameraType"); switch (v["CameraType"]) { case "Orthographic": v.AssertExistenceOf("CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraWidth"); camera = new OrthographicCamera(); SetProjectionCameraParameters(camera, v); ((OrthographicCamera)camera).Width = StringConverter.ToDouble(v["CameraWidth"]); break; case "Perspective": v.AssertExistenceOf("CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraFieldOfView"); camera = new PerspectiveCamera(); SetProjectionCameraParameters(camera, v); ((PerspectiveCamera)camera).FieldOfView = StringConverter.ToDouble(v["CameraFieldOfView"]); break; case "Matrix": v.AssertExistenceOf("CameraViewMatrix", "CameraProjectionMatrix"); camera = new MatrixCamera(); ((MatrixCamera)camera).ViewMatrix = StringConverter.ToMatrix3D(v["CameraViewMatrix"]); ((MatrixCamera)camera).ProjectionMatrix = StringConverter.ToMatrix3D(v["CameraProjectionMatrix"]); break; case "MatrixOrtho": v.AssertExistenceOf("CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraWidth", "CameraHeight"); camera = new MatrixCamera(); ((MatrixCamera)camera).ViewMatrix = MakeViewMatrix(v); ((MatrixCamera)camera).ProjectionMatrix = MakeOrthoMatrix(v); break; case "MatrixPersp": v.AssertExistenceOf("CameraPosition", "CameraLookDirection", "CameraUp", "CameraNearPlaneDistance", "CameraFarPlaneDistance", "CameraFieldOfViewX", "CameraFieldOfViewY"); camera = new MatrixCamera(); ((MatrixCamera)camera).ViewMatrix = MakeViewMatrix(v); ((MatrixCamera)camera).ProjectionMatrix = MakePerspMatrix(v); break; default: throw new ApplicationException("Invalid camera type: " + v["CameraType"]); } } return(camera); }
private static Visual3D MakeModelVisual3D(Variation v, string visualName) { Model3D model = MakeCustomModel3D(v, visualName); ModelVisual3D visual = new ModelVisual3D(); visual.Content = model; PopulateChildVisuals(v, visualName, visual.Children); return(visual); }
private static void SetProjectionCameraParameters(Camera camera, Variation v) { ProjectionCamera c = (ProjectionCamera)camera; c.Position = StringConverter.ToPoint3D(v["CameraPosition"]); c.LookDirection = StringConverter.ToVector3D(v["CameraLookDirection"]); c.UpDirection = StringConverter.ToVector3D(v["CameraUp"]); c.NearPlaneDistance = StringConverter.ToDouble(v["CameraNearPlaneDistance"]); c.FarPlaneDistance = StringConverter.ToDouble(v["CameraFarPlaneDistance"]); }
private static Model3DCollection MakeModelCollection(Variation v, string namePrefix) { // Meta-symbology: // { }* == Klene star, or 0 or more occurrances of the stuff inside the brackets // { }? == Optional, the stuff inside the brackets may or may not exist // < > == Description of what's parsed, the stuff inside the brackets is not a literal string // You can specify up to 10 children per model group (0-9) // namePrefix has format: "Child{n}*" Model3DCollection collection = new Model3DCollection(); for (int i = 0; i < 10; i++) { string modelName = namePrefix + i.ToString(); string modelValue = v[modelName]; if (modelValue == null) { break; } string materialName = modelName.Replace("Child", "Material"); string backMaterialName = modelName.Replace("Child", "BackMaterial"); string transformName = modelName.Replace("Child", "ModelTransform"); try { Model3D model = ModelFactory.MakeModel(modelValue); if (model is GeometryModel3D) { Material front = MakeMaterial(v, materialName); Material back = MakeMaterial(v, backMaterialName); if (front != null) { ((GeometryModel3D)model).Material = front; } ((GeometryModel3D)model).BackMaterial = back; } model.Transform = TransformFactory.MakeTransform(v[transformName]); if (model is Model3DGroup && v[modelName + "0"] != null) { ((Model3DGroup)model).Children = MakeModelCollection(v, modelName); } collection.Add(model); } catch (ArgumentException) { throw new ApplicationException("Confused by attribute (" + modelName + " = " + modelValue + ")"); } } return(collection); }
private static void PopulateChildVisuals(Variation v, string visualName, Visual3DCollection visualChildren) { if (v[visualName + "0"] != null) { Visual3D[] children = MakeVisuals(v, visualName); foreach (Visual3D v3d in children) { visualChildren.Add(v3d); } } }
private static Visual3D[] MakeVisuals(Variation v, string namePrefix) { // Meta-symbology: // { }* == Klene star, or 0 or more occurrances of the stuff inside the brackets // { }? == Optional, the stuff inside the brackets may or may not exist // < > == Description of what's parsed, the stuff inside the brackets is not a literal string // You can specify up to 10 children per model group (0-9) // namePrefix has format: "Visual{n}*" List <Visual3D> visuals = new List <Visual3D>(); string visualName = null; try { for (int i = 0; i < 10; i++) { visualName = namePrefix + i.ToString(); string visualContent = v[visualName]; if (visualContent == null) { break; } // Each visual can have extra properties set on it: // i.e: // Visual0="mesh" // Material0="255,255,255,255" // BackMaterial0="255,255,255,255" // Skip0="SkipSelf" // VisualTransform0="Translate 0,0,1" // ModelTransform0="Translate 0,0,-1" // // Visual1="Group" // Child10="light" // Child11="mesh" // Child12="Group" // Child120="mesh" visuals.Add(MakeVisual3D(v, visualName)); } } catch (ArgumentException ex) { throw new ApplicationException("Failed to create (" + visualName + ")", ex); } Visual3D[] result = new Visual3D[visuals.Count]; visuals.CopyTo(result); return(result); }
/// <summary/> public static HitTestFilterCallback MakeFilter(Variation v) { if (v["HitTestFilter"] == null) { // return(null); } else { return(HitTestFilterFactory.MakeFilter(v["HitTestFilter"])); } }
/// <summary/> protected virtual void ParseOptionalParameters(Variation v) { #if !STANDALONE_BUILD // For logging purposes in the lab, we don't need to save ALL of these images... bool enableLessCrucialOptions = false; #else bool enableLessCrucialOptions = true; #endif forceSave = v["ForceSave", false]; saveXamlRepro = v["SaveXamlRepro", false]; saveExpectedFB = v["SaveExpectedFrameBuffer", true]; saveExpectedTB = v["SaveExpectedToleranceBuffer", true]; saveExpectedZB = v["SaveExpectedZBuffer", enableLessCrucialOptions]; saveDiffFB = true; // v["SaveDiffFrameBuffer", enableLessCrucialOptions]; saveDiffTB = v["SaveDiffToleranceBuffer", true]; saveDiffZB = v["SaveDiffZBuffer", enableLessCrucialOptions]; verifySerialization = v["VerifySerialization", false]; renderingEffect = (v["RenderingEffect"] != null) ? (RenderingEffect)Enum.Parse(typeof(RenderingEffect), v["RenderingEffect"]) : RenderingEffect.None; interpolationMode = (v["InterpolationMode"] != null) ? (InterpolationMode)Enum.Parse(typeof(InterpolationMode), v["InterpolationMode"]) : InterpolationMode.Gouraud; SceneRenderer.EnableAntiAliasedRendering = v["EnableAntiAliasedRendering", false]; TextureFilter.SaveTextures = v["SaveTextures", false]; numAllowableMismatches = -1; VScanToleranceFile = null; // First try getting them from the variation parameters if (v["VScanToleranceFile"] != null) { Int32.TryParse((string)v["NumAllowableMismatches"], out numAllowableMismatches); } if (v["VScanToleranceFile"] != null) { VScanToleranceFile = (string)v["VScanToleranceFile"]; } // If not found, try the test driver parameters if (numAllowableMismatches < 0) { Int32.TryParse((string)Application.Current.Properties["NumAllowableMismatches"], out numAllowableMismatches); } if (VScanToleranceFile == null) { VScanToleranceFile = (string)Application.Current.Properties["VScanToleranceFile"]; } }
private ModelVisual3D CreateModelVisual(Variation v) { Model3DGroup group = new Model3DGroup(); group.Children = new Model3DCollection(new Model3D[] { light, model }); ModelVisual3D visual = new ModelVisual3D(); visual.Content = group; SetTransform(visual, v); return(visual); }
/// <summary/> public override void Init(Variation v) { base.Init(v); v.AssertExistenceOf("RenderingMode", "Visual", "ReferenceWindowPosition"); renderingMode = v["RenderingMode"]; // Create two copies so that we don't have aliasing problems firstVisual = VisualFactory.MakeVisual(v["Visual"]); secondVisual = VisualFactory.MakeVisual(v["Visual"]); firstPass = true; referenceWindowPosition = StringConverter.ToPoint(v["ReferenceWindowPosition"]); }
/// <summary> /// This summary has not been prepared yet. NOSUMMARY - pantal07 /// </summary> public AnimationTimeline MakeAnimation(Variation v, Type baseType) { v.AssertExistenceOf("From", "To", "DurationSeconds"); Type animationType = GetAnimationType(baseType); object[] args = GetAnimationConstructorArgs(v, baseType); AnimationTimeline timeline = (AnimationTimeline)TrustedActivator.CreateInstance(animationType, args); timeline.RepeatBehavior = RepeatBehavior.Forever; return(timeline); }
/// <summary/> public static void MakeTolerance(Variation v) { RenderTolerance.ResetDefaults(); if (v["PixelToEdgeTolerance"] != null) { RenderTolerance.PixelToEdgeTolerance = StringConverter.ToDouble(v["PixelToEdgeTolerance"]); } if (v["LightingRangeTolerance"] != null) { RenderTolerance.LightingRangeTolerance = StringConverter.ToDouble(v["LightingRangeTolerance"]); } if (v["SpotLightAngleTolerance"] != null) { RenderTolerance.SpotLightAngleTolerance = StringConverter.ToDouble(v["SpotLightAngleTolerance"]); } if (v["ZBufferTolerance"] != null) { RenderTolerance.ZBufferTolerance = StringConverter.ToDouble(v["ZBufferTolerance"]); } if (v["SpecularLightDotProductTolerance"] != null) { RenderTolerance.SpecularLightDotProductTolerance = StringConverter.ToDouble(v["SpecularLightDotProductTolerance"]); } if (v["DefaultColorTolerance"] != null) { RenderTolerance.DefaultColorTolerance = StringConverter.ToColor(v["DefaultColorTolerance"]); } if (v["TextureLookUpTolerance"] != null) { RenderTolerance.TextureLookUpTolerance = StringConverter.ToDouble(v["TextureLookUpTolerance"]); } if (v["SilhouetteEdgeTolerance"] != null) { RenderTolerance.SilhouetteEdgeTolerance = StringConverter.ToDouble(v["SilhouetteEdgeTolerance"]); } if (v["ViewportClippingTolerance"] != null) { RenderTolerance.ViewportClippingTolerance = StringConverter.ToDouble(v["ViewportClippingTolerance"]); } }
/// <summary/> public static Light MakeLight(Variation v) { Light light = null; if (v["Light"] != null) { v.AssertAbsenceOf("LightType", "LightColor", "LightPosition", "LightDirection", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation", "LightInnerConeAngle", "LightOuterConeAngle"); light = LightFactory.MakeLight(v["Light"]); } else { v.AssertExistenceOf("LightType", "LightColor"); switch (v["LightType"]) { case "Ambient": light = new AmbientLight(); break; case "Directional": v.AssertExistenceOf("LightDirection"); light = new DirectionalLight(); ((DirectionalLight)light).Direction = StringConverter.ToVector3D(v["LightDirection"]); break; case "Point": v.AssertExistenceOf("LightPosition", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation"); light = new PointLight(); SetLocalLightParameters((PointLight)light, v); break; case "Spot": v.AssertExistenceOf("LightPosition", "LightDirection", "LightRange", "LightConstantAttenuation", "LightLinearAttenuation", "LightQuadraticAttenuation", "LightInnerConeAngle", "LightOuterConeAngle"); light = new SpotLight(); SetLocalLightParameters((SpotLight)light, v); ((SpotLight)light).Direction = StringConverter.ToVector3D(v["LightDirection"]); ((SpotLight)light).InnerConeAngle = StringConverter.ToDouble(v["LightInnerConeAngle"]); ((SpotLight)light).OuterConeAngle = StringConverter.ToDouble(v["LightOuterConeAngle"]); break; default: throw new ApplicationException("Invalid light type: " + v["LightType"]); } light.Color = StringConverter.ToColor(v["LightColor"]); } return(light); }
private object[] GetAnimationConstructorArgs(Variation v, Type baseType) { string from = v["From"]; string to = v["To"]; string seconds = v["DurationSeconds"]; Duration duration = TimeSpan.FromSeconds(StringConverter.ToDouble(seconds)); if (baseType.IsValueType) { return(new object[] { MakeValue(from, baseType), MakeValue(to, baseType), duration }); } else { return(new object[] { MakeObject(from), MakeObject(to), duration }); } }
private void CreateVariations(XmlElement init) { ArrayList list = new ArrayList(); for (XmlNode node = init["VARIATION"]; node != null; node = node.NextSibling) { XmlElement variation = node as XmlElement; if (variation == null || variation.Name != "VARIATION") { continue; } Variation v = new Variation(new TokenList(variation)); list.Add(v); } variations = new Variation[list.Count]; list.CopyTo(variations); }
/// <summary/> public override void Init(Variation v) { base.Init(v); xamlFile = v["Xaml"]; if (xamlFile == null) { throw new ApplicationException("SerializationTest is missing Xaml="); } string bad = v["Bad"]; shouldFail = (bad == null) ? false : StringConverter.ToBool(bad); if (shouldFail) { Log("Expecting bad parameters"); } }
/// <summary/> protected RenderingWindow(Variation v) { variation = v; photographer = new Photographer(); RenderingTest.Invoke(DispatcherPriority.Normal, CreateWindow, null); // If the window position is not valid, that means the system placed it somewhere on the primary display. // (0,0) will get us the primary display. Point windowPosition = v.IsWindowPositionValid ? v.WindowPosition : new Point(0, 0); ColorOperations.DiscoverBitDepth(windowPosition); if (v.RenderingMode != null) { RenderingTest.Invoke(DispatcherPriority.Normal, SetRenderingMode, v.RenderingMode); } }