Skip to content

Commit

Permalink
Merge pull request #579 from peppy/general-fixes
Browse files Browse the repository at this point in the history
Framework & VisualTests update
  • Loading branch information
smoogipoo authored Apr 1, 2017
2 parents ba7f123 + 062d996 commit 9bd19e9
Show file tree
Hide file tree
Showing 25 changed files with 123 additions and 132 deletions.
2 changes: 1 addition & 1 deletion osu-framework
Submodule osu-framework updated 44 files
+1 −1 appveyor.yml
+4 −3 osu.Framework.Desktop.Tests/Benchmark/VisualTests.cs
+5 −1 osu.Framework.Desktop.Tests/osu.Framework.Desktop.Tests.csproj
+34 −0 osu.Framework.Testing/Drawables/StepButtons/AssertButton.cs
+56 −0 osu.Framework.Testing/Drawables/StepButtons/RepeatStepButton.cs
+23 −0 osu.Framework.Testing/Drawables/StepButtons/SingleStepButton.cs
+38 −0 osu.Framework.Testing/Drawables/StepButtons/StepButton.cs
+39 −0 osu.Framework.Testing/Drawables/StepButtons/ToggleStepButton.cs
+101 −0 osu.Framework.Testing/Drawables/TestCaseButton.cs
+127 −0 osu.Framework.Testing/DynamicClassCompiler.cs
+4 −0 osu.Framework.Testing/OpenTK.dll.config
+117 −291 osu.Framework.Testing/TestBrowser.cs
+22 −0 osu.Framework.Testing/TestBrowserConfig.cs
+120 −54 osu.Framework.Testing/TestCase.cs
+66 −0 osu.Framework.Testing/TestRunner.cs
+15 −6 osu.Framework.Testing/osu.Framework.Testing.csproj
+4 −0 osu.Framework.Testing/packages.config
+15 −0 osu.Framework.VisualTests/AutomatedVisualTestGame.cs
+0 −39 osu.Framework.VisualTests/Benchmark.cs
+1 −1 osu.Framework.VisualTests/Program.cs
+6 −6 osu.Framework.VisualTests/Tests/TestCaseCheckboxes.cs
+42 −9 osu.Framework.VisualTests/Tests/TestCaseDropdownBox.cs
+103 −103 osu.Framework.VisualTests/Tests/TestCaseFlow.cs
+1 −1 osu.Framework.VisualTests/Tests/TestCaseMasking.cs
+17 −5 osu.Framework.VisualTests/Tests/TestCaseOnlineTextures.cs
+7 −8 osu.Framework.VisualTests/Tests/TestCaseScrollableFlow.cs
+1 −1 osu.Framework.VisualTests/Tests/TestCaseSizing.cs
+3 −3 osu.Framework.VisualTests/Tests/TestCaseTabControl.cs
+1 −1 osu.Framework.VisualTests/Tests/TestCaseTriangles.cs
+5 −4 osu.Framework.VisualTests/osu.Framework.VisualTests.csproj
+0 −0 osu.Framework/Extensions/ExtensionMethods.cs
+32 −6 osu.Framework/Graphics/Containers/Container.cs
+0 −0 osu.Framework/Graphics/Transforms/TransformEdgeEffectAlpha.cs
+2 −2 osu.Framework/Graphics/UserInterface/BasicCheckbox.cs
+7 −7 osu.Framework/Graphics/UserInterface/Checkbox.cs
+0 −0 osu.Framework/Input/ITextInputSource.cs
+2 −20 osu.Framework/Input/KeyDownEventArgs.cs
+13 −0 osu.Framework/Input/KeyUpEventArgs.cs
+9 −0 osu.Framework/Input/MouseDownEventArgs.cs
+13 −0 osu.Framework/Input/MouseEventArgs.cs
+9 −0 osu.Framework/Input/MouseUpEventArgs.cs
+2 −1 osu.Framework/Platform/GameHost.cs
+4 −0 osu.Framework/Timing/FrameTimeInfo.cs
+11 −7 osu.Framework/osu.Framework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
namespace osu.Desktop.Tests
{
[TestFixture]
public class BenchmarkTest
public class VisualTests
{
[Test]
public void TestBenchmark()
public void TestVisualTests()
{
using (var host = new HeadlessGameHost())
{
Expand All @@ -25,7 +25,7 @@ public void TestBenchmark()
Ruleset.Register(new ManiaRuleset());
Ruleset.Register(new CatchRuleset());

host.Run(new Benchmark());
host.Run(new AutomatedVisualTestGame());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Desktop.Tests/osu.Desktop.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BenchmarkTest.cs" />
<Compile Include="VisualTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu-framework\osu.Framework.Desktop\osu.Framework.Desktop.csproj">
Expand Down
20 changes: 20 additions & 0 deletions osu.Desktop.VisualTests/AutomatedVisualTestGame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using osu.Framework.Testing;
using osu.Game;

namespace osu.Desktop.VisualTests
{
public class AutomatedVisualTestGame : OsuGameBase
{
protected override void LoadComplete()
{
base.LoadComplete();

// Have to construct this here, rather than in the constructor, because
// we depend on some dependencies to be loaded within OsuGameBase.load().
Add(new TestRunner(new TestBrowser()));
}
}
}
45 changes: 0 additions & 45 deletions osu.Desktop.VisualTests/Benchmark.cs

This file was deleted.

2 changes: 1 addition & 1 deletion osu.Desktop.VisualTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static void Main(string[] args)
Ruleset.Register(new CatchRuleset());

if (benchmark)
host.Run(new Benchmark());
host.Run(new AutomatedVisualTestGame());
else
host.Run(new VisualTestGame());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override void Reset()

Add(overlay);

AddButton(@"Toggle", overlay.ToggleVisibility);
AddStep(@"Toggle", overlay.ToggleVisibility);
}
}
}
4 changes: 2 additions & 2 deletions osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public override void Reset()

Add(overlay = new DialogOverlay());

AddButton("dialog #1", () => overlay.Push(new PopupDialog
AddStep("dialog #1", () => overlay.Push(new PopupDialog
{
Icon = FontAwesome.fa_trash_o,
HeaderText = @"Confirm deletion of",
Expand All @@ -40,7 +40,7 @@ public override void Reset()
},
}));

AddButton("dialog #2", () => overlay.Push(new PopupDialog
AddStep("dialog #2", () => overlay.Push(new PopupDialog
{
Icon = FontAwesome.fa_gear,
HeaderText = @"What do you want to do with",
Expand Down
29 changes: 19 additions & 10 deletions osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,28 @@ public override void Reset()

playbackSpeed.TriggerChange();

AddButton(@"circles", () => load(HitObjectType.Circle));
AddButton(@"slider", () => load(HitObjectType.Slider));
AddButton(@"spinner", () => load(HitObjectType.Spinner));
AddStep(@"circles", () => load(HitObjectType.Circle));
AddStep(@"slider", () => load(HitObjectType.Slider));
AddStep(@"spinner", () => load(HitObjectType.Spinner));

AddToggle(@"auto", state => { auto = state; load(mode); });
AddToggleStep(@"auto", state => { auto = state; load(mode); });

ButtonsContainer.Add(new SpriteText { Text = "Playback Speed" });
ButtonsContainer.Add(new BasicSliderBar<double>
Add(new Container
{
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
Bindable = playbackSpeed
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new SpriteText { Text = "Playback Speed" },
new BasicSliderBar<double>
{
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
Bindable = playbackSpeed
}
}
});

framedClock.ProcessFrame();
Expand Down
26 changes: 19 additions & 7 deletions osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using OpenTK.Input;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Containers;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.MathUtils;
Expand Down Expand Up @@ -37,19 +38,30 @@ public override void Reset()
};
BindableInt bindable = new BindableInt { MinValue = 0, MaxValue = 200, Default = 50 };
bindable.ValueChanged += delegate { kc.FadeTime = bindable.Value; };
AddButton("Add Random", () =>
AddStep("Add Random", () =>
{
Key key = (Key)((int)Key.A + RNG.Next(26));
kc.Add(new KeyCounterKeyboard(key));
});
ButtonsContainer.Add(new SpriteText { Text = "FadeTime" });
ButtonsContainer.Add(new TestSliderBar<int>

Add(new Container
{
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
Bindable = bindable
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
AutoSizeAxes = Axes.Both,
Children = new Drawable[]
{
new SpriteText { Text = "FadeTime" },
new TestSliderBar<int>
{
Width = 150,
Height = 10,
SelectionColor = Color4.Orange,
Bindable = bindable
}
}
});

Add(kc);
}
private class TestSliderBar<T> : SliderBar<T> where T : struct
Expand Down
2 changes: 1 addition & 1 deletion osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public override void Reset()
Size = new Vector2(550f, 450f),
});

AddButton(@"New Scores", newScores);
AddStep(@"New Scores", newScores);
newScores();
}
}
Expand Down
10 changes: 5 additions & 5 deletions osu.Desktop.VisualTests/Tests/TestCaseModSelectOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public override void Reset()
Anchor = Anchor.BottomCentre,
});

AddButton("Toggle", modSelect.ToggleVisibility);
AddButton("osu!", () => modSelect.PlayMode.Value = PlayMode.Osu);
AddButton("osu!taiko", () => modSelect.PlayMode.Value = PlayMode.Taiko);
AddButton("osu!catch", () => modSelect.PlayMode.Value = PlayMode.Catch);
AddButton("osu!mania", () => modSelect.PlayMode.Value = PlayMode.Mania);
AddStep("Toggle", modSelect.ToggleVisibility);
AddStep("osu!", () => modSelect.PlayMode.Value = PlayMode.Osu);
AddStep("osu!taiko", () => modSelect.PlayMode.Value = PlayMode.Taiko);
AddStep("osu!catch", () => modSelect.PlayMode.Value = PlayMode.Catch);
AddStep("osu!mania", () => modSelect.PlayMode.Value = PlayMode.Mania);
}
}
}
2 changes: 1 addition & 1 deletion osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void Reset()
Anchor = Anchor.Centre
};
Add(mc);
AddToggle(@"Show", state => mc.State = state ? Visibility.Visible : Visibility.Hidden);
AddToggleStep(@"Show", state => mc.State = state ? Visibility.Visible : Visibility.Hidden);
}
}
}
12 changes: 6 additions & 6 deletions osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public override void Reset()
Origin = Anchor.TopRight,
});

