Skip to content

Commit

Permalink
Merge branch 'master' into ptim-sync-initial-state
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Nov 17, 2024
2 parents e5562f4 + 0e85825 commit 85dfae6
Show file tree
Hide file tree
Showing 36 changed files with 444 additions and 560 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
# Attempt to upload results even if test fails.
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#always
- name: Upload Test Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: osu-framework-test-results-${{matrix.os.prettyname}}-${{matrix.threadingMode}}-${{matrix.os.configuration}}
Expand Down
34 changes: 22 additions & 12 deletions .github/workflows/report-nunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,40 @@
name: Annotate CI run with test results
on:
workflow_run:
workflows: ["Continuous Integration"]
workflows: [ "Continuous Integration" ]
types:
- completed

permissions:
contents: read
actions: read
checks: write

jobs:
annotate:
name: Annotate CI run with test results
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion != 'cancelled' }}
strategy:
fail-fast: false
matrix:
os:
- { prettyname: Windows, configuration: Debug }
- { prettyname: macOS, configuration: Debug }
- { prettyname: Linux, configuration: Debug }
- { prettyname: Linux, configuration: Release }
threadingMode: ['SingleThread', 'MultiThreaded']
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.repository.full_name }}
ref: ${{ github.event.workflow_run.head_sha }}

- name: Download results
uses: actions/download-artifact@v4
with:
pattern: osu-framework-test-results-*
merge-multiple: true
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}

- name: Annotate CI run with test results
uses: dorny/[email protected]
with:
artifact: osu-framework-test-results-${{matrix.os.prettyname}}-${{matrix.threadingMode}}-${{matrix.os.configuration}}
name: Test Results (${{matrix.os.prettyname}}, ${{matrix.threadingMode}}, ${{matrix.os.configuration}})
name: Results
path: "*.trx"
reporter: dotnet-trx
list-suites: 'failed'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using System.Diagnostics.CodeAnalysis;
using NUnit.Framework;
using osu.Framework.Allocation;
Expand All @@ -15,24 +12,6 @@ namespace osu.Framework.Tests.Dependencies.Reflection
[SuppressMessage("Performance", "OFSG001:Class contributes to dependency injection and should be partial")]
public class CachedModelDependenciesTest
{
[Test]
public void TestModelWithNonBindableFieldsFails()
{
IReadOnlyDependencyContainer unused;

Assert.Throws<TypeInitializationException>(() => unused = new CachedModelDependencyContainer<NonBindablePublicFieldModel>(null));
Assert.Throws<TypeInitializationException>(() => unused = new CachedModelDependencyContainer<NonBindablePrivateFieldModel>(null));
}

[Test]
public void TestModelWithNonReadOnlyFieldsFails()
{
IReadOnlyDependencyContainer unused;

Assert.Throws<TypeInitializationException>(() => unused = new CachedModelDependencyContainer<NonReadOnlyFieldModel>(null));
Assert.Throws<TypeInitializationException>(() => unused = new CachedModelDependencyContainer<PropertyModel>(null));
}

[Test]
public void TestSettingNoModelResolvesDefault()
{
Expand Down Expand Up @@ -195,7 +174,7 @@ public void TestSetModelToNullAfterResolved()

var model = new FieldModel { Bindable = { Value = 2 } };

var dependencies = new CachedModelDependencyContainer<FieldModel>(null)
var dependencies = new CachedModelDependencyContainer<FieldModel?>(null)
{
Model = { Value = model }
};
Expand Down Expand Up @@ -248,7 +227,7 @@ public void TestResolveIndividualProperties()
BindableString = { Value = "3" }
};

var dependencies = new CachedModelDependencyContainer<DerivedFieldModel>(null)
var dependencies = new CachedModelDependencyContainer<DerivedFieldModel?>(null)
{
Model = { Value = model1 }
};
Expand All @@ -269,33 +248,6 @@ public void TestResolveIndividualProperties()
Assert.AreEqual(null, resolver.BindableString.Value);
}

private class NonBindablePublicFieldModel : IDependencyInjectionCandidate
{
#pragma warning disable 649
public readonly int FailingField;
#pragma warning restore 649
}

private class NonBindablePrivateFieldModel : IDependencyInjectionCandidate
{
#pragma warning disable 169
private readonly int failingField;
#pragma warning restore 169
}

