Move examples from tests/interactive to a new top-level
authorEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 1 May 2012 17:30:10 +0000 (18:30 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 1 May 2012 18:00:35 +0000 (19:00 +0100)
The example code that is meant to be XIncluded into the API reference
should not be part of the interactive test suite: it's code that it is
meant to be used as a reference implementation - whereas the interactive
test suite should be allowed to be lean and test behaviour even in nasty
ways. In short: the test suite should not be the place where we show off
idiomatic code for educational purposes.

23 files changed:
Makefile.am
clutter/clutter-actor.c
clutter/clutter-bin-layout.c
clutter/clutter-bind-constraint.c
clutter/clutter-canvas.c
clutter/clutter-constraint.c
clutter/clutter-drag-action.c
clutter/clutter-drop-action.c
clutter/clutter-image.c
clutter/clutter-main.c
configure.ac
examples/Makefile.am [new file with mode: 0644]
examples/README [new file with mode: 0644]
examples/basic-actor.c [moved from tests/interactive/test-actor.c with 96% similarity]
examples/bin-layout.c [moved from tests/interactive/test-bin-layout.c with 98% similarity]
examples/bind-constraint.c [moved from tests/interactive/test-constraints.c with 97% similarity]
examples/canvas.c [moved from tests/interactive/test-canvas.c with 95% similarity]
examples/constraints.c [moved from tests/interactive/test-snap-constraint.c with 97% similarity]
examples/drag-action.c [moved from tests/interactive/test-drag.c with 98% similarity]
examples/drop-action.c [moved from tests/interactive/test-drop.c with 98% similarity]
examples/image-content.c [moved from tests/interactive/test-image-box.c with 95% similarity]
examples/threads.c [moved from tests/interactive/test-threads.c with 97% similarity]
tests/interactive/Makefile.am

index ba5e54d..c8b3de9 100644 (file)
@@ -2,7 +2,7 @@ include $(top_srcdir)/build/autotools/Makefile.am.silent
 
 NULL =
 
-SUBDIRS = clutter tests doc po build
+SUBDIRS = clutter tests examples doc po build
 
 # XXX - this is a massive hack to make autoreconf honour the ACLOCAL_FLAGS
 # that jhbuild sets while still retaining build/autotools as the authoritative
index 025d1a1..56b13d3 100644 (file)
  *   of children from a ClutterActor, use the #ClutterContainer::actor-removed
  *   signal.</para>
  *   <informalexample><programlisting>
- * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../tests/interactive/test-actor.c">
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/basic-actor.c">
  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
  * </xi:include>
  *   </programlisting></informalexample>
index f8245b1..8ba2157 100644 (file)
@@ -52,7 +52,7 @@
  * <example id="example-clutter-bin-layout">
  *  <title>How to pack actors inside a BinLayout</title>
  *  <programlisting>
- * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../tests/interactive/test-bin-layout.c">
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/bin-layout.c">
  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
  * </xi:include>
  *  </programlisting>
index 51b3e35..c645873 100644 (file)
@@ -80,7 +80,7 @@
  * <example id="bind-constraint-example">
  *   <title>Animating the offset property of ClutterBindConstraint</title>
  *   <programlisting>
- * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../tests/interactive/test-constraints.c">
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/bind-constraint.c">
  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
  * </xi:include>
  *   </programlisting>
index 4e6e766..de29489 100644 (file)
@@ -38,7 +38,7 @@
  *
  * <informalexample id="canvas-example">
  *   <programlisting>
- * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../tests/interactive/test-canvas.c">
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/canvas.c">
  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
  * </xi:include>
  *   </programlisting>
index 61f6fc6..9b481b5 100644 (file)
@@ -91,7 +91,9 @@
  *       <graphic fileref="constraints-example.png" format="PNG"/>
  *     </figure>
  *     <programlisting>
- *<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../../../../tests/interactive/test-snap-constraint.c" parse="text"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include>
+ *<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../../../../examples/constraints.c" parse="text">
+ *  <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
+ *</xi:include>
  *     </programlisting>
  *     <para>You can try resizing interactively the #ClutterStage and verify
  *     that the three #ClutterActor<!-- -->s maintain the same position and
index 0de8c99..cd25ecd 100644 (file)
@@ -57,7 +57,7 @@
  * <example id="drag-action-example">
  *   <title>A simple draggable actor</title>
  *   <programlisting>
- * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../tests/interactive/test-drag.c">
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/drag-action.c">
  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
  * </xi:include>
  *   </programlisting>
index 90b238f..e91a3cd 100644 (file)
@@ -52,7 +52,7 @@
  * <example id="drop-action-example">
  *   <title>Drop targets</title>
  *   <programlisting>
- * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../tests/interactive/test-drop.c">
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/drop-action.c">
  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
  * </xi:include>
  *   </programlisting>
index d1c766a..95d88b2 100644 (file)
@@ -31,7 +31,7 @@
  * image data.
  *
  * <informalexample><programlisting>
- * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../tests/interactive/test-image-box.c">
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/image-content.c">
  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
  * </xi:include>
  * </programlisting></informalexample>
index a412f67..7e4bef8 100644 (file)
@@ -81,7 +81,7 @@
  *   <example id="worker-thread-example">
  *     <title>A worker thread example</title>
  *     <programlisting>
- * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../tests/interactive/test-thread.c">
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../examples/threads.c">
  *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
  * </xi:include>
  *     </programlisting>
index 686505e..18b7923 100644 (file)
@@ -1121,6 +1121,8 @@ AC_CONFIG_FILES([
        tests/micro-bench/Makefile
        tests/performance/Makefile
 
+        examples/Makefile
+
        doc/Makefile
        doc/reference/Makefile
        doc/reference/clutter/Makefile
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644 (file)
index 0000000..3f46d21
--- /dev/null
@@ -0,0 +1,39 @@
+include $(top_srcdir)/build/autotools/Makefile.am.silent
+
+all_examples = \
+       basic-actor \
+       bind-constraint \
+       canvas \
+       constraints \
+       drag-action \
+       drop-action \
+       threads
+
+if PIXBUF_TESTS
+all_examples += \
+       bin-layout \
+       image-content
+endif
+
+INCLUDES = \
+       -I$(top_srcdir)                 \
+       -I$(top_srcdir)/clutter         \
+       -I$(top_builddir)/clutter
+
+LDADD = \
+       $(top_builddir)/clutter/libclutter-@CLUTTER_API_VERSION@.la \
+       $(CLUTTER_LIBS) \
+       $(GDK_PIXBUF_LIBS) \
+       -lm
+
+AM_CFLAGS = $(CLUTTER_CFLAGS) $(GDK_PIXBUF_CFLAGS)
+
+AM_CPPFLAGS = \
+       -DTESTS_DATADIR=\""$(abs_top_srcdir)/tests/data"\" \
+       -DG_DISABLE_SINGLE_INCLUDES \
+       -DGLIB_DISABLE_DEPRECATION_WARNINGS \
+       -DCLUTTER_DISABLE_DEPRECATION_WARNINGS
+
+noinst_PROGRAMS = $(all_examples)
+
+-include $(top_srcdir)/build/autotools/Makefile.am.gitignore
diff --git a/examples/README b/examples/README
new file mode 100644 (file)
index 0000000..d3e3556
--- /dev/null
@@ -0,0 +1,10 @@
+The code in this directory is meant to be XIncluded into the Clutter API
+reference, and thus is to be considered part of the Clutter documentation.
+
+As such, the code MUST be:
+
+  - correct;
+  - idiomatic, i.e. show how a task is meant to be achieved using the
+    best possible practices given the current API;
+  - well documented;
+  - ready for copy and paste.
similarity index 96%
rename from tests/interactive/test-actor.c
rename to examples/basic-actor.c
index 9801fc1..5778223 100644 (file)
@@ -1,5 +1,4 @@
 #include <stdlib.h>
-#include <gmodule.h>
 #include <clutter/clutter.h>
 
 #define SIZE    128
@@ -84,8 +83,8 @@ animate_rotation (ClutterActor *actor,
   return CLUTTER_EVENT_STOP;
 }
 
-G_MODULE_EXPORT int
-test_actor_main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *stage, *vase;
   ClutterActor *flowers[3];
@@ -152,9 +151,3 @@ test_actor_main (int argc, char *argv[])
 
   return EXIT_SUCCESS;
 }
-
-G_MODULE_EXPORT const char *
-test_actor_describe (void)
-{
-  return "Basic example of actor usage.";
-}
similarity index 98%
rename from tests/interactive/test-bin-layout.c
rename to examples/bin-layout.c
index 807d5f2..048f3b4 100644 (file)
@@ -1,5 +1,4 @@
 #include <stdlib.h>
-#include <gmodule.h>
 #include <cairo.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <clutter/clutter.h>
@@ -160,8 +159,8 @@ redraw_canvas (ClutterActor  *actor,
                            clutter_actor_get_height (actor));
 }
 
-G_MODULE_EXPORT int
-test_bin_layout_main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *stage, *box, *bg, *icon, *emblem, *label;
   ClutterLayoutManager *layout;
@@ -306,9 +305,3 @@ test_bin_layout_main (int argc, char *argv[])
 
   return EXIT_SUCCESS;
 }
