public void VerifySimpleCollectionScenario()
        {
            var objects = new Dictionary <string, WeakReference>();

            RunOnUIThread.Execute(() =>
            {
                var rating        = new RatingControl();
                objects["Rating"] = new WeakReference(rating);

                var colorPicker        = new ColorPicker();
                objects["ColorPicker"] = new WeakReference(colorPicker);

                var navigationView        = new NavigationView();
                objects["NavigationView"] = new WeakReference(navigationView);

                var parallaxView        = new ParallaxView();
                objects["ParallaxView"] = new WeakReference(parallaxView);

                var scroller        = new Scroller();
                objects["Scroller"] = new WeakReference(scroller);

                if (PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
                {
                    var scrollViewer        = new ScrollViewer();
                    objects["ScrollViewer"] = new WeakReference(scrollViewer);
                }
            });
            IdleSynchronizer.Wait();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            RunOnUIThread.Execute(() => CheckLeaks(objects));
        }
Exemple #2
0
		public void VerifyValuesCoercion()
		{
			RunOnUIThread.Execute(() =>
			{
				RatingControl ratingControl = new RatingControl();
				Verify.IsNotNull(ratingControl);
				Verify.AreEqual(ratingControl.PlaceholderValue, -1);
				Verify.AreEqual(ratingControl.Value, -1);

				ratingControl.PlaceholderValue = 0.1;
				ratingControl.Value = 0.1;
				Verify.AreEqual(ratingControl.PlaceholderValue, 1.0, "Should coerce small PlaceholderValue values to 1.0");
				Verify.AreEqual(ratingControl.Value, 1.0, "Should coerce small Value values to 1.0");

				ratingControl.PlaceholderValue = 6.0;
				ratingControl.Value = 6.0;
				Verify.AreEqual(ratingControl.PlaceholderValue, 5.0, "Should coerce PlaceholderValue above MaxRating back to MaxRating");
				Verify.AreEqual(ratingControl.Value, 5.0, "Should coerce Value above MaxRating back to MaxRating");

				ratingControl.MaxRating = -2;
				Verify.AreEqual(ratingControl.MaxRating, 1, "Should coerce MaxRating below 1 back up to 1.");

				Verify.AreEqual(ratingControl.PlaceholderValue, 1.0, "Should auto-coerce now outdated PlaceholderValue above MaxRating back to MaxRating [2]");
				Verify.AreEqual(ratingControl.Value, 1.0, "Should auto-coerce now outdated Value above MaxRating back to MaxRating [2]");

				ratingControl.PlaceholderValue = 6.0;
				ratingControl.Value = 6.0;
				Verify.AreEqual(ratingControl.PlaceholderValue, 1.0, "Should coerce set PlaceholderValue above MaxRating back to MaxRating");
				Verify.AreEqual(ratingControl.Value, 1.0, "Should coerce set Value above MaxRating back to MaxRating");
			});
		}
Exemple #3
0
        public EventCycleTest(bool addToTree = true)
        {
            _rating = new RatingControl();
            _rating.ValueChanged += OnRatingValueChanged;
            if (addToTree)
            {
                Children.Add(_rating);
            }

            _colorPicker = new ColorPicker();
            _colorPicker.ColorChanged += OnColorPickerColorChanged;
            if (addToTree)
            {
                Children.Add(_colorPicker);
            }

            _navigationView = new NavigationView();
            _navigationView.SelectionChanged += OnNavigationViewSelectionChanged;
            if (addToTree)
            {
                Children.Add(_navigationView);
            }

            var item = new NavigationViewItem();

            _navigationView.MenuItems.Add(item);

            _scroller              = new Scroller();
            _scroller.ViewChanged += OnScrollerViewChanged;
            if (addToTree)
            {
                Children.Add(_scroller);
            }
        }
        void PerformImageVerification(RatingControl rc, String expectedUri, TextBlock resultTb, String stackPanelName, SolidColorBrush expectedColor = null)
        {
            ContentPresenter presenter = FindVisualChildByName(rc, "ForegroundContentPresenter") as ContentPresenter;

            DependencyObject obj = FindVisualChildByName(rc, stackPanelName);
            var   child          = VisualTreeHelper.GetChild(obj, 0);
            Image image          = child as Image;
            var   source         = image.Source;

            Windows.UI.Xaml.Media.Imaging.BitmapImage bitImage = source as Windows.UI.Xaml.Media.Imaging.BitmapImage;

            String uri = bitImage.UriSource.ToString();

            if (uri.Equals(expectedUri))
            {
                resultTb.Text = "+";
                // Verify colour to make sure we don't accidentally take the non-pointer over as a false-positive
                // The colours aren't used, but the state is there so we can still check.
                if (expectedColor == null || presenter.Foreground.Equals(expectedColor))
                {
                    resultTb.Text = "+";
                }
                else
                {
                    resultTb.Text = "/";
                }
            }
            else
            {
                resultTb.Text = "-";
            }
        }
        void PerformGlyphVerification(RatingControl rc, String expectedGlyph, TextBlock resultTb, String stackPanelName, SolidColorBrush expectedColor = null)
        {
            ContentPresenter presenter = FindVisualChildByName(rc, "ForegroundContentPresenter") as ContentPresenter;

            DependencyObject obj = FindVisualChildByName(rc, stackPanelName);
            var       child      = VisualTreeHelper.GetChild(obj, 0);
            TextBlock tb         = child as TextBlock;

            String glyph = tb.Text;

            if (glyph.Equals(expectedGlyph))
            {
                resultTb.Text = "+";
                // Verify colour to make sure we don't accidentally take the non-pointer over as a false-positive
                if (expectedColor == null || presenter.Foreground.Equals(expectedColor))
                {
                    resultTb.Text = "+";
                }
                else
                {
                    resultTb.Text = "/";
                }
            }
            else
            {
                resultTb.Text = "-";
            }
        }
 public void VerifyDontCrashWhenCollapsedAndValueSet()
 {
     RunOnUIThread.Execute(() =>
     {
         RatingControl ratingControl = new RatingControl();
         ratingControl.Visibility    = Visibility.Collapsed;
         ratingControl.Value         = 3.3;
     });
 }
 private void ValueChangeInMarkup_ValueChanged(RatingControl sender, object args)
 {
     if (ValueChangeInMarkup.Value == -1)
     {
         ValueChangeInMarkupText.Text = "!!" + ValueChangeInMarkup.PlaceholderValue.ToString();
     }
     else
     {
         ValueChangeInMarkupText.Text = ValueChangeInMarkup.Value.ToString();
     }
 }
 private void MaxRating9Unset_ValueChanged(RatingControl sender, object args)
 {
     if (sender.Value == -1)
     {
         MaxRating9UnsetTextBlock.Text = "!!" + sender.PlaceholderValue.ToString();
     }
     else
     {
         MaxRating9UnsetTextBlock.Text = sender.Value.ToString();
     }
 }
 private void MyRatingIsClearEnabled_ValueChanged(RatingControl sender, object args)
 {
     if (sender.Value == -1)
     {
         MyRatingIsClearEnabledText.Text = "!" + sender.PlaceholderValue.ToString();
     }
     else
     {
         MyRatingIsClearEnabledText.Text = sender.Value.ToString();
     }
 }
Exemple #10
0
 private void RatingControl_ValueChanged(Microsoft.UI.Xaml.Controls.RatingControl sender, object args)
 {
     if (rating.Value >= 5)
     {
         txtTips.Visibility = Visibility.Visible;
     }
     else
     {
         txtTips.Visibility = Visibility.Collapsed;
     }
     rating.Caption = (rating.Value * 2).ToString("0");
 }
        public async Task VerifyDefaultsAndBasicSetting()
        {
            RatingControl ratingControl = null;

            RunOnUIThread.Execute(() =>
            {
                ratingControl = new RatingControl();
                Verify.IsNotNull(ratingControl);

                Verify.AreEqual(ratingControl.Caption, "");
                Verify.AreEqual(ratingControl.InitialSetValue, 1);
                Verify.AreEqual(ratingControl.IsClearEnabled, true);
                Verify.AreEqual(ratingControl.IsReadOnly, false);
                Verify.AreEqual(ratingControl.MaxRating, 5);
                Verify.AreEqual(ratingControl.PlaceholderValue, -1);
                Verify.AreEqual(ratingControl.Value, -1);

                // Disabled due to 12359255 reliability issue
                // Verify.IsTrue(ratingControl.ItemInfo is RatingItemFontInfo, "Verify default type of ItemInfo");
                // Verify.IsTrue((ratingControl.ItemInfo as RatingItemFontInfo).Glyph.Equals("\uE735"));

                // Now verify basic setting the value, and reaccessing it:

                ratingControl.Caption          = "Rating API Test Caption";
                ratingControl.InitialSetValue  = 2;
                ratingControl.IsClearEnabled   = false;
                ratingControl.IsReadOnly       = true;
                ratingControl.MaxRating        = 10;
                ratingControl.PlaceholderValue = 3.0;
                ratingControl.Value            = 2.0;

                var imageInfo          = new RatingItemImageInfo();
                imageInfo.Image        = new BitmapImage(new Uri("ms-appx:/Assets/rating_set.png"));
                ratingControl.ItemInfo = imageInfo;
            });


            await TestServices.WindowHelper.WaitForIdle();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(ratingControl.Caption, "Rating API Test Caption");
                Verify.AreEqual(ratingControl.InitialSetValue, 2);
                Verify.AreEqual(ratingControl.IsClearEnabled, false);
                Verify.AreEqual(ratingControl.IsReadOnly, true);
                Verify.AreEqual(ratingControl.MaxRating, 10);
                Verify.AreEqual(ratingControl.PlaceholderValue, 3.0);
                Verify.AreEqual(ratingControl.Value, 2.0);
                Verify.IsTrue(ratingControl.ItemInfo is RatingItemImageInfo, "Verify default type of ItemInfo [2]");
                Verify.IsTrue(((ratingControl.ItemInfo as RatingItemImageInfo).Image as BitmapImage).UriSource.Equals("ms-appx:/Assets/rating_set.png"));
            });
        }
        private void MagicDisengager_ValueChanged(RatingControl sender, object args)
        {
            if (sender.Value == 3.0)
            {
                sender.RemoveFocusEngagement();
            }

            if (sender.Value == -1)
            {
                MagicDisengagerTextBlock.Text = "null";
            }
            else
            {
                MagicDisengagerTextBlock.Text = sender.Value.ToString();
            }
        }
 private void TestRatingControl_ValueChanged(RatingControl sender, object args)
 {
     if (TestRatingControl.Value == -1)
     {
         if (TestRatingControl.PlaceholderValue == -1)
         {
             TestTextBlockControl.Text = "!";
         }
         else
         {
             TestTextBlockControl.Text = "!" + TestRatingControl.PlaceholderValue.ToString();
         }
     }
     else
     {
         TestTextBlockControl.Text = sender.Value.ToString();                 // Having both ways of referring to the control to make sure both work
     }
 }
 private void _ratingControl2_OnValueChanged(RatingControl sender, object args)
 {
 }
 private void OnRatingValueChanged(RatingControl sender, object args)
 {
 }
 public LeakObject()
 {
     _ratingControl1 = new RatingControl();
     _ratingControl2 = new RatingControl();
     _ratingControl2.ValueChanged += _ratingControl2_OnValueChanged;
 }
