Example #1
0
        public void TestBasicInvalidations()
        {
            var services = new ServiceRegistry();

            services.AddService(typeof(IGame), new Game());

            var edit = new EditText();

            edit.UIElementServices = new UIElementServices {
                Services = services
            };

            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(edit, () => edit.Font = new DummyFont());
            edit.Font = null;
            UIElementLayeringTests.TestMeasureInvalidation(edit, () => edit.MaxLines     = 34);
            UIElementLayeringTests.TestMeasureInvalidation(edit, () => edit.MinLines     = 34);
            UIElementLayeringTests.TestMeasureInvalidation(edit, () => edit.SelectedText = "toto");
            UIElementLayeringTests.TestMeasureInvalidation(edit, () => edit.Text         = "titi");
            UIElementLayeringTests.TestMeasureInvalidation(edit, () => edit.MaxLength    = 3); // text is modified

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.IsReadOnly      = !edit.IsReadOnly);
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.ActiveImage     = (SpriteFromTexture) new Sprite());
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.InactiveImage   = (SpriteFromTexture) new Sprite());
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.TextColor       = new Color(1, 2, 3, 4));
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.SelectionColor  = new Color(1, 2, 3, 4));
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.CaretColor      = new Color(1, 7, 3, 4));
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.CaretPosition   = 34);
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.SelectionLength = 2);
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.SelectionStart  = 0);
            UIElementLayeringTests.TestNoInvalidation(edit, () => edit.MaxLength       = 34); // text is not modified
        }
Example #2
0
        public void TestBasicInvalidations()
        {
            var stackPanel = new StackPanel();

            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(stackPanel, () => stackPanel.Orientation = Orientation.InDepth);
        }
Example #3
0
        public void TestBasicInvalidations()
        {
            ResetState();

            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(this, () => Orientation = Orientation.InDepth);
        }
Example #4
0
 public void TestBasicInvalidations()
 {
     // - test the properties that are supposed to invalidate the object measurement
     UIElementLayeringTests.TestMeasureInvalidation(this, () => Columns = 7);
     UIElementLayeringTests.TestMeasureInvalidation(this, () => Rows    = 34);
     UIElementLayeringTests.TestMeasureInvalidation(this, () => Layers  = 34);
 }
Example #5
0
        public void TestBasicInvalidations()
        {
            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(this, () => Font = null);
            UIElementLayeringTests.TestMeasureInvalidation(this, () => Text = "New Text");

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(this, () => TextColor = new Color(1, 2, 3, 4));
        }
Example #6
0
        public void TestBasicInvalidations()
        {
            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(this, () => DesiredCharacterNumber = 99);

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(this, () => ScrollingSpeed = 5.5f);
            UIElementLayeringTests.TestNoInvalidation(this, () => RepeatText     = !RepeatText);
        }
Example #7
0
        public void TestBasicInvalidations()
        {
            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(this, () => ScrollMode = ScrollingMode.InDepthHorizontal);

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(this, () => Deceleration          = 5.5f);
            UIElementLayeringTests.TestNoInvalidation(this, () => TouchScrollingEnabled = !TouchScrollingEnabled);
            UIElementLayeringTests.TestNoInvalidation(this, () => ScrollBarColor        = new Color(1, 2, 3, 4));
            UIElementLayeringTests.TestNoInvalidation(this, () => ScrollBarThickness    = 34);
        }
Example #8
0
        public void TestBasicInvalidations()
        {
            var newButton = new Button();

            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(this, () => Content = newButton);

            var sameButton = newButton;

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(this, () => Content = sameButton);
        }
Example #9
0
        public void TestBasicInvalidations()
        {
            SizeToContent = true;
            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(this, () => PressedImage    = (SpriteFromTexture) new Sprite());
            UIElementLayeringTests.TestNoInvalidation(this, () => NotPressedImage = (SpriteFromTexture) new Sprite());

            SizeToContent = false;
            // - test the properties that are supposed to invalidate the object layout state
            UIElementLayeringTests.TestMeasureInvalidation(this, () => PressedImage    = (SpriteFromTexture) new Sprite());
            UIElementLayeringTests.TestMeasureInvalidation(this, () => NotPressedImage = (SpriteFromTexture) new Sprite());
        }