-
-G_MODULE_EXPORT const char *
-test_bin_layout_describe (void)
-{
-  return "BinLayout layout manager example";
-}
similarity index 97%
rename from tests/interactive/test-constraints.c
rename to examples/bind-constraint.c
index 172ba9b..4278e18 100644 (file)
@@ -1,5 +1,4 @@
 #include <stdlib.h>
-#include <gmodule.h>
 #include <clutter/clutter.h>
 
 #define RECT_SIZE       128
@@ -155,8 +154,8 @@ on_button_release (ClutterActor *actor,
   return TRUE;
 }
 
-G_MODULE_EXPORT int
-test_constraints_main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *stage, *rect;
   ClutterConstraint *constraint;
@@ -245,9 +244,3 @@ test_constraints_main (int argc, char *argv[])
 
   return EXIT_SUCCESS;
 }
-
-G_MODULE_EXPORT const char *
-test_constraints_describe (void)
-{
-  return "Visualize usage of Bind and Align constraints";
-}
similarity index 95%
rename from tests/interactive/test-canvas.c
rename to examples/canvas.c
index 01f11c9..c4e2aa3 100644 (file)
@@ -80,8 +80,8 @@ invalidate_clock (gpointer data_)
   return TRUE;
 }
 
-G_MODULE_EXPORT int
-test_canvas_main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *stage, *actor;
   ClutterContent *canvas;
