From da8f34c6645c1e4896339bbc4f7d02a02702acbe Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Fri, 23 Mar 2018 20:39:22 +0900 Subject: [PATCH] [USB][Non-ACR][Apply NotSupported Exception] Change-Id: I16c555060e39cb84213e63cab577388348ffff06 Signed-off-by: lokilee73 --- .../Tizen.Usb.Tests/testcase/TSUsbBulkEndpoint.cs | 29 ++++++++++++++++++++ .../Tizen.Usb.Tests/testcase/TSUsbConfiguration.cs | 29 ++++++++++++++++++++ .../testcase/TSUsbControlEndpoint.cs | 29 ++++++++++++++++++++ .../Tizen.Usb.Tests/testcase/TSUsbDevice.cs | 30 ++++++++++++++++++++ .../testcase/TSUsbDeviceInformation.cs | 29 ++++++++++++++++++++ .../Tizen.Usb.Tests/testcase/TSUsbDeviceStrings.cs | 30 ++++++++++++++++++++ .../Tizen.Usb.Tests/testcase/TSUsbEndpoint.cs | 29 ++++++++++++++++++++ .../Tizen.Usb.Tests/testcase/TSUsbInterface.cs | 28 +++++++++++++++++++ .../testcase/TSUsbInterruptEndpoint.cs | 29 ++++++++++++++++++++ .../testcase/TSUsbIsochronousEndpoint.cs | 30 ++++++++++++++++++++ .../Tizen.Usb.Tests/testcase/TSUsbManager.cs | 29 ++++++++++++++++++++ .../Tizen.Usb.Tests/testcase/support/Helper.cs | 32 ++-------------------- 12 files changed, 323 insertions(+), 30 deletions(-) diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbBulkEndpoint.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbBulkEndpoint.cs index 2f203f6..938c121 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbBulkEndpoint.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbBulkEndpoint.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbConfiguration.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbConfiguration.cs index f7b38af..945c30c 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbConfiguration.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbConfiguration.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbControlEndpoint.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbControlEndpoint.cs index 108fe5d..9acfa6f 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbControlEndpoint.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbControlEndpoint.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDevice.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDevice.cs index 979223d..b404cfe 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDevice.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDevice.cs @@ -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("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(); diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceInformation.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceInformation.cs index 8ad6ab8..de6cb00 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceInformation.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceInformation.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceStrings.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceStrings.cs index 20687b5..a43f085 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceStrings.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceStrings.cs @@ -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("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; diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbEndpoint.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbEndpoint.cs index dd22078..7fbc93f 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbEndpoint.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbEndpoint.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterface.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterface.cs index b08874d..fba2efb 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterface.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterface.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterruptEndpoint.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterruptEndpoint.cs index 10906b2..b82dbb9 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterruptEndpoint.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbInterruptEndpoint.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbIsochronousEndpoint.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbIsochronousEndpoint.cs index 991f71d..5d56c2b 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbIsochronousEndpoint.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbIsochronousEndpoint.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbManager.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbManager.cs index 32fa1f1..2157b8a 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbManager.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbManager.cs @@ -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("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")] diff --git a/tct-suite-vs/Tizen.Usb.Tests/testcase/support/Helper.cs b/tct-suite-vs/Tizen.Usb.Tests/testcase/support/Helper.cs index 2eece7e..b4608ee 100755 --- a/tct-suite-vs/Tizen.Usb.Tests/testcase/support/Helper.cs +++ b/tct-suite-vs/Tizen.Usb.Tests/testcase/support/Helper.cs @@ -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 _testData = new List { @@ -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; } } -- 2.7.4