Example #1
0
        public void FlexLayoutOnMeasure()
        {
            tlog.Debug(tag, $"FlexLayoutOnMeasure 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),
                Layout           = new FlexLayout()
            };

            layoutItem.AttachToOwner(view);

            var testingTarget = new MyFlexLayout();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <FlexLayout>(testingTarget, "Should be an instance of FlexLayout type.");

            testingTarget.AttachToOwner(view);
            testingTarget.Add(layoutItem);

            MeasureSpecification measureWidth  = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.Exactly);
            MeasureSpecification measureHeight = new MeasureSpecification(new LayoutLength(50.0f), MeasureSpecification.ModeType.AtMost);

            testingTarget.OnMeasureTest(measureWidth, measureHeight);
            Assert.True(flagOnMeasureOverride, "FlexLayout overridden method not invoked.");

            tlog.Debug(tag, $"FlexLayoutOnMeasure END (OK)");
        }
Example #2
0
        public void FlexLayoutOnLayout()
        {
            tlog.Debug(tag, $"FlexLayoutOnLayout START");

            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            LayoutItem layoutItem = new LinearLayout();

            View view = new View()
            {
                ExcludeLayouting = false,
                Size             = new Size(100, 150),
                Layout           = new FlexLayout()
            };

            layoutItem.AttachToOwner(view);

            var testingTarget = new MyFlexLayout();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <FlexLayout>(testingTarget, "Should be an instance of FlexLayout type.");

            testingTarget.AttachToOwner(view);
            testingTarget.Add(layoutItem);

            testingTarget.OnLayoutTest(true, new LayoutLength(5), new LayoutLength(5), new LayoutLength(10), new LayoutLength(10));
            Assert.True(flagOnLayoutOverride, "FlexLayout overridden method not invoked.");

            // Test with false parameter
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");
            testingTarget.OnLayoutTest(false, new LayoutLength(5), new LayoutLength(5), new LayoutLength(10), new LayoutLength(10));
            Assert.True(flagOnLayoutOverride, "FlexLayout overridden method not invoked with false parameter.");

            tlog.Debug(tag, $"FlexLayoutOnLayout END (OK)");
        }