private class NonReadOnlyFieldModel : IDependencyInjectionCandidate
{
#pragma warning disable 649
public Bindable<int> Bindable;
#pragma warning restore 649
}

private class PropertyModel : IDependencyInjectionCandidate
{
// ReSharper disable once UnusedMember.Local
public Bindable<int> Bindable { get; private set; }
}

private class FieldModel : IDependencyInjectionCandidate
{
[Cached]
Expand All @@ -311,22 +263,22 @@ private class DerivedFieldModel : FieldModel
private class FieldModelResolver : IDependencyInjectionCandidate
{
[Resolved]
public FieldModel Model { get; private set; }
public FieldModel Model { get; private set; } = null!;
}

private class DerivedFieldModelResolver : IDependencyInjectionCandidate
{
[Resolved]
public DerivedFieldModel Model { get; private set; }
public DerivedFieldModel Model { get; private set; } = null!;
}

private class DerivedFieldModelPropertyResolver : IDependencyInjectionCandidate
{
[Resolved(typeof(DerivedFieldModel))]
public Bindable<int> Bindable { get; private set; }
public Bindable<int> Bindable { get; private set; } = null!;

[Resolved(typeof(DerivedFieldModel))]
public Bindable<string> BindableString { get; private set; }
public Bindable<string> BindableString { get; private set; } = null!;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
Expand All @@ -13,24 +10,6 @@ namespace osu.Framework.Tests.Dependencies.SourceGeneration
[TestFixture]
public partial class CachedModelDependenciesTest
{
[Test]
public void TestModelWithNonBindableFieldsFails()
{
IReadOnlyDependencyContainer unused;

Assert.Throws<TypeInitializationException>(() => unused = new CachedModelDependencyContainer<NonBindablePublicFieldModel>(null));
Assert.Throws<TypeInitializationException>(() => unused = new CachedModelDependencyContainer<NonBindablePrivateFieldModel>(null));
}

[Test]
public void TestModelWithNonReadOnlyFieldsFails()
{
IReadOnlyDependencyContainer unused;

Assert.Throws<TypeInitializationException>(() => unused = new CachedModelDependencyContainer<NonReadOnlyFieldModel>(null));
Assert.Throws<TypeInitializationException>(() => unused = new CachedModelDependencyContainer<PropertyModel>(null));
}

[Test]
public void TestSettingNoModelResolvesDefault()
{
Expand Down Expand Up @@ -193,7 +172,7 @@ public void TestSetModelToNullAfterResolved()

var model = new FieldModel { Bindable = { Value = 2 } };

var dependencies = new CachedModelDependencyContainer<FieldModel>(null)
var dependencies = new CachedModelDependencyContainer<FieldModel?>(null)
{
Model = { Value = model }
};
Expand Down Expand Up @@ -246,7 +225,7 @@ public void TestResolveIndividualProperties()
BindableString = { Value = "3" }
};

var dependencies = new CachedModelDependencyContainer<DerivedFieldModel>(null)
var dependencies = new CachedModelDependencyContainer<DerivedFieldModel?>(null)
{
Model = { Value = model1 }
};
Expand All @@ -267,33 +246,6 @@ public void TestResolveIndividualProperties()
Assert.AreEqual(null, resolver.BindableString.Value);
}

private partial class NonBindablePublicFieldModel : IDependencyInjectionCandidate
{
#pragma warning disable 649
public readonly int FailingField;
#pragma warning restore 649
}

private partial class NonBindablePrivateFieldModel : IDependencyInjectionCandidate
{
#pragma warning disable 169
private readonly int failingField;
#pragma warning restore 169
}

private partial class NonReadOnlyFieldModel : IDependencyInjectionCandidate
{
#pragma warning disable 649
public Bindable<int> Bindable;
#pragma warning restore 649
}

private partial class PropertyModel : IDependencyInjectionCandidate
{
// ReSharper disable once UnusedMember.Local
public Bindable<int> Bindable { get; private set; }
}

private partial class FieldModel : IDependencyInjectionCandidate
{
[Cached]
Expand All @@ -309,22 +261,22 @@ private partial class DerivedFieldModel : FieldModel
private partial class FieldModelResolver : IDependencyInjectionCandidate
{
[Resolved]
public FieldModel Model { get; private set; }
public FieldModel Model { get; private set; } = null!;
}

private partial class DerivedFieldModelResolver : IDependencyInjectionCandidate
{
[Resolved]
public DerivedFieldModel Model { get; private set; }
public DerivedFieldModel Model { get; private set; } = null!;
}

private partial class DerivedFieldModelPropertyResolver : IDependencyInjectionCandidate
{
[Resolved(typeof(DerivedFieldModel))]
public Bindable<int> Bindable { get; private set; }
public Bindable<int> Bindable { get; private set; } = null!;

[Resolved(typeof(DerivedFieldModel))]
public Bindable<string> BindableString { get; private set; }
public Bindable<string> BindableString { get; private set; } = null!;
}
}
}
23 changes: 23 additions & 0 deletions osu.Framework.Tests/Graphics/RendererTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,28 @@ public void TestWhitePixelReuseUpdatesTextureWrapping()
Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.None));
Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.None));
}

