public void LayoutGroupMeasureChildWithMargins() { tlog.Debug(tag, $"LayoutGroupMeasureChildWithMargins START"); flagOnMeasureChild = false; Assert.False(flagOnMeasureChild, "flagOnMeasureChild should be false initially"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); View view = new View() { ExcludeLayouting = false, Size = new Size(100, 150) }; using (LayoutItem child = new LayoutItem()) { child.AttachToOwner(view); testingTarget.Add(child); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); testingTarget.MeasureChildWithMarginsTest(child, measureWidth, new LayoutLength(10), measureHeight, new LayoutLength(10)); Assert.True(flagOnMeasureChild, "LayoutGroup MeasureChild method not invoked when children measured."); } testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupMeasureChildWithMargins END (OK)"); }
public void LayoutGroupMeasureChildWithMarginsWithNullArgument() { tlog.Debug(tag, $"LayoutGroupMeasureChildWithMarginsWithNullArgument START"); flagOnMeasureChild = false; Assert.False(flagOnMeasureChild, "flagOnMeasureChild should be false initially"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); try { testingTarget.MeasureChildWithMarginsTest(null, measureWidth, new LayoutLength(10), measureHeight, new LayoutLength(10)); Assert.Fail("Should return null argument exception"); } catch (ArgumentNullException) { testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupMeasureChildWithMarginsWithNullArgument END (OK)"); Assert.Pass("ArgumentNullException: passed!"); } }
public void LayoutGroupOnLayout() { tlog.Debug(tag, $"LayoutGroupOnLayout START"); flagOnLayoutOverride = false; Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); using (LayoutItem child = new LayoutItem()) { testingTarget.Add(child); View view = new View() { Position = new Position(100, 150) }; child.AttachToOwner(view); testingTarget.OnLayoutTest(true, new LayoutLength(5), new LayoutLength(5), new LayoutLength(10), new LayoutLength(10)); Assert.True(flagOnLayoutOverride, "LayoutGroup overridden method not invoked."); // Test with false parameter. flagOnLayoutOverride = false; Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial"); testingTarget.OnLayoutTest(false, new LayoutLength(10), new LayoutLength(10), new LayoutLength(20), new LayoutLength(20)); Assert.True(flagOnLayoutOverride, "LayoutGroup overridden method not invoked."); } testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupOnLayout END (OK)"); }
public void LayoutGroupRemove() { tlog.Debug(tag, $"LayoutGroupRemove START"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should return LayoutGroup instance."); using (LayoutItem layoutItem = new LayoutItem()) { testingTarget.LayoutWithTransition = true; testingTarget.Add(layoutItem); Assert.AreEqual(testingTarget.ChildCount(), 1, "Should 1 for the added child."); using (LayoutItem siblingLayoutItem = new LayoutItem()) { testingTarget.Add(siblingLayoutItem); Assert.AreEqual(testingTarget.ChildCount(), 2, "Should 1 for the added child."); testingTarget.Remove(layoutItem); Assert.AreEqual(testingTarget.ChildCount(), 1, "Should 0 as child removed"); } } testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupRemove END (OK)"); }
public void LayoutGroupMeasureChild() { tlog.Debug(tag, $"LayoutGroupMeasureChild START"); flagOnMeasureChild = false; Assert.False(flagOnMeasureChild, "flagOnMeasureChild should be false initially"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); View view = new View() { Size = new Size(100, 150), }; // MeasureSpecification.ModeType.Exactly using (LayoutItem child = new LayoutItem()) { child.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.MeasureChildTest(child, measureWidth, measureHeight); Assert.True(flagOnMeasureChild, "LayoutGroup overridden method not invoked."); } // MeasureSpecification.ModeType.AtMost using (LayoutItem child = new LayoutItem()) { child.AttachToOwner(view); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.AtMost); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.AtMost); testingTarget.MeasureChildTest(child, measureWidth, measureHeight); Assert.True(flagOnMeasureChild, "LayoutGroup overridden method not invoked."); } // MeasureSpecification.ModeType.Unspecified using (LayoutItem child = new LayoutItem()) { child.AttachToOwner(view); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Unspecified); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Unspecified); testingTarget.MeasureChildTest(child, measureWidth, measureHeight); Assert.True(flagOnMeasureChild, "LayoutGroup overridden method not invoked."); } view.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupMeasureChild END (OK)"); }
public void LayoutGroupLayoutChildren() { tlog.Debug(tag, $"LayoutGroupLayoutChildren START"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should return LayoutGroup instance."); using (LayoutItem layoutItem = new LayoutItem()) { testingTarget.Add(layoutItem); Assert.AreEqual(1, testingTarget.ChildCount(), "Should number of children added"); } testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupLayoutChildren END (OK)"); }
public void LayoutGroupOnMeasure() { tlog.Debug(tag, $"LayoutGroupOnMeasure START"); flagOnMeasureOverride = false; Assert.False(flagOnMeasureOverride, "flagOnMeasureOverride should be false initial"); LayoutItem layoutItem = new LinearLayout(); View view = new View() { ExcludeLayouting = false, Size = new Size(100, 150) }; layoutItem.AttachToOwner(view); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); testingTarget.AttachToOwner(view); testingTarget.Add(layoutItem); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.AtMost); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.AtMost); testingTarget.OnMeasureTest(measureWidth, measureHeight); Assert.True(flagOnMeasureOverride, "LayoutGroup overridden method not invoked."); // Test LayoutChildren.Count == 0 flagOnMeasureOverride = false; Assert.False(flagOnMeasureOverride, "flagOnMeasureOverride should be false initial"); testingTarget.Remove(layoutItem); testingTarget.OnMeasureTest(measureWidth, measureHeight); Assert.True(flagOnMeasureOverride, "LayoutGroup overridden method not invoked."); testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupOnMeasure END (OK)"); }
public void LayoutGroupOnChildRemove() { tlog.Debug(tag, $"LayoutGroupOnChildRemove START"); flagOnChildRemoveOverride = false; Assert.False(flagOnChildRemoveOverride, "flagOnChildRemoveOverride should be false initially"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); using (LayoutItem child = new LayoutItem()) { testingTarget.OnChildRemoveTest(child); Assert.True(flagOnChildRemoveOverride, "LayoutGroup overridden method not invoked."); } testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupOnChildRemove END (OK)"); }
public void LayoutGroupAddWithNullArgument() { tlog.Debug(tag, $"LayoutGroupAddWithNullArgument START"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should return LayoutGroup instance."); try { testingTarget.Add(null); Assert.Fail("Should return null argument exception"); } catch (ArgumentNullException) { testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupAddWithNullArgument END (OK)"); Assert.Pass("ArgumentNullException: passed!"); } }
public void LayoutGroupMeasureChildWithoutPadding() { tlog.Debug(tag, $"LayoutGroupMeasureChildWithoutPadding START"); var testingTarget = new MyLayoutGroup(); Assert.IsNotNull(testingTarget, "null handle"); Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should be an instance of LayoutGroup type."); View view = new View() { ExcludeLayouting = false, Size = new Size(100, 150) }; using (LayoutItem child = new LayoutItem()) { child.AttachToOwner(view); testingTarget.Add(child); MeasureSpecification measureWidth = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly); try { testingTarget.MeasureChildWithoutPaddingTest(child, measureWidth, measureHeight); } 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()); } } testingTarget.Dispose(); tlog.Debug(tag, $"LayoutGroupMeasureChildWithoutPadding END (OK)"); }