Exemplo n.º 1
0
        public void AbsoluteLayoutOnMeasure()
        {
            tlog.Debug(tag, $"AbsoluteLayoutOnMeasure 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 AbsoluteLayout()
            };

            layoutItem.AttachToOwner(view);

            var testingTarget = new MyAbsoluteLayout();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <AbsoluteLayout>(testingTarget, "Should be an instance of AbsoluteLayout 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, "AbsoluteLayout overridden method not invoked.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"AbsoluteLayoutOnMeasure END (OK)");
        }
Exemplo n.º 2
0
        public void AbsoluteLayoutOnLayout()
        {
            tlog.Debug(tag, $"AbsoluteLayoutOnLayout 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 AbsoluteLayout()
            };

            layoutItem.AttachToOwner(view);

            var testingTarget = new MyAbsoluteLayout();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <AbsoluteLayout>(testingTarget, "Should be an instance of AbsoluteLayout 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, "AbsoluteLayout 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, "AbsoluteLayout overridden method not invoked with false parameter.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"AbsoluteLayoutOnLayout END (OK)");
        }