@@ -131,9 +131,3 @@ test_canvas_main (int argc, char *argv[])
 
   return EXIT_SUCCESS;
 }
-
-G_MODULE_EXPORT const char *
-test_canvas_describe (void)
-{
-  return "Simple 2D clock using the Canvas content";
-}
similarity index 97%
rename from tests/interactive/test-snap-constraint.c
rename to examples/constraints.c
index 6a492d1..532eb32 100644 (file)
@@ -1,11 +1,8 @@
 #include <stdlib.h>
-#include <gmodule.h>
-
 #include <clutter/clutter.h>
 
-G_MODULE_EXPORT int
-test_snap_constraint_main (int   argc,
-                           char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *stage, *layer_a, *layer_b, *layer_c;
 
similarity index 98%
rename from tests/interactive/test-drag.c
rename to examples/drag-action.c
index 05bc5cd..ee5a839 100644 (file)
@@ -1,5 +1,4 @@
 #include <stdlib.h>
-#include <gmodule.h>
 #include <clutter/clutter.h>
 
 static gboolean
@@ -148,8 +147,8 @@ static GOptionEntry entries[] = {
   { NULL }
 };
 
-G_MODULE_EXPORT int
-test_drag_main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *stage, *handle;
   ClutterAction *action;
similarity index 98%
rename from tests/interactive/test-drop.c
rename to examples/drop-action.c
index 0427b02..f14d145 100644 (file)
@@ -169,8 +169,8 @@ on_target_drop (ClutterDropAction *action,
   add_drag_object (actor);
 }
 
-G_MODULE_EXPORT int
-test_drop_main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *dummy;
 
@@ -243,9 +243,3 @@ test_drop_main (int argc, char *argv[])
 
   return EXIT_SUCCESS;
 }
-
-G_MODULE_EXPORT const char *
-test_drop_describe (void)
-{
-  return "Drop action support";
-}
similarity index 95%
rename from tests/interactive/test-image-box.c
rename to examples/image-content.c
index c4b8244..2c7ad6d 100644 (file)
@@ -1,5 +1,4 @@
 #include <stdlib.h>
-#include <gmodule.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <clutter/clutter.h>
 
@@ -47,14 +46,8 @@ on_clicked (ClutterClickAction *action,
     cur_gravity = 0;
 }
 
-G_MODULE_EXPORT const char *
-test_image_box_describe (void)
-{
-  return "A test with image content.";
-}
-
-G_MODULE_EXPORT int
-test_image_box_main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *stage, *box, *text;
   ClutterContent *image;
similarity index 97%
rename from tests/interactive/test-threads.c
rename to examples/threads.c
index 31baa88..e0fd6a8 100644 (file)
@@ -1,6 +1,5 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <gmodule.h>
 #include <clutter/clutter.h>
 
 /* our thread-specific data */
@@ -195,8 +194,8 @@ on_key_press_event (ClutterStage *stage,
   return FALSE;
 }
 
-G_MODULE_EXPORT int
-test_threads_main (int argc, char *argv[])
+int
+main (int argc, char *argv[])
 {
   ClutterActor *stage;
   ClutterActor *rect;
@@ -273,9 +272,3 @@ test_threads_main (int argc, char *argv[])
 
   return EXIT_SUCCESS;
 }
-
-const char *
-test_threads_describe (void)
-{
-  return "Multi-threading programming with Clutter";
-}
index 72b545d..3669c36 100644 (file)
@@ -8,8 +8,6 @@ UNIT_TESTS = \
        test-scale.c \
         test-actors.c \
        test-shader-effects.c \
-       test-depth.c \
-       test-threads.c \
        test-script.c \
        test-grab.c \
        test-cogl-shader-arbfp.c \
@@ -43,21 +41,15 @@ UNIT_TESTS = \
        test-flow-layout.c \
        test-box-layout.c \
        test-stage-sizing.c \
-       test-drag.c \
-       test-constraints.c \
        test-scrolling.c \
        test-swipe-action.c \
        test-cogl-point-sprites.c \
        test-table-layout.c \
        test-path-constraint.c \
-       test-snap-constraint.c \
        test-state-script.c \
-       test-drop.c \
        test-devices.c \
-       test-actor.c \
        test-transitions.c \
        test-content.c \
-       test-canvas.c \
        test-keyframe-transition.c \
        test-scroll-actor.c
 
@@ -67,9 +59,7 @@ endif
 
 if PIXBUF_TESTS
 UNIT_TESTS += \
-       test-bin-layout.c \
-       test-image.c \
-       test-image-box.c
+       test-image.c
 endif
 
 if OS_WIN32