Add failing test

This commit is contained in:
Dan Balasescu
2023-06-15 16:30:24 +09:00
parent f24cc147c3
commit 34574f5e55
2 changed files with 63 additions and 1 deletions

View File

@@ -0,0 +1,62 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
namespace osu.Framework.Tests.Input.HandleInputCache
{
public partial class HandleInputCacheTest
{
[Test]
public void TestNonPartialLeafClass()
{
var d = new NonPartialLeafClass();
Assert.That(Drawable.HandleInputCache.RequestsPositionalInput(d));
Assert.That(Drawable.HandleInputCache.RequestsNonPositionalInput(d));
}
[Test]
public void TestPartialLeafClass()
{
var d = new PartialLeafClass();
Assert.That(Drawable.HandleInputCache.RequestsPositionalInput(d));
Assert.That(Drawable.HandleInputCache.RequestsNonPositionalInput(d));
}
[Test]
public void TestPartialLeafClassWithNonPartialIntermediateClass()
{
var d = new PartialLeafClassWithIntermediateNonPartial();
Assert.That(Drawable.HandleInputCache.RequestsPositionalInput(d));
Assert.That(Drawable.HandleInputCache.RequestsNonPositionalInput(d));
}
#pragma warning disable OFSG001
private sealed class NonPartialLeafClass : Drawable
{
protected override bool Handle(UIEvent e) => true;
}
#pragma warning restore OFSG001
private partial class PartialLeafClass : Drawable
{
protected override bool Handle(UIEvent e) => true;
}
#pragma warning disable OFSG001
private class IntermediateNonPartialClass : Drawable
{
protected override bool Handle(UIEvent e) => true;
}
#pragma warning restore OFSG001
private partial class PartialLeafClassWithIntermediateNonPartial : IntermediateNonPartialClass
{
}
}
}

View File

@@ -16,7 +16,7 @@ namespace osu.Framework.Graphics
/// <summary>
/// Nested class which is used for caching <see cref="HandleNonPositionalInput"/>, <see cref="HandlePositionalInput"/> values.
/// </summary>
private static class HandleInputCache
internal static class HandleInputCache
{
private static readonly ConcurrentDictionary<Type, bool> positional_cached_values = new ConcurrentDictionary<Type, bool>();
private static readonly ConcurrentDictionary<Type, bool> non_positional_cached_values = new ConcurrentDictionary<Type, bool>();