mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Add comprehensive tests for changelog overlay
Includes failing case
This commit is contained in:
parent
962449a5fa
commit
834e82d543
@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneChangelogOverlay : OsuTestScene
|
public class TestSceneChangelogOverlay : OsuTestScene
|
||||||
{
|
{
|
||||||
private ChangelogOverlay changelog;
|
private TestChangelogOverlay changelog;
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
@ -29,23 +29,40 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
|
|
||||||
protected override bool UseOnlineAPI => true;
|
protected override bool UseOnlineAPI => true;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
[SetUp]
|
||||||
|
public void SetUp() => Schedule(() =>
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
Child = changelog = new TestChangelogOverlay();
|
||||||
|
});
|
||||||
|
|
||||||
Add(changelog = new ChangelogOverlay());
|
[Test]
|
||||||
AddStep(@"Show", changelog.Show);
|
public void ShowWithNoFetch()
|
||||||
AddStep(@"Hide", changelog.Hide);
|
{
|
||||||
|
AddStep(@"Show", () => changelog.Show());
|
||||||
|
AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
|
||||||
|
AddAssert(@"listing displayed", () => changelog.Current.Value == null);
|
||||||
|
AddAssert(@"no stream selected", () => changelog.Header.Streams.Current.Value == null);
|
||||||
|
}
|
||||||
|
|
||||||
AddWaitStep("wait for hide", 3);
|
[Test]
|
||||||
|
public void ShowWithListing()
|
||||||
|
{
|
||||||
|
AddStep(@"Show with listing", () => changelog.ShowListing());
|
||||||
|
AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
|
||||||
|
AddAssert(@"listing displayed", () => changelog.Current.Value == null);
|
||||||
|
AddAssert(@"no stream selected", () => changelog.Header.Streams.Current.Value == null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ShowWithBuild()
|
||||||
|
{
|
||||||
AddStep(@"Show with Lazer 2018.712.0", () =>
|
AddStep(@"Show with Lazer 2018.712.0", () =>
|
||||||
{
|
{
|
||||||
changelog.ShowBuild(new APIChangelogBuild
|
changelog.ShowBuild(new APIChangelogBuild
|
||||||
{
|
{
|
||||||
Version = "2018.712.0",
|
Version = "2018.712.0",
|
||||||
DisplayVersion = "2018.712.0",
|
DisplayVersion = "2018.712.0",
|
||||||
UpdateStream = new APIUpdateStream { Name = OsuGameBase.CLIENT_STREAM_NAME },
|
UpdateStream = new APIUpdateStream { Id = 7, Name = OsuGameBase.CLIENT_STREAM_NAME },
|
||||||
ChangelogEntries = new List<APIChangelogEntry>
|
ChangelogEntries = new List<APIChangelogEntry>
|
||||||
{
|
{
|
||||||
new APIChangelogEntry
|
new APIChangelogEntry
|
||||||
@ -56,19 +73,16 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
changelog.Show();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddWaitStep("wait for show", 3);
|
AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
|
||||||
AddStep(@"Hide", changelog.Hide);
|
AddAssert(@"correct build displayed", () => changelog.Current.Value.Version == "2018.712.0");
|
||||||
AddWaitStep("wait for hide", 3);
|
AddAssert(@"correct stream selected", () => changelog.Header.Streams.Current.Value.Id == 7);
|
||||||
|
}
|
||||||
AddStep(@"Show with listing", () =>
|
|
||||||
{
|
|
||||||
changelog.ShowListing();
|
|
||||||
changelog.Show();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestHTMLUnescaping()
|
||||||
|
{
|
||||||
AddStep(@"Ensure HTML string unescaping", () =>
|
AddStep(@"Ensure HTML string unescaping", () =>
|
||||||
{
|
{
|
||||||
changelog.ShowBuild(new APIChangelogBuild
|
changelog.ShowBuild(new APIChangelogBuild
|
||||||
@ -97,5 +111,12 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestChangelogOverlay : ChangelogOverlay
|
||||||
|
{
|
||||||
|
public new List<APIUpdateStream> Streams => base.Streams;
|
||||||
|
|
||||||
|
public new ChangelogHeader Header => base.Header;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -26,7 +26,7 @@ namespace osu.Game.Overlays
|
|||||||
{
|
{
|
||||||
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
|
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
|
||||||
|
|
||||||
private ChangelogHeader header;
|
protected ChangelogHeader Header;
|
||||||
|
|
||||||
private Container<ChangelogContent> content;
|
private Container<ChangelogContent> content;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
private List<APIChangelogBuild> builds;
|
private List<APIChangelogBuild> builds;
|
||||||
|
|
||||||
private List<APIUpdateStream> streams;
|
protected List<APIUpdateStream> Streams;
|
||||||
|
|
||||||
public ChangelogOverlay()
|
public ChangelogOverlay()
|
||||||
: base(OverlayColourScheme.Purple)
|
: base(OverlayColourScheme.Purple)
|
||||||
@ -62,7 +62,7 @@ namespace osu.Game.Overlays
|
|||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
header = new ChangelogHeader
|
Header = new ChangelogHeader
|
||||||
{
|
{
|
||||||
ListingSelected = ShowListing,
|
ListingSelected = ShowListing,
|
||||||
},
|
},
|
||||||
@ -78,7 +78,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
sampleBack = audio.Samples.Get(@"UI/generic-select-soft");
|
sampleBack = audio.Samples.Get(@"UI/generic-select-soft");
|
||||||
|
|
||||||
header.Current.BindTo(Current);
|
Header.Current.BindTo(Current);
|
||||||
|
|
||||||
Current.BindValueChanged(e =>
|
Current.BindValueChanged(e =>
|
||||||
{
|
{
|
||||||
@ -117,7 +117,7 @@ namespace osu.Game.Overlays
|
|||||||
performAfterFetch(() =>
|
performAfterFetch(() =>
|
||||||
{
|
{
|
||||||
var build = builds.Find(b => b.Version == version && b.UpdateStream.Name == updateStream)
|
var build = builds.Find(b => b.Version == version && b.UpdateStream.Name == updateStream)
|
||||||
?? streams.Find(s => s.Name == updateStream)?.LatestBuild;
|
?? Streams.Find(s => s.Name == updateStream)?.LatestBuild;
|
||||||
|
|
||||||
if (build != null)
|
if (build != null)
|
||||||
ShowBuild(build);
|
ShowBuild(build);
|
||||||
@ -179,9 +179,9 @@ namespace osu.Game.Overlays
|
|||||||
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
|
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
|
||||||
|
|
||||||
builds = res.Builds;
|
builds = res.Builds;
|
||||||
streams = res.Streams;
|
Streams = res.Streams;
|
||||||
|
|
||||||
header.Streams.Populate(res.Streams);
|
Header.Streams.Populate(res.Streams);
|
||||||
|
|
||||||
tcs.SetResult(true);
|
tcs.SetResult(true);
|
||||||
});
|
});
|
||||||
|
@ -298,6 +298,7 @@
|
|||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GLSL/@EntryIndexedValue">GLSL</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GLSL/@EntryIndexedValue">GLSL</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTML/@EntryIndexedValue">HTML</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>
|
||||||
|
Loading…
Reference in New Issue
Block a user