reftests: Add test for the overflow methods
authorBenjamin Otte <otte@redhat.com>
Thu, 9 Jun 2022 23:09:49 +0000 (01:09 +0200)
committerBenjamin Otte <otte@redhat.com>
Sat, 11 Jun 2022 00:15:08 +0000 (02:15 +0200)
Reference is using labels again

gtk/gtkinscription.c
testsuite/reftests/inscription-overflow.ref.ui [new file with mode: 0644]
testsuite/reftests/inscription-overflow.ui [new file with mode: 0644]
testsuite/reftests/meson.build

index e043e3a0e4ecfecda4b96a790d235cc3cc5e77e6..155f334ad80a13a26fe29a1c7d90fe4021474b55 100644 (file)
@@ -367,8 +367,8 @@ gtk_inscription_measure (GtkWidget      *widget,
 
 static void
 gtk_inscription_get_layout_location (GtkInscription *self,
-                                     int            *x_out,
-                                     int            *y_out)
+                                     float          *x_out,
+                                     float          *y_out)
 {
   GtkWidget *widget = GTK_WIDGET (self);
   const int widget_width = gtk_widget_get_width (widget);
@@ -376,7 +376,7 @@ gtk_inscription_get_layout_location (GtkInscription *self,
   PangoRectangle logical;
   float xalign;
   int baseline;
-  int x, y;
+  float x, y;
 
   g_assert (x_out);
   g_assert (y_out);
@@ -451,7 +451,7 @@ gtk_inscription_snapshot (GtkWidget   *widget,
 {
   GtkInscription *self = GTK_INSCRIPTION (widget);
   GtkStyleContext *context;
-  int lx, ly;
+  float lx, ly;
 
   if (!self->text || (*self->text == '\0'))
     return;
diff --git a/testsuite/reftests/inscription-overflow.ref.ui b/testsuite/reftests/inscription-overflow.ref.ui
new file mode 100644 (file)
index 0000000..e9b131b
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkWindow">
+    <property name="default-width">200</property>
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkOverlay">
+            <child>
+              <object class="GtkLabel" />
+            </child>
+            <child type="overlay">
+              <object class="GtkLabel">
+                <property name="label" translatable="yes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="label" translatable="yes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</property>
+            <property name="ellipsize">start</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="label" translatable="yes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</property>
+            <property name="ellipsize">middle</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkLabel">
+            <property name="label" translatable="yes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</property>
+            <property name="ellipsize">end</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/testsuite/reftests/inscription-overflow.ui b/testsuite/reftests/inscription-overflow.ui
new file mode 100644 (file)
index 0000000..4884893
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <object class="GtkWindow">
+    <property name="default-width">200</property>
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkInscription">
+            <property name="text" translatable="yes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</property>
+            <property name="text-overflow">clip</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkInscription">
+            <property name="text" translatable="yes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</property>
+            <property name="text-overflow">ellipsize-start</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkInscription">
+            <property name="text" translatable="yes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</property>
+            <property name="text-overflow">ellipsize-middle</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkInscription">
+            <property name="text" translatable="yes">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</property>
+            <property name="text-overflow">ellipsize-end</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
index 3001d0e127733d04c0b24f607faee4964d284b44..7c03cb7062cfbb9935f4cba17f8d3c46031a6be9 100644 (file)
@@ -369,6 +369,8 @@ testdata = [
   'image-load-from-file.ui',
   'inscription-markup.ref.ui',
   'inscription-markup.ui',
+  'inscription-overflow.ref.ui',
+  'inscription-overflow.ui',
   'label-attribute-preference.css',
   'label-attribute-preference.ref.ui',
   'label-attribute-preference.ui',