1
1
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2
2
// See the LICENCE file in the repository root for full licence text.
3
3
4
+ using Moq ;
4
5
using Newtonsoft . Json . Linq ;
5
6
using NUnit . Framework ;
7
+ using osu . Framework . Bindables ;
8
+ using osu . Framework . Graphics ;
6
9
using osu . Framework . Graphics . Containers ;
7
10
using osu . Framework . Testing ;
8
11
using osu . Game . Online . API ;
@@ -16,14 +19,26 @@ namespace osu.Game.Tests.Visual.Gameplay
16
19
[ TestFixture ]
17
20
public partial class TestSceneMedalOverlay : OsuManualInputManagerTestScene
18
21
{
19
- private DummyAPIAccess dummyAPI => ( DummyAPIAccess ) API ;
22
+ private readonly Bindable < OverlayActivation > overlayActivationMode = new Bindable < OverlayActivation > ( OverlayActivation . All ) ;
20
23
24
+ private DummyAPIAccess dummyAPI => ( DummyAPIAccess ) API ;
21
25
private MedalOverlay overlay = null ! ;
22
26
23
27
[ SetUpSteps ]
24
28
public void SetUpSteps ( )
25
29
{
26
- AddStep ( "create overlay" , ( ) => Child = overlay = new MedalOverlay ( ) ) ;
30
+ var overlayManagerMock = new Mock < IOverlayManager > ( ) ;
31
+ overlayManagerMock . Setup ( mock => mock . OverlayActivationMode ) . Returns ( overlayActivationMode ) ;
32
+
33
+ AddStep ( "create overlay" , ( ) => Child = new DependencyProvidingContainer
34
+ {
35
+ Child = overlay = new MedalOverlay ( ) ,
36
+ RelativeSizeAxes = Axes . Both ,
37
+ CachedDependencies =
38
+ [
39
+ ( typeof ( IOverlayManager ) , overlayManagerMock . Object )
40
+ ]
41
+ } ) ;
27
42
}
28
43
29
44
[ Test ]
@@ -63,6 +78,22 @@ public void TestMultipleMedalsInQuickSuccession()
63
78
} ) ;
64
79
}
65
80
81
+ [ Test ]
82
+ public void TestDelayMedalDisplayUntilActivationModeAllowsIt ( )
83
+ {
84
+ AddStep ( "disable overlay activation" , ( ) => overlayActivationMode . Value = OverlayActivation . Disabled ) ;
85
+ awardMedal ( new UserAchievementUnlock
86
+ {
87
+ Title = "Time And A Half" ,
88
+ Description = "Having a right ol' time. One and a half of them, almost." ,
89
+ Slug = @"all-intro-doubletime"
90
+ } ) ;
91
+ AddUntilStep ( "overlay hidden" , ( ) => overlay . State . Value , ( ) => Is . EqualTo ( Visibility . Hidden ) ) ;
92
+
93
+ AddStep ( "re-enable overlay activation" , ( ) => overlayActivationMode . Value = OverlayActivation . All ) ;
94
+ AddUntilStep ( "overlay shown" , ( ) => overlay . State . Value , ( ) => Is . EqualTo ( Visibility . Visible ) ) ;
95
+ }
96
+
66
97
private void awardMedal ( UserAchievementUnlock unlock ) => AddStep ( "award medal" , ( ) => dummyAPI . NotificationsClient . Receive ( new SocketMessage
67
98
{
68
99
Event = @"new" ,
0 commit comments