Exemplo n.º 1
0
        public void FlexLayoutRecognizesVisibilityChange()
        {
            var root       = new Grid();
            var flexLayout = new FlexLayout() as IFlexLayout;
            var view       = new TestLabel();
            var view2      = new TestLabel();

            root.Add(flexLayout);
            flexLayout.Add(view as IView);
            flexLayout.Add(view2 as IView);

            var manager = new FlexLayoutManager(flexLayout);

            // Measure and arrange the layout while the first view is visible
            var measure = manager.Measure(1000, 1000);

            manager.ArrangeChildren(new Rect(Point.Zero, measure));

            // Keep track of where the second view is arranged
            var whenVisible = view2.Frame.X;

            // Change the visibility
            view.IsVisible = false;

            // Measure and arrange againg
            measure = manager.Measure(1000, 1000);
            manager.ArrangeChildren(new Rect(Point.Zero, measure));

            var whenInvisible = view2.Frame.X;

            // The location of the second view should have changed
            // now that the first view is not visible
            Assert.True(whenInvisible != whenVisible);
        }
        static void AssertListElement(XPathNavigator nav, TestLabel label)
        {
            Assert.That(nav.HasChildren, Is.True, label.Get());
            var iter = nav.SelectChildren(XPathNodeType.Element);

            Assert.That(iter.Count, Is.EqualTo(1), label.Get());
            Assert.That(iter.MoveNext(), Is.True, label.Get());

            var my = iter.Current;

            label.EnterScope("my");
            Assert.That(my.Name, Is.EqualTo("my"), label.Get());
            Assert.That(my.HasAttributes, Is.False, label.Get());

            label.EnterScope("children");
            Assert.That(my.HasChildren, Is.True, label.Get());
            var iter2 = my.SelectChildren(XPathNodeType.Element);

            Assert.That(iter2.Count, Is.EqualTo(1), label.Get());
            Assert.That(iter2.MoveNext(), Is.True, label.Get());

            var test = iter2.Current;

            label.EnterScope("test");
            Assert.That(test.Name, Is.EqualTo("test"), label.Get());
            Assert.That(test.HasChildren, Is.False, label.Get());
            Assert.That(test.HasAttributes, Is.True, label.Get());

            var attr = test.GetAttribute("Hello", string.Empty);

            Assert.That(attr, Is.EqualTo("29"), label.Get());
            label.LeaveScope();
            label.LeaveScope();
            label.LeaveScope();
        }
Exemplo n.º 3
0
        public Page()
        {
            var label = new Label
            {
                HorizontalTextAlignment = TextAlignment.Center,
                Text = "Welcome to Xamarin Forms!"
            };
            var test = new TestLabel
            {
                HorizontalTextAlignment = TextAlignment.Center,
                Text = "Test here"
                       //Text = '\xf118'.ToString()
            };
            var button = new Button
            {
                Text = "Change color"
            };

            Title = "FontTest";

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        =
                {
                    label, test, button
                }
            };

            label.SetBinding(Label.TextColorProperty, "Color");
            test.SetBinding(Label.TextColorProperty, "Color");
            button.SetBinding(Button.CommandProperty, "Click");
        }
 static void AssertNotModified(MySection my, TestLabel label)
 {
     label.EnterScope("modified");
     Assert.That(my, Is.Not.Null, label.Get());
     Assert.That(my.IsModified, Is.False, label.Get());
     Assert.That(my.List, Is.Not.Null, label.Get());
     Assert.That(my.List.Collection.Count, Is.EqualTo(0), label.Get());
     Assert.That(my.List.IsModified, Is.False, label.Get());
     label.LeaveScope();
 }
Exemplo n.º 5
0
 static void AssertNotModified(MySection my, TestLabel label)
 {
     label.EnterScope("modified");
     Assert.NotNull(my);
     Assert.False(my.IsModified, label.Get());
     Assert.NotNull(my.List);
     Assert.Equal(0, my.List.Collection.Count);
     Assert.False(my.List.IsModified, label.Get());
     label.LeaveScope();
 }
