From: chakradhar Date: Tue, 11 Aug 2020 05:40:33 +0000 (+0530) Subject: [ACR-310]Add Tizen.System.PowerUsage.Tests from 5.5 to 6.0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e4272d87f8c081116e45f14a725227bf573fb90;p=test%2Ftct%2Fcsharp%2Fapi.git [ACR-310]Add Tizen.System.PowerUsage.Tests from 5.5 to 6.0 Change-Id: Ic107388b3914d7f2ed751ca6988fd61c6201f3b1 --- diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/Program.cs b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Program.cs new file mode 100755 index 000000000..3373c7d55 --- /dev/null +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Program.cs @@ -0,0 +1,52 @@ +/* + * 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 System; +using NUnitLite.TUnit; +using AutoTemplate; + +namespace XamarinForTizen.Tizen +{ + + class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication + { + private static App _app; + protected override void OnCreate() + { + base.OnCreate(); + + Console.WriteLine("TCT : OnCreate()"); + _app = new App(); + LoadApplication(_app); + + TRunner t = new TRunner(); + t.LoadTestsuite(); + t.Execute(); + } + + public static App getApp() + { + return _app; + } + static void Main(string[] args) + { + Console.WriteLine("TCT : Main()"); + var app = new Program(); + global::Xamarin.Forms.Platform.Tizen.Forms.Init(app); + app.Run(args); + } + } +} diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.csproj b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.csproj new file mode 100755 index 000000000..21e479b86 --- /dev/null +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.csproj @@ -0,0 +1,40 @@ + + + + + Exe + tizen80 + Tizen + + + + + true + + + + portable + + + None + + + + + + + + + + + Runtime + + + + + + + + + + diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.sln b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.sln new file mode 100755 index 000000000..13afb17cc --- /dev/null +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/Tizen.System.PowerUsage.Tests.sln @@ -0,0 +1,78 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26730.15 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.PowerUsage.Tests", "Tizen.System.PowerUsage.Tests.csproj", "{D92BEEAC-3B2A-45F8-8C53-53B92550404A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.framework", "..\nunit.framework\nunit.framework.csproj", "{B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunitlite", "..\nunitlite\nunitlite.csproj", "{FDB8025A-C029-461F-895E-287B4C65939B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoTemplate", "..\Template\AutoTemplate\AutoTemplate.csproj", "{B11ABB0C-C3C1-4B5C-8251-A15628A775F3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x64.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.ActiveCfg = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Debug|x86.Build.0 = Debug|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|Any CPU.Build.0 = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x64.Build.0 = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.ActiveCfg = Release|Any CPU + {D92BEEAC-3B2A-45F8-8C53-53B92550404A}.Release|x86.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x64.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x86.ActiveCfg = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Debug|x86.Build.0 = Debug|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x64.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x64.Build.0 = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x86.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|x86.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x64.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x64.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x86.ActiveCfg = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Debug|x86.Build.0 = Debug|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x64.Build.0 = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|x86.Build.0 = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x64.ActiveCfg = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x64.Build.0 = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x86.ActiveCfg = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Debug|x86.Build.0 = Debug|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.Build.0 = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x64.ActiveCfg = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x64.Build.0 = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x86.ActiveCfg = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ED382B91-9930-40B6-B3D7-362304C78680} + EndGlobalSection +EndGlobal diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/shared/res/Tizen.System.PowerUsage.Tests.png b/tct-suite-vs/Tizen.System.PowerUsage.Tests/shared/res/Tizen.System.PowerUsage.Tests.png new file mode 100755 index 000000000..9765b1bda Binary files /dev/null and b/tct-suite-vs/Tizen.System.PowerUsage.Tests/shared/res/Tizen.System.PowerUsage.Tests.png differ diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs b/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs new file mode 100755 index 000000000..c1e90a0d1 --- /dev/null +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/testcase/TSPowerUsage.cs @@ -0,0 +1,820 @@ +/* + * 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("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, 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 rtypes = new List(); + rtypes.Add(PowerUsageResourceType.Cpu); + IDictionary 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, 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 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] + [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, 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 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"); + } + } + 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, 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 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"); + } + } + 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, 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 rtypes = new List(); + rtypes.Add(PowerUsageResourceType.Cpu); + IDictionary 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, 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 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"); + } + 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!"); + } + } + } +} diff --git a/tct-suite-vs/Tizen.System.PowerUsage.Tests/tizen-manifest.xml b/tct-suite-vs/Tizen.System.PowerUsage.Tests/tizen-manifest.xml new file mode 100755 index 000000000..8846419f9 --- /dev/null +++ b/tct-suite-vs/Tizen.System.PowerUsage.Tests/tizen-manifest.xml @@ -0,0 +1,17 @@ + + + + + Tizen.System.PowerUsage.Tests.png + + + + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/systemmonitor + +