public void LayoutItemOnLayout() { tlog.Debug(tag, $"LayoutItemOnLayout START"); flagOnLayoutOverride = false; Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initially"); var testingTarget = new MyLayoutItem(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutItem>(testingTarget, "Should be an instance of LayoutItem type."); testingTarget.OnLayoutTest(true, new LayoutLength(5), new LayoutLength(5), new LayoutLength(10), new LayoutLength(10)); Assert.True(flagOnLayoutOverride, "LayoutItem overridden method not invoked."); // Test with false parameter flagOnLayoutOverride = false; Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initially"); testingTarget.OnLayoutTest(false, new LayoutLength(5), new LayoutLength(5), new LayoutLength(10), new LayoutLength(10)); Assert.True(flagOnLayoutOverride, "LayoutItem overridden method not invoked with false parameter."); testingTarget.Dispose(); tlog.Debug(tag, $"LayoutItemOnLayout END (OK)"); }
public void LayoutItemResolveSizeAndState() { tlog.Debug(tag, $"LayoutItemResolveSizeAndState START"); var testingTarget = new MyLayoutItem(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutItem>(testingTarget, "Should be an instance of LayoutItem type."); MeasureSpecification measureSpec = new MeasureSpecification(new LayoutLength(10), MeasureSpecification.ModeType.Exactly); MeasuredSize measuredSize = testingTarget.ResolveSizeAndState(new LayoutLength(50), measureSpec, MeasuredSize.StateType.MeasuredSizeOK); Assert.AreEqual(measureSpec.GetSize().AsRoundedValue(), 10, "measuredSize not resolved correctly"); testingTarget.Dispose(); tlog.Debug(tag, $"LayoutItemResolveSizeAndState END (OK)"); }
public void LayoutItemOnAttachedToOwner() { tlog.Debug(tag, $"LayoutItemOnAttachedToOwner START"); flagOnAttachedToOwnerOverride = false; Assert.False(flagOnAttachedToOwnerOverride, "flag should be false initially"); var testingTarget = new MyLayoutItem(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutItem>(testingTarget, "Should be an instance of LayoutItem type."); testingTarget.OnAttachedToOwnerTest(); Assert.True(flagOnAttachedToOwnerOverride, "LayoutItem overridden method not invoked."); testingTarget.Dispose(); tlog.Debug(tag, $"LayoutItemOnAttachedToOwner END (OK)"); }
public void LayoutItemMeasure() { tlog.Debug(tag, $"LayoutItemMeasure START"); var testingTarget = new MyLayoutItem(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutItem>(testingTarget, "Should be an instance of LayoutGroup type."); View view = new View() { ExcludeLayouting = false, Size = new Size(100, 150) }; testingTarget.AttachToOwner(view); LayoutGroup layoutGroup = new LayoutGroup(); testingTarget.SetParent(layoutGroup); testingTarget.RequestLayout(); // Ensures a layout pass is needed. MeasureSpecification imposedWidth = new MeasureSpecification(new LayoutLength(300.0f), MeasureSpecification.ModeType.Exactly); MeasureSpecification imposedHeight = new MeasureSpecification(new LayoutLength(300.0f), MeasureSpecification.ModeType.Exactly); try { testingTarget.Measure(imposedWidth, imposedHeight); } catch (Exception e) { tlog.Error(tag, "Caught Exception" + e.ToString()); LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); Assert.Fail("Caught Exception" + e.ToString()); } layoutGroup.Dispose(); testingTarget.Dispose(); view.Dispose(); tlog.Debug(tag, $"LayoutItemMeasure END (OK)"); }
public void LayoutItemSetMeasuredDimensions() { tlog.Debug(tag, $"LayoutItemSetMeasuredDimensions START"); var testingTarget = new MyLayoutItem(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutItem>(testingTarget, "Should be an instance of LayoutItem type."); MeasuredSize measuredWidth = new MeasuredSize(new LayoutLength(100), MeasuredSize.StateType.MeasuredSizeOK); MeasuredSize measuredHeight = new MeasuredSize(new LayoutLength(50), MeasuredSize.StateType.MeasuredSizeOK); testingTarget.SetMeasuredDimensions(measuredWidth, measuredHeight); Assert.AreEqual(100, testingTarget.MeasuredWidth.Size.AsRoundedValue(), "Should be value set"); Assert.AreEqual(50, testingTarget.MeasuredHeight.Size.AsRoundedValue(), "Should be value set"); testingTarget.Dispose(); tlog.Debug(tag, $"LayoutItemSetMeasuredDimensions END (OK)"); }
public void LayoutItemOnMeasure() { tlog.Debug(tag, $"LayoutItemOnMeasure START"); flagOnMeasureOverride = false; Assert.False(flagOnMeasureOverride, "flagOnMeasureOverride should be false initial"); var testingTarget = new MyLayoutItem(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutItem>(testingTarget, "Should be an instance of LayoutItem type."); View view = new View() { ExcludeLayouting = false, Size = new Size(100, 150) }; testingTarget.AttachToOwner(view); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); testingTarget.OnMeasureTest(measureWidth, measureHeight); Assert.True(flagOnMeasureOverride, "LayoutItem overridden method not invoked."); /** MeasureSpecification.ModeType.Atmost & Unspecified */ flagOnMeasureOverride = false; Assert.False(flagOnMeasureOverride, "flagOnMeasureOverride should be false initial"); MeasureSpecification measureWidth2 = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.AtMost); MeasureSpecification measureHeight2 = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Unspecified); testingTarget.OnMeasureTest(measureWidth2, measureHeight2); Assert.True(flagOnMeasureOverride, "LayoutItem overridden method not invoked."); testingTarget.Dispose(); tlog.Debug(tag, $"LayoutItemOnMeasure END (OK)"); }
public void LayoutItemLayout() { tlog.Debug(tag, $"LayoutItemLayout START"); var testingTarget = new MyLayoutItem(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutItem>(testingTarget, "Should be an instance of LayoutGroup type."); View view = new View() { ExcludeLayouting = false, Size = new Size(100, 150), Layout = new LinearLayout() { LayoutWithTransition = true } }; testingTarget.AttachToOwner(view); try { testingTarget.Layout(new LayoutLength(0), new LayoutLength(10), new LayoutLength(0), new LayoutLength(5)); } catch (Exception e) { tlog.Error(tag, "Caught Exception" + e.ToString()); LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); Assert.Fail("Caught Exception" + e.ToString()); } view.Dispose(); testingTarget?.Dispose(); tlog.Debug(tag, $"LayoutItemLayout END (OK)"); }