[USB][Non-ACR][Apply NotSupported Exception] 30/173730/2
authorlokilee73 <changjoo.lee@samsung.com>
Fri, 23 Mar 2018 11:39:22 +0000 (20:39 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Mon, 26 Mar 2018 07:50:58 +0000 (16:50 +0900)
Change-Id: I16c555060e39cb84213e63cab577388348ffff06
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
12 files changed:
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbBulkEndpoint.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbConfiguration.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbControlEndpoint.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDevice.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceInformation.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceStrings.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbEndpoint.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterface.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterruptEndpoint.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbIsochronousEndpoint.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbManager.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/support/Helper.cs

index 2f203f6..938c121 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -26,6 +27,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbBulkEndpoint test class")]
     public class UsbBulkEndpointTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported= true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "_isSupported:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                     Assert.Pass("Feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if transfer on loopback is sent correctly")]
index f7b38af..945c30c 100755 (executable)
@@ -16,6 +16,7 @@
 
 using System.Linq;
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 using System.Collections.Generic;
 using System;
 
@@ -25,6 +26,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbConfiguration test class")]
     public class UsbConfigurationTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if SetAsActive method sets active configuration for device")]
index 108fe5d..9acfa6f 100755 (executable)
@@ -17,6 +17,7 @@
 using System;
 using NUnit.Framework;
 using System.Runtime.InteropServices;
+using NUnit.Framework.TUnit;
 
 namespace Tizen.System.Usb.Tests
 {
@@ -44,6 +45,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbControlEndpoint test class")]
     public class UsbControlEndpointTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if request for device descriptor returns valid descriptor")]
index 979223d..b404cfe 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -25,6 +26,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbDevice test class")]
     public class UsbDeviceTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Call Open method and check if device is in open state")]
@@ -296,6 +325,7 @@ namespace Tizen.System.Usb.Tests
         public static void ActiveConfiguration_InvalidOperationException()
         {
             Helper.Check();
+
             try
             {
                 Helper.Check();
index 8ad6ab8..de6cb00 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 using System;
 using System.Linq;
 
@@ -24,6 +25,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbDeviceInformation test class")]
     public class UsbDeviceInformationTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if UsbVersion property returns valid value")]
index 20687b5..a43f085 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 using System;
 using System.Linq;
 
@@ -24,6 +25,35 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbDeviceStrings test class")]
     public class UsbDeviceStringsTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
+
         private static DeviceStringsData GetTestData(UsbDevice testUsbDevice)
         {
             var info = testUsbDevice.DeviceInformation;
index dd22078..7fbc93f 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -25,6 +26,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbEndpoint test class")]
     public class UsbEndpointTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if Id property returns valid value")]
index b08874d..fba2efb 100755 (executable)
@@ -26,6 +26,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbInterface test class")]
     public class UsbInterfaceTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Claim method should not throw any exception")]
index 10906b2..b82dbb9 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -26,6 +27,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbInterruptEndpoint test class")]
     public class UsbInterruptEndpointTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if transfer on loopback is sent correctly")]
index 991f71d..5d56c2b 100755 (executable)
@@ -15,6 +15,7 @@
  */
 
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -25,6 +26,35 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbIsochronousEndpoint test class")]
     public class UsbIsochronousEndpointTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if SynchronizationType property returns valid value")]
index 32fa1f1..2157b8a 100755 (executable)
@@ -16,6 +16,7 @@
 
 using System;
 using NUnit.Framework;
+using NUnit.Framework.TUnit;
 
 namespace Tizen.System.Usb.Tests
 {
@@ -24,6 +25,34 @@ namespace Tizen.System.Usb.Tests
     [Description("Tizen.System.Usb.UsbManager Class Tests")]
     public class UsbManagerTests
     {
+        [SetUp]
+        public static void Init()
+        {
+            bool ret_value;
+            bool value;
+
+            ret_value = Tizen.System.SystemInfo.TryGetValue<bool>("http://tizen.org/feature/usb.host", out value);
+            if (ret_value == true && value == true)
+            {
+                Helper._isSupported = true;
+            }
+            else
+            {
+                Helper._isSupported = false;
+            }
+            LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "isSupport:" + Helper._isSupported);
+
+            try
+            {
+                Helper._manager = new UsbManager();
+            }
+            catch (NotSupportedException)
+            {
+                if (Helper._isSupported == false)
+                    Assert.Pass("Usb host feature is false");
+            }
+        }
+
         [Test]
         [Category("P1")]
         [Description("Test: Check if constructor returns valid UsbManager object without any failure or exception")]
index 2eece7e..b4608ee 100755 (executable)
@@ -27,9 +27,8 @@ namespace Tizen.System.Usb.Tests
 {
     internal static class Helper
     {
-        private static bool _isInitialized = false;
-        private static bool _isSupported = false;
-        private static UsbManager _manager = null;
+        public static bool _isSupported = false;
+        public static UsbManager _manager = null;
 
         private static IEnumerable<DeviceData> _testData = new List<DeviceData>
         {
@@ -108,36 +107,10 @@ namespace Tizen.System.Usb.Tests
             }
         };
 
-        private static void Initialize()
-        {
-            _isInitialized = true;
-            Information.TryGetValue("http://tizen.org/feature/usb.host", out _isSupported);
-            if (_isSupported == false) return;
-
-            try
-            {
-                _manager = new UsbManager();
-            }
-            catch (Exception e)
-            {
-                if (_isSupported == false)
-                {
-                    Assert.IsTrue(e.GetType().Name.Equals("NotSupportedException"),
-                        $"Expecting: NotSupportedException, Actual: {e.GetType().Name}");
-                }
-                else
-                {
-                    Assert.IsTrue(false, $"Unexpected Exception : {e.GetType().Name} -- {e.Message}");
-                    foreach(var line in Regex.Split(e.StackTrace, "\n")) Log(line);
-                }
-            }
-        }
-
         internal static bool IsUsbSupported
         {
             get
             {
-                if (_isInitialized == false) Initialize();
                 return _isSupported;
             }
         }
@@ -146,7 +119,6 @@ namespace Tizen.System.Usb.Tests
         {
             get
             {
-                if (_isInitialized == false) Initialize();
                 return _manager;
             }
         }