--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.System.Tests
+{
+
+ [TestFixture]
+ [Description("Tizen.System.PowerUsage Class 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";
+
+ [SetUp]
+ public void Init()
+ {
+ bool ret;
+ bool value;
+ string profile;
+ ret = Information.TryGetValue<bool>("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]
+ public void Destroy()
+ {
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check if GetPowerUsage() return proper value")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "string, IList<Tizen.System.PowerUsageResourceType>, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_RESULT_BY_APP_FOR_ALL_RESOURCES()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ try
+ {
+ object powerUsage;
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();
+ rtypes.Add(PowerUsageResourceType.Cpu);
+ IDictionary<PowerUsageResourceType, double> result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime);
+
+ 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)
+ {
+ 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());
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises not supported exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, IList<Tizen.System.PowerUsageResourceType>, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP_FOR_ALL_RESOURCES()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ Assert.Pass("Test skipped! Can't test not supported exception");
+ }
+ else
+ {
+ try
+ {
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();
+ foreach (PowerUsageResourceType rtype in Enum.GetValues(typeof(PowerUsageResourceType)))
+ {
+ rtypes.Add(rtype);
+ }
+ IDictionary<PowerUsageResourceType, double> 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]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, IList<Tizen.System.PowerUsageResourceType>, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP_FOR_ALL_RESOURCES()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ try
+ {
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();
+ rtypes.Add(PowerUsageResourceType.Cpu);
+ IDictionary<PowerUsageResourceType, double> 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");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument null exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, IList<Tizen.System.PowerUsageResourceType>, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_NULL_ARGUMENT_EXCEPTION_BY_APP_FOR_ALL_RESOURCES()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ try
+ {
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();
+ IDictionary<PowerUsageResourceType, double> 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");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, IList<Tizen.System.PowerUsageResourceType>, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_ARGUMENT_NULL_EXCEPTION_BY_APP_FOR_ALL_RESOURCES()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ try
+ {
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();
+ rtypes.Add(PowerUsageResourceType.Cpu);
+ IDictionary<PowerUsageResourceType, double> result = PowerUsage.GetPowerUsage(null, rtypes, startTime, endTime);
+ Assert.IsTrue(false, "This operation should raise ArgumentException");
+ }
+ catch (Exception ex)
+ {
+ Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises invalid operation exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, IList<Tizen.System.PowerUsageResourceType>, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP_FOR_ALL_RESOURCES()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ try
+ {
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();
+ rtypes.Add(PowerUsageResourceType.Cpu);
+ IDictionary<PowerUsageResourceType, double> 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");
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check if GetPowerUsage() return proper value")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_RESULT_BY_APP_PER_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ 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());
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises not supported exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP_PER_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ Assert.Pass("Test skipped! Can't test not supported exception");
+ }
+ else
+ {
+ 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]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP_PER_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ 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");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_NULL_ARGUMENT_EXCEPTION_BY_APP_PER_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ try
+ {
+ object powerUsage = PowerUsage.GetPowerUsage(null, PowerUsageResourceType.Cpu, startTime, endTime);
+ Assert.IsTrue(false, "This operation should raise ArgumentException");
+ }
+ catch (Exception ex)
+ {
+ Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises invalid operation exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP_PER_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ 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");
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check if GetPowerUsage() return proper value")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "string, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_RESULT_BY_APP()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ 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());
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises not supported exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_APP()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ Assert.Pass("Test skipped! Can't test not supported exception");
+ }
+ else
+ {
+ 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]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_APP()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ 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");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_NULL_ARGUMENT_EXCEPTION_BY_APP()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ try
+ {
+ object powerUsage = PowerUsage.GetPowerUsage(null, startTime, endTime);
+ Assert.IsTrue(false, "This operation should raise ArgumentException");
+ }
+ catch (Exception ex)
+ {
+ Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises invalid operation exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "string, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_APP()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ 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");
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check if GetPowerUsage() return proper value")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("COVPARAM", "Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_RESULT_BY_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ 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 (ArgumentException)
+ {
+ Assert.Pass("No data record corresponding to given resource type");
+ }
+ catch (Exception e)
+ {
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString());
+ Assert.IsTrue(false, e.ToString());
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises not supported exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_NOT_SUPPORTED_EXCEPTION_BY_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ Assert.Pass("Test skipped! Can't test not supported exception");
+ }
+ else
+ {
+ 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]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_ARGUMENT_EXCEPTION_BY_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ 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");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises invalid operation exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("COVPARAM", "Tizen.System.PowerUsageResourceType, DateTime, DateTime")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsage_CHECK_INVALID_OPERATION_EXCEPTION_BY_RESOURCE()
+ {
+ if (profileAvailability)
+ {
+ if (support)
+ {
+ try
+ {
+ object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime);
+ }
+ catch (ArgumentException)
+ {
+ Assert.Pass("No data record corresponding to given resource type");
+ }
+ 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");
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Can't test due to not support feature");
+ }
+ }
+ else
+ {
+ Assert.Pass("Test skipped! Profile not supported, Can only test on wearable profile!");
+ }
+ }
+ }
+}