[Test]
public void TestTextureAtlasReuseUpdatesTextureWrapping()
{
DummyRenderer renderer = new DummyRenderer();

TextureAtlas atlas = new TextureAtlas(renderer, 1024, 1024);

Texture textureWrapNone = atlas.Add(100, 100, WrapMode.None, WrapMode.None)!;
Texture textureWrapClamp = atlas.Add(100, 100, WrapMode.ClampToEdge, WrapMode.ClampToEdge)!;

renderer.BindTexture(textureWrapNone, 0, null, null);
Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.None));
Assert.That(renderer.CurrentWrapModeT, Is.EqualTo(WrapMode.None));

renderer.BindTexture(textureWrapClamp, 0, null, null);
Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.ClampToEdge));
Assert.That(renderer.CurrentWrapModeT, Is.EqualTo(WrapMode.ClampToEdge));

renderer.BindTexture(textureWrapNone, 0, null, null);
Assert.That(renderer.CurrentWrapModeS, Is.EqualTo(WrapMode.None));
Assert.That(renderer.CurrentWrapModeT, Is.EqualTo(WrapMode.None));
}
}
}
46 changes: 38 additions & 8 deletions osu.Framework.Tests/Visual/Testing/TestSceneStepButton.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

#nullable disable

using System.Diagnostics;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing.Drawables.Steps;
Expand All @@ -22,12 +21,43 @@ public TestSceneStepButton()
Spacing = new Vector2(5),
Children = new Drawable[]
{
new LabelStep { Text = nameof(LabelStep) },
new AssertButton { Text = nameof(AssertButton), Assertion = () => true },
new SingleStepButton { Text = nameof(SingleStepButton) },
new RepeatStepButton(null) { Text = nameof(RepeatStepButton) },
new ToggleStepButton(null) { Text = nameof(ToggleStepButton) },
new UntilStepButton(() => true) { Text = nameof(UntilStepButton) },
new LabelStep
{
Text = nameof(LabelStep),
IsSetupStep = false,
Action = _ => { },
},
new AssertButton
{
Text = nameof(AssertButton),
IsSetupStep = false,
Assertion = () => true,
CallStack = new StackTrace()
},
new SingleStepButton
{
Text = nameof(SingleStepButton),
IsSetupStep = false,
Action = () => { }
},
new RepeatStepButton
{
Text = nameof(RepeatStepButton),
IsSetupStep = false
},
new ToggleStepButton
{
Text = nameof(ToggleStepButton),
IsSetupStep = false,
Action = _ => { }
},
new UntilStepButton
{
Text = nameof(UntilStepButton),
IsSetupStep = false,
Assertion = () => true,
CallStack = new StackTrace()
},
new StepSlider<int>(nameof(StepSlider<int>), 0, 10, 5),
}
};
Expand Down
5 changes: 3 additions & 2 deletions osu.Framework.Tests/Visual/Testing/TestSceneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ public virtual void SetUpSteps()
if (DebugUtils.IsNUnitRunning && TestContext.CurrentContext.Test.MethodName == nameof(TestConstructor))
return;

AddStep(new SingleStepButton(true)
AddStep(new SingleStepButton
{
Name = "set up dummy",
Text = "set up dummy",
IsSetupStep = true,
Action = () => setupStepsDummyRun++
});

Expand Down
Loading

0 comments on commit 85dfae6

Please sign in to comment.