Example #10
0
        public void TestBasicInvalidations()
        {
            var canvas = new Canvas();
            var child  = new Canvas();

            canvas.Children.Add(child);

            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(canvas, () => child.DependencyProperties.Set(PinOriginPropertyKey, new Vector3(0.1f, 0.2f, 0.3f)));
            UIElementLayeringTests.TestMeasureInvalidation(canvas, () => child.DependencyProperties.Set(RelativePositionPropertyKey, new Vector3(1f, 2f, 3f)));
            UIElementLayeringTests.TestMeasureInvalidation(canvas, () => child.DependencyProperties.Set(AbsolutePositionPropertyKey, new Vector3(1f, 2f, 3f)));
            UIElementLayeringTests.TestMeasureInvalidation(canvas, () => child.DependencyProperties.Set(RelativeSizePropertyKey, new Vector3(1f, 2f, 3f)));
        }
Example #11
0
        public void TestBasicInvalidations()
        {
            var grid = new UniformGrid {
                Rows = 2, Columns = 2, Layers = 2
            };
            var child = new UniformGrid();

            grid.Children.Add(child);

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => child.DependencyProperties.Set(ColumnPropertyKey, 2));
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => child.DependencyProperties.Set(RowPropertyKey, 2));
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => child.DependencyProperties.Set(LayerPropertyKey, 2));
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => child.DependencyProperties.Set(ColumnSpanPropertyKey, 2));
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => child.DependencyProperties.Set(RowSpanPropertyKey, 2));
            UIElementLayeringTests.TestMeasureInvalidation(grid, () => child.DependencyProperties.Set(LayerSpanPropertyKey, 2));
        }
Example #12
0
        public void TestBasicInvalidations()
        {
            var source = new Sprite();

            // ReSharper disable ImplicitlyCapturedClosure

            // - test the properties that are supposed to invalidate the object measurement
            UIElementLayeringTests.TestMeasureInvalidation(this, () => StretchType        = StretchType.None);
            UIElementLayeringTests.TestMeasureInvalidation(this, () => StretchDirection   = StretchDirection.DownOnly);
            UIElementLayeringTests.TestMeasureInvalidation(this, () => Source             = (SpriteFromTexture)source);
            UIElementLayeringTests.TestMeasureInvalidation(this, () => source.Region      = new Rectangle(1, 2, 3, 4));
            UIElementLayeringTests.TestMeasureInvalidation(this, () => source.Orientation = ImageOrientation.Rotated90);
            UIElementLayeringTests.TestMeasureInvalidation(this, () => source.Borders     = Vector4.One);

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(this, () => source.Region      = new Rectangle(8, 9, 3, 4));  // if the size of the region does not change we avoid re-measuring
            UIElementLayeringTests.TestNoInvalidation(this, () => source.Orientation = ImageOrientation.Rotated90); // no changes
            UIElementLayeringTests.TestNoInvalidation(this, () => source.Borders     = Vector4.One);                // no changes

            // ReSharper restore ImplicitlyCapturedClosure
        }
Example #13
0
        public void TestBasicInvalidations()
        {
            var slider = new Slider();

            // - test the properties that are supposed to invalidate the object layout state
            UIElementLayeringTests.TestMeasureInvalidation(slider, () => slider.Orientation          = Orientation.Vertical);
            UIElementLayeringTests.TestMeasureInvalidation(slider, () => slider.TrackBackgroundImage = new UIImage());

            // - test the properties that are not supposed to invalidate the object layout state
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.AreTicksDisplayed = true);
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.CanBeHitByUser    = false);
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.ShouldSnapToTicks = true);
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.DrawLayerNumber   = 60);
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.Value             = 0.5f);
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.Step    = 0.2f);
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.Maximum = 0.2f);
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.Minimum = 0.1f);
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.TrackForegroundImage = new UIImage());
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.ThumbImage           = new UIImage());
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.MouseOverThumbImage  = new UIImage());
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.DependencyProperties.Set(Slider.TickImagePropertyKey, new UIImage()));
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.TickOffset           = new float());
            UIElementLayeringTests.TestNoInvalidation(slider, () => slider.TrackStartingOffsets = new Vector2());
        }
Example #14
0
        public void TestBasicInvalidations()
        {
            // - test the properties that are not supposed to invalidate the object layout state

            UIElementLayeringTests.TestMeasureInvalidation(this, () => Padding = Thickness.UniformRectangle(23));
        }