Esempio n. 1
0
        public void EnabledShouldAffectChildControls(IContainerTypeInfo <Container> containerType, IControlTypeInfo <Control> controlType)
        {
            Invoke(() =>
            {
                var enabledChild  = controlType.CreateControl();
                var disabledChild = controlType.CreateControl();
                var neutralChild  = controlType.CreateControl();
                var childPanel    = new TableLayout
                {
                    Rows = { enabledChild, disabledChild, neutralChild }
                };

                var container = containerType.CreateControl(childPanel);

                // load the control
                container.AttachNative();

                var neutralEnabled = neutralChild.Enabled;
                // disabled child should always be disabled
                disabledChild.Enabled = false;
                enabledChild.Enabled  = true;

                // default values
                Assert.IsTrue(container.Enabled, "#1.1");
                Assert.IsTrue(enabledChild.Enabled, "#1.2");
                Assert.IsFalse(disabledChild.Enabled, "#1.3");
                Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#1.4");

                // setting container to disabled
                container.Enabled = false;

                Assert.IsFalse(container.Enabled, "#2.1");
                Assert.IsFalse(enabledChild.Enabled, "#2.2");
                Assert.IsFalse(disabledChild.Enabled, "#2.3");
                Assert.IsFalse(neutralChild.Enabled, "#2.4");

                // set child to enabled when parent is disabled, should still stay disabled
                enabledChild.Enabled = true;

                Assert.IsFalse(container.Enabled, "#3.1");
                Assert.IsFalse(enabledChild.Enabled, "#3.2");
                Assert.IsFalse(disabledChild.Enabled, "#3.3");
                Assert.IsFalse(neutralChild.Enabled, "#3.4");

                // set container back to enabled
                container.Enabled = true;

                Assert.IsTrue(container.Enabled, "#4.1");
                Assert.IsTrue(enabledChild.Enabled, "#4.2");
                Assert.IsFalse(disabledChild.Enabled, "#4.3");
                Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#4.4");
            });
        }
Esempio n. 2
0
        public void PanelPaddingBottomRightShouldWork(IContainerTypeInfo <Panel> type)
        {
            ManualForm(
                "There should be 40px padding at the bottom and right of the blue rectangle",
                form =>
            {
                var panel = type.CreateControl();
                Assert.IsNotNull(panel);

                panel.Padding = new Padding(0, 0, 40, 40);
                panel.Content = new Panel
                {
                    BackgroundColor = Colors.Blue,
                    Size            = new Size(200, 200)
                };
                return(type.CreateContainer(panel));
            });
        }
Esempio n. 3
0
        public void EnabledShouldAffectChildControlsWhenDynamicallyAdded(IContainerTypeInfo <Container> containerType, IControlTypeInfo <Control> controlType)
        {
            Invoke(() =>
            {
                var enabledChild  = controlType.CreateControl();
                var disabledChild = controlType.CreateControl();
                var neutralChild  = controlType.CreateControl();
                var childPanel    = new Panel();

                void addControls() => childPanel.Content = new TableLayout
                {
                    Rows = { enabledChild, disabledChild, neutralChild }
                };

                void removeControls() => childPanel.Content = null;

                var container = containerType.CreateControl(childPanel);

                // load the control (for virtual containers like Stack/Dynamic layouts)
                container.AttachNative();

                var neutralEnabled = neutralChild.Enabled;
                // disabled child should always be disabled
                disabledChild.Enabled = false;
                enabledChild.Enabled  = true;

                // default values
                Assert.IsTrue(container.Enabled, "#1.1");
                Assert.IsTrue(enabledChild.Enabled, "#1.2");
                Assert.IsFalse(disabledChild.Enabled, "#1.3");
                Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#1.4");

                addControls();

                // default values after added to the container
                Assert.IsTrue(container.Enabled, "#2.1");
                Assert.IsTrue(enabledChild.Enabled, "#2.2");
                Assert.IsFalse(disabledChild.Enabled, "#2.3");
                Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#2.4");

                removeControls();

                // setting container to disabled
                container.Enabled = false;

                // default values after removed from the container (and container set to disabled)
                Assert.IsTrue(enabledChild.Enabled, "#3.1");
                Assert.IsFalse(disabledChild.Enabled, "#3.2");
                Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#3.3");

                addControls();
                // values after adding back to the container
                Assert.IsFalse(container.Enabled, "#4.1");
                Assert.IsFalse(enabledChild.Enabled, "#4.2");
                Assert.IsFalse(disabledChild.Enabled, "#4.3");
                Assert.IsFalse(neutralChild.Enabled, "#4.4");

                // set child to enabled when parent is disabled, should still stay disabled
                enabledChild.Enabled = true;

                Assert.IsFalse(container.Enabled, "#5.1");
                Assert.IsFalse(enabledChild.Enabled, "#5.2");
                Assert.IsFalse(disabledChild.Enabled, "#5.3");
                Assert.IsFalse(neutralChild.Enabled, "#5.4");

                removeControls();
                // default values after removed from the container (again)
                Assert.IsTrue(enabledChild.Enabled, "#6.1");
                Assert.IsFalse(disabledChild.Enabled, "#6.2");
                Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#6.3");

                // set container back to enabled
                container.Enabled = true;

                addControls();

                Assert.IsTrue(container.Enabled, "#7.1");
                Assert.IsTrue(enabledChild.Enabled, "#7.2");
                Assert.IsFalse(disabledChild.Enabled, "#7.3");
                Assert.AreEqual(neutralEnabled, neutralChild.Enabled, "#7.4");
            });
        }