public void IsHitTestVisibleActivatesFrameworkElement()
        {
            var uc = new TestUserControl();

            uc.IsHitTestVisible = false;
            var activation = new ActivationForViewFetcher();

            var obs       = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection(scheduler: ImmediateScheduler.Instance);

            RoutedEventArgs loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            // IsHitTestVisible still false
            new bool[0].AssertAreEqual(activated);

            uc.IsHitTestVisible = true;

            // IsHitTestVisible true
            new[] { true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
Пример #2
0
        public void IsHitTestVisibleActivatesFrameworkElement()
        {
            var uc = new TestUserControl();

            uc.IsHitTestVisible = false;
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);

            obs.ToObservableChangeSet(scheduler: ImmediateScheduler.Instance).Bind(out var activated).Subscribe();

            var loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            // IsHitTestVisible still false
            new bool[0].AssertAreEqual(activated);

            uc.IsHitTestVisible = true;

            // IsHitTestVisible true
            new[] { true }.AssertAreEqual(activated);

            var unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
        public void FrameworkElementIsActivatedAndDeactivatedWithHitTest()
        {
            var uc         = new TestUserControl();
            var activation = new ActivationForViewFetcher();

            var obs       = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection(scheduler: ImmediateScheduler.Instance);

            RoutedEventArgs loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            new[] { true }.AssertAreEqual(activated);

            // this should deactivate it
            uc.IsHitTestVisible = false;

            new[] { true, false }.AssertAreEqual(activated);

            // this should activate it
            uc.IsHitTestVisible = true;

            new[] { true, false, true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false, true, false }.AssertAreEqual(activated);
        }
Пример #4
0
        public void FrameworkElementIsActivatedAndDeactivated()
        {
            var uc         = new TestUserControl();
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);

            obs.ToObservableChangeSet(scheduler: ImmediateScheduler.Instance).Bind(out var activated).Subscribe();

            var loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            new[] { true }.AssertAreEqual(activated);

            var unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
        public void IsHitTestVisibleActivatesFrameworkElement()
        {
            var uc = new TestUserControl();
            uc.IsHitTestVisible = false;
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection();

            RoutedEventArgs loaded = new RoutedEventArgs();
            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            // IsHitTestVisible still false
            new bool[0].AssertAreEqual(activated);

            uc.IsHitTestVisible = true;

            // IsHitTestVisible true
            new[] { true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();
            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
Пример #6
0
        public void IsHitTestVisibleActivatesFrameworkElement()
        {
            var uc = new TestUserControl();

            uc.IsHitTestVisible = false;
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);

            obs.ToObservableChangeSet(scheduler: ImmediateScheduler.Instance).Bind(out var activated).Subscribe();

            var loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            // Loaded has happened.
            new[] { true }.AssertAreEqual(activated);

            uc.IsHitTestVisible = true;

            // IsHitTestVisible true, we don't want the event to repeat unnecessarily.
            new[] { true }.AssertAreEqual(activated);

            var unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            // We had both a loaded/hit test visible change/unloaded happen.
            new[] { true, false }.AssertAreEqual(activated);
        }
        public void FrameworkElementIsActivatedAndDeactivated()
        {
            var uc = new TestUserControl();
            var activation = new ActivationForViewFetcher();

            var obs = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection();

            RoutedEventArgs loaded = new RoutedEventArgs();
            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            new[] { true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();
            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }
Пример #8
0
        public void FrameworkElementIsActivatedAndDeactivated()
        {
            var uc         = new TestUserControl();
            var activation = new ActivationForViewFetcher();

            var obs       = activation.GetActivationForView(uc);
            var activated = obs.CreateCollection();

            RoutedEventArgs loaded = new RoutedEventArgs();

            loaded.RoutedEvent = FrameworkElement.LoadedEvent;

            uc.RaiseEvent(loaded);

            new[] { true }.AssertAreEqual(activated);

            RoutedEventArgs unloaded = new RoutedEventArgs();

            unloaded.RoutedEvent = FrameworkElement.UnloadedEvent;

            uc.RaiseEvent(unloaded);

            new[] { true, false }.AssertAreEqual(activated);
        }