[Usb][Non-ACR] Do not test devices existing in the system 30/213630/2
authorPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 9 Sep 2019 08:54:06 +0000 (10:54 +0200)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 9 Sep 2019 10:58:17 +0000 (12:58 +0200)
Some devices may be unavailable to the testing framework and we should
not consider them a target of our tests.

Change-Id: Ie59bd0661c6e1ae7efa9e680146cf2c2a5a02fdd
Signed-off-by: Paweł Szewczyk <p.szewczyk@samsung.com>
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbConfiguration.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/TSUsbDeviceStrings.cs
tct-suite-vs/Tizen.Usb.Tests/testcase/support/Helper.cs

index 076cd91..e0a0428 100755 (executable)
@@ -65,7 +65,7 @@ namespace Tizen.System.Usb.Tests
         {
             try
             {
-                var testUsbDevice = Helper.Manager.AvailableDevices.FirstOrDefault();
+                var testUsbDevice = Helper.GetTestDevices().FirstOrDefault();
                 var testConfiguration = testUsbDevice?.Configurations.FirstOrDefault().Value;
 
                 // PRECONDITION
@@ -99,7 +99,7 @@ namespace Tizen.System.Usb.Tests
         {
             try
             {
-                var testUsbDevice = Helper.Manager.AvailableDevices.FirstOrDefault();
+                var testUsbDevice = Helper.GetTestDevices().FirstOrDefault();
                 var testConfiguration = testUsbDevice?.Configurations.FirstOrDefault().Value;
 
                 // PRECONDITION
index 5a31d18..27e6cf0 100755 (executable)
@@ -72,7 +72,7 @@ namespace Tizen.System.Usb.Tests
         {
             try
             {
-                foreach (var testUsbDevice in Helper.Manager.AvailableDevices)
+                foreach (var testUsbDevice in Helper.GetTestDevices())
                 {
                     // PRECONDITION
                     Assert.IsNotNull(testUsbDevice, "Invalid USB Device for test");
@@ -111,7 +111,7 @@ namespace Tizen.System.Usb.Tests
         {
             try
             {
-                foreach (var testUsbDevice in Helper.Manager.AvailableDevices)
+                foreach (var testUsbDevice in Helper.GetTestDevices())
                 {
                     // PRECONDITION
                     Assert.IsNotNull(testUsbDevice, "Invalid USB Device for test");
@@ -151,7 +151,7 @@ namespace Tizen.System.Usb.Tests
         {
             try
             {
-                foreach (var testUsbDevice in Helper.Manager.AvailableDevices)
+                foreach (var testUsbDevice in Helper.GetTestDevices())
                 {
                     // PRECONDITION
                     Assert.IsNotNull(testUsbDevice, "Invalid USB Device for test");
index b4608ee..8f58345 100755 (executable)
@@ -153,8 +153,12 @@ namespace Tizen.System.Usb.Tests
                 // This is a special device generated by dummy_hcd, not for testing
                 if (testUsbDevice.DeviceInformation.ProductId == 0x0002 && testUsbDevice.DeviceInformation.VendorId == 0x1d6b)
                     continue;
+
                 var info = testUsbDevice.DeviceInformation;
                 var testDeviceData = TestDevices.Where(d => d.DeviceInformation.ProductId == info.ProductId).FirstOrDefault();
+                if (testDeviceData == null)
+                    continue;
+
                 testData.Add(testUsbDevice, testDeviceData);
             }
             return testData;
@@ -206,6 +210,11 @@ namespace Tizen.System.Usb.Tests
             return testData;
         }
 
+       internal static IEnumerable<UsbDevice> GetTestDevices()
+       {
+               return Manager.AvailableDevices.Where(d => d.DeviceInformation.VendorId == 0x1d6b && d.DeviceInformation.ProductId == 0x0104);
+       }
+
         internal static void ListUsb()
         {
             foreach (var testUsbDevice in Manager.AvailableDevices) Print(testUsbDevice, "");