Exemplo n.º 6
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            // todo: The label scale to 0 breaks the macOS app
            await TestLabel.ScaleTo(0, 1000);

            //await TestLabel.ScaleTo(0.0001, 1000); // this works

            await TestLabel.ScaleTo(1, 1000); // Do something to see that the app is not crashed
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            TestGarbageCollector.execute();

            //TestGarbageCollector.execute();
            //TestGarbageCollector.execute();
            //TestGarbageCollector.execute();
            TestUINode.execute();
            TestLabel.execute();
            TestButtons.execute();
            Console.ReadKey();
        }
        public static void Run(string name, TestFunction func)
        {
            var label = new TestLabel(name);

            TestUtil.RunWithTempFile(filename => {
                var fileMap = new ExeConfigurationFileMap();
                fileMap.ExeConfigFilename = filename;
                var config = ConfigurationManager.OpenMappedExeConfiguration(
                    fileMap, ConfigurationUserLevel.None);

                func(config, label);
            });
        }
Exemplo n.º 9
0
        private static void Run <TConfig>(
            TestLabel label, TestFunction func, XmlCheckFunction check)
            where TConfig : ConfigProvider, new()
        {
            TestUtil.RunWithTempFiles((parent, filename) =>
            {
                var provider = new TConfig();
                provider.Create(parent);

                Assert.False(File.Exists(filename));

                var config = provider.OpenConfig(parent, filename);

                Assert.False(File.Exists(filename));

                try
                {
                    label.EnterScope("config");
                    func(config, label);
                }
                finally
                {
                    label.LeaveScope();
                }

                if (check == null)
                {
                    return;
                }

                var xml = new XmlDocument();
                xml.Load(filename);

                var nav = xml.CreateNavigator().SelectSingleNode("/configuration");
                try
                {
                    label.EnterScope("xml");
                    check(nav, label);
                }
                finally
                {
                    label.LeaveScope();
                }
            });
        }
Exemplo n.º 10
0
        public void TestValidateBitcoinAddress()
        {
            var tl = new TestLabel {
            };

            bool isValid(string btc, bool isProduction) => ValidateBitcoinAddress(btc, isProduction);

            Assert.AreEqual(true, isValid("33hGFJZQAfbdzyHGqhJPvZwncDjUBdZqjW", true), tl.label());
            Assert.AreEqual(false, isValid("2N6ibfrTwUSSvzAz1esPe1gYULG82asTHiS", true), tl.label());
            Assert.AreEqual(true, isValid("2N6ibfrTwUSSvzAz1esPe1gYULG82asTHiS", false), tl.label());
            Assert.AreEqual(true, isValid("whatever", false), tl.label());
            Assert.AreEqual(false, isValid("", false), tl.label());
            Assert.AreEqual(false, isValid(" ", false), tl.label());
            Assert.AreEqual(false, isValid(null, false), tl.label());
            Assert.AreEqual(true, isValid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4", true), tl.label());
            Assert.AreEqual(true, isValid("tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx", false), tl.label());
            Assert.AreEqual(true, isValid("tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsc", false), tl.label());
            Assert.AreEqual(true, isValid("tc1qw508d6qejxtdg4y5r3zarvary0c5xw7kg3g4ty", false), tl.label());
            Assert.AreEqual(false, isValid("bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5", true), tl.label());
        }
 public static void Run <TConfig> (TestLabel label, TestFunction func)
     where TConfig : ConfigProvider, new ()
 {
     Run <TConfig> (label, func, null);
 }
Exemplo n.º 12
0
        protected async Task TestLabelAsync()
        {
            try
            {
                var ip = this.SelectedIpAddress == IPAddress.Any ? IPAddress.Loopback : this.SelectedIpAddress;
                (bool result, string errorMessage) = await TestClient.SendStringAsync(ip, this.Port, await TestLabel.GetZplAsync());

                if (!result)
                {
                    this.StatusText = errorMessage;
                }
            }
            catch (Exception ex)
            {
                this.StatusText = $"Error: {ex.Message}";
            }
        }