Merge pull request #19137 from frenzibyte/country-enum

Replace `Country` class with enumeration
This commit is contained in:
Dean Herbert
2022-07-18 16:12:24 +09:00
committed by GitHub
33 changed files with 915 additions and 255 deletions

View File

@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual.Online
Id = 3103765,
IsOnline = true,
Statistics = new UserStatistics { GlobalRank = 1111 },
Country = new Country { FlagName = "JP" },
CountryCode = CountryCode.JP,
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
},
new APIUser
@ -64,7 +64,7 @@ namespace osu.Game.Tests.Visual.Online
Id = 2,
IsOnline = false,
Statistics = new UserStatistics { GlobalRank = 2222 },
Country = new Country { FlagName = "AU" },
CountryCode = CountryCode.AU,
CoverUrl = "https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
IsSupporter = true,
SupportLevel = 3,
@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.Online
{
Username = "Evast",
Id = 8195163,
Country = new Country { FlagName = "BY" },
CountryCode = CountryCode.BY,
CoverUrl = "https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
IsOnline = false,
LastVisit = DateTimeOffset.Now

View File

@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneRankingsCountryFilter()
{
var countryBindable = new Bindable<Country>();
var countryBindable = new Bindable<CountryCode>();
AddRange(new Drawable[]
{
@ -56,20 +56,12 @@ namespace osu.Game.Tests.Visual.Online
}
});
var country = new Country
{
FlagName = "BY",
FullName = "Belarus"
};
var unknownCountry = new Country
{
FlagName = "CK",
FullName = "Cook Islands"
};
const CountryCode country = CountryCode.BY;
const CountryCode unknown_country = CountryCode.CK;
AddStep("Set country", () => countryBindable.Value = country);
AddStep("Set null country", () => countryBindable.Value = null);
AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry);
AddStep("Set default country", () => countryBindable.Value = default);
AddStep("Set country with no flag", () => countryBindable.Value = unknown_country);
}
}
}

View File

@ -19,7 +19,7 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneRankingsHeader()
{
var countryBindable = new Bindable<Country>();
var countryBindable = new Bindable<CountryCode>();
var ruleset = new Bindable<RulesetInfo>();
var scope = new Bindable<RankingsScope>();
@ -30,21 +30,12 @@ namespace osu.Game.Tests.Visual.Online
Ruleset = { BindTarget = ruleset }
});
var country = new Country
{
FlagName = "BY",
FullName = "Belarus"
};
var unknownCountry = new Country
{
FlagName = "CK",
FullName = "Cook Islands"
};
const CountryCode country = CountryCode.BY;
const CountryCode unknown_country = CountryCode.CK;
AddStep("Set country", () => countryBindable.Value = country);
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry);
AddStep("Set country with no flag", () => countryBindable.Value = unknown_country);
}
}
}

View File

@ -21,7 +21,7 @@ namespace osu.Game.Tests.Visual.Online
private TestRankingsOverlay rankingsOverlay;
private readonly Bindable<Country> countryBindable = new Bindable<Country>();
private readonly Bindable<CountryCode> countryBindable = new Bindable<CountryCode>();
private readonly Bindable<RankingsScope> scope = new Bindable<RankingsScope>();
[SetUp]
@ -48,15 +48,15 @@ namespace osu.Game.Tests.Visual.Online
public void TestFlagScopeDependency()
{
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
AddAssert("Check country is Null", () => countryBindable.Value == null);
AddStep("Set country", () => countryBindable.Value = us_country);
AddAssert("Check country is default", () => countryBindable.IsDefault);
AddStep("Set country", () => countryBindable.Value = CountryCode.US);
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
}
[Test]
public void TestShowCountry()
{
AddStep("Show US", () => rankingsOverlay.ShowCountry(us_country));
AddStep("Show US", () => rankingsOverlay.ShowCountry(CountryCode.US));
}
private void loadRankingsOverlay()
@ -69,15 +69,9 @@ namespace osu.Game.Tests.Visual.Online
};
}
private static readonly Country us_country = new Country
{
FlagName = "US",
FullName = "United States"
};
private class TestRankingsOverlay : RankingsOverlay
{
public new Bindable<Country> Country => base.Country;
public new Bindable<CountryCode> Country => base.Country;
}
}
}