Exemple #17
0
        public void VerifyOverrides()
        {
            RatingControl ratingControl = null;
            PersonPicture personPicture = null;
            Slider        slider        = null;
            Grid          root          = null;

            RunOnUIThread.Execute(() =>
            {
                var appResources = Application.Current.Resources;
                // 1) Override WinUI defined brush in App.Resources.
                appResources["RatingControlCaptionForeground"] = new SolidColorBrush(Colors.Orange);

                // 2) Override system brush used by WinUI ThemeResource.

                ((ResourceDictionary)appResources.ThemeDictionaries["Light"])["SystemAltHighColor"]   = Colors.Green;
                ((ResourceDictionary)appResources.ThemeDictionaries["Default"])["SystemAltHighColor"] = Colors.Green;
                ((ResourceDictionary)appResources.ThemeDictionaries["HighContrast"])["SystemColorButtonTextColor"] = Colors.Green;

                // 3) Override brush name used by a system control
                appResources["SliderTrackValueFill"] = new SolidColorBrush(Colors.Purple);

                root = new Grid
                {
                    Background = new SolidColorBrush(Colors.AntiqueWhite),
                };

                StackPanel panel = new StackPanel {
                    Orientation = Orientation.Vertical
                };
                panel.Children.Add(slider = new Slider());

                panel.Children.Add(ratingControl = new RatingControl()
                {
                    Value = 2
                });
                panel.Children.Add(personPicture = new PersonPicture());

                root.Children.Add(panel);
                // Add an element over top to prevent stray mouse input from interfering.
                root.Children.Add(new Button
                {
                    Background          = new SolidColorBrush(Color.FromArgb(30, 0, 255, 0)),
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                });

                MUXControlsTestApp.App.TestContentRoot = root;
            });
            IdleSynchronizer.TryWait();

            //System.Threading.Tasks.Task.Delay(TimeSpan.FromSeconds(20)).Wait();

            RunOnUIThread.Execute(() =>
            {
                // 1) Verify that overriding WinUI defined brushes in App.Resources works.
                Verify.AreEqual(Colors.Orange, ((SolidColorBrush)ratingControl.Foreground).Color,
                                "Verify RatingControlCaptionForeground override in Application.Resources gets picked up by WinUI control");

                // 2) Verify that overriding a system color used by a WinUI control works.
                Verify.AreEqual(Colors.Green, ((SolidColorBrush)personPicture.Foreground).Color,
                                "Verify PersonPictureForegroundThemeBrush (which uses SystemAltHighColor) overridden in Application.Resources gets picked up by WinUI control");

                // 3) Verify that overriding a system brush used by a system control works.
                if (PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone1))
                {
                    // Below code is comment because of bug 19180323 and we expect the code to be enabled again after test case is moved to nuget testapp

                    //Verify.AreEqual(Colors.Purple, ((SolidColorBrush)slider.Foreground).Color,
                    //    "Verify Slider (which uses SliderTrackValueFill as its .Foreground) overridden in Application.Resources gets picked up by Slider control");
                }
                else
                {
                    // Before RS1, we used to reference system brushes directly.
                }

                Log.Comment("Setting Window.Current.Content = null");
                MUXControlsTestApp.App.TestContentRoot = null;
            });
            IdleSynchronizer.TryWait();
        }
Exemple #18
0
 private void RatingControl1_ValueChanged(Microsoft.UI.Xaml.Controls.RatingControl sender, object args)
 {
     RatingControl1.Caption = "Your rating";
 }
 private void MyRatingReadOnly_ValueChanged(RatingControl sender, object args)
 {
     MyRatingReadOnlyTextBlock.Text = sender.Value.ToString();
 }
 /// <summary>
 /// Initializes a new instance of the RatingControlAutomationPeer class.
 /// </summary>
 /// <param name="owner">Rating control.</param>
 public RatingControlAutomationPeer(RatingControl owner) : base(owner)
 {
 }