public void TestContent() { ResetState(); // default value Assert.Null(Content); // test parent setting var content = new ContentControlTest(); Content = content; Assert.Equal(this, content.Parent); Assert.Equal(content, Content); // unset content Content = null; Assert.Null(content.Parent); Assert.Null(Content); // reset the content var contentControl = new ContentControlTest { Content = content }; contentControl.Content = content; // content reused Assert.Throws <InvalidOperationException>(() => Content = content); }
public void TestCollapseOverride() { ResetState(); // create a content var child = new ContentControlTest(); Content = child; // set the size of the content child.Width = 100 * rand.NextFloat(); child.Height = 100 * rand.NextFloat(); child.Depth = 150 * rand.NextFloat(); // arrange and check child render size Arrange(1000 * rand.NextVector3(), true); Assert.Equal(Vector3.Zero, child.RenderSize); }
public void TestUpdateWorldMatrix() { ResetState(); DepthAlignment = DepthAlignment.Stretch; // set the panel size to 1 Arrange(Vector3.One, false); // test that the world matrix of the panel is correctly updated. var localMatrix = Matrix.Scaling(0.1f, 0.5f, 1f); var worldMatrix = Matrix.Scaling(1f, 0.8f, 0.4f); LocalMatrix = localMatrix; UpdateWorldMatrix(ref worldMatrix, true); Assert.Equal(new Matrix(0.1f, 0, 0, 0, 0, 0.4f, 0, 0, 0, 0, 0.4f, 0, 0.5f, 0.4f, 0.2f, 1), WorldMatrix); // add a child and set its local matrix var child = new ContentControlTest { DepthAlignment = DepthAlignment.Stretch }; var childArrangementMatrix = Matrix.Translation(10, 20, 30); var childLocalMatrix = new Matrix(0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); child.LocalMatrix = childLocalMatrix; Content = child; // set the child's panel arrangement matrix VisualContent.DependencyProperties.Set(ContentArrangeMatrixPropertyKey, childArrangementMatrix); // arrange the child (set its size to 1) child.Arrange(Vector3.One, false); // check that the value of the world matrix of the child is correctly updated too UpdateWorldMatrix(ref worldMatrix, true); Assert.Equal(new Matrix(0, -0.4f, 0, 0, 0.1f, 0, 0, 0, 0, 0, 0.4f, 0, 1.55f, 8.6f, 12.4f, 1), child.WorldMatrix); }