View File

@ -57,8 +57,7 @@ namespace osu.Game.Tests.Visual.Online
{
new CountryStatistics
{
Country = new Country { FlagName = "US", FullName = "United States" },
FlagName = "US",
Code = CountryCode.US,
ActiveUsers = 2_972_623,
PlayCount = 3_086_515_743,
RankedScore = 449_407_643_332_546,
@ -66,8 +65,7 @@ namespace osu.Game.Tests.Visual.Online
},
new CountryStatistics
{
Country = new Country { FlagName = "RU", FullName = "Russian Federation" },
FlagName = "RU",
Code = CountryCode.RU,
ActiveUsers = 1_609_989,
PlayCount = 1_637_052_841,
RankedScore = 221_660_827_473_004,
@ -86,7 +84,7 @@ namespace osu.Game.Tests.Visual.Online
User = new APIUser
{
Username = "first active user",
Country = new Country { FlagName = "JP" },
CountryCode = CountryCode.JP,
Active = true,
},
Accuracy = 0.9972,
@ -106,7 +104,7 @@ namespace osu.Game.Tests.Visual.Online
User = new APIUser
{
Username = "inactive user",
Country = new Country { FlagName = "AU" },
CountryCode = CountryCode.AU,
Active = false,
},
Accuracy = 0.9831,
@ -126,7 +124,7 @@ namespace osu.Game.Tests.Visual.Online
User = new APIUser
{
Username = "second active user",
Country = new Country { FlagName = "PL" },
CountryCode = CountryCode.PL,
Active = true,
},
Accuracy = 0.9584,

View File

@ -157,11 +157,7 @@ namespace osu.Game.Tests.Visual.Online
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
CountryCode = CountryCode.ES,
},
Mods = new[]
{
@ -184,11 +180,7 @@ namespace osu.Game.Tests.Visual.Online
{
Id = 4608074,
Username = @"Skycries",
Country = new Country
{
FullName = @"Brazil",
FlagName = @"BR",
},
CountryCode = CountryCode.BR,
},
Mods = new[]
{
@ -210,11 +202,7 @@ namespace osu.Game.Tests.Visual.Online
{
Id = 1014222,
Username = @"eLy",
Country = new Country
{
FullName = @"Japan",
FlagName = @"JP",
},
CountryCode = CountryCode.JP,
},
Mods = new[]
{
@ -235,11 +223,7 @@ namespace osu.Game.Tests.Visual.Online
{
Id = 1541390,
Username = @"Toukai",
Country = new Country
{
FullName = @"Canada",
FlagName = @"CA",
},
CountryCode = CountryCode.CA,
},
Mods = new[]
{
@ -259,11 +243,7 @@ namespace osu.Game.Tests.Visual.Online
{
Id = 7151382,
Username = @"Mayuri Hana",
Country = new Country
{
FullName = @"Thailand",
FlagName = @"TH",
},
CountryCode = CountryCode.TH,
},
Rank = ScoreRank.D,
PP = 160,
@ -302,11 +282,7 @@ namespace osu.Game.Tests.Visual.Online
{
Id = 7151382,
Username = @"Mayuri Hana",
Country = new Country
{
FullName = @"Thailand",
FlagName = @"TH",
},
CountryCode = CountryCode.TH,
},
Rank = ScoreRank.D,
PP = 160,

View File

@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual.Online
{
Username = @"flyte",
Id = 3103765,
Country = new Country { FlagName = @"JP" },
CountryCode = CountryCode.JP,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg",
Status = { Value = new UserStatusOnline() }
}) { Width = 300 },
@ -68,7 +68,7 @@ namespace osu.Game.Tests.Visual.Online
{
Username = @"peppy",
Id = 2,
Country = new Country { FlagName = @"AU" },
CountryCode = CountryCode.AU,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
IsSupporter = true,
SupportLevel = 3,
@ -77,7 +77,7 @@ namespace osu.Game.Tests.Visual.Online
{
Username = @"Evast",
Id = 8195163,
Country = new Country { FlagName = @"BY" },
CountryCode = CountryCode.BY,
CoverUrl = @"https://assets.ppy.sh/user-profile-covers/8195163/4a8e2ad5a02a2642b631438cfa6c6bd7e2f9db289be881cb27df18331f64144c.jpeg",
IsOnline = false,
LastVisit = DateTimeOffset.Now

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online
{
Username = @"Somebody",
Id = 1,
Country = new Country { FullName = @"Alien" },
CountryCode = CountryCode.Unknown,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg",
JoinDate = DateTimeOffset.Now.AddDays(-1),
LastVisit = DateTimeOffset.Now,
@ -82,7 +82,7 @@ namespace osu.Game.Tests.Visual.Online
Username = @"peppy",
Id = 2,
IsSupporter = true,
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
CountryCode = CountryCode.AU,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
}));
@ -90,7 +90,7 @@ namespace osu.Game.Tests.Visual.Online
{
Username = @"flyte",
Id = 3103765,
Country = new Country { FullName = @"Japan", FlagName = @"JP" },
CountryCode = CountryCode.JP,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
}));
@ -99,7 +99,7 @@ namespace osu.Game.Tests.Visual.Online
Username = @"BanchoBot",
Id = 3,
IsBot = true,
Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" },
CountryCode = CountryCode.SH,
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
}));

