Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2013-11-12 23:00:45 +0400
committerLluis Sanchez <lluis@xamarin.com>2013-11-12 23:01:38 +0400
commit43fa54bd3ebcc5e373a5caa2f49965759373e3a1 (patch)
treebfecb0c8501194f7a8cc39e6ba6921d8056f455e /Testing
parent7b92e6ef15212d29525220d21ce8c035cebfe304 (diff)
[GTK] Fixed label alignment when in wrapping mode
Also added unit tests for label alignment
Diffstat (limited to 'Testing')
-rw-r--r--Testing/Tests/LabelTests.cs71
-rw-r--r--Testing/Tests/ReferenceImages/Label.AlignCenterbin0 -> 1728 bytes
-rw-r--r--Testing/Tests/ReferenceImages/Label.AlignCenterWrappedbin0 -> 2773 bytes
-rw-r--r--Testing/Tests/ReferenceImages/Label.AlignLeftbin0 -> 1708 bytes
-rw-r--r--Testing/Tests/ReferenceImages/Label.AlignLeftWrappedbin0 -> 2786 bytes
-rw-r--r--Testing/Tests/ReferenceImages/Label.AlignRightbin0 -> 1694 bytes
-rw-r--r--Testing/Tests/ReferenceImages/Label.AlignRightWrappedbin0 -> 2813 bytes
-rw-r--r--Testing/Tests/XwtTest.cs10
8 files changed, 81 insertions, 0 deletions
diff --git a/Testing/Tests/LabelTests.cs b/Testing/Tests/LabelTests.cs
index 76c08552..349f7d18 100644
--- a/Testing/Tests/LabelTests.cs
+++ b/Testing/Tests/LabelTests.cs
@@ -24,6 +24,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
+using NUnit.Framework;
namespace Xwt
{
@@ -33,6 +34,76 @@ namespace Xwt
{
return new Label ("Hello World");
}
+
+ [Test]
+ public void DefaultValues ()
+ {
+ var la = new Label ();
+ Assert.AreEqual ("", la.Text);
+ Assert.AreEqual (Alignment.Start, la.TextAlignment);
+ Assert.AreEqual (EllipsizeMode.None, la.Ellipsize);
+ Assert.AreEqual (WrapMode.None, la.Wrap);
+ }
+
+ [Test]
+ public void AlignCenter ()
+ {
+ var la = new Label ("Some text here");
+ la.TextAlignment = Alignment.Center;
+ la.BackgroundColor = Xwt.Drawing.Colors.LightGray;
+ CheckWidgetRender ("Label.AlignCenter", la);
+ }
+
+ [Test]
+ public void AlignCenterWrapped ()
+ {
+ var la = new Label ("Some text here Some text here Some text here Some text here");
+ la.TextAlignment = Alignment.Center;
+ la.Wrap = WrapMode.Word;
+ la.WidthRequest = 200;
+ la.BackgroundColor = Xwt.Drawing.Colors.LightGray;
+ CheckWidgetRender ("Label.AlignCenterWrapped", la);
+ }
+
+ [Test]
+ public void AlignLeft ()
+ {
+ var la = new Label ("Some text here");
+ la.TextAlignment = Alignment.Start;
+ la.BackgroundColor = Xwt.Drawing.Colors.LightGray;
+ CheckWidgetRender ("Label.AlignLeft", la);
+ }
+
+ [Test]
+ public void AlignLeftWrapped ()
+ {
+ var la = new Label ("Some text here Some text here Some text here Some text here");
+ la.TextAlignment = Alignment.Start;
+ la.Wrap = WrapMode.Word;
+ la.WidthRequest = 200;
+ la.BackgroundColor = Xwt.Drawing.Colors.LightGray;
+ CheckWidgetRender ("Label.AlignLeftWrapped", la);
+ }
+
+ [Test]
+ public void AlignRight ()
+ {
+ var la = new Label ("Some text here");
+ la.TextAlignment = Alignment.End;
+ la.BackgroundColor = Xwt.Drawing.Colors.LightGray;
+ CheckWidgetRender ("Label.AlignRight", la);
+ }
+
+ [Test]
+ public void AlignRightWrapped ()
+ {
+ var la = new Label ("Some text here Some text here Some text here Some text here");
+ la.TextAlignment = Alignment.End;
+ la.Wrap = WrapMode.Word;
+ la.WidthRequest = 200;
+ la.BackgroundColor = Xwt.Drawing.Colors.LightGray;
+ CheckWidgetRender ("Label.AlignRightWrapped", la);
+ }
}
}
diff --git a/Testing/Tests/ReferenceImages/Label.AlignCenter b/Testing/Tests/ReferenceImages/Label.AlignCenter
new file mode 100644
index 00000000..01b6eb60
--- /dev/null
+++ b/Testing/Tests/ReferenceImages/Label.AlignCenter
Binary files differ
diff --git a/Testing/Tests/ReferenceImages/Label.AlignCenterWrapped b/Testing/Tests/ReferenceImages/Label.AlignCenterWrapped
new file mode 100644
index 00000000..bb5d6c78
--- /dev/null
+++ b/Testing/Tests/ReferenceImages/Label.AlignCenterWrapped
Binary files differ
diff --git a/Testing/Tests/ReferenceImages/Label.AlignLeft b/Testing/Tests/ReferenceImages/Label.AlignLeft
new file mode 100644
index 00000000..1cf548f3
--- /dev/null
+++ b/Testing/Tests/ReferenceImages/Label.AlignLeft
Binary files differ
diff --git a/Testing/Tests/ReferenceImages/Label.AlignLeftWrapped b/Testing/Tests/ReferenceImages/Label.AlignLeftWrapped
new file mode 100644
index 00000000..b60e96b7
--- /dev/null
+++ b/Testing/Tests/ReferenceImages/Label.AlignLeftWrapped
Binary files differ
diff --git a/Testing/Tests/ReferenceImages/Label.AlignRight b/Testing/Tests/ReferenceImages/Label.AlignRight
new file mode 100644
index 00000000..a991200a
--- /dev/null
+++ b/Testing/Tests/ReferenceImages/Label.AlignRight
Binary files differ
diff --git a/Testing/Tests/ReferenceImages/Label.AlignRightWrapped b/Testing/Tests/ReferenceImages/Label.AlignRightWrapped
new file mode 100644
index 00000000..b084f5ad
--- /dev/null
+++ b/Testing/Tests/ReferenceImages/Label.AlignRightWrapped
Binary files differ
diff --git a/Testing/Tests/XwtTest.cs b/Testing/Tests/XwtTest.cs
index 3f00a44d..4f3d1369 100644
--- a/Testing/Tests/XwtTest.cs
+++ b/Testing/Tests/XwtTest.cs
@@ -68,6 +68,16 @@ namespace Xwt
ev.WaitForEvent ();
Application.MainLoop.DispatchPendingEvents ();
}
+
+ public void CheckWidgetRender (string refImageName, Xwt.Widget widget, int winWidth = 300, int winHeight = 100)
+ {
+ using (var win = new Window { Width = winWidth, Height = winHeight }) {
+ win.Content = widget;
+ ShowWindow (win);
+ var img = Toolkit.CurrentEngine.RenderWidget (widget);
+ ReferenceImageManager.CheckImage (refImageName, img);
+ }
+ }
}
static class EventHelper