From: Lokesh Date: Fri, 27 Sep 2019 04:37:31 +0000 (+0530) Subject: [Network.Stc][TCSACR-217][Add new TC's for Network.Stc] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F41%2F214841%2F11;p=test%2Ftct%2Fcsharp%2Fapi.git [Network.Stc][TCSACR-217][Add new TC's for Network.Stc] Change-Id: I23119b0661eeb3319dcff000500c9fabe5582586 Signed-off-by: Lokesh --- diff --git a/tct-suite-vs/Tizen.Network.Stc.Tests/Program.cs b/tct-suite-vs/Tizen.Network.Stc.Tests/Program.cs new file mode 100755 index 0000000..e0f15eb --- /dev/null +++ b/tct-suite-vs/Tizen.Network.Stc.Tests/Program.cs @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 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.Network.Stc.Tests/Tizen.Network.Stc.Tests.csproj b/tct-suite-vs/Tizen.Network.Stc.Tests/Tizen.Network.Stc.Tests.csproj new file mode 100755 index 0000000..8bc4dfc --- /dev/null +++ b/tct-suite-vs/Tizen.Network.Stc.Tests/Tizen.Network.Stc.Tests.csproj @@ -0,0 +1,39 @@ + + + + + Exe + tizen60 + + + + + true + + + + portable + + + None + + + + + + + + + + + Runtime + + + + + + + + + + diff --git a/tct-suite-vs/Tizen.Network.Stc.Tests/Tizen.Network.Stc.Tests.sln b/tct-suite-vs/Tizen.Network.Stc.Tests/Tizen.Network.Stc.Tests.sln new file mode 100755 index 0000000..95473b8 --- /dev/null +++ b/tct-suite-vs/Tizen.Network.Stc.Tests/Tizen.Network.Stc.Tests.sln @@ -0,0 +1,43 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29306.81 +MinimumVisualStudioVersion = 15.0.26124.0 +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 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Network.Stc.Tests", "Tizen.Network.Stc.Tests.csproj", "{1C5F6E4E-4395-499D-A8EB-634F2C99FBC7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {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}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9E7C1FD-CB38-42F7-AC43-7BD2E5B4D216}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FDB8025A-C029-461F-895E-287B4C65939B}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.Build.0 = Release|Any CPU + {1C5F6E4E-4395-499D-A8EB-634F2C99FBC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C5F6E4E-4395-499D-A8EB-634F2C99FBC7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C5F6E4E-4395-499D-A8EB-634F2C99FBC7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C5F6E4E-4395-499D-A8EB-634F2C99FBC7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ED382B91-9930-40B6-B3D7-362304C78680} + SolutionGuid = {04B2328D-BB06-4F71-B97D-C99481600474} + EndGlobalSection +EndGlobal diff --git a/tct-suite-vs/Tizen.Network.Stc.Tests/shared/res/Tizen.Network.Stc.Tests.png b/tct-suite-vs/Tizen.Network.Stc.Tests/shared/res/Tizen.Network.Stc.Tests.png new file mode 100755 index 0000000..9765b1b Binary files /dev/null and b/tct-suite-vs/Tizen.Network.Stc.Tests/shared/res/Tizen.Network.Stc.Tests.png differ diff --git a/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcManager.cs b/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcManager.cs new file mode 100755 index 0000000..1e3b0fe --- /dev/null +++ b/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcManager.cs @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2019 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 Tizen.System; +using System.Threading.Tasks; +using StcUtils; +using System.Collections.Generic; + +namespace Tizen.Network.Stc.Tests +{ + [TestFixture] + [Description("Tizen.Network.Stc.StcManager Tests")] + public class StcManagerTests + { + private bool s_isStcSupported = false; + + [SetUp] + public void Init() + { + Log.Info(Globals.LogTag, "Preconditions for each TEST"); + Information.TryGetValue("http://tizen.org/feature/network.traffic_control", out s_isStcSupported); + } + + [Test] + [Category("P1")] + [Description("A task containing list of NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.StcManager.GetStatisticsAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public async Task GetStatisticsAsync_GET_STATS() + { + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A task containing list of NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.StcManager.GetStatisticsAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public async Task GetStatisticsAsync_APPID_NULL() + { + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + _filter.AppId = null; + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P2")] + [Description("A task containing list of NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.StcManager.GetStatisticsAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public async Task GetStatisticsAsync_INVALID_FROM() + { + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + _filter.From = new DateTime(1968, 1, 1); + + Log.Info(Globals.LogTag, "ArgumentException should be thrown"); + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + + Assert.IsTrue(false, "ArgumentException should be thrown"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (ArgumentException) + { + Log.Info(Globals.LogTag, "Inside ArgumentException: Invalid 'From'"); + Assert.IsTrue(true, "Inside ArgumentException: Invalid 'From'"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P2")] + [Description("A task containing list of NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.StcManager.GetStatisticsAsync M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public async Task GetStatisticsAsync_INVALID_TO() + { + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + _filter.To = new DateTime(1968, 1, 1); + + Log.Info(Globals.LogTag, "ArgumentException should be thrown"); + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + + Assert.IsTrue(false, "ArgumentException should be thrown"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (ArgumentException) + { + Log.Info(Globals.LogTag, "Inside ArgumentException: Invalid 'To'"); + Assert.IsTrue(true, "Inside ArgumentException: Invalid 'To'"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + } +} diff --git a/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcStatistics.cs b/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcStatistics.cs new file mode 100755 index 0000000..44b27f4 --- /dev/null +++ b/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcStatistics.cs @@ -0,0 +1,491 @@ +/* + * Copyright(c) 2019 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 Tizen.System; +using StcUtils; +using System.Threading.Tasks; +using System.Collections.Generic; + +namespace Tizen.Network.Stc.Tests +{ + [TestFixture] + [Description("Tizen.Network.Stc.NetworkStatistics Tests")] + class NetworkStatisticsTests + { + private bool s_isStcSupported = false; + + [SetUp] + public void Init() + { + Log.Info(Globals.LogTag, "Preconditions for each TEST"); + Information.TryGetValue("http://tizen.org/feature/network.traffic_control", out s_isStcSupported); + } + + [Test] + [Category("P1")] + [Description("A property to get the application ID from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.AppId A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task AppId_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC AppId_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = stats.GetEnumerator()) + { + _iter.MoveNext(); + + string _appId = _iter.Current.AppId; + Assert.IsTrue(_appId != null, "AppId Is Null"); + Log.Info(Globals.LogTag, "AppId: " + _appId); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "Inside NullReferenceException: 'stats' is null"); + Assert.True(true, "Inside NullReferenceException: 'stats' is null"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get interface name from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.InterfaceName A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task InterfaceName_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC InterfaceName_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + string _interfaceName = _iter.Current.InterfaceName; + Assert.IsTrue(_interfaceName != null, "InterfaceName Is Null"); + Log.Info(Globals.LogTag, "InterfaceName: " + _interfaceName); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "'stats' is null: Inside NullReferenceException"); + Assert.True(true, "'stats' is null: Inside NullReferenceException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get 'from' value(start) of time interval from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.From A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task From_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC From_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + + DateTime _from = _iter.Current.From; + Log.Info(Globals.LogTag, "FromDate: " + _from); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "'stats' is null: Inside NullReferenceException"); + Assert.True(true, "'stats' is null: Inside NullReferenceException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get 'to' value(end) of time interval from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.To A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task To_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC To_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + + DateTime _to = _iter.Current.To; + Log.Info(Globals.LogTag, "ToDate: " + _to); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "Inside NullReferenceException: 'stats' is null"); + Assert.True(true, "Inside NullReferenceException: 'stats' is null"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get the interface type from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.InterfaceType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task InterfaceType_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC InterfaceType_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + + NetworkInterface _interfaceType = _iter.Current.InterfaceType; + Log.Info(Globals.LogTag, "InterfaceType: " + _interfaceType); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "Inside NullReferenceException: 'stats' is null"); + Assert.True(true, "Inside NullReferenceException: 'stats' is null"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get incoming counter from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.IncomingCounter A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task IncomingCounter_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC IncomingCounter_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + + long _incomingCounter = _iter.Current.IncomingCounter; + Log.Info(Globals.LogTag, "IncomingCounter: " + _incomingCounter); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "Inside NullReferenceException: 'stats' is null"); + Assert.True(true, "Inside NullReferenceException: 'stats' is null"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get outgoing counter from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.OutgoingCounter A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task OutgoingCounter_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC OutgoingCounter_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + + long _outgoingCounter = _iter.Current.OutgoingCounter; + Log.Info(Globals.LogTag, "OutgoingCounter: " + _outgoingCounter); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "Inside NullReferenceException: 'stats' is null"); + Assert.True(true, "Inside NullReferenceException: 'stats' is null"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get the roaming type from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.IsRoaming A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task IsRoaming_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC IsRoaming_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + + bool _isRoaming = _iter.Current.IsRoaming; + Log.Info(Globals.LogTag, "IsRoaming: " + _isRoaming); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "Inside NullReferenceException: 'stats' is null"); + Assert.True(true, "Inside NullReferenceException: 'stats' is null"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get the network protocol type from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.Protocol A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task Protocol_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC Protocol_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + + NetworkProtocol _protocol = _iter.Current.Protocol; + Log.Info(Globals.LogTag, "Protocol: " + _protocol); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "Inside NullReferenceException: 'stats' is null"); + Assert.True(true, "Inside NullReferenceException: 'stats' is null"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("A property to get the application state from NetworkStatistics")] + [Property("SPEC", "Tizen.Network.Stc.NetworkStatistics.ApplicationState A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "prashanth kumar prasadam, prasadam.p@samsung.com")] + public async Task ApplicationState_GETPROPERTY() + { + Log.Info(Globals.LogTag, "Started TC ApplicationState_GETPROPERTY"); + try + { + StatisticsFilter _filter = StcSetup.MakeFilter(); + + Task> _task = StcManager.GetStatisticsAsync(_filter); + var _stats = await _task; + await Task.Delay(1000); + using (IEnumerator _iter = _stats.GetEnumerator()) + { + _iter.MoveNext(); + + ApplicationStateType _applicationState = _iter.Current.ApplicationState; + Log.Info(Globals.LogTag, "ApplicationState: " + _applicationState); + } + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (TypeInitializationException e) + { + Assert.IsTrue(s_isStcSupported == false && e.InnerException.GetType() == typeof(NotSupportedException), "Invalid NotSupportedException or TypeInitializationException"); + } + catch (NullReferenceException) + { + Log.Info(Globals.LogTag, "Inside NullReferenceException: 'stats' is null"); + Assert.True(true, "Inside NullReferenceException: 'stats' is null"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + } +} diff --git a/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcStatsFilter.cs b/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcStatsFilter.cs new file mode 100755 index 0000000..1f6d309 --- /dev/null +++ b/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/TSStcStatsFilter.cs @@ -0,0 +1,428 @@ +/* + * Copyright (c) 2019 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 Tizen.System; +using StcUtils; + +namespace Tizen.Network.Stc.Tests +{ + [TestFixture] + [Description("Tizen.Network.Stc.StatisticsFilter Tests")] + public class StatisticsFilterTests + { + private bool s_isStcSupported = false; + + [SetUp] + public void Init() + { + Log.Info(Globals.LogTag, "Preconditions for each TEST"); + Information.TryGetValue("http://tizen.org/feature/network.traffic_control", out s_isStcSupported); + } + + [Test] + [Category("P1")] + [Description("Create a StatisticsFilter object")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.StatisticsFilter C")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "CONSTR")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void StatisticsFilter_INIT() + { + try + { + var _filter = new StatisticsFilter(); + Assert.IsNotNull(_filter, "StatisticsFilter object reference is found Null"); + Assert.IsInstanceOf(_filter, "Creating StatisticsFilter is failed"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test AppId property of StatisticsFilter")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.AppId A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void AppId_PROPERTY() + { + string _appId = "org.tizen.browser"; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.AppId = _appId; + Assert.AreEqual(_appId, _filter.AppId, "AppId set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test From property of StatisticsFilter")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.From A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void From_PROPERTY() + { + DateTime? _from = DateTime.Now.AddMonths(-1); + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.From = _from; + Assert.AreEqual(_from, _filter.From, "From set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test To property of StatisticsFilter")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.To A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void To_PROPERTY() + { + DateTime? _to = DateTime.Now; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.To = _to; + Assert.AreEqual(_to, _filter.To, "To set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test InterfaceType property of StatisticsFilter with enum value as Others")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.InterfaceType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void InterfaceType_PROPERTY_OTHERS() + { + NetworkInterface? _interfaceType = NetworkInterface.Others; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.InterfaceType = _interfaceType; + Assert.AreEqual(_interfaceType, _filter.InterfaceType, "InterfaceType set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test InterfaceType property of StatisticsFilter with enum value as Datacall")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.InterfaceType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void InterfaceType_PROPERTY_DATACALL() + { + NetworkInterface? _interfaceType = NetworkInterface.Datacall; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.InterfaceType = _interfaceType; + Assert.AreEqual(_interfaceType, _filter.InterfaceType, "InterfaceType set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test InterfaceType property of StatisticsFilter with enum value as Wifi")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.InterfaceType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void InterfaceType_PROPERTY_WIFI() + { + NetworkInterface? _interfaceType = NetworkInterface.Wifi; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.InterfaceType = _interfaceType; + Assert.AreEqual(_interfaceType, _filter.InterfaceType, "InterfaceType set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test InterfaceType property of StatisticsFilter with enum value as Wired")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.InterfaceType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void InterfaceType_PROPERTY_WIRED() + { + NetworkInterface? _interfaceType = NetworkInterface.Wired; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.InterfaceType = _interfaceType; + Assert.AreEqual(_interfaceType, _filter.InterfaceType, "InterfaceType set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test InterfaceType property of StatisticsFilter with enum value as Bluetooth")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.InterfaceType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void InterfaceType_PROPERTY_BLUETOOTH() + { + NetworkInterface? _interfaceType = NetworkInterface.Bluetooth; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.InterfaceType = _interfaceType; + Assert.AreEqual(_interfaceType, _filter.InterfaceType, "InterfaceType set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test InterfaceType property of StatisticsFilter with enum value as All")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.InterfaceType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void InterfaceType_PROPERTY_ALL() + { + NetworkInterface? _interfaceType = NetworkInterface.All; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.InterfaceType = _interfaceType; + Assert.AreEqual(_interfaceType, _filter.InterfaceType, "InterfaceType set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test TimePeriod property of StatisticsFilter with enum value as Hour")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.TimePeriod A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void TimePeriod_PROPERTY_HOUR() + { + TimePeriodType? _timePeriod = TimePeriodType.Hour; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.TimePeriod = _timePeriod; + Assert.AreEqual(_timePeriod, _filter.TimePeriod, "TimePeriod set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test TimePeriod property of StatisticsFilter with enum value as Day")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.TimePeriod A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void TimePeriod_PROPERTY_DAY() + { + TimePeriodType? _timePeriod = TimePeriodType.Day; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.TimePeriod = _timePeriod; + Assert.AreEqual(_timePeriod, _filter.TimePeriod, "TimePeriod set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test TimePeriod property of StatisticsFilter with enum value as Week")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.TimePeriod A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void TimePeriod_PROPERTY_WEEK() + { + TimePeriodType? _timePeriod = TimePeriodType.Week; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.TimePeriod = _timePeriod; + Assert.AreEqual(_timePeriod, _filter.TimePeriod, "TimePeriod set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + + [Test] + [Category("P1")] + [Description("Test TimePeriod property of StatisticsFilter with enum value as Month")] + [Property("SPEC", "Tizen.Network.Stc.StatisticsFilter.TimePeriod A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRW")] + [Property("AUTHOR", "Lokesh kasana, l.kasana@samsung.com")] + public void TimePeriod_PROPERTY_MONTH() + { + TimePeriodType? _timePeriod = TimePeriodType.Month; + try + { + StatisticsFilter _filter = new StatisticsFilter(); + + _filter.TimePeriod = _timePeriod; + Assert.AreEqual(_timePeriod, _filter.TimePeriod, "TimePeriod set and get is not successful"); + } + catch (NotSupportedException) + { + Assert.IsTrue(s_isStcSupported == false, "Invalid NotSupportedException"); + } + catch (Exception ex) + { + Assert.True(false, "Exception occurs. Msg : " + ex.ToString()); + } + Log.Info(Globals.LogTag, "Successfully done"); + } + } +} diff --git a/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/support/StcSetup.cs b/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/support/StcSetup.cs new file mode 100755 index 0000000..3650eb5 --- /dev/null +++ b/tct-suite-vs/Tizen.Network.Stc.Tests/testcase/support/StcSetup.cs @@ -0,0 +1,28 @@ +using System; +using Tizen.Network.Stc; + +namespace StcUtils +{ + static internal class Globals + { + internal const string LogTag = "StcTC"; + } + + public class StcSetup + { + public static StatisticsFilter MakeFilter() + { + Tizen.Log.Info(Globals.LogTag, "StcSetup.MakeFilter"); + + StatisticsFilter _filter = new StatisticsFilter + { + AppId = "TOTAL_IPV4", + From = DateTime.Now.AddMonths(-1), + To = DateTime.Now, + InterfaceType = NetworkInterface.Wifi, + TimePeriod = TimePeriodType.Week + }; + return _filter; + } + } +} diff --git a/tct-suite-vs/Tizen.Network.Stc.Tests/tizen-manifest.xml b/tct-suite-vs/Tizen.Network.Stc.Tests/tizen-manifest.xml new file mode 100755 index 0000000..93ce297 --- /dev/null +++ b/tct-suite-vs/Tizen.Network.Stc.Tests/tizen-manifest.xml @@ -0,0 +1,17 @@ + + + + + Tizen.Network.Stc.Tests.png + + + + http://tizen.org/privilege/network.get + http://tizen.org/privilege/appmanager.launch + +