|
|
@ -4,6 +4,7 @@ using System.Reactive.Disposables; |
|
|
using Avalonia.Controls; |
|
|
using Avalonia.Controls; |
|
|
using Avalonia.Rendering; |
|
|
using Avalonia.Rendering; |
|
|
using Avalonia.Platform; |
|
|
using Avalonia.Platform; |
|
|
|
|
|
using Avalonia.UnitTests; |
|
|
using Avalonia; |
|
|
using Avalonia; |
|
|
using ReactiveUI; |
|
|
using ReactiveUI; |
|
|
using DynamicData; |
|
|
using DynamicData; |
|
|
@ -16,23 +17,6 @@ namespace Avalonia |
|
|
{ |
|
|
{ |
|
|
public class TestUserControl : UserControl, IActivatable { } |
|
|
public class TestUserControl : UserControl, IActivatable { } |
|
|
|
|
|
|
|
|
public class FakeRenderDecorator : Decorator, IRenderRoot |
|
|
|
|
|
{ |
|
|
|
|
|
public Size ClientSize => new Size(100, 100); |
|
|
|
|
|
|
|
|
|
|
|
public IRenderer Renderer { get; } |
|
|
|
|
|
|
|
|
|
|
|
public double RenderScaling => 1; |
|
|
|
|
|
|
|
|
|
|
|
public IRenderTarget CreateRenderTarget() => null; |
|
|
|
|
|
|
|
|
|
|
|
public void Invalidate(Rect rect) { } |
|
|
|
|
|
|
|
|
|
|
|
public Point PointToClient(Point point) => point; |
|
|
|
|
|
|
|
|
|
|
|
public Point PointToScreen(Point point) => point; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class TestUserControlWithWhenActivated : UserControl, IActivatable |
|
|
public class TestUserControlWithWhenActivated : UserControl, IActivatable |
|
|
{ |
|
|
{ |
|
|
public bool Active { get; private set; } |
|
|
public bool Active { get; private set; } |
|
|
@ -60,7 +44,7 @@ namespace Avalonia |
|
|
.Bind(out var activated) |
|
|
.Bind(out var activated) |
|
|
.Subscribe(); |
|
|
.Subscribe(); |
|
|
|
|
|
|
|
|
var fakeRenderedDecorator = new FakeRenderDecorator(); |
|
|
var fakeRenderedDecorator = new TestRoot(); |
|
|
fakeRenderedDecorator.Child = userControl; |
|
|
fakeRenderedDecorator.Child = userControl; |
|
|
Assert.True(activated[0]); |
|
|
Assert.True(activated[0]); |
|
|
Assert.Equal(1, activated.Count); |
|
|
Assert.Equal(1, activated.Count); |
|
|
@ -94,7 +78,7 @@ namespace Avalonia |
|
|
var userControl = new TestUserControlWithWhenActivated(); |
|
|
var userControl = new TestUserControlWithWhenActivated(); |
|
|
Assert.False(userControl.Active); |
|
|
Assert.False(userControl.Active); |
|
|
|
|
|
|
|
|
var fakeRenderedDecorator = new FakeRenderDecorator(); |
|
|
var fakeRenderedDecorator = new TestRoot(); |
|
|
fakeRenderedDecorator.Child = userControl; |
|
|
fakeRenderedDecorator.Child = userControl; |
|
|
Assert.True(userControl.Active); |
|
|
Assert.True(userControl.Active); |
|
|
|
|
|
|
|
|
|