Beispiel #1
0
        public void LayoutGroupIterateLayoutChildren()
        {
            tlog.Debug(tag, $"LayoutGroupIterateLayoutChildren START");

            LayoutItem layoutItem = new LinearLayout();

            View view = new View()
            {
                ExcludeLayouting = false,
            };

            layoutItem.AttachToOwner(view);

            var testingTarget = new MyLayoutGroup();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <LayoutGroup>(testingTarget, "Should return LayoutGroup instance.");

            testingTarget.Add(layoutItem);

            var result = testingTarget.ForeachLayoutChildren();

            Assert.AreEqual(1, result.Count(), "should be equal!");

            tlog.Debug(tag, $"LayoutGroupIterateLayoutChildren END (OK)");
        }
Beispiel #2
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)");
        }
Beispiel #3
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)");
        }
Beispiel #4
0
        public void GridLayoutOnLayout()
        {
            tlog.Debug(tag, $"GridLayoutOnLayout 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 MyGridLayout();

            Assert.IsNotNull(testingTarget, "null handle");
            Assert.IsInstanceOf <GridLayout>(testingTarget, "Should be an instance of GridLayout 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.Exactly);

            testingTarget.OnMeasureTest(measureWidth, measureHeight);

            testingTarget.OnLayoutTest(true, new LayoutLength(5), new LayoutLength(5), new LayoutLength(10), new LayoutLength(10));
            Assert.True(flagOnLayoutOverride, "GridLayout 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, "GridLayout overridden method not invoked.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"GridLayoutOnLayout END (OK)");
        }
Beispiel #5
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)");
        }
Beispiel #6
0
        public void LinearLayoutOnLayout()
        {
            tlog.Debug(tag, $"LinearLayoutOnLayout START");

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

            LayoutItem layoutItem = new LinearLayout();

            View view = new View()
            {
                ExcludeLayouting    = false,
                Weight              = 10,
                WidthSpecification  = 0,
                HeightSpecification = 0,
                Layout              = new LinearLayout(),
                LayoutDirection     = ViewLayoutDirectionType.RTL
            };

            layoutItem.AttachToOwner(view);

            var testingTarget = new MyLinearLayout()
            {
                LinearAlignment = LinearLayout.Alignment.Begin,
            };

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

            /** Alignment.End */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.End;

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

            /** Alignment.CenterHorizontal */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.CenterHorizontal;

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

            /** Alignment.Center */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.Center;

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

            /** Alignment.CenterVertical */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.CenterVertical;

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

            /** Alignment.Bottom */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.Bottom;

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

            /** Alignment.Top */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.Top;

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

            /** Owner.LayoutDirection == ViewLayoutDirectionType.LTR */
            view.LayoutDirection = ViewLayoutDirectionType.LTR;

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

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

            /** Alignment.End */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.End;

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

            /** Alignment.CenterHorizontal */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.CenterHorizontal;

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

            /** Alignment.Center */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.Center;

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

            /** Alignment.CenterVertical */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.CenterVertical;

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

            /** Alignment.Bottom */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.Bottom;

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

            /** Alignment.Begin */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.Begin;

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

            /**
             * Test LinearLayout.Orientation.Vertical
             */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearOrientation = LinearLayout.Orientation.Vertical;

            /** Alignment.Bottom */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.Bottom;

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

            /** Alignment.Center */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.Center;

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

            /** Alignment.End */
            flagOnLayoutOverride = false;
            Assert.False(flagOnLayoutOverride, "flagOnLayoutOverride should be false initial");

            testingTarget.LinearAlignment = LinearLayout.Alignment.End;

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

            /**Test false method override works with false flag too */
            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, "LinearLayout overridden method not invoked.");

            testingTarget.Dispose();
            tlog.Debug(tag, $"LinearLayoutOnLayout END (OK)");
        }
Beispiel #7
0
        public void LinearLayoutOnMeasure()
        {
            tlog.Debug(tag, $"LinearLayoutOnMeasure START");

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

            LayoutItem layoutItem = new LinearLayout();

            View view = new View()
            {
                ExcludeLayouting    = false,
                Weight              = 10,
                WidthSpecification  = 0,
                HeightSpecification = 0,
                Layout              = new LinearLayout()
            };

            layoutItem.AttachToOwner(view);

            var testingTarget = new MyLinearLayout();

            Assert.IsNotNull(testingTarget, "null handle returned");
            Assert.IsInstanceOf <LinearLayout>(testingTarget, "Should be an instance of LinearLayout 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.Exactly);

            /**
             * isExactly is true
             * useExcessSpace is true :(childLayout.Owner.WidthSpecification == 0) && (childWeight > 0)
             */
            testingTarget.OnMeasureTest(measureWidth, measureHeight);
            Assert.True(flagOnMeasureOverride, "LinearLayout overridden method not invoked.");

            /**
             * isExactly is false
             * useExcessSpace is true :(childLayout.Owner.WidthSpecification == 0) && (childWeight > 0)
             */
            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, "LinearLayout overridden method not invoked.");

            /**
             *  matchHeight
             *  heightMode != MeasureSpecification.ModeType.Exactly && childDesiredHeight == LayoutParamPolicies.MatchParent
             */
            view.HeightSpecification = LayoutParamPolicies.MatchParent;
            testingTarget.OnMeasureTest(measureWidth2, measureHeight2);

            /**Test LinearLayout.Orientation.Vertical */
            testingTarget.LinearOrientation = LinearLayout.Orientation.Vertical;
            view.HeightSpecification        = 0;

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

            /**
             * isExactly is true
             * useExcessSpace is true :(childLayout.Owner.HeightSpecification == 0) && (childWeight > 0)
             */
            testingTarget.OnMeasureTest(measureWidth, measureHeight);
            Assert.True(flagOnMeasureOverride, "LinearLayout overridden method not invoked.");

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

            /**
             * isExactly is true
             * useExcessSpace is true :(childLayout.Owner.HeightSpecification == 0) && (childWeight > 0)
             *
             * matchWidth
             * widthMode != MeasureSpecification.ModeType.Exactly && childDesiredWidth == LayoutParamPolicies.MatchParent
             */
            view.WidthSpecification = LayoutParamPolicies.MatchParent;
            testingTarget.OnMeasureTest(measureWidth2, measureHeight2);
            Assert.True(flagOnMeasureOverride, "LinearLayout overridden method not invoked.");

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