Esempio n. 1
0
		public void EnsureFlowLayoutMinSizeFitsChildrenMinSize()
		{
			// This test is to prove that a flow layout widget always has it's min size set
			// to the enclosing bounds size of all it's childrens min size.
			// The code to be tested will expand the flow layouts min size as it's children's min size change.
			GuiWidget containerTest = new GuiWidget(640, 480);
			FlowLayoutWidget topToBottomFlowLayoutAll = new FlowLayoutWidget(FlowDirection.TopToBottom);
			containerTest.AddChild(topToBottomFlowLayoutAll);
			containerTest.DoubleBuffer = true;

			FlowLayoutWidget topLeftToRight = new FlowLayoutWidget(FlowDirection.LeftToRight);
			topToBottomFlowLayoutAll.AddChild(topLeftToRight);
			GuiWidget bottomLeftToRight = new FlowLayoutWidget(FlowDirection.LeftToRight);
			topToBottomFlowLayoutAll.AddChild(bottomLeftToRight);

			topLeftToRight.AddChild(new Button("top button"));

			FlowLayoutWidget bottomContentTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			bottomLeftToRight.AddChild(bottomContentTopToBottom);

			Button button1 = new Button("button1");
			Assert.IsTrue(button1.MinimumSize.x > 0, "Buttons should set their min size on construction.");
			bottomContentTopToBottom.AddChild(button1);
			//Assert.IsTrue(bottomContentTopToBottom.MinimumSize.x >= button1.MinimumSize.x, "There should be space for the button.");
			bottomContentTopToBottom.AddChild(new Button("button2"));
			Button wideButton = new Button("button3 Wide");
			bottomContentTopToBottom.AddChild(wideButton);
			//Assert.IsTrue(bottomContentTopToBottom.MinimumSize.x >= wideButton.MinimumSize.x, "These should be space for the button.");

			containerTest.BackgroundColor = RGBA_Bytes.White;
			containerTest.OnDrawBackground(containerTest.NewGraphics2D());
			containerTest.OnDraw(containerTest.NewGraphics2D());
			OutputImage(containerTest.BackBuffer, "zFlowLaoutsGetMinSize.tga");

			Assert.IsTrue(bottomLeftToRight.Width > 0, "This needs to have been expanded when the bottomContentTopToBottom grew.");
			Assert.IsTrue(bottomLeftToRight.MinimumSize.x >= bottomContentTopToBottom.MinimumSize.x, "These should be space for the next flowLayout.");
			Assert.IsTrue(containerTest.BackBuffer != null, "When we set a guiWidget to DoubleBuffer it needs to create one.");
		}