View File

@ -140,11 +140,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
CountryCode = CountryCode.ES,
},
});
}
@ -164,12 +160,8 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
},
CountryCode = CountryCode.ES,
}
});
}
@ -225,11 +217,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
CountryCode = CountryCode.ES,
},
},
new ScoreInfo
@ -246,11 +234,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 4608074,
Username = @"Skycries",
Country = new Country
{
FullName = @"Brazil",
FlagName = @"BR",
},
CountryCode = CountryCode.BR,
},
},
new ScoreInfo
@ -268,11 +252,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 1014222,
Username = @"eLy",
Country = new Country
{
FullName = @"Japan",
FlagName = @"JP",
},
CountryCode = CountryCode.JP,
},
},
new ScoreInfo
@ -290,11 +270,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 1541390,
Username = @"Toukai",
Country = new Country
{
FullName = @"Canada",
FlagName = @"CA",
},
CountryCode = CountryCode.CA,
},
},
new ScoreInfo
@ -312,11 +288,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 2243452,
Username = @"Satoruu",
Country = new Country
{
FullName = @"Venezuela",
FlagName = @"VE",
},
CountryCode = CountryCode.VE,
},
},
new ScoreInfo
@ -334,11 +306,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 2705430,
Username = @"Mooha",
Country = new Country
{
FullName = @"France",
FlagName = @"FR",
},
CountryCode = CountryCode.FR,
},
},
new ScoreInfo
@ -356,11 +324,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 7151382,
Username = @"Mayuri Hana",
Country = new Country
{
FullName = @"Thailand",
FlagName = @"TH",
},
CountryCode = CountryCode.TH,
},
},
new ScoreInfo
@ -378,11 +342,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 2051389,
Username = @"FunOrange",
Country = new Country
{
FullName = @"Canada",
FlagName = @"CA",
},
CountryCode = CountryCode.CA,
},
},
new ScoreInfo
@ -400,11 +360,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 6169483,
Username = @"-Hebel-",
Country = new Country
{
FullName = @"Mexico",
FlagName = @"MX",
},
CountryCode = CountryCode.MX,
},
},
new ScoreInfo
@ -422,11 +378,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 6702666,
Username = @"prhtnsm",
Country = new Country
{
FullName = @"Germany",
FlagName = @"DE",
},
CountryCode = CountryCode.DE,
},
},
};

View File

@ -69,11 +69,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 6602580,
Username = @"waaiiru",
Country = new Country
{
FullName = @"Spain",
FlagName = @"ES",
},
CountryCode = CountryCode.ES,
},
},
new ScoreInfo
@ -88,11 +84,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 4608074,
Username = @"Skycries",
Country = new Country
{
FullName = @"Brazil",
FlagName = @"BR",
},
CountryCode = CountryCode.BR,
},
},
new ScoreInfo
@ -107,11 +99,7 @@ namespace osu.Game.Tests.Visual.SongSelect
{
Id = 1541390,
Username = @"Toukai",
Country = new Country
{
FullName = @"Canada",
FlagName = @"CA",
},
CountryCode = CountryCode.CA,
},
}
};