Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void TestBasicGameplayTest()
});
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog);

AddStep("save changes", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddStep("save changes", () => (DialogOverlay.CurrentDialog as SaveRequiredPopupDialog)!.PerformOkAction());
AddUntilStep("player pushed", () => Stack.CurrentScreen is EditorPlayer);
AddUntilStep("wait for return to editor", () => Stack.CurrentScreen is Screens.Edit.Editor);
}
Expand Down
16 changes: 8 additions & 8 deletions osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public void TestCreateNewDifficulty([Values] bool sameRuleset)
if (sameRuleset)
{
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction());
}

AddUntilStep("wait for created", () =>
Expand Down Expand Up @@ -240,7 +240,7 @@ public void TestCreateNewDifficultyWithScrollSpeed_SameRuleset()
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new ManiaRuleset().RulesetInfo));

AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction());

AddUntilStep("wait for created", () =>
{
Expand Down Expand Up @@ -386,7 +386,7 @@ public void TestCopyDifficulty()
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));

AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog!.Buttons.ElementAt(1).TriggerClick());
AddStep("confirm creation as a copy", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.Buttons.ElementAt(1).TriggerClick());

AddUntilStep("wait for created", () =>
{
Expand Down Expand Up @@ -464,7 +464,7 @@ public void TestCopyDifficultyDoesNotChangeCollections()
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));

AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog!.Buttons.ElementAt(1).TriggerClick());
AddStep("confirm creation as a copy", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.Buttons.ElementAt(1).TriggerClick());

AddUntilStep("wait for created", () =>
{
Expand Down Expand Up @@ -504,7 +504,7 @@ public void TestCreateMultipleNewDifficultiesSucceeds()

AddStep("try to create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction());

AddUntilStep("wait for created", () =>
{
Expand Down Expand Up @@ -542,7 +542,7 @@ public void TestSavingBeatmapFailsWithSameNamedDifficulties([Values] bool sameRu
if (sameRuleset)
{
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction());
}

AddUntilStep("wait for created", () =>
Expand Down Expand Up @@ -608,7 +608,7 @@ public void TestExitBlockedWhenSavingBeatmapWithSameNamedDifficulties()

AddStep("exit", () => Editor.Exit());
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is PromptForSaveDialog);
AddStep("attempt to save", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddStep("attempt to save", () => (DialogOverlay.CurrentDialog as PromptForSaveDialog)!.PerformOkAction());
AddAssert("editor is still current", () => Editor.IsCurrentScreen());
}

Expand Down Expand Up @@ -799,7 +799,7 @@ private void createNewDifficulty()
});

AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddStep("confirm creation with no objects", () => (DialogOverlay.CurrentDialog as CreateNewDifficultyDialog)!.PerformOkAction());

AddUntilStep("wait for created", () =>
{
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void TestCancelGameplayTestWithUnsavedChanges()

AddStep("dismiss prompt", () =>
{
var button = DialogOverlay.CurrentDialog!.Buttons.Last();
var button = (DialogOverlay.CurrentDialog as SaveRequiredPopupDialog)!.Buttons.Last();
InputManager.MoveMouseTo(button);
InputManager.Click(MouseButton.Left);
});
Expand All @@ -193,7 +193,7 @@ public void TestSaveChangesBeforeGameplayTest()
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog);
AddAssert("track stopped", () => !Beatmap.Value.Track.IsRunning);

AddStep("save changes", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddStep("save changes", () => (DialogOverlay.CurrentDialog as SaveRequiredPopupDialog)!.PerformOkAction());

EditorPlayer editorPlayer = null;
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public void TestCreateNewDifficultyOnNonExistentBeatmap()
});
AddAssert("save dialog displayed", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is SaveRequiredPopupDialog);

AddStep("press save", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog!.PerformOkAction());
AddStep("press save", () => (Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog as SaveRequiredPopupDialog)!.PerformOkAction());
AddUntilStep("wait for editor", () => Game.ScreenStack.CurrentScreen is Editor editor && editor.IsLoaded);
AddAssert("editor beatmap uses catch ruleset", () => getEditorBeatmap().BeatmapInfo.Ruleset.ShortName == "fruits");
}
Expand Down
28 changes: 21 additions & 7 deletions osu.Game.Tests/Visual/Online/TestSceneChatOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Logging;
using osu.Framework.Testing;
using osu.Game.Configuration;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
Expand All @@ -40,6 +41,7 @@ namespace osu.Game.Tests.Visual.Online
public partial class TestSceneChatOverlay : OsuManualInputManagerTestScene
{
private TestChatOverlay chatOverlay;
private DialogOverlay dialogOverlay;
private ChannelManager channelManager;

private readonly APIUser testUser = new APIUser { Username = "test user", Id = 5071479 };
Expand Down Expand Up @@ -72,11 +74,13 @@ public void SetUp() => Schedule(() =>
CachedDependencies = new (Type, object)[]
{
(typeof(ChannelManager), channelManager = new ChannelManager(API)),
(typeof(IDialogOverlay), dialogOverlay = new DialogOverlay())
},
Children = new Drawable[]
{
channelManager,
chatOverlay = new TestChatOverlay(),
dialogOverlay,
},
};
});
Expand Down Expand Up @@ -694,7 +698,17 @@ public void TestChatReport()
};
});

AddStep("Show report popover", () => this.ChildrenOfType<ChatLine>().First().ShowPopover());
AddStep("Open context menu", () =>
{
var username = this.ChildrenOfType<DrawableChatUsername>().First().ChildrenOfType<TruncatingSpriteText>().First();
InputManager.MoveMouseTo(username);
InputManager.Click(MouseButton.Right);
});
AddStep("Select report option", () =>
{
InputManager.MoveMouseTo(this.ChildrenOfType<Menu.DrawableMenuItem>().First(m => m.Item.Text.ToString() == "Report"));
InputManager.Click(MouseButton.Left);
});

AddStep("Set report reason to other", () =>
{
Expand All @@ -704,26 +718,26 @@ public void TestChatReport()

AddStep("Try to report", () =>
{
var btn = this.ChildrenOfType<ReportChatPopover>().Single().ChildrenOfType<RoundedButton>().Single();
var btn = this.ChildrenOfType<ChatReportDialog>().Single().ChildrenOfType<RoundedButton>().Single();
InputManager.MoveMouseTo(btn);
InputManager.Click(MouseButton.Left);
});

AddAssert("Nothing happened", () => this.ChildrenOfType<ReportChatPopover>().Any());
AddAssert("Nothing happened", () => this.ChildrenOfType<ChatReportDialog>().Any());
AddStep("Set report data", () =>
{
var field = this.ChildrenOfType<ReportChatPopover>().Single().ChildrenOfType<OsuTextBox>().First();
var field = this.ChildrenOfType<ChatReportDialog>().Single().ChildrenOfType<OsuTextBox>().First();
field.Current.Value = "test other";
});

AddStep("Try to report", () =>
{
var btn = this.ChildrenOfType<ReportChatPopover>().Single().ChildrenOfType<RoundedButton>().Single();
var btn = this.ChildrenOfType<ChatReportDialog>().Single().ChildrenOfType<RoundedButton>().Single();
InputManager.MoveMouseTo(btn);
InputManager.Click(MouseButton.Left);
});

AddUntilStep("Overlay closed", () => !this.ChildrenOfType<ReportChatPopover>().Any());
AddUntilStep("Overlay closed", () => !this.ChildrenOfType<ChatReportDialog>().Any());
AddStep("Complete request", () => requestLock.Set());
AddUntilStep("Request sent", () => request != null);
AddUntilStep("Info message displayed", () => channelManager.CurrentChannel.Value.Messages.Last(), () => Is.InstanceOf(typeof(InfoMessage)));
Expand Down
10 changes: 5 additions & 5 deletions osu.Game.Tests/Visual/Online/TestSceneCommentActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,25 +260,25 @@ public void TestReport()
});
AddStep("Try to report", () =>
{
var btn = this.ChildrenOfType<ReportCommentPopover>().Single().ChildrenOfType<RoundedButton>().Single();
var btn = this.ChildrenOfType<CommentReportDialog>().Single().ChildrenOfType<RoundedButton>().Single();
InputManager.MoveMouseTo(btn);
InputManager.Click(MouseButton.Left);
});
AddWaitStep("Wait", 3);
AddAssert("Nothing happened", () => this.ChildrenOfType<ReportCommentPopover>().Any());
AddAssert("Nothing happened", () => this.ChildrenOfType<CommentReportDialog>().Any());
AddStep("Add comment", () =>
{
var field = this.ChildrenOfType<ReportCommentPopover>().Single().ChildrenOfType<OsuTextBox>().First();
var field = this.ChildrenOfType<CommentReportDialog>().Single().ChildrenOfType<OsuTextBox>().First();
field.Current.Value = report_text;
});
AddStep("Try to report", () =>
{
var btn = this.ChildrenOfType<ReportCommentPopover>().Single().ChildrenOfType<RoundedButton>().Single();
var btn = this.ChildrenOfType<CommentReportDialog>().Single().ChildrenOfType<RoundedButton>().Single();
InputManager.MoveMouseTo(btn);
InputManager.Click(MouseButton.Left);
});
AddWaitStep("Wait", 3);
AddAssert("Overlay closed", () => !this.ChildrenOfType<ReportCommentPopover>().Any());
AddAssert("Overlay closed", () => !this.ChildrenOfType<CommentReportDialog>().Any());
AddAssert("Loading spinner shown", () => targetComment.ChildrenOfType<LoadingSpinner>().Any(d => d.IsPresent));
AddStep("Complete request", () => requestLock.Set());
AddUntilStep("Request sent", () => request != null);
Expand Down
39 changes: 30 additions & 9 deletions osu.Game.Tests/Visual/Online/TestSceneCommentReportButton.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
// 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 osu.Framework.Extensions;
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Testing;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Comments;
using osu.Game.Tests.Visual.UserInterface;
using osuTK;
using osuTK.Input;

namespace osu.Game.Tests.Visual.Online
{
public partial class TestSceneCommentReportButton : ThemeComparisonTestScene
{
private DialogOverlay dialogOverlay = null!;

public TestSceneCommentReportButton()
: base(false)
{
}

[SetUpSteps]
public void SetUpSteps()
{
Expand All @@ -32,15 +41,27 @@ public void SetUpSteps()
});
}

protected override Drawable CreateContent() => new PopoverContainer
protected override Drawable CreateContent() => new DependencyProvidingContainer
{
RelativeSizeAxes = Axes.Both,
Child = new CommentReportButton(new Comment { User = new APIUser { Username = "Someone" } })
CachedDependencies = new (Type, object)[]
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(2f),
}.With(b => Schedule(b.ShowPopover)),
};
(typeof(IDialogOverlay), dialogOverlay = new DialogOverlay()),
},
Children = new Drawable[]
{
new CommentReportButton(new Comment { User = new APIUser { Username = "Someone" } })
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(2f),
},
dialogOverlay,
}
}.With(c => c.OnLoadComplete += _ =>
{
InputManager.MoveMouseTo(c.ChildrenOfType<CommentReportButton>().First());
InputManager.Click(MouseButton.Left);
});
}
}
Loading
Loading