*/
using System;
+using System.IO;
using System.Threading.Tasks;
using NUnit.Framework;
using NUnit.Framework.TUnit;
-using ElmSharp;
using ElmSharpApplication.Tizen;
namespace ElmSharp.Tests
await ManualTest.WaitForConfirm();
_image.Clicked -= OnClicked;
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Test: Check wheter image loading is working or not asynchronously.")]
+ [Property("SPEC", "ElmSharp.Image.LoadAsync M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "kangho.hur@samsung.com")]
+ [Precondition(1, "Ensure network connectoin is available")]
+ [Step(1, "Click run TC")]
+ [Step(2, "Click 'File' Button")]
+ [Step(3, "Click 'URI' Button")]
+ [Step(4, "Wait for 5~10 seconds")]
+ [Step(6, "Click 'Stream' Button")]
+ [Step(7, "Click 'Invalid' Button")]
+ [Step(8, "Test results are automatically determined")]
+ [Postcondition(1, "NA")]
+ public static async Task LoadAsync_Check()
+ {
+ bool checkFile = false;
+ bool checkUri = false;
+ bool checkStream = false;
+ bool checkInvalid = true;
+ bool checkLoadingCompleted = false;
+ bool checkLoadingFailed = false;
+
+ Box box = new Box(_window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ };
+ box.Show();
+
+ Box buttonBox = new Box(_window)
+ {
+ IsHorizontal = true,
+ AlignmentX = -1,
+ AlignmentY = 0,
+ };
+ buttonBox.Show();
+
+ Button btnFile = new Button(_window)
+ {
+ Text = "File",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnFile.Show();
+
+ Button btnUri = new Button(_window)
+ {
+ Text = "URI",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnUri.Show();
+
+ Button btnStream = new Button(_window)
+ {
+ Text = "Stream",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnStream.Show();
+
+ Button btnInvalid = new Button(_window)
+ {
+ Text = "Invalid",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ btnInvalid.Show();
+
+ Label info = new Label(_window)
+ {
+ Color = Color.White,
+ AlignmentX = -1,
+ AlignmentY = 0,
+ WeightX = 1
+ };
+ info.Show();
+
+ Image image = new Image(_window)
+ {
+ IsFixedAspect = true,
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ image.Show();
+
+ image.LoadingCompleted += (s, e) =>
+ {
+ checkLoadingCompleted = true;
+ info.Text = "Image has been loaded successfully.";
+ };
+
+ image.LoadingFailed += (s, e) =>
+ {
+ checkLoadingFailed = true;
+ info.Text = "Image loading has been failed.";
+ ManualTest.Confirm();
+ };
+
+ buttonBox.PackEnd(btnFile);
+ buttonBox.PackEnd(btnUri);
+ buttonBox.PackEnd(btnStream);
+ buttonBox.PackEnd(btnInvalid);
+
+ if (ElmSharpProfile.GetProfile() != ElmSharpProfile.WearableProfile)
+ {
+ buttonBox.PackEnd(image);
+ box.PackEnd(buttonBox);
+ box.PackEnd(info);
+ }
+ else
+ {
+ box.PackEnd(image);
+ Scroller scroller = new Scroller(_window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1,
+ };
+ scroller.Show();
+ scroller.SetContent(buttonBox);
+ box.PackEnd(scroller);
+ box.PackEnd(info);
+ }
+
+ box.PackEnd(buttonBox);
+ box.PackEnd(info);
+
+ btnFile.Clicked += async (s, e) =>
+ {
+ info.Text = "";
+ checkFile = await image.LoadAsync(Program.Current.DirectoryInfo.Resource + "test.jpg");
+ };
+
+ btnUri.Clicked += async (s, e) =>
+ {
+ info.Text = "";
+ checkUri = await image.LoadAsync("http://pe.tedcdn.com/images/ted/2e306b9655267cee35e45688ace775590b820510_615x461.jpg");
+ };
+
+ btnStream.Clicked += async (s, e) =>
+ {
+ info.Text = "";
+ FileStream fs = new FileStream(Program.Current.DirectoryInfo.Resource + "test2.jpg", FileMode.Open, FileAccess.Read);
+ checkStream = await image.LoadAsync(fs);
+ fs.Dispose();
+ };
+
+ btnInvalid.Clicked += async (s, e) =>
+ {
+ info.Text = "";
+ checkInvalid = await image.LoadAsync(Program.Current.DirectoryInfo.Resource + "null.jpg");
+ };
+
+ _testPage.ExecuteTC(box);
+ await ManualTest.WaitForConfirm();
+
+ //Clean up
+ box.Unrealize();
+ box = null;
+
+ // Validation
+ if (checkFile && checkUri && checkStream && !checkInvalid && checkLoadingCompleted && checkLoadingFailed)
+ {
+ Assert.Pass("Image.LoadAsync working properly");
+ }
+ else
+ {
+ Assert.Fail("Image.LoadAsync doesn't working properly");
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test: Check LoadingCompleted is invoked successfully")]
+ [Property("SPEC", "ElmSharp.Image.LoadingCompleted E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "kangho.hur@samsung.com")]
+ [Precondition(1, "NA")]
+ [Step(1, "Click run TC")]
+ [Step(2, "Click 'Load' button")]
+ [Step(3, "Click 'Check' button")]
+ [Step(4, "Test results are automatically determined")]
+ [Postcondition(1, "NA")]
+ public static async Task LoadingCompleted_Check()
+ {
+ bool isValid = false;
+ Box box = new Box(_window)
+ {
+ IsHorizontal = true,
+ AlignmentX = -1,
+ AlignmentY = 0,
+ };
+ box.Show();
+
+ Image image = new Image(_window)
+ {
+ IsFixedAspect = true,
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ image.Show();
+
+ image.LoadingCompleted += (s, e) =>
+ {
+ isValid = true;
+ };
+
+ Button loadButton = new Button(_window)
+ {
+ Text = "Load",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ loadButton.Show();
+ loadButton.Clicked += async (s, e) =>
+ {
+ await image.LoadAsync(Program.Current.DirectoryInfo.Resource + "test.jpg");
+ };
+
+ Button validateButton = new Button(_window)
+ {
+ Text = "Check",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ validateButton.Show();
+ validateButton.Clicked += (s, e) =>
+ {
+ ManualTest.Confirm();
+ };
+
+ box.PackEnd(loadButton);
+ box.PackEnd(validateButton);
+ box.PackEnd(image);
+ _testPage.ExecuteTC(box);
+ await ManualTest.WaitForConfirm();
+
+ //Clean up
+ box.Unrealize();
+ box = null;
+
+ if (isValid)
+ {
+ Assert.Pass("Image.LoadingCompleted working properly");
+ }
+ else
+ {
+ Assert.Fail("Image.LoadingCompleted doesn't working properly");
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Test: Check LoadingFailed is invoked successfully")]
+ [Property("SPEC", "ElmSharp.Image.LoadingFailed E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "kangho.hur@samsung.com")]
+ [Precondition(1, "NA")]
+ [Step(1, "Click run TC")]
+ [Step(2, "Click 'Load' button")]
+ [Step(3, "Click 'Check' button")]
+ [Step(3, "Test results are automatically determined")]
+ [Postcondition(1, "NA")]
+ public static async Task LoadingFailed_Check()
+ {
+ bool isValid = false;
+ Box box = new Box(_window)
+ {
+ IsHorizontal = true,
+ AlignmentX = -1,
+ AlignmentY = 0,
+ };
+ box.Show();
+
+ Image image = new Image(_window)
+ {
+ IsFixedAspect = true,
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ image.Show();
+
+ image.LoadingFailed += (s, e) =>
+ {
+ isValid = true;
+ };
+
+ Button loadButton = new Button(_window)
+ {
+ Text = "Load",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ loadButton.Show();
+ loadButton.Clicked += async (s, e) =>
+ {
+ await image.LoadAsync("null.jpg");
+ };
+
+ Button validateButton = new Button(_window)
+ {
+ Text = "Check",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1
+ };
+ validateButton.Show();
+ validateButton.Clicked += (s, e) =>
+ {
+ ManualTest.Confirm();
+ };
+
+ box.PackEnd(loadButton);
+ box.PackEnd(validateButton);
+ box.PackEnd(image);
+ _testPage.ExecuteTC(box);
+ await ManualTest.WaitForConfirm();
+
+ //Clean up
+ box.Unrealize();
+ box = null;
+
+ if (isValid)
+ {
+ Assert.Pass("Image.LoadingFailed working properly");
+ }
+ else
+ {
+ Assert.Fail("Image.LoadingFailed doesn't working properly");
+ }
+ }
}
}
\ No newline at end of file
_mark = 1;
}
- [Test]
- [Category("P1")]
- [Description("Check LoadingCompleted is invoked successfully")]
- [Property("SPEC", "ElmSharp.Image.LoadingCompleted E")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "EVL")]
- [Property("AUTHOR", "Qian Sui, qian.sui@samsung.com")]
- public async Task LoadingCompleted_CHECK()
- {
- _mark = 0;
- _image.LoadingCompleted += OnLoadingCompleted;
- await _image.LoadAsync(Program.Current.DirectoryInfo.Resource + "test.jpg");
-
- Thread.Sleep(2000);
- if (_mark == 0)
- {
- Assert.Fail("The event should be invoked, but is not invoked");
- }
- _image.LoadingCompleted -= OnLoadingCompleted;
- }
-
- [Test]
- [Category("P1")]
- [Description("Check LoadingFailed is invoked successfully")]
- [Property("SPEC", "ElmSharp.Image.LoadingFailed E")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "EVL")]
- [Property("AUTHOR", "Qian Sui, qian.sui@samsung.com")]
- public async Task LoadingFailed_CHECK()
- {
- _mark = 0;
- _image.LoadingFailed += OnLoadingFailed;
- await _image.LoadAsync(Program.Current.DirectoryInfo.Resource + "null.jpg");
-
- Thread.Sleep(2000);
- if (_mark == 0)
- {
- Assert.Fail("The event should be invoked, but is not invoked");
- }
- _image.LoadingFailed -= OnLoadingFailed;
- }
-
[Test]
[Category("P1")]
[Description("Create a Image instance. Check whether object is successfully created or not.")]
Assert.IsTrue(mark);
}
- [Test]
- [Category("P1")]
- [Description("Check LoadAsync(System.Uri) return value")]
- [Property("SPEC", "ElmSharp.Image.LoadAsync M")]
- [Property("COVPARAM", "Uri, CancellationToken")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "MR")]
- [Precondition(1, "make sure the device can access to the internet")]
- [Property("AUTHOR", "Qian Sui, qian.sui@samsung.com")]
- public async Task LoadAsync_Uri_CHECK()
- {
- bool mark = await _image.LoadAsync("http://pe.tedcdn.com/images/ted/2e306b9655267cee35e45688ace775590b820510_615x461.jpg");
- Assert.IsTrue(mark);
- }
-
- [Test]
- [Category("P1")]
- [Description("Check LoadAsync(System.IO.Stream) return value")]
- [Property("SPEC", "ElmSharp.Image.LoadAsync M")]
- [Property("COVPARAM", "string, CancellationToken")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "MR")]
- [Property("AUTHOR", "Qian Sui, qian.sui@samsung.com")]
- public async Task LoadAsync_File_CHECK()
- {
- bool mark = await _image.LoadAsync(Program.Current.DirectoryInfo.Resource + "test.jpg");
- Assert.IsTrue(mark, "LoadAsync method return true");
- }
-
- [Test]
- [Category("P1")]
- [Description("Check LoadAsync(System.IO.Stream) return value")]
- [Property("SPEC", "ElmSharp.Image.LoadAsync M")]
- [Property("COVPARAM", "Stream, CancellationToken")]
- [Property("SPEC_URL", "-")]
- [Property("CRITERIA", "MR")]
- [Property("AUTHOR", "Qian Sui, qian.sui@samsung.com")]
- public async Task LoadAsync_Stream_CHECK()
- {
- FileStream fs = new FileStream(Program.Current.DirectoryInfo.Resource + "test.jpg", FileMode.Open, FileAccess.Read);
- bool mark = await _image.LoadAsync(fs);
- Assert.IsTrue(mark);
- fs.Dispose();
- }
-
[Test]
[Category("P0")]
[Description("Check whether setting and getting BackgroundColor are equal.")]