e57ea497a95f600914653514a88d03d63b0b0c54
[test/tct/csharp/api.git] /
1 using NUnit.Framework;
2 using System.Threading.Tasks;
3
4 namespace Tizen.Multimedia.Tests
5 {
6     [TestFixture]
7     [Description("Testing Tizen.Multimedia.AudioStreamPolicyFocusStateChangedEventArgs class")]
8     public class AudioStreamPolicyFocusStateChangedEventArgsTests
9     {
10         private const AudioStreamFocusOptions FocusOptions = AudioStreamFocusOptions.Playback;
11         private const AudioStreamBehaviors Behaviors = AudioStreamBehaviors.Fading;
12         private const string ExtraInfo = "some string";
13
14         private static async Task<AudioStreamPolicyFocusStateChangedEventArgs> RaiseEvent()
15         {
16             using (var eventAwaiter = EventAwaiter<AudioStreamPolicyFocusStateChangedEventArgs>.Create())
17             using (AudioStreamPolicy toBeTested = new AudioStreamPolicy(AudioStreamType.Media),
18                 toAcquire = new AudioStreamPolicy(AudioStreamType.Media))
19             {
20                 toBeTested.FocusStateChanged += eventAwaiter;
21
22                 toBeTested.AcquireFocus(AudioStreamFocusOptions.Playback, 0, "");
23                 toAcquire.AcquireFocus(FocusOptions, Behaviors, ExtraInfo);
24
25                 return await eventAwaiter.GetResultAsync();
26             }
27         }
28
29         [Test]
30         [Category("P1")]
31         [Description("AudioStreamPolicyFocusStateChangedEventArgs Reason")]
32         [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicyFocusStateChangedEventArgs.Reason A")]
33         [Property("SPEC_URL", "-")]
34         [Property("CRITERIA", "PRO")]
35         [Property("AUTHOR", "JungHo Kim, jhyo.kim@samsung.com")]
36         public async Task Reason_PROPERTY_READ_ONLY()
37         {
38             Assert.That((await RaiseEvent()).Reason, Is.EqualTo(AudioStreamFocusChangedReason.Media));
39         }
40
41         [Test]
42         [Category("P1")]
43         [Description("AudioStreamPolicyFocusStateChangedEventArgs Behaviors")]
44         [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicyFocusStateChangedEventArgs.Behaviors A")]
45         [Property("SPEC_URL", "-")]
46         [Property("CRITERIA", "PRO")]
47         [Property("AUTHOR", "JungHo Kim, jhyo.kim@samsung.com")]
48         public async Task Behaviors_PROPERTY_READ_ONLY()
49         {
50             Assert.That((await RaiseEvent()).Behaviors, Is.EqualTo(Behaviors));
51         }
52
53         [Test]
54         [Category("P1")]
55         [Description("AudioStreamPolicyFocusStateChangedEventArgs FocusOptions")]
56         [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicyFocusStateChangedEventArgs.FocusOptions A")]
57         [Property("SPEC_URL", "-")]
58         [Property("CRITERIA", "PRO")]
59         [Property("AUTHOR", "JungHo Kim, jhyo.kim@samsung.com")]
60         public async Task FocusOptions_PROPERTY_READ_ONLY()
61         {
62             Assert.That((await RaiseEvent()).FocusOptions, Is.EqualTo(FocusOptions));
63         }
64
65         [Test]
66         [Category("P1")]
67         [Description("AudioStreamPolicyFocusStateChangedEventArgs FocusState")]
68         [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicyFocusStateChangedEventArgs.FocusState A")]
69         [Property("SPEC_URL", "-")]
70         [Property("CRITERIA", "PRO")]
71         [Property("AUTHOR", "JungHo Kim, jhyo.kim@samsung.com")]
72         public async Task FocusState_PROPERTY_READ_ONLY()
73         {
74             Assert.That((await RaiseEvent()).FocusState, Is.EqualTo(AudioStreamFocusState.Released));
75         }
76
77         [Test]
78         [Category("P1")]
79         [Description("AudioStreamPolicyFocusStateChangedEventArgs ExtraInfo")]
80         [Property("SPEC", "Tizen.Multimedia.AudioStreamPolicyFocusStateChangedEventArgs.ExtraInfo A")]
81         [Property("SPEC_URL", "-")]
82         [Property("CRITERIA", "PRO")]
83         [Property("AUTHOR", "JungHo Kim, jhyo.kim@samsung.com")]
84         public async Task ExtraInfo_PROPERTY_READ_ONLY()
85         {
86             Assert.That((await RaiseEvent()).ExtraInfo, Is.EqualTo(ExtraInfo));
87         }
88     }
89 }