AddToggle(@"show", state => manager.State = state ? Visibility.Visible : Visibility.Hidden);
AddToggleStep(@"show", state => manager.State = state ? Visibility.Visible : Visibility.Hidden);

AddButton(@"simple #1", sendNotification1);
AddButton(@"simple #2", sendNotification2);
AddButton(@"progress #1", sendProgress1);
AddButton(@"progress #2", sendProgress2);
AddButton(@"barrage", () => sendBarrage());
AddStep(@"simple #1", sendNotification1);
AddStep(@"simple #2", sendNotification2);
AddStep(@"progress #1", sendProgress1);
AddStep(@"progress #2", sendProgress2);
AddStep(@"barrage", () => sendBarrage());
}

private void sendBarrage(int remaining = 100)
Expand Down
4 changes: 2 additions & 2 deletions osu.Desktop.VisualTests/Tests/TestCasePauseOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public override void Reset()
OnRetry = () => Logger.Log(@"Retry"),
OnQuit = () => Logger.Log(@"Quit")
});
AddButton("Pause", pauseOverlay.Show);
AddButton("Add Retry", delegate
AddStep("Pause", pauseOverlay.Show);
AddStep("Add Retry", delegate
{
retryCount++;
pauseOverlay.Retries = retryCount;
Expand Down
13 changes: 4 additions & 9 deletions osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ internal class TestCasePlaySongSelect : TestCase
public override void Reset()
{
base.Reset();
oldDb = Dependencies.Get<BeatmapDatabase>();
if (db == null)
{
storage = new TestStorage(@"TestCasePlaySongSelect");
db = new BeatmapDatabase(storage);
Dependencies.Cache(db, true);

var sets = new List<BeatmapSetInfo>();

Expand All @@ -40,19 +38,16 @@ public override void Reset()

Add(songSelect = new PlaySongSelect());

AddButton(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
AddButton(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
AddButton(@"Sort by Author", delegate { songSelect.FilterControl.Sort = SortMode.Author; });
AddButton(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; });
AddStep(@"Sort by Artist", delegate { songSelect.FilterControl.Sort = SortMode.Artist; });
AddStep(@"Sort by Title", delegate { songSelect.FilterControl.Sort = SortMode.Title; });
AddStep(@"Sort by Author", delegate { songSelect.FilterControl.Sort = SortMode.Author; });
AddStep(@"Sort by Difficulty", delegate { songSelect.FilterControl.Sort = SortMode.Difficulty; });
}

protected override void Dispose(bool isDisposing)
{
if (oldDb != null)
{
Dependencies.Cache(oldDb, true);
db = null;
}

base.Dispose(isDisposing);
}
Expand Down
10 changes: 5 additions & 5 deletions osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public override void Reset()
};
Add(starsLabel);

AddButton(@"Reset all", delegate
AddStep(@"Reset all", delegate
{
score.Current.Value = 0;
comboCounter.Current.Value = 0;
Expand All @@ -78,28 +78,28 @@ public override void Reset()
starsLabel.Text = stars.Count.ToString("0.00");
});

AddButton(@"Hit! :D", delegate
AddStep(@"Hit! :D", delegate
{
score.Current.Value += 300 + (ulong)(300.0 * (comboCounter.Current > 0 ? comboCounter.Current - 1 : 0) / 25.0);
comboCounter.Increment();
numerator++; denominator++;
accuracyCounter.SetFraction(numerator, denominator);
});

AddButton(@"miss...", delegate
AddStep(@"miss...", delegate
{
comboCounter.Current.Value = 0;
denominator++;
accuracyCounter.SetFraction(numerator, denominator);
});

AddButton(@"Alter stars", delegate
AddStep(@"Alter stars", delegate
{
stars.Count = RNG.NextSingle() * (stars.StarCount + 1);
starsLabel.Text = stars.Count.ToString("0.00");
});

AddButton(@"Stop counters", delegate
AddStep(@"Stop counters", delegate
{
score.StopRolling();
comboCounter.StopRolling();
Expand Down
2 changes: 1 addition & 1 deletion osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void Reset()
{
base.Reset();

AddToggle("Kiai", b =>
AddToggleStep("Kiai", b =>
{
kiai = !kiai;
Reset();
Expand Down
14 changes: 7 additions & 7 deletions osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public override void Reset()
{
base.Reset();

AddButton("Hit!", addHitJudgement);
AddButton("Miss :(", addMissJudgement);
AddButton("Swell", addSwell);
AddButton("Centre", () => addCentreHit(false));
AddButton("Strong Centre", () => addCentreHit(true));
AddButton("Rim", () => addRimHit(false));
AddButton("Strong Rim", () => addRimHit(true));
AddStep("Hit!", addHitJudgement);
AddStep("Miss :(", addMissJudgement);
AddStep("Swell", addSwell);
AddStep("Centre", () => addCentreHit(false));
AddStep("Strong Centre", () => addCentreHit(true));
AddStep("Rim", () => addRimHit(false));
AddStep("Strong Rim", () => addRimHit(true));

Add(new Container
{
Expand Down
Loading

0 comments on commit 9bd19e9

Please sign in to comment.