[Network][TCSACR-192][[Add a TCT for WiFi scan state] 00/193600/4
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 22 Nov 2018 07:41:26 +0000 (16:41 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Fri, 30 Nov 2018 05:17:11 +0000 (14:17 +0900)
Change-Id: I9a98345f9d29ade8eb1370657aaa995a6689337d

tct-suite-vs/Tizen.Network.Tests/testcase/TSScanStateChangedEventArgs.cs [new file with mode: 0644]
tct-suite-vs/Tizen.Network.Tests/testcase/TSWiFiManager.cs

diff --git a/tct-suite-vs/Tizen.Network.Tests/testcase/TSScanStateChangedEventArgs.cs b/tct-suite-vs/Tizen.Network.Tests/testcase/TSScanStateChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..6f3b3fb
--- /dev/null
@@ -0,0 +1,88 @@
+using System;
+using System.Threading.Tasks;
+using networkUtils;
+using NUnit.Framework;
+using Tizen.System;\r
+\r
+namespace Tizen.Network.WiFi.Tests\r
+{\r
+    [TestFixture]
+    [Description("Tizen.Network.WiFi.ScanStateChangedEventArgs test")]
+    public class ScanStateChangedEventArgsTests
+    {
+        private static bool _flag;
+        static bool isWiFiSupported = false;
+
+        [OneTimeSetUp]
+        public static void InitFixture()
+        {
+            networkParameter.SetPrecondition();
+        }
+
+        [SetUp]
+        public static void Init()
+        {
+            Log.Info(Globals.LogTag, "Preconditions for each TEST");
+            _flag = false;
+            Information.TryGetValue("http://tizen.org/feature/network.wifi", out isWiFiSupported);
+        }
+
+        [TearDown]
+        public static void Destroy()
+        {
+            Log.Info(Globals.LogTag, "Postconditional for each TEST");
+        }
+
+        public static async Task setUp()
+        {
+            await networkSetup.WiFiActivate(networkParameter.wnPRIVATE, networkParameter.wType.wPrivate, networkParameter.wPASS);
+        }
+
+        private static void EventHandlerScanStateChangedCB(object sender, ScanStateChangedEventArgs State)
+        {
+            if (!_flag && (State.State == WiFiScanState.Scanning))
+            {
+                _flag = true;
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test State property of ScanStateChangedEventArgs")]
+        [Property("SPEC", "Tizen.Network.WiFi.ScanStateChangedEventArgs.State A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Seonah Moon, seonah1.moon@samsung.com")]
+        public async Task State_PROPERTY()
+        {
+            try
+            {\r
+                /*
+                 * TEST CODE
+                 */\r
+                if (!WiFiManager.IsActive)
+                {
+                    await WiFiManager.ActivateAsync();
+                    await Task.Delay(3000);
+                }
+                WiFiManager.ScanStateChanged += EventHandlerScanStateChangedCB;
+                await WiFiManager.ScanAsync();\r
+                WiFiManager.ScanStateChanged -= EventHandlerScanStateChangedCB;\r
+\r
+                Assert.IsTrue(_flag, "Flag should be true after checking");
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWiFiSupported == false, "Invalid NotSupportedException");
+            }
+            catch (TypeInitializationException e)
+            {
+                Assert.IsTrue(isWiFiSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException");
+            }
+            catch (Exception ex)
+            {
+                Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+            }
+        }
+    }\r
+}\r
index ca493a12f7c27652709d6e3a57f2ddc270466dcc..9f2bfc28f72d1dc07be035c4133c5ea3bd433f81 100755 (executable)
@@ -979,5 +979,81 @@ namespace Tizen.Network.WiFi.Tests
                 Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
             }
         }
+
+        public static void EventHandlerScanState(object sender, ScanStateChangedEventArgs State)
+        {
+            if (State.State == WiFiScanState.Scanning)
+                _flag = true;
+        }
+
+
+        [Test]
+        [Category("P1")]
+        [Description("Test ScanStateChanged event of WiFiManager")]
+        [Property("SPEC", "Tizen.Network.WiFi.WiFiManager.ScanStateChanged E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Seonah Moon, seonah1.moon@samsung.com")]
+        public async Task ScanStateChanged_CHECK_CB_EVENT()
+        {
+            try
+            {
+                if (!WiFiManager.IsActive)
+                {
+                    await WiFiManager.ActivateAsync();
+                    await Task.Delay(3000);
+                }
+                WiFiManager.ScanStateChanged += EventHandlerScanState;
+                await WiFiManager.ScanAsync();
+                WiFiManager.ScanStateChanged -= EventHandlerScanState;
+                Assert.IsTrue(_flag, "ScanState is not changed.");
+                Log.Info(Globals.LogTag, "Successfully done");
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWiFiSupported == false, "Invalid NotSupportedException");
+            }
+            catch (TypeInitializationException e)
+            {
+                Assert.IsTrue(isWiFiSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException");
+            }
+            catch (Exception ex)
+            {
+                Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Test ScanState property")]
+        [Property("SPEC", "Tizen.Network.WiFi.WiFiManager.ScanState A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Seonah Moon, seonah1.moon@samsung.com")]
+        public async Task ScanState_PROPERTY()
+        {
+            try
+            {
+                if (!WiFiManager.IsActive)
+                {
+                    await WiFiManager.ActivateAsync();
+                    await Task.Delay(3000);
+                }
+                Assert.AreEqual(WiFiScanState.NotScanning, WiFiManager.ScanState, "ScanState didn't return NotScanning");
+                Log.Info(Globals.LogTag, "Successfully done");
+            }
+            catch (NotSupportedException)
+            {
+                Assert.IsTrue(isWiFiSupported == false, "Invalid NotSupportedException");
+            }
+            catch (TypeInitializationException e)
+            {
+                Assert.IsTrue(isWiFiSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException");
+            }
+            catch (Exception ex)
+            {
+                Assert.True(false, "Exception occurs. Msg : " + ex.ToString());
+            }
+        }
     }
 }