Exemplo n.º 1
0
        public void LayoutGroupOnLayoutIndependentChildren()
        {
            tlog.Debug(tag, $"LayoutGroupOnLayoutIndependentChildren START");

            using (View owner = new View())
            {
                TextLabel textLabel = new TextLabel()
                {
                    ExcludeLayouting = false,
                    Size             = new Size(100, 150),
                    Layout           = new AbsoluteLayout(),
                };

                owner.Add(textLabel);

                using (MyLayoutGroup testingTarget = new MyLayoutGroup())
                {
                    testingTarget.AttachToOwner(owner);
                    try
                    {
                        testingTarget.OnLayoutIndependentChildren(true, new LayoutLength(5), new LayoutLength(5), new LayoutLength(5), new LayoutLength(5));
                    }
                    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());
                    }
                }

                textLabel.Dispose();
            }

            tlog.Debug(tag, $"LayoutGroupOnLayoutIndependentChildren END (OK)");
        }
Exemplo n.º 2
0
        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!");
            }
        }
Exemplo n.º 3
0
        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)");
        }
Exemplo n.º 4
0
        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)");
        }
Exemplo n.º 5
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)");
        }
Exemplo n.º 6
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)");
        }
Exemplo n.º 7
0
        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)");
        }
Exemplo n.º 8
0
        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)");
        }
Exemplo n.º 9
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)");
        }
Exemplo n.º 10
0
        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)");
        }
Exemplo n.º 11
0
        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!");
            }
        }
Exemplo n.º 12
0
        public void LayoutGroupRemoveChildFromLayoutGroup()
        {
            tlog.Debug(tag, $"LayoutGroupRemoveChildFromLayoutGroup START");

            LayoutItem layoutItem = new AbsoluteLayout();

            View parent = new View();

            View child = new View()
            {
                ExcludeLayouting = false,
                Layout           = new AbsoluteLayout()
            };

            parent.Add(child);

            layoutItem.AttachToOwner(child);

            var testingTarget = new MyLayoutGroup();

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

            testingTarget.Add(layoutItem);

            try
            {
                testingTarget.RemoveChildFromLayoutGroup(child);
            }
            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());
            }

            tlog.Debug(tag, $"LayoutGroupRemoveChildFromLayoutGroup END (OK)");
        }
Exemplo n.º 13
0
        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)");
        }