Fix hot reload server not launch after App run
Fix state not update UI after it added to global properties Fix test cases build issue
This commit is contained in:
Родитель
a8d1db7f6b
Коммит
33122cdfaf
|
@ -1 +1 @@
|
|||
Subproject commit 439853d004681b16a5ff20d0c16903606d1a77ee
|
||||
Subproject commit 10edb9416a9fe2832748fd9c9c76e683cd9b0d25
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"tools": {
|
||||
"dotnet": "6.0.100-rc.2.21478.25"
|
||||
"dotnet": "6.0.100"
|
||||
},
|
||||
"msbuild-sdks": {
|
||||
"MSBuild.Sdk.Extras": "3.0.23",
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace Comet
|
|||
|
||||
public int IdePort { get; set; } = 9988;
|
||||
|
||||
int _attempts = 3;
|
||||
|
||||
public async void Initialize(IServiceProvider services)
|
||||
{
|
||||
var handlers = services.GetRequiredService<IMauiHandlersFactory>();
|
||||
|
@ -60,6 +62,14 @@ namespace Comet
|
|||
{
|
||||
var success = await Reloadify.Reload.Init(IdeIp, IdePort);
|
||||
|
||||
while(!success && _attempts > 0)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
Console.WriteLine("Trying to connect HotReload server....");
|
||||
success = await Reloadify.Reload.Init(IdeIp, IdePort);
|
||||
_attempts--;
|
||||
}
|
||||
|
||||
Console.WriteLine($"HotReload Initialize: {success}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Comet
|
|||
public static readonly Alignment Top = new Alignment(LayoutAlignment.Center, LayoutAlignment.Start);
|
||||
public static readonly Alignment TopLeading = new Alignment(LayoutAlignment.Start, LayoutAlignment.Start);
|
||||
public static readonly Alignment TopTrailing = new Alignment(LayoutAlignment.End, LayoutAlignment.Start);
|
||||
public static readonly Alignment Fill = new Alignment(LayoutAlignment.Fill, LayoutAlignment.Fill);
|
||||
|
||||
public Alignment(LayoutAlignment horizontal, LayoutAlignment vertical)
|
||||
{
|
||||
|
|
|
@ -141,8 +141,6 @@ namespace Comet
|
|||
{
|
||||
changeDictionary[fullProperty] = value;
|
||||
UpdatePropertyChangeProperty(view, fullProperty, value);
|
||||
if (GlobalProperties.Contains(property))
|
||||
return false;
|
||||
if (ViewUpdateProperties.TryGetValue((property.BindingObject, property.PropertyName), out var bindings))
|
||||
{
|
||||
foreach (var binding in bindings.ToList())
|
||||
|
@ -150,6 +148,10 @@ namespace Comet
|
|||
binding.Binding.BindingValueChanged(property.BindingObject, binding.PropertyName, value);
|
||||
}
|
||||
}
|
||||
if (GlobalProperties.Contains(property))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -428,7 +428,8 @@ namespace Comet
|
|||
//Get the current MauiContext
|
||||
//I might be able to do something better, like searching up though the parent
|
||||
//Maybe I can do something where I get the current Context whenever I build
|
||||
var mauiContext = this.ViewHandler?.MauiContext ?? CometApp.CurrentWindow?.MauiContext;
|
||||
//In test project, we don't assign the CurrentWindows to have the MauiContext
|
||||
var mauiContext = GetMauiContext();
|
||||
if (mauiContext != null)
|
||||
{
|
||||
var type = this.GetType();
|
||||
|
@ -620,6 +621,13 @@ namespace Comet
|
|||
this.SetFrameFromPlatformView(frame);
|
||||
if (BuiltView != null)
|
||||
BuiltView.LayoutSubviews(frame);
|
||||
else if (this is ContainerView container)
|
||||
{
|
||||
foreach (var view in container)
|
||||
{
|
||||
view.LayoutSubviews(this.Frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
public override string ToString() => $"{this.GetType()} - {this.Id}";
|
||||
|
||||
|
@ -793,8 +801,9 @@ namespace Comet
|
|||
//Measure(new Size(widthConstraint, heightConstraint));
|
||||
Measure(widthConstraint, heightConstraint);
|
||||
void IView.InvalidateMeasure() => InvalidateMeasurement();
|
||||
void IView.InvalidateArrange() {}
|
||||
void IHotReloadableView.TransferState(IView newView) {
|
||||
void IView.InvalidateArrange() { }
|
||||
void IHotReloadableView.TransferState(IView newView)
|
||||
{
|
||||
var oldState = this.GetState();
|
||||
if (oldState == null)
|
||||
return;
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace Comet
|
|||
|
||||
public int IdePort { get; set; } = 9988;
|
||||
|
||||
int _attempts = 3;
|
||||
|
||||
public async void Initialize(IServiceProvider services)
|
||||
{
|
||||
var handlers = services.GetRequiredService<IMauiHandlersFactory>();
|
||||
|
@ -51,6 +53,14 @@ namespace Comet
|
|||
{
|
||||
var success = await Reloadify.Reload.Init(IdeIp, IdePort);
|
||||
|
||||
while(!success && _attempts > 0)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
Console.WriteLine("Trying to connect HotReload server....");
|
||||
success = await Reloadify.Reload.Init(IdeIp, IdePort);
|
||||
_attempts--;
|
||||
}
|
||||
|
||||
Console.WriteLine($"HotReload Initialize: {success}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -121,6 +121,27 @@ namespace Comet.Tests
|
|||
Assert.True(textHandler.ChangedProperties.TryGetValue(nameof(IText.Text), out var changedText), "Text.Value Change was not set to Text handler");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BindingShouldKeepUpdate()
|
||||
{
|
||||
Text text = null;
|
||||
Text text1 = null;
|
||||
var view = new StatePage();
|
||||
|
||||
view.Body = () => new VStack
|
||||
{
|
||||
(text = new Text(() => $"{view.clickCount}")),
|
||||
(text1 = new Text(() => $"{view.clickCount}")),
|
||||
};
|
||||
view.SetViewHandlerToGeneric();
|
||||
|
||||
for (int i = 1; i < 10; ++i)
|
||||
{
|
||||
Assert.Equal(text.Value.CurrentValue, $"{i}");
|
||||
Assert.Equal(text1.Value.CurrentValue, $"{i}");
|
||||
view.clickCount.Value++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SingleBindingNotEffectedByGlobal()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp6.0</TargetFramework>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<Configurations>Release;Debug</Configurations>
|
||||
</PropertyGroup>
|
||||
|
@ -14,11 +14,9 @@
|
|||
<DebugSymbols>false</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
|
||||
<PackageReference Include="Microsoft.Maui.Graphics" Version="6.0.100-preview.3.34" />
|
||||
<PackageReference Include="Microsoft.Maui.Graphics" Version="$(_MicrosoftMauiGraphics)" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
@ -26,8 +24,8 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Comet.SourceGenerator\Comet.SourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||
<ProjectReference Include="..\..\src\Comet\Comet.csproj" />
|
||||
<ProjectReference Include="..\..\external\Maui\src\Core\src\Core.csproj" />
|
||||
<ProjectReference Include="..\..\external\Maui\src\Essentials\src\Essentials.csproj" />
|
||||
<ProjectReference Include="..\..\External\Maui\src\Core\src\Core.csproj" />
|
||||
<ProjectReference Include="..\..\External\Maui\src\Graphics\src\Graphics\Graphics.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Helpers\" />
|
||||
|
|
|
@ -31,28 +31,28 @@ namespace Comet.Tests
|
|||
var text1 = view.GetViewWithTag<Text>("text1");
|
||||
var text2 = view.GetViewWithTag<Text>("text2");
|
||||
|
||||
view.Frame = new Rectangle(0, 0, 320, 600);
|
||||
view.Frame = new Rect(0, 0, 320, 600);
|
||||
view.Measure(view.Frame.Width, view.Frame.Height);
|
||||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(320, 40), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(grid.MeasurementValid);
|
||||
Assert.Equal(new Size(320, 40), grid.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 280, 320, 40), grid.Frame);
|
||||
Assert.Equal(new Rect(0, 280, 320, 40), grid.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 20), textField.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 20), textField.Frame);
|
||||
|
||||
Assert.True(text1.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), text1.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 20, 160, 20), text1.Frame);
|
||||
Assert.Equal(new Rect(0, 20, 160, 20), text1.Frame);
|
||||
|
||||
Assert.True(text2.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), text2.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(160, 20, 160, 20), text2.Frame);
|
||||
Assert.Equal(new Rect(160, 20, 160, 20), text2.Frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,27 +32,27 @@ namespace Comet.Tests
|
|||
var spacer = view.GetViewWithTag<Spacer>("spacer");
|
||||
var text = view.GetViewWithTag<Text>("text");
|
||||
|
||||
view.Frame = new Rectangle(0, 0, 320, 600);
|
||||
view.Frame = new Rect(0, 0, 320, 600);
|
||||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(320, 12), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(stack.MeasurementValid);
|
||||
Assert.Equal(new Size(320, 12), stack.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 294, 320, 12), stack.Frame);
|
||||
Assert.Equal(new Rect(0, 294, 320, 12), stack.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 40, 12), textField.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 40, 12), textField.Frame);
|
||||
|
||||
Assert.True(spacer.MeasurementValid);
|
||||
Assert.Equal(new Size(-1, -1), spacer.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(40, 0, 240, 12), spacer.Frame);
|
||||
Assert.Equal(new Rect(40, 0, 240, 12), spacer.Frame);
|
||||
|
||||
Assert.True(text.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), text.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(280, 0, 40, 12), text.Frame);
|
||||
Assert.Equal(new Rect(280, 0, 40, 12), text.Frame);
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,23 +69,23 @@ namespace Comet.Tests
|
|||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(320, 12), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(stack.MeasurementValid);
|
||||
Assert.Equal(new Size(320, 12), stack.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 294, 320, 12), stack.Frame);
|
||||
Assert.Equal(new Rect(0, 294, 320, 12), stack.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 40, 12), textField.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 40, 12), textField.Frame);
|
||||
|
||||
Assert.True(spacer.MeasurementValid);
|
||||
Assert.Equal(new Size(-1, -1), spacer.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(40, 0, 240, 12), spacer.Frame);
|
||||
Assert.Equal(new Rect(40, 0, 240, 12), spacer.Frame);
|
||||
|
||||
Assert.True(text.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), text.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(280, 0, 40, 12), text.Frame);
|
||||
Assert.Equal(new Rect(280, 0, 40, 12), text.Frame);
|
||||
}
|
||||
|
||||
|
||||
|
@ -100,27 +100,27 @@ namespace Comet.Tests
|
|||
var spacer = view.GetViewWithTag<Spacer>("spacer");
|
||||
var text = view.GetViewWithTag<Text>("text");
|
||||
|
||||
view.Frame = new Rectangle(0, 0, 320, 600);
|
||||
view.Frame = new Rect(0, 0, 320, 600);
|
||||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 12), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(stack.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 12), stack.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(10, 294, 300, 12), stack.Frame);
|
||||
Assert.Equal(new Rect(10, 294, 300, 12), stack.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 40, 12), textField.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 40, 12), textField.Frame);
|
||||
|
||||
Assert.True(spacer.MeasurementValid);
|
||||
Assert.Equal(new Size(-1, -1), spacer.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(40, 0, 220, 12), spacer.Frame);
|
||||
Assert.Equal(new Rect(40, 0, 220, 12), spacer.Frame);
|
||||
|
||||
Assert.True(text.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), text.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(260, 0, 40, 12), text.Frame);
|
||||
Assert.Equal(new Rect(260, 0, 40, 12), text.Frame);
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,27 +135,27 @@ namespace Comet.Tests
|
|||
var spacer = view.GetViewWithTag<Spacer>("spacer");
|
||||
var text = view.GetViewWithTag<Text>("text");
|
||||
|
||||
view.Frame = new Rectangle(0, 0, 320, 600);
|
||||
view.Frame = new Rect(0, 0, 320, 600);
|
||||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 20), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(stack.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 20), stack.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(10, 290, 300, 20), stack.Frame);
|
||||
Assert.Equal(new Rect(10, 290, 300, 20), stack.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 4, 40, 12), textField.Frame);
|
||||
Assert.Equal(new Rect(0, 4, 40, 12), textField.Frame);
|
||||
|
||||
Assert.True(spacer.MeasurementValid);
|
||||
Assert.Equal(new Size(-1, -1), spacer.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(40, 4, 220, 12), spacer.Frame);
|
||||
Assert.Equal(new Rect(40, 4, 220, 12), spacer.Frame);
|
||||
|
||||
Assert.True(text.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), text.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(260, 4, 40, 12), text.Frame);
|
||||
Assert.Equal(new Rect(260, 4, 40, 12), text.Frame);
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,31 +166,31 @@ namespace Comet.Tests
|
|||
InitializeHandlers(view);
|
||||
|
||||
var stack = view.GetViewWithTag<HStack>("stack").Margin().Frame(height: 20);
|
||||
var textField = view.GetViewWithTag<TextField>("textfield").Frame(alignment: Alignment.Top);
|
||||
var textField = view.GetViewWithTag<TextField>("textfield");//.Frame(alignment: Alignment.Top);
|
||||
var spacer = view.GetViewWithTag<Spacer>("spacer");
|
||||
var text = view.GetViewWithTag<Text>("text").Frame(alignment: Alignment.Bottom);
|
||||
var text = view.GetViewWithTag<Text>("text");//.Frame(alignment: Alignment.Bottom);
|
||||
|
||||
view.Frame = new Rectangle(0, 0, 320, 600);
|
||||
view.Frame = new Rect(0, 0, 320, 600);
|
||||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 20), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(stack.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 20), stack.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(10, 290, 300, 20), stack.Frame);
|
||||
Assert.Equal(new Rect(10, 290, 300, 20), stack.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 40, 12), textField.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 40, 12), textField.Frame);
|
||||
|
||||
Assert.True(spacer.MeasurementValid);
|
||||
Assert.Equal(new Size(-1, -1), spacer.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(40, 4, 220, 12), spacer.Frame);
|
||||
Assert.Equal(new Rect(40, 4, 220, 12), spacer.Frame);
|
||||
|
||||
Assert.True(text.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), text.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(260, 8, 40, 12), text.Frame);
|
||||
Assert.Equal(new Rect(260, 8, 40, 12), text.Frame);
|
||||
}
|
||||
|
||||
|
||||
|
@ -205,27 +205,27 @@ namespace Comet.Tests
|
|||
var spacer = view.GetViewWithTag<Spacer>("spacer");
|
||||
var text = view.GetViewWithTag<Text>("text").Frame(height: 18);
|
||||
|
||||
view.Frame = new Rectangle(0, 0, 320, 600);
|
||||
view.Frame = new Rect(0, 0, 320, 600);
|
||||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 22), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(stack.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 22), stack.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(10, 289, 300, 22), stack.Frame);
|
||||
Assert.Equal(new Rect(10, 289, 300, 22), stack.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 22), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 40, 22), textField.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 40, 22), textField.Frame);
|
||||
|
||||
Assert.True(spacer.MeasurementValid);
|
||||
Assert.Equal(new Size(-1, -1), spacer.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(40, 0, 220, 22), spacer.Frame);
|
||||
Assert.Equal(new Rect(40, 0, 220, 22), spacer.Frame);
|
||||
|
||||
Assert.True(text.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 18), text.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(260, 2, 40, 18), text.Frame);
|
||||
Assert.Equal(new Rect(260, 2, 40, 18), text.Frame);
|
||||
}
|
||||
|
||||
|
||||
|
@ -240,28 +240,28 @@ namespace Comet.Tests
|
|||
var spacer = view.GetViewWithTag<Spacer>("spacer");
|
||||
var text = view.GetViewWithTag<Text>("text").Frame(height: 18);
|
||||
|
||||
view.Frame = new Rectangle(0, 0, 320, 600);
|
||||
view.Frame = new Rect(0, 0, 320, 600);
|
||||
view.Measure(view.Frame.Width, view.Frame.Height);
|
||||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 42), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(stack.MeasurementValid);
|
||||
Assert.Equal(new Size(300, 42), stack.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(10, 279, 300, 42), stack.Frame);
|
||||
Assert.Equal(new Rect(10, 279, 300, 42), stack.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 22), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(10, 10, 40, 22), textField.Frame);
|
||||
Assert.Equal(new Rect(10, 10, 40, 22), textField.Frame);
|
||||
|
||||
Assert.True(spacer.MeasurementValid);
|
||||
Assert.Equal(new Size(-1, -1), spacer.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(60, 10, 200, 22), spacer.Frame);
|
||||
Assert.Equal(new Rect(60, 10, 200, 22), spacer.Frame);
|
||||
|
||||
Assert.True(text.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 18), text.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(260, 12, 40, 18), text.Frame);
|
||||
Assert.Equal(new Rect(260, 12, 40, 18), text.Frame);
|
||||
}
|
||||
|
||||
public class HStackTestView2 : View
|
||||
|
@ -287,23 +287,23 @@ namespace Comet.Tests
|
|||
var textField = view.GetViewWithTag<TextField>("textfield");
|
||||
var text = view.GetViewWithTag<Text>("text");
|
||||
|
||||
view.Frame = new Rectangle(0, 0, 320, 600);
|
||||
view.Frame = new Rect(0, 0, 320, 600);
|
||||
|
||||
Assert.True(view.MeasurementValid);
|
||||
Assert.Equal(new Size(90, 12), view.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
|
||||
Assert.True(stack.MeasurementValid);
|
||||
Assert.Equal(new Size(90, 12), stack.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(115, 294, 90, 12), stack.Frame);
|
||||
Assert.Equal(new Rect(115, 294, 90, 12), stack.Frame);
|
||||
|
||||
Assert.True(textField.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), textField.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(0, 0, 40, 12), textField.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 40, 12), textField.Frame);
|
||||
|
||||
Assert.True(text.MeasurementValid);
|
||||
Assert.Equal(new Size(40, 12), text.MeasuredSize);
|
||||
Assert.Equal(new Rectangle(50, 0, 40, 12), text.Frame);
|
||||
Assert.Equal(new Rect(50, 0, 40, 12), text.Frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,21 +21,22 @@ namespace Comet.Tests.Handlers
|
|||
|
||||
public SizeF GetIntrinsicSize(double widthConstraint, double heightConstraint) => OnGetIntrinsicSize?.Invoke(widthConstraint,heightConstraint) ?? new Size(-1,-1);
|
||||
|
||||
public void SetFrame(RectangleF frame)
|
||||
public void SetFrame(Rect frame)
|
||||
{
|
||||
Frame = frame;
|
||||
}
|
||||
|
||||
public Func<double, double, Size> OnGetIntrinsicSize { get; set; }
|
||||
|
||||
public Rectangle Frame
|
||||
public Rect Frame
|
||||
{
|
||||
get => (Rectangle)ChangedProperties[nameof(Frame)];
|
||||
get => (Rect)ChangedProperties[nameof(Frame)];
|
||||
set => ChangedProperties[nameof(Frame)] = value;
|
||||
}
|
||||
|
||||
IElement IElementHandler.VirtualView => CurrentView;
|
||||
IView IViewHandler.VirtualView => CurrentView;
|
||||
object? IElementHandler.PlatformView => CurrentView;
|
||||
|
||||
public object ContainerView => throw new NotImplementedException();
|
||||
|
||||
|
@ -68,7 +69,7 @@ namespace Comet.Tests.Handlers
|
|||
public void DisconnectHandler() => CurrentView = null;
|
||||
void IElementHandler.SetMauiContext(IMauiContext mauiContext) => MauiContext = mauiContext;
|
||||
Size IViewHandler.GetDesiredSize(double widthConstraint, double heightConstraint) => GetIntrinsicSize(widthConstraint, heightConstraint);
|
||||
void IViewHandler.NativeArrange(Rectangle frame) => Frame = frame;
|
||||
void IViewHandler.PlatformArrange(Rect frame) => Frame = frame;
|
||||
public void Invoke(string command, object args = null) => InvokedCommands.Add(command, args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
using Microsoft.Maui.Graphics;
|
||||
using Comet.Tests.Handlers;
|
||||
using Xunit;
|
||||
using Microsoft.Maui;
|
||||
using Microsoft.Maui.Primitives;
|
||||
|
||||
namespace Comet.Tests
|
||||
{
|
||||
|
@ -14,10 +16,13 @@ namespace Comet.Tests
|
|||
[Body]
|
||||
View body() => new VStack()
|
||||
{
|
||||
new Text(text).Tag("text"),
|
||||
}.Tag("stack");
|
||||
new Text(text).FitHorizontal().Tag("text"),
|
||||
}.FillHorizontal()
|
||||
.FitVertical()
|
||||
.Padding(new Thickness())
|
||||
.Tag("stack");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TextInVStackIsFullWidth()
|
||||
{
|
||||
|
@ -26,12 +31,12 @@ namespace Comet.Tests
|
|||
|
||||
var stack = view.GetViewWithTag("stack");
|
||||
var text = view.GetViewWithTag("text");
|
||||
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
//Assert.Equal(new Rectangle(0, 294, 320, 12), stack.Frame);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 12), text.Frame);
|
||||
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 12), stack.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 40, 12), text.Frame);
|
||||
}
|
||||
|
||||
|
||||
public class TextFieldInVStackTestView : View
|
||||
{
|
||||
public readonly State<string> text = "Test";
|
||||
|
@ -39,10 +44,13 @@ namespace Comet.Tests
|
|||
[Body]
|
||||
View body() => new VStack()
|
||||
{
|
||||
new TextField(text).Tag("textfield"),
|
||||
}.Tag("stack");
|
||||
new TextField(text).FillHorizontal().Tag("textfield"),
|
||||
}.FillHorizontal()
|
||||
.FitVertical()
|
||||
.Padding(new Thickness())
|
||||
.Tag("stack");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TextFieldInVStackIsFullWidth()
|
||||
{
|
||||
|
@ -51,12 +59,12 @@ namespace Comet.Tests
|
|||
|
||||
var stack = view.GetViewWithTag("stack");
|
||||
var textfield = view.GetViewWithTag("textfield");
|
||||
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
//Assert.Equal(new Rectangle(0, 294, 320, 12), stack.Frame);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 12), textfield.Frame);
|
||||
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 12), stack.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 12), textfield.Frame);
|
||||
}
|
||||
|
||||
|
||||
public class SecureFieldInVStackTestView : View
|
||||
{
|
||||
public readonly State<string> text = "Test";
|
||||
|
@ -65,9 +73,12 @@ namespace Comet.Tests
|
|||
View body() => new VStack()
|
||||
{
|
||||
new SecureField(text).Tag("securefield"),
|
||||
}.Tag("stack");
|
||||
}.FillHorizontal()
|
||||
.FitVertical()
|
||||
.Padding(new Thickness())
|
||||
.Tag("stack");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void SecureFieldInVStackIsFullWidth()
|
||||
{
|
||||
|
@ -76,21 +87,24 @@ namespace Comet.Tests
|
|||
|
||||
var stack = view.GetViewWithTag("stack");
|
||||
var securefield = view.GetViewWithTag("securefield");
|
||||
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
//Assert.Equal(new Rectangle(0, 294, 320, 12), stack.Frame);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 12), securefield.Frame);
|
||||
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 12), stack.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 12), securefield.Frame);
|
||||
}
|
||||
|
||||
|
||||
public class SliderInVStackTestView : View
|
||||
{
|
||||
[Body]
|
||||
View body() => new VStack()
|
||||
{
|
||||
new Slider(0).Tag("slider"),
|
||||
}.Tag("stack");
|
||||
}.FillHorizontal()
|
||||
.FitVertical()
|
||||
.Padding(new Thickness())
|
||||
.Tag("stack");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void SliderInVStackIsFullWidth()
|
||||
{
|
||||
|
@ -99,21 +113,24 @@ namespace Comet.Tests
|
|||
|
||||
var stack = view.GetViewWithTag("stack");
|
||||
var slider = view.GetViewWithTag("slider");
|
||||
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
//Assert.Equal(new Rectangle(0, 290, 320, 20), stack.Frame);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 20), slider.Frame);
|
||||
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 20), stack.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 20), slider.Frame);
|
||||
}
|
||||
|
||||
|
||||
public class ProgressBarInVStackTestView : View
|
||||
{
|
||||
[Body]
|
||||
View body() => new VStack()
|
||||
{
|
||||
new ProgressBar(0).Tag("progressbar"),
|
||||
}.Tag("stack");
|
||||
}.FillHorizontal()
|
||||
.FitVertical()
|
||||
.Padding(new Thickness())
|
||||
.Tag("stack");
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ProgressBarInVStackIsFullWidth()
|
||||
{
|
||||
|
@ -122,34 +139,34 @@ namespace Comet.Tests
|
|||
|
||||
var stack = view.GetViewWithTag("stack");
|
||||
var progressbar = view.GetViewWithTag("progressbar");
|
||||
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 600), view.Frame);
|
||||
//Assert.Equal(new Rectangle(0, 290, 320, 20), stack.Frame);
|
||||
Assert.Equal(new Rectangle(0, 0, 320, 20), progressbar.Frame);
|
||||
|
||||
Assert.Equal(new Rect(0, 0, 320, 600), view.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 20), stack.Frame);
|
||||
Assert.Equal(new Rect(0, 0, 320, 20), progressbar.Frame);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ComboBoxInVStackDefaultsToAMinimumWidth()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ButtonInVStackDefaultsToAMinimumWidth()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void LabelInHStackIsCenterAlignedVertically()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ListViewInAVStackTakesRemainingHeight()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using System;
|
||||
using Microsoft.Maui.Graphics;
|
||||
using Comet.Internal;
|
||||
using Xunit;
|
||||
using Microsoft.Maui.HotReload;
|
||||
using Comet.Internal;
|
||||
using Microsoft.Maui;
|
||||
using Microsoft.Maui.Graphics;
|
||||
using Microsoft.Maui.HotReload;
|
||||
using Xunit;
|
||||
|
||||
[assembly: CollectionBehavior(DisableTestParallelization = true)]
|
||||
namespace Comet.Tests
|
||||
|
@ -50,10 +49,11 @@ namespace Comet.Tests
|
|||
public static void InitializeHandlers(View view, float width, float height)
|
||||
{
|
||||
InitializeHandlers(view);
|
||||
var frame = new Rectangle(0, 0, width, height);
|
||||
view.Alignment(Alignment.Fill);
|
||||
var frame = new Rect(0, 0, width, height);
|
||||
var iView = (IView)view;
|
||||
iView.Measure(frame.Width, frame.Height);
|
||||
iView.Arrange(new Rectangle(0, 0, width, height));
|
||||
iView.Arrange(frame);
|
||||
}
|
||||
|
||||
public static void ResetComet()
|
||||
|
|
|
@ -8,14 +8,14 @@ using Microsoft.Maui;
|
|||
using Microsoft.Maui.Hosting;
|
||||
using Microsoft.Maui.Hosting.Internal;
|
||||
using Microsoft.Maui.HotReload;
|
||||
using static Microsoft.Maui.HandlerMauiAppBuilderExtensions;
|
||||
using static Microsoft.Maui.Hosting.HandlerMauiAppBuilderExtensions;
|
||||
|
||||
namespace Comet.Tests
|
||||
{
|
||||
public static class UI
|
||||
{
|
||||
static bool hasInit;
|
||||
public static IMauiHandlersServiceProvider Handlers { get; set; }
|
||||
public static IMauiHandlersFactory Handlers { get; set; }
|
||||
public static void Init(bool force = false)
|
||||
{
|
||||
if (hasInit && !force)
|
||||
|
@ -41,7 +41,7 @@ namespace Comet.Tests
|
|||
};
|
||||
|
||||
|
||||
Handlers = new MauiHandlersServiceProvider(handlers.Select(x=> new HandlerRegistration((a)=> a.AddHandler(x.Key,x.Value))));
|
||||
Handlers = new MauiHandlersFactory(handlers.Select(x=> new HandlerRegistration((a)=> a.AddHandler(x.Key,x.Value))));
|
||||
|
||||
MauiHotReloadHelper.IsEnabled = true;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче