1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-22 15:52:54 +08:00

Make fields protected and expose them in tests

This commit is contained in:
iiSaLMaN 2019-06-26 22:42:34 +03:00 committed by KingLuigi4932
parent eaf6f6891d
commit 9ada4d68b1
7 changed files with 41 additions and 13 deletions

View File

@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Online
[TestFixture]
public class TestSceneBeatmapSetOverlay : OsuTestScene
{
private readonly BeatmapSetOverlay overlay;
private readonly TestBeatmapSetOverlay overlay;
public override IReadOnlyList<Type> RequiredTypes => new[]
{
@ -47,7 +47,7 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneBeatmapSetOverlay()
{
Add(overlay = new BeatmapSetOverlay());
Add(overlay = new TestBeatmapSetOverlay());
}
[BackgroundDependencyLoader]
@ -435,7 +435,12 @@ namespace osu.Game.Tests.Visual.Online
private void downloadAssert(bool shown)
{
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.DownloadButtonsContainer.Any() == shown);
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.IsDownloadButtonsShown == shown);
}
private class TestBeatmapSetOverlay : BeatmapSetOverlay
{
public bool IsDownloadButtonsShown => Header.DownloadButtonsContainer.Any();
}
}
}

View File

@ -52,7 +52,8 @@ namespace osu.Game.Tests.Visual.Online
normal.OnlineInfo.HasStoryboard = true;
var undownloadable = getUndownloadableBeatmapSet(ruleset);
DirectPanel undownloadableGridPanel, undownloadableListPanel;
TestDirectGridPanel undownloadableGridPanel;
TestDirectListPanel undownloadableListPanel;
Child = new BasicScrollContainer
{
@ -68,14 +69,34 @@ namespace osu.Game.Tests.Visual.Online
{
new DirectGridPanel(normal),
new DirectListPanel(normal),
undownloadableGridPanel = new DirectGridPanel(undownloadable),
undownloadableListPanel = new DirectListPanel(undownloadable),
undownloadableGridPanel = new TestDirectGridPanel(undownloadable),
undownloadableListPanel = new TestDirectListPanel(undownloadable),
},
},
};
AddAssert("is download button disabled on second grid panel", () => !undownloadableGridPanel.DownloadButton.Enabled.Value);
AddAssert("is download button disabled on second list panel", () => !undownloadableListPanel.DownloadButton.Enabled.Value);
AddAssert("is download button disabled on second grid panel", () => !undownloadableGridPanel.IsDownloadButtonEnabled);
AddAssert("is download button disabled on second list panel", () => !undownloadableListPanel.IsDownloadButtonEnabled);
}
private class TestDirectGridPanel : DirectGridPanel
{
public bool IsDownloadButtonEnabled => DownloadButton.Enabled.Value;
public TestDirectGridPanel(BeatmapSetInfo beatmap)
: base(beatmap)
{
}
}
private class TestDirectListPanel : DirectListPanel
{
public bool IsDownloadButtonEnabled => DownloadButton.Enabled.Value;
public TestDirectListPanel(BeatmapSetInfo beatmap)
: base(beatmap)
{
}
}
}
}

View File

@ -34,7 +34,8 @@ namespace osu.Game.Overlays.BeatmapSet
private readonly BeatmapNotAvailable beatmapNotAvailable;
private readonly BeatmapSetOnlineStatusPill onlineStatusPill;
public Details Details;
public FillFlowContainer DownloadButtonsContainer;
public readonly FillFlowContainer DownloadButtonsContainer;
public readonly BeatmapPicker Picker;

View File

@ -27,7 +27,7 @@ namespace osu.Game.Overlays
public const float TOP_PADDING = 25;
public const float RIGHT_WIDTH = 275;
public readonly Header Header;
protected readonly Header Header;
private RulesetStore rulesets;

View File

@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Direct
private PlayButton playButton;
private Box progressBar;
public override DownloadButton DownloadButton => downloadButton;
protected override DownloadButton DownloadButton => downloadButton;
protected override PlayButton PlayButton => playButton;
protected override Box PreviewBar => progressBar;

View File

@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Direct
protected override bool FadePlayButton => false;
public override DownloadButton DownloadButton => downloadButton;
protected override DownloadButton DownloadButton => downloadButton;
protected override PlayButton PlayButton => playButton;
protected override Box PreviewBar => progressBar;

View File

@ -34,7 +34,8 @@ namespace osu.Game.Overlays.Direct
public PreviewTrack Preview => PlayButton.Preview;
public Bindable<bool> PreviewPlaying => PlayButton.Playing;
public abstract DownloadButton DownloadButton { get; }
protected abstract DownloadButton DownloadButton { get; }
protected abstract PlayButton PlayButton { get; }
protected abstract Box PreviewBar { get; }