예제 #1
0
        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)");
        }
예제 #2
0
        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)");
        }