From 3bdef12602e7874f7054a1f4bf697256b7b5fc67 Mon Sep 17 00:00:00 2001 From: sri Date: Fri, 15 May 2020 11:17:34 +0530 Subject: [PATCH] [Non-ACR][Tizen.System.PowerUsage.Tests] Enabling tests only for wearable profile Change-Id: I4c9b95328ae97ec975d8716dfd548cffa8ac7334 --- .../testcase/TSPowerUsage.cs | 485 +++++++++++++-------- 1 file changed, 306 insertions(+), 179 deletions(-) diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs b/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs index af3924b..cf28c02 100755 --- a/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs @@ -27,6 +27,7 @@ namespace Tizen.System.Tests public class PowerUsageTests { static bool support = true; + static bool profileAvailability = false; static DateTime startTime = DateTime.Now.AddDays(-2); static DateTime endTime = DateTime.Now.AddDays(-1); static string appID = "Tizen.System.PowerUsage.Tests"; @@ -36,11 +37,18 @@ namespace Tizen.System.Tests { bool ret; bool value; + string profile; ret = Information.TryGetValue("http://tizen.org/feature/battery", out value); if (ret && value) support = true; else support = false; + + Information.TryGetValue("http://tizen.org/feature/profile", out profile); + if (String.Compare(profile, "wearable", true) == 0) + profileAvailability = true; + else + profileAvailability = false; } [TearDown] @@ -58,35 +66,42 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_RESULT_BY_APP_FOR_ALL_RESOURCES() { - if (support) + if (profileAvailability) { - try + if (support) { - object powerUsage; - IList rtypes = new List(); - rtypes.Add(PowerUsageResourceType.Cpu); - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + try + { + object powerUsage; + IList rtypes = new List(); + rtypes.Add(PowerUsageResourceType.Cpu); + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); - foreach (PowerUsageResourceType type in rtypes) + foreach (PowerUsageResourceType type in rtypes) + { + powerUsage = result[type]; + Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the resources specified by the application in custom interval"); + Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the resources specified by the application in custom interval"); + } + } + catch (InvalidOperationException) { - powerUsage = result[type]; - Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the resources specified by the application in custom interval"); - Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the resources specified by the application in custom interval"); + Assert.Pass("No data record corresponding to given appID"); + } + catch (Exception e) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); + Assert.IsTrue(false, e.ToString()); } } - catch (InvalidOperationException) - { - Assert.Pass("No data record corresponding to given appID"); - } - catch (Exception e) + else { - LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); - Assert.IsTrue(false, e.ToString()); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -100,27 +115,34 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP_FOR_ALL_RESOURCES() { - if (support) - { - Assert.Pass("Test skipped! Can't test not supported exception"); - } - else + if (profileAvailability) { - try + if (support) { - IList rtypes = new List(); - foreach (PowerUsageResourceType rtype in Enum.GetValues(typeof(PowerUsageResourceType))) - { - rtypes.Add(rtype); - } - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); - Assert.IsTrue(false, "This operation should raise NotSupportedException"); + Assert.Pass("Test skipped! Can't test not supported exception"); } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + try + { + IList rtypes = new List(); + foreach (PowerUsageResourceType rtype in Enum.GetValues(typeof(PowerUsageResourceType))) + { + rtypes.Add(rtype); + } + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } } } + else + { + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); + } } [Test] @@ -133,23 +155,30 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP_FOR_ALL_RESOURCES() { - if (support) + if (profileAvailability) { - try + if (support) { - IList rtypes = new List(); - rtypes.Add(PowerUsageResourceType.Cpu); - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); - Assert.IsTrue(false, "This operation should raise ArgumentException"); + try + { + IList rtypes = new List(); + rtypes.Add(PowerUsageResourceType.Cpu); + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); + Assert.IsTrue(false, "This operation should raise ArgumentException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + } } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -163,26 +192,33 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_NULL_ARGUMENT_EXCEPTION_BY_APP_FOR_ALL_RESOURCES() { - if (support) + if (profileAvailability) { - try + if (support) { - IList rtypes = new List(); - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); - Assert.IsTrue(false, "This operation should raise ArgumentNullException"); + try + { + IList rtypes = new List(); + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + Assert.IsTrue(false, "This operation should raise ArgumentNullException"); + } + catch (InvalidOperationException) + { + Assert.Pass("No data record corresponding to given appID"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException), "this operation should raise ArgumentNullException exception"); + } } - catch (InvalidOperationException) - { - Assert.Pass("No data record corresponding to given appID"); - } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException), "this operation should raise ArgumentNullException exception"); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -196,24 +232,31 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP_FOR_ALL_RESOURCES() { - if (support) + if (profileAvailability) { - try + if (support) { - IList rtypes = new List(); - rtypes.Add(PowerUsageResourceType.Cpu); - IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + try + { + IList rtypes = new List(); + rtypes.Add(PowerUsageResourceType.Cpu); + IDictionary result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + return; + } + Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); - return; + Assert.Pass("Test skipped! Can't test due to not support feature"); } - Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -227,27 +270,34 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_RESULT_BY_APP_PER_RESOURCE() { - if (support) + if (profileAvailability) { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); - Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the specific resource for the given application in custom interval"); - Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the specific resource for the given application in custom interval"); - } - catch (ArgumentException) + if (support) { - Assert.Pass("No data record corresponding to given resource type and appID"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); + Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the specific resource for the given application in custom interval"); + Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the specific resource for the given application in custom interval"); + } + catch (ArgumentException) + { + Assert.Pass("No data record corresponding to given resource type and appID"); + } + catch (Exception e) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); + Assert.IsTrue(false, e.ToString()); + } } - catch (Exception e) + else { - LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); - Assert.IsTrue(false, e.ToString()); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -261,22 +311,29 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP_PER_RESOURCE() { - if (support) + if (profileAvailability) { - Assert.Pass("Test skipped! Can't test not supported exception"); - } - else - { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); - Assert.IsTrue(false, "This operation should raise NotSupportedException"); + Assert.Pass("Test skipped! Can't test not supported exception"); } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } } } + else + { + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); + } } [Test] @@ -289,21 +346,28 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP_PER_RESOURCE() { - if (support) + if (profileAvailability) { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); - Assert.IsTrue(false, "This operation should raise ArgumentException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); + Assert.IsTrue(false, "This operation should raise ArgumentException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + } } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -317,27 +381,34 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP_PER_RESOURCE() { - if (support) + if (profileAvailability) { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); - } - catch (ArgumentException) - { - Assert.Pass("No data record corresponding to given resource type and appID"); - return; + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime); + } + catch (ArgumentException) + { + Assert.Pass("No data record corresponding to given resource type and appID"); + return; + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + return; + } + Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); - return; + Assert.Pass("Test skipped! Can't test due to not support feature"); } - Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -351,27 +422,34 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_RESULT_BY_APP() { - if (support) + if (profileAvailability) { - try - { - object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); - Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value corresponding to app in double"); - Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value corresponding to app"); - } - catch (InvalidOperationException) + if (support) { - Assert.Pass("No data record corresponding to given appID"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); + Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value corresponding to app in double"); + Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value corresponding to app"); + } + catch (InvalidOperationException) + { + Assert.Pass("No data record corresponding to given appID"); + } + catch (Exception e) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); + Assert.IsTrue(false, e.ToString()); + } } - catch (Exception e) + else { - LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); - Assert.IsTrue(false, e.ToString()); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -385,22 +463,29 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP() { - if (support) + if (profileAvailability) { - Assert.Pass("Test skipped! Can't test not supported exception"); - } - else - { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); - Assert.IsTrue(false, "This operation should raise NotSupportedException"); + Assert.Pass("Test skipped! Can't test not supported exception"); } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } } } + else + { + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); + } } [Test] @@ -413,21 +498,28 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP() { - if (support) + if (profileAvailability) { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(appID, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); - Assert.IsTrue(false, "This operation should raise ArgumentException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); + Assert.IsTrue(false, "This operation should raise ArgumentException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + } } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -441,22 +533,29 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP() { - if (support) + if (profileAvailability) { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); + try + { + object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + return; + } + Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); - return; + Assert.Pass("Test skipped! Can't test due to not support feature"); } - Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -470,23 +569,30 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_RESULT_BY_RESOURCE() { - if (support) + if (profileAvailability) { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); - Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double by a resource for certain time interval"); - Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value by a resource for certain time interval"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); + Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double by a resource for certain time interval"); + Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value by a resource for certain time interval"); + } + catch (Exception e) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); + Assert.IsTrue(false, e.ToString()); + } } - catch (Exception e) + else { - LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString()); - Assert.IsTrue(false, e.ToString()); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -500,22 +606,29 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_RESOURCE() { - if (support) + if (profileAvailability) { - Assert.Pass("Test skipped! Can't test not supported exception"); - } - else - { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); - Assert.IsTrue(false, "This operation should raise NotSupportedException"); + Assert.Pass("Test skipped! Can't test not supported exception"); } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); + Assert.IsTrue(false, "This operation should raise NotSupportedException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException"); + } } } + else + { + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); + } } [Test] @@ -528,21 +641,28 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_RESOURCE() { - if (support) + if (profileAvailability) { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); - Assert.IsTrue(false, "This operation should raise ArgumentException"); + try + { + object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-2)); + Assert.IsTrue(false, "This operation should raise ArgumentException"); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + } } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception"); + Assert.Pass("Test skipped! Can't test due to not support feature"); } } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } @@ -556,22 +676,29 @@ namespace Tizen.System.Tests [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")] public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_RESOURCE() { - if (support) + if (profileAvailability) { - try + if (support) { - object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); + try + { + object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime); + } + catch (Exception ex) + { + Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); + return; + } + Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); } - catch (Exception ex) + else { - Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error"); - return; + Assert.Pass("Test skipped! Can't test due to not support feature"); } - Assert.Pass("Test skipped! since no system error occured to test Invalid operation"); } else { - Assert.Pass("Test skipped! Can't test due to not supported exception"); + Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!"); } } } -- 2.7.4