Skip to content

Commit

Permalink
Update TestCase to not rely on online loading of textures
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Aug 23, 2017
1 parent 47c1bb0 commit 92aea3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE

using System.Linq;
Expand All @@ -7,19 +7,18 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Testing;
using OpenTK;
using OpenTK.Graphics;

namespace osu.Framework.Desktop.Tests.Visual
{
[TestFixture]
internal class TestCaseOnlineTextures : TestCase
internal class TestCaseDelayedLoad : TestCase
{
private const int panel_count = 2048;

public TestCaseOnlineTextures()
public TestCaseDelayedLoad()
{
FillFlowContainerNoInput flow;
ScrollContainer scroll;
Expand Down Expand Up @@ -49,23 +48,9 @@ public TestCaseOnlineTextures()
new DelayedLoadWrapper(new Container
{
RelativeSizeAxes = Axes.Both,
OnLoadComplete = d =>
{
var c = (Container)d;
if ((c.Children.FirstOrDefault() as Sprite)?.Texture == null)
{
c.Add(new SpriteText {
Colour = Color4.Gray,
Text = @"nope",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
});
}
},
Children = new Drawable[]
{
new Avatar(i) { RelativeSizeAxes = Axes.Both }
new TestBox{ RelativeSizeAxes = Axes.Both }
}
}),
new SpriteText { Text = i.ToString() },
Expand All @@ -87,19 +72,23 @@ private class FillFlowContainerNoInput : FillFlowContainer<Container>
}
}

public class Avatar : Sprite
public class TestBox : Container
{
private readonly int userId;

public Avatar(int userId)
public TestBox()
{
this.userId = userId;
RelativeSizeAxes = Axes.Both;
}

[BackgroundDependencyLoader]
private void load(TextureStore textures)
private void load()
{
Texture = textures.Get($@"https://a.ppy.sh/{userId}");
Child = new SpriteText
{
Colour = Color4.Yellow,
Text = @"loaded",
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<Compile Include="Visual\TestCaseColourGradient.cs" />
<Compile Include="Visual\TestCaseContextMenu.cs" />
<Compile Include="Visual\TestCaseCoordinateSpaces.cs" />
<Compile Include="Visual\TestCaseDelayedLoad.cs" />
<Compile Include="Visual\TestCaseDrawablePath.cs" />
<Compile Include="Visual\TestCaseDropdownBox.cs" />
<Compile Include="Visual\TestCaseDynamicDepth.cs" />
Expand All @@ -72,7 +73,6 @@
<Compile Include="Visual\TestCaseMasking.cs" />
<Compile Include="Visual\TestCaseNestedHover.cs" />
<Compile Include="Visual\TestCaseContainerState.cs" />
<Compile Include="Visual\TestCaseOnlineTextures.cs" />
<Compile Include="Visual\TestCasePadding.cs" />
<Compile Include="Visual\TestCasePropertyBoundaries.cs" />
<Compile Include="Visual\TestCaseRigidBody.cs" />
Expand Down

0 comments on commit 92aea3d

Please sign in to comment.