using Tizen.Applications;
using NUnit.Framework.TUnit;
using NUnit.Framework;
+using System;
+using Tizen.System;
namespace Tizen.WidgetControl.Scale.Tests
{
private const string MyWidgetId = "org.tizen.WidgetCtrlSample";
private const string MyPreviewImage = "preview.png";
+ static bool isWidgetSupported = false;
+
[SetUp]
public void Init()
{
_widgetControl = new Tizen.Applications.WidgetControl(MyWidgetId);
_appInfo = new ApplicationInfo(MyWidgetId);
+
+ Information.TryGetValue("http://tizen.org/feature/shell.appwidget", out isWidgetSupported);
LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for each TEST");
}
{
bool flag = false;
- foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
- {
- if (MyWidgetScale != null)
+ try
+ {\r
+ foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
{
- Assert.AreEqual(MyWidgetScale.Type, Applications.WidgetControl.Scale.SizeType.Basic4x4, "Expects given values to be equal");
- flag = true;
+ if (MyWidgetScale != null)
+ {
+ Assert.AreEqual(MyWidgetScale.Type, Applications.WidgetControl.Scale.SizeType.Basic4x4, "Expects given values to be equal");
+ flag = true;
+ }
}
+ Assert.AreNotEqual(flag, false, "The flag should be 'true'");\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
}
- Assert.AreNotEqual(flag, false, "The flag should be 'true'");
}
[Test]
{
bool flag = false;
- foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
+ try
{
- if (MyWidgetScale != null)
+ foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
{
- Assert.AreEqual(MyWidgetScale.PreviewImagePath, _appInfo.SharedResourcePath + MyPreviewImage, "The value should be equal");
- flag = true;
+ if (MyWidgetScale != null)
+ {
+ Assert.AreEqual(MyWidgetScale.PreviewImagePath, _appInfo.SharedResourcePath + MyPreviewImage, "The value should be equal");
+ flag = true;
+ }
}
+ Assert.AreNotEqual(flag, false, "The falg should be 'true'");\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
}
- Assert.AreNotEqual(flag, false, "The falg should be 'true'");
}
[Test]
{
bool flag = false;
- foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
- {
- if (MyWidgetScale != null)
+ try
+ {\r
+ foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
{
- if (MyWidgetScale.Height >= 0)
+ if (MyWidgetScale != null)
{
- Assert.Pass();
- }
- else
- {
- Assert.Fail("The value should be greater than 0");
- }
+ if (MyWidgetScale.Height >= 0)
+ {
+ Assert.Pass();
+ }
+ else
+ {
+ Assert.Fail("The value should be greater than 0");
+ }
- flag = true;
+ flag = true;
+ }
}
+ Assert.AreNotEqual(flag, false, "The falg should be 'true'");\r
+ }\r
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
}
- Assert.AreNotEqual(flag, false, "The falg should be 'true'");
}
[Test]
{
bool flag = false;
- foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
- {
- if (MyWidgetScale != null)
+ try
+ {\r
+ foreach (Applications.WidgetControl.Scale MyWidgetScale in _widgetControl.GetScales())
{
- if (MyWidgetScale.Width >= 0)
+ if (MyWidgetScale != null)
{
- Assert.Pass();
- }
- else
- {
- Assert.Fail("The value should be greater than 0");
- }
+ if (MyWidgetScale.Width >= 0)
+ {
+ Assert.Pass();
+ }
+ else
+ {
+ Assert.Fail("The value should be greater than 0");
+ }
- flag = true;
+ flag = true;
+ }
}
+ Assert.AreNotEqual(flag, false, "The flag should be 'true'");\r
+ }\r
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
}
- Assert.AreNotEqual(flag, false, "The flag should be 'true'");
}
}
}
[Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
public void WidgetControl_INIT()
{
- var MyWidgetControl = new Tizen.Applications.WidgetControl(MyWidgetId1);
- Assert.IsNotNull(MyWidgetControl, "Object should not be null after initialization");
- MyWidgetControl.Dispose();
+ try
+ {\r
+ var MyWidgetControl = new Tizen.Applications.WidgetControl(MyWidgetId1);
+ Assert.IsNotNull(MyWidgetControl, "Object should not be null after initialization");
+ MyWidgetControl.Dispose();\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
[Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
public void Id_PROPERTY_GET()
{
- Assert.IsInstanceOf<string>(_widgetControl.Id);
- Assert.AreEqual(MyWidgetId, _widgetControl.Id, "Property \"Id\": the get value should be equal");
+ try
+ {\r
+ Assert.IsInstanceOf<string>(_widgetControl.Id);
+ Assert.AreEqual(MyWidgetId, _widgetControl.Id, "Property \"Id\": the get value should be equal");\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
[Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
public void IsNoDisplay_PROPERTY_GET()
{
- Assert.IsInstanceOf<bool>(_widgetControl.IsNoDisplay);
- Assert.AreEqual(false, _widgetControl.IsNoDisplay, "Property \"IsNoDisplay\": the get value should be false");
+ try
+ {\r
+ Assert.IsInstanceOf<bool>(_widgetControl.IsNoDisplay);
+ Assert.AreEqual(false, _widgetControl.IsNoDisplay, "Property \"IsNoDisplay\": the get value should be false");\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
[Property("AUTHOR", "Hwankyu Jhun, h.jhun@samsung.com")]
public void GetScales_RETURN_VALUE()
{
- IEnumerable<Applications.WidgetControl.Scale> MyWidgetScale = _widgetControl.GetScales();
- Assert.IsNotNull(MyWidgetScale, "Object should not be null");
+ try
+ {\r
+ IEnumerable<Applications.WidgetControl.Scale> MyWidgetScale = _widgetControl.GetScales();
+ Assert.IsNotNull(MyWidgetScale, "Object should not be null");\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
[Property("AUTHOR", "Hyunho Kang, hhstark.kang@samsung.com")]
public void CreateAll_RETURN_VALUE()
{
- Tizen.Applications.WidgetControl[] controlArr = Tizen.Applications.WidgetControl.CreateAll(MyWidgetId);
- Assert.IsNotNull(controlArr, "Object should not be null");
- Assert.IsInstanceOf< Tizen.Applications.WidgetControl[]>(controlArr, "The object should be of WidgetControl array");
+ try
+ {\r
+ Tizen.Applications.WidgetControl[] controlArr = Tizen.Applications.WidgetControl.CreateAll(MyWidgetId);
+ Assert.IsNotNull(controlArr, "Object should not be null");
+ Assert.IsInstanceOf<Tizen.Applications.WidgetControl[]>(controlArr, "The object should be of WidgetControl array");\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
[Property("AUTHOR", "Hyunho Kang, hhstark.kang@samsung.com")]
public void GetIconPath_RETURN_VALUE()
{
- string iconPath = _widgetControl.GetIconPath(Lang);
- Assert.IsNotNull(iconPath, "Object should not be null");
- Assert.IsInstanceOf<string>(iconPath);
+ try
+ {\r
+ string iconPath = _widgetControl.GetIconPath(Lang);
+ Assert.IsNotNull(iconPath, "Object should not be null");
+ Assert.IsInstanceOf<string>(iconPath);\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
[Property("AUTHOR", "Hyunho Kang, hhstark.kang@samsung.com")]
public void GetName_RETURN_VALUE()
{
- string name = _widgetControl.GetName(Lang);
- Assert.IsNotNull(name, "Object should not be null");
- Assert.IsInstanceOf<string>(name);
+ try
+ {\r
+ string name = _widgetControl.GetName(Lang);
+ Assert.IsNotNull(name, "Object should not be null");
+ Assert.IsInstanceOf<string>(name);\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
[Property("AUTHOR", "Hyunho Kang, hhstark.kang@samsung.com")]
public void GetWidgetIds_RETURN_VALUE()
{
- string[] idArr = Tizen.Applications.WidgetControl.GetWidgetIds(MyWidgetId);
- Assert.IsNotNull(idArr, "Object should not be null");
- Assert.IsInstanceOf<string[]>(idArr);
+ try
+ {\r
+ string[] idArr = Tizen.Applications.WidgetControl.GetWidgetIds(MyWidgetId);
+ Assert.IsNotNull(idArr, "Object should not be null");
+ Assert.IsInstanceOf<string[]>(idArr);\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
try
{
_widgetControl.Created += OnCreated;
- _widgetControl.Created -= OnCreated;
+ _widgetControl.Created -= OnCreated;\r
+\r
+ }\r
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
}
catch (Exception e)
{
_widgetControl.Destroyed += OnCreated;
_widgetControl.Destroyed -= OnCreated;
}
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
catch (Exception e)
{
Log.Debug(TAG, "Caught Exception" + e.ToString());
_widgetControl.Paused += OnPaused;
_widgetControl.Paused -= OnPaused;
}
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
catch (Exception e)
{
Log.Debug(TAG, "Caught Exception" + e.ToString());
_widgetControl.Resumed += OnResumed;
_widgetControl.Resumed -= OnResumed;
}
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
catch (Exception e)
{
Log.Debug(TAG, "Caught Exception" + e.ToString());
[Property("AUTHOR", "Junghoon Park, jh9216.park@samsung.com")]
public void MainAppId_PROPERTY_GET()
{
- Assert.IsInstanceOf<string>(_widgetControl.MainAppId);
- Assert.AreEqual(_widgetControl.MainAppId, "org.tizen.WidgetCtrlSample");
+ try
+ {\r
+ Assert.IsInstanceOf<string>(_widgetControl.MainAppId);
+ Assert.AreEqual(_widgetControl.MainAppId, "org.tizen.WidgetCtrlSample");\r
+ }
+ catch (NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
[Property("AUTHOR", "Junghoon Park, jh9216.park@samsung.com")]
public void PackageId_PROPERTY_GET()
{
- Assert.IsInstanceOf<string>(_widgetControl.PackageId);
- Assert.AreEqual(_widgetControl.PackageId, "WidgetCtrlSample.Tizen");
+ try
+ {\r
+ Assert.IsInstanceOf<string>(_widgetControl.PackageId);
+ Assert.AreEqual(_widgetControl.PackageId, "WidgetCtrlSample.Tizen");\r
+ }
+ catch(NotSupportedException)
+ {
+ Assert.IsTrue(isWidgetSupported == false, "Invalid NotSupportedException");
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("There should be no exception " + e.ToString());
+ }
}
[Test]
{
try
{
- Assert.Throws<InvalidOperationException>(delegate
- {
- string id = _widgetControl3.SetupAppId;
- });
+ string id = _widgetControl3.SetupAppId;
+ }
+ catch (InvalidOperationException)
+ {\r
+ Assert.Pass("InvalidOperationException passed");\r
}
catch (NotSupportedException)
{