Esempio n. 1
0
 public void LayoutTracker_leak_test()
 {
     RunInMainThread(() =>
     {
         AssertIsGarbageCollected(
             () =>
         {
             BehaviorSubject <IEnumerable <IControl> > innerControls =
                 new BehaviorSubject <IEnumerable <IControl> >(Enumerable.Empty <IControl>());
             var container = LayoutTracker.Create(
                 x => innerControls.CachePerElement(y => x.TrackVisualBounds(frame => { }, y)).StackFromLeft());
             container.MountRoot();
             return(new { innerControls, container });
         },
             env =>
         {
             var innerControls   = env.innerControls;
             var rectangleHeight = new BehaviorSubject <Points>(33);
             var rectangle       = Shapes.Rectangle(fill: Brush.Transparent).WithWidth(rectangleHeight);
             Assert.That(rectangleHeight.HasObservers, Is.False);
             innerControls.OnNext(new[] { rectangle });
             Assert.That(rectangleHeight.HasObservers, Is.True);
             innerControls.OnNext(Enumerable.Empty <IControl>());
             Assert.That(rectangleHeight.HasObservers, Is.False);
             return(rectangle);
         });
     });
 }