--- /dev/null
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 15\r
+VisualStudioVersion = 15.0.26730.15\r
+MinimumVisualStudioVersion = 15.0.26124.0\r
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.PowerUsage.Tests", "Tizen.System.PowerUsage.Tests.csproj", "{D92BEEAC-3B2A-45F8-8C53-53B92550404A}"\r
+EndProject\r
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.framework", "..\nunit.framework\nunit.framework.csproj", "{B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}"\r
+EndProject\r
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunitlite", "..\nunitlite\nunitlite.csproj", "{FDB8025A-C029-461F-895E-287B4C65939B}"\r
+EndProject\r
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoTemplate", "..\Template\AutoTemplate\AutoTemplate.csproj", "{B11ABB0C-C3C1-4B5C-8251-A15628A775F3}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Any CPU = Debug|Any CPU\r
+ Debug|x64 = Debug|x64\r
+ Debug|x86 = Debug|x86\r
+ Release|Any CPU = Release|Any CPU\r
+ Release|x64 = Release|x64\r
+ Release|x86 = Release|x86\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.ActiveCfg = Debug|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.Build.0 = Debug|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.ActiveCfg = Debug|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.Build.0 = Debug|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.ActiveCfg = Release|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.Build.0 = Release|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.ActiveCfg = Release|Any CPU\r
+ {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.Build.0 = Release|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.ActiveCfg = Debug|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.Build.0 = Debug|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x86.ActiveCfg = Debug|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x86.Build.0 = Debug|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x64.ActiveCfg = Release|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x64.Build.0 = Release|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x86.ActiveCfg = Release|Any CPU\r
+ {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x86.Build.0 = Release|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x64.ActiveCfg = Debug|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x64.Build.0 = Debug|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x86.ActiveCfg = Debug|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x86.Build.0 = Debug|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.ActiveCfg = Release|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.Build.0 = Release|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.ActiveCfg = Release|Any CPU\r
+ {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.Build.0 = Release|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x64.ActiveCfg = Debug|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x64.Build.0 = Debug|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x86.ActiveCfg = Debug|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x86.Build.0 = Debug|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x64.ActiveCfg = Release|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x64.Build.0 = Release|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x86.ActiveCfg = Release|Any CPU\r
+ {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x86.Build.0 = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+ GlobalSection(ExtensibilityGlobals) = postSolution\r
+ SolutionGuid = {ED382B91-9930-40B6-B3D7-362304C78680}\r
+ EndGlobalSection\r
+EndGlobal\r
--- /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;\r
+\r
+namespace Tizen.System.Tests\r
+{
+
+ [TestFixture]
+ [Description("Tizen.System.PowerUsage Class Tests")]
+ public class PowerUsageTests\r
+ {
+ static bool support = true;
+ 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;
+ ret = Information.TryGetValue<bool>("http://tizen.org/feature/battery", out value);
+ if (ret && value)
+ support = true;
+ else
+ support = 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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByAppForAllResources_CHECK_RESULT()
+ {\r
+ if (support)
+ {\r
+ try\r
+ {\r
+ object powerUsage;\r
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();\r
+ rtypes.Add(PowerUsageResourceType.Cpu);\r
+ IDictionary<PowerUsageResourceType, double> result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime);\r
+\r
+ foreach (PowerUsageResourceType type in rtypes)\r
+ {\r
+ powerUsage = result[type];\r
+ Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the resources specified by the application in custom interval");\r
+ Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the resources specified by the application in custom interval");\r
+ }\r
+ }\r
+ catch (Exception e)\r
+ {\r
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString());\r
+ Assert.IsTrue(false, e.ToString());\r
+ }
+ }
+ else\r
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }
+ }
+
+ [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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByAppForAllResources_CHECK_NOT_SUPPORTED_EXCEPTION()
+ {\r
+ if (support)
+ {
+ Assert.Pass("Test skipped! Can't test not supported exception");
+ }
+ else
+ {\r
+ try\r
+ {\r
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();\r
+ foreach (PowerUsageResourceType rtype in Enum.GetValues(typeof(PowerUsageResourceType)))\r
+ {\r
+ rtypes.Add(rtype);\r
+ }\r
+ IDictionary<PowerUsageResourceType, double> result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime);\r
+ Assert.IsTrue(false, "This operation should raise NotSupportedException");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException");\r
+ }\r
+ }\r
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByAppForAllResources_CHECK_ARGUMENT_EXCEPTION()
+ {\r
+ if (support)
+ {
+ try\r
+ {\r
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();\r
+ rtypes.Add(PowerUsageResourceType.Cpu);\r
+ IDictionary<PowerUsageResourceType, double> result = PowerUsage.GetPowerUsage(appID, rtypes, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));\r
+ Assert.IsTrue(false, "This operation should raise ArgumentException");\r
+ }
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception");\r
+ }
+ }
+ else
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }\r
+ }
+
+ [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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByAppForAllResources_CHECK_INVALID_OPERATION_EXCEPTION()\r
+ {\r
+ if (support)\r
+ {\r
+ try\r
+ {\r
+ IList<PowerUsageResourceType> rtypes = new List<PowerUsageResourceType>();\r
+ rtypes.Add(PowerUsageResourceType.Cpu);\r
+ IDictionary<PowerUsageResourceType, double> result = PowerUsage.GetPowerUsage(appID, rtypes, startTime, endTime);\r
+ Assert.Pass("Test skipped! since no system error occured to test Invalid operation");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error");\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }\r
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check if GetPowerUsage() return proper value")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByAppPerResource_CHECK_RESULT()
+ {
+ if (support)\r
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime);\r
+ Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double for the specific resource for the given application in custom interval");\r
+ Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value for the specific resource for the given application in custom interval");\r
+ }\r
+ catch (Exception e)\r
+ {\r
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString());\r
+ Assert.IsTrue(false, e.ToString());\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }
+ }
+
+ [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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByAppPerResource_CHECK_NOT_SUPPORTED_EXCEPTION()
+ {\r
+ if (support)
+ {
+ Assert.Pass("Test skipped! Can't test not supported exception");
+ }
+ else
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime);\r
+ Assert.IsTrue(false, "This operation should raise NotSupportedException");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException");\r
+ }\r
+ }\r
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByAppPerResource_CHECK_ARGUMENT_EXCEPTION()
+ {\r
+ if (support)
+ {
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));\r
+ Assert.IsTrue(false, "This operation should raise ArgumentException");\r
+ }
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception");\r
+ }
+ }
+ else
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }\r
+ }
+
+ [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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByAppPerResource_CHECK_INVALID_OPERATION_EXCEPTION()\r
+ {\r
+ if (support)\r
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(appID, PowerUsageResourceType.Cpu, startTime, endTime);\r
+ Assert.Pass("Test skipped! since no system error occured to test Invalid operation");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error");\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }\r
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check if GetPowerUsage() return proper value")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByApp_CHECK_RESULT()
+ {
+ if (support)\r
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime);\r
+ Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value corresponding to app in double");\r
+ Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value corresponding to app");\r
+ }\r
+ catch (Exception e)\r
+ {\r
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString());\r
+ Assert.IsTrue(false, e.ToString());\r
+ }\r
+ }
+ else\r
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }
+ }\r
+\r
+ [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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByApp_CHECK_NOT_SUPPORTED_EXCEPTION()
+ {\r
+ if (support)
+ {
+ Assert.Pass("Test skipped! Can't test not supported exception");
+ }
+ else
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime);\r
+ Assert.IsTrue(false, "This operation should raise NotSupportedException");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException");\r
+ }\r
+ }\r
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByApp_CHECK_ARGUMENT_EXCEPTION()
+ {\r
+ if (support)
+ {
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(appID, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));\r
+ Assert.IsTrue(false, "This operation should raise ArgumentException");\r
+ }
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception");\r
+ }
+ }
+ else
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }\r
+ }
+
+ [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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByApp_CHECK_INVALID_OPERATION_EXCEPTION()\r
+ {\r
+ if (support)\r
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(appID, startTime, endTime);\r
+ Assert.Pass("Test skipped! since no system error occured to test Invalid operation");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error");\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }\r
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check if GetPowerUsage() return proper value")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByResource_CHECK_RESULT()
+ {
+ if (support)\r
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime);\r
+ Assert.IsTrue(powerUsage is double, "GetPowerUsage() should return power usage value in double by a resource for certain time interval");\r
+ Assert.IsTrue((double)powerUsage >= 0, "GetPowerUsage() should return usage value by a resource for certain time interval");\r
+ }\r
+ catch (Exception e)\r
+ {\r
+ LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, e.ToString());\r
+ Assert.IsTrue(false, e.ToString());\r
+ }\r
+ }
+ else\r
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }
+ }
+
+ [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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByResource_CHECK_NOT_SUPPORTED_EXCEPTION()
+ {\r
+ if (support)
+ {
+ Assert.Pass("Test skipped! Can't test not supported exception");
+ }
+ else
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime);\r
+ Assert.IsTrue(false, "This operation should raise NotSupportedException");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(NotSupportedException), "This operation should raise NotSupportedException");\r
+ }\r
+ }\r
+ }
+
+ [Test]
+ [Category("P2")]
+ [Description("Check if GetPowerUsage() raises argument exception")]
+ [Property("SPEC", "Tizen.System.PowerUsage.GetPowerUsage M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MEX")]
+ [Property("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByResource_CHECK_ARGUMENT_EXCEPTION()
+ {\r
+ if (support)
+ {
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, DateTime.Now.AddDays(1), DateTime.Now.AddDays(2));\r
+ Assert.IsTrue(false, "This operation should raise ArgumentException");\r
+ }
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(ArgumentException), "this operation should raise ArgumentException exception");\r
+ }
+ }
+ else
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }\r
+ }
+
+ [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("AUTHOR", "Venkata Sai Chakradhar Pogiri, v.pogiri@samsung.com")]
+ public void GetPowerUsageByResource_CHECK_INVALID_OPERATION_EXCEPTION()\r
+ {\r
+ if (support)\r
+ {\r
+ try\r
+ {\r
+ object powerUsage = PowerUsage.GetPowerUsage(PowerUsageResourceType.Cpu, startTime, endTime);\r
+ Assert.Pass("Test skipped! since no system error occured to test Invalid operation");\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ Assert.IsTrue(ex.GetType() == typeof(InvalidOperationException), "This operation will raise InvalidOperationException incase of any system error");\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Assert.Pass("Test skipped! Can't test due to not supported exception");\r
+ }\r
+ }
+ }
+}