A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using System.Linq;
5using NUnit.Framework;
6using osu.Framework.Allocation;
7using osu.Framework.Configuration;
8using osu.Framework.Graphics;
9using osu.Framework.Graphics.Containers;
10using osu.Framework.Graphics.Sprites;
11using osu.Framework.Localisation;
12
13namespace osu.Framework.Tests.Visual.Sprites
14{
15 public class TestSceneRomanisableSpriteText : FrameworkTestScene
16 {
17 private readonly FillFlowContainer flow;
18
19 public TestSceneRomanisableSpriteText()
20 {
21 Children = new Drawable[]
22 {
23 new BasicScrollContainer
24 {
25 RelativeSizeAxes = Axes.Both,
26 Children = new[]
27 {
28 flow = new FillFlowContainer
29 {
30 Anchor = Anchor.TopLeft,
31 AutoSizeAxes = Axes.Y,
32 RelativeSizeAxes = Axes.X,
33 Direction = FillDirection.Vertical,
34 }
35 }
36 }
37 };
38
39 flow.Add(new SpriteText { Text = new RomanisableString("ongaku", "music") });
40 flow.Add(new SpriteText { Text = new RomanisableString("", "music") });
41 flow.Add(new SpriteText { Text = new RomanisableString("ongaku", "") });
42 }
43
44 [Resolved]
45 private FrameworkConfigManager config { get; set; }
46
47 [Test]
48 public void TestToggleRomanisedState()
49 {
50 AddStep("prefer romanised", () => config.SetValue(FrameworkSetting.ShowUnicode, false));
51 AddAssert("check strings correct", () => flow.OfType<SpriteText>().Select(st => st.Current.Value).SequenceEqual(new[] { "music", "music", "ongaku" }));
52
53 AddStep("prefer unicode", () => config.SetValue(FrameworkSetting.ShowUnicode, true));
54 AddAssert("check strings correct", () => flow.OfType<SpriteText>().Select(st => st.Current.Value).SequenceEqual(new[] { "ongaku", "music", "ongaku" }));
55 }
56 }
57}