examples: move tests to src/examples
authorHermet Park <hermetpark@gmail.com>
Fri, 18 Sep 2020 15:34:46 +0000 (00:34 +0900)
committerHermet Park <chuneon.park@samsung.com>
Mon, 21 Sep 2020 10:30:47 +0000 (19:30 +0900)
tests is now officially placed in src/examples,
default is turned off, only necessaries turn it on.

ex) meson . build -Dexamples=true

+ this examples are required efl 'elementary' package.

Change-Id: I60be4a45d520eab138e25212fbc4de3691bf1127

48 files changed:
meson.build
meson_options.txt
src/bin/meson.build
src/examples/main.cpp [deleted file]
src/examples/meson.build
src/examples/svgs/batman1.svg [moved from test/svgs/batman1.svg with 100% similarity]
src/examples/svgs/bojo.svg [moved from test/svgs/bojo.svg with 100% similarity]
src/examples/svgs/bzrfeed.svg [moved from test/svgs/bzrfeed.svg with 100% similarity]
src/examples/svgs/cartman.svg [moved from test/svgs/cartman.svg with 100% similarity]
src/examples/svgs/dst.svg [moved from test/svgs/dst.svg with 100% similarity]
src/examples/svgs/duke.svg [moved from test/svgs/duke.svg with 100% similarity]
src/examples/svgs/eee.svg [moved from test/svgs/eee.svg with 100% similarity]
src/examples/svgs/favorite_on.svg [moved from test/svgs/favorite_on.svg with 100% similarity]
src/examples/svgs/google.svg [moved from test/svgs/google.svg with 100% similarity]
src/examples/svgs/ibm.svg [moved from test/svgs/ibm.svg with 100% similarity]
src/examples/svgs/lineargrad1.svg [moved from test/svgs/lineargrad1.svg with 100% similarity]
src/examples/svgs/radialgrad1.svg [moved from test/svgs/radialgrad1.svg with 100% similarity]
src/examples/svgs/scion.svg [moved from test/svgs/scion.svg with 100% similarity]
src/examples/svgs/tiger.svg [moved from test/svgs/tiger.svg with 100% similarity]
src/examples/svgs/yadis.svg [moved from test/svgs/yadis.svg with 100% similarity]
src/examples/svgs/yinyang.svg [moved from test/svgs/yinyang.svg with 100% similarity]
src/examples/testArc.cpp [moved from test/testArc.cpp with 100% similarity]
src/examples/testAsync.cpp [moved from test/testAsync.cpp with 100% similarity]
src/examples/testBlending.cpp [moved from test/testBlending.cpp with 100% similarity]
src/examples/testBoundary.cpp [moved from test/testBoundary.cpp with 100% similarity]
src/examples/testCapi.cpp [moved from test/testCapi.c with 95% similarity]
src/examples/testCommon.h [moved from test/testCommon.h with 100% similarity]
src/examples/testCustomTransform.cpp [moved from test/testCustomTransform.cpp with 100% similarity]
src/examples/testDirectUpdate.cpp [moved from test/testDirectUpdate.cpp with 100% similarity]
src/examples/testDuplicate.cpp [moved from test/testDuplicate.cpp with 100% similarity]
src/examples/testGradientTransform.cpp [moved from test/testGradientTransform.cpp with 100% similarity]
src/examples/testLinearGradient.cpp [moved from test/testLinearGradient.cpp with 100% similarity]
src/examples/testMultiCanvas.cpp [moved from test/testMultiCanvas.cpp with 97% similarity]
src/examples/testMultiShapes.cpp [moved from test/testMultiShapes.cpp with 100% similarity]
src/examples/testPath.cpp [moved from test/testPath.cpp with 100% similarity]
src/examples/testPathCopy.cpp [moved from test/testPathCopy.cpp with 100% similarity]
src/examples/testRadialGradient.cpp [moved from test/testRadialGradient.cpp with 100% similarity]
src/examples/testScene.cpp [moved from test/testScene.cpp with 100% similarity]
src/examples/testSceneTransform.cpp [moved from test/testSceneTransform.cpp with 100% similarity]
src/examples/testShape.cpp [moved from test/testShape.cpp with 100% similarity]
src/examples/testStroke.cpp [moved from test/testStroke.cpp with 100% similarity]
src/examples/testStrokeLine.cpp [moved from test/testStrokeLine.cpp with 100% similarity]
src/examples/testSvg.cpp [moved from test/testSvg.cpp with 96% similarity]
src/examples/testSvg2.cpp [moved from test/testSvg2.cpp with 100% similarity]
src/examples/testTransform.cpp [moved from test/testTransform.cpp with 100% similarity]
src/examples/testUpdate.cpp [moved from test/testUpdate.cpp with 100% similarity]
src/meson.build
test/makefile [deleted file]

index 981e753..8cff0aa 100644 (file)
@@ -6,6 +6,8 @@ project('thorvg',
 
 config_h = configuration_data()
 
+add_project_arguments('-DEXAMPLE_DIR="@0@/src/examples/svgs"'.format(meson.current_source_dir()), language : 'cpp')
+
 if get_option('engines').contains('sw') == true
     config_h.set10('THORVG_SW_RASTER_SUPPORT', true)
 endif
index 14a31ed..d784bb2 100644 (file)
@@ -26,4 +26,9 @@ option('tools',
    type: 'array',
    choices: ['', 'svg2png'],
    value: [''],
-   description: 'Enable building ThorVG Tools')
+   description: 'Enable building thorvg tools')
+
+option('examples',
+    type: 'boolean',
+    value: false,
+    description: 'Enable building examples')
index fa68f84..9ee39e9 100644 (file)
@@ -1,4 +1,5 @@
 if get_option('tools').contains('svg2png') == true
+   message('Enable Tools: svg2png')
    subdir('svg2png')
 endif
 
diff --git a/src/examples/main.cpp b/src/examples/main.cpp
deleted file mode 100644 (file)
index 8bd265a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <iostream>
-
-using namespace std;
-
-int
-main(int argc, char *argv[])
-{
-   cout << "test thorvg!" << endl;
-
-   return 0;
-}
index 4ba6e9b..4c40890 100644 (file)
@@ -1 +1,36 @@
-executable('thorvg_sample', 'main.cpp')
+examples_dep = dependency('elementary', required : true)
+
+source_file = [
+    'testArc.cpp',
+    'testAsync.cpp',
+    'testBlending.cpp',
+    'testBoundary.cpp',
+    'testCapi.cpp',
+    'testCustomTransform.cpp',
+    'testDirectUpdate.cpp',
+    'testDuplicate.cpp',
+    'testGradientTransform.cpp',
+    'testLinearGradient.cpp',
+    'testMultiCanvas.cpp',
+    'testMultiShapes.cpp',
+    'testPathCopy.cpp',
+    'testPath.cpp',
+    'testRadialGradient.cpp',
+    'testScene.cpp',
+    'testSceneTransform.cpp',
+    'testShape.cpp',
+    'testStroke.cpp',
+    'testStrokeLine.cpp',
+    'testSvg2.cpp',
+    'testSvg.cpp',
+    'testTransform.cpp',
+    'testUpdate.cpp',
+]
+
+foreach current_file : source_file
+    name = current_file.split('.')[0]
+    executable(name, current_file,
+           include_directories : headers,
+           link_with : thorvg_lib,
+           dependencies : examples_dep)
+endforeach
similarity index 100%
rename from test/svgs/dst.svg
rename to src/examples/svgs/dst.svg
similarity index 100%
rename from test/svgs/eee.svg
rename to src/examples/svgs/eee.svg
similarity index 100%
rename from test/svgs/ibm.svg
rename to src/examples/svgs/ibm.svg
similarity index 100%
rename from test/testArc.cpp
rename to src/examples/testArc.cpp
similarity index 95%
rename from test/testCapi.c
rename to src/examples/testCapi.cpp
index 82df1f5..bdcc349 100644 (file)
@@ -126,13 +126,13 @@ void testCapi()
 \r
     tvg_shape_get_path_commands(shape, &cmds, &cmdCnt);\r
     printf("---- First Shape Commands(%u) ----\n", cmdCnt);\r
-    for(int i=0; i < cmdCnt; ++i) {\r
+    for(uint32_t i = 0; i < cmdCnt; ++i) {\r
         printf("%d\n", cmds[i]);\r
     }\r
 \r
     tvg_shape_get_path_coords(shape, &pts, &ptsCnt);\r
     printf("---- First Shape Points(%u) ----\n", ptsCnt);\r
-    for(int i=0; i < ptsCnt; ++i) {\r
+    for(uint32_t i = 0; i < ptsCnt; ++i) {\r
         printf("(%.2lf, %.2lf)\n", pts[i].x, pts[i].y);\r
     }\r
     \r
similarity index 100%
rename from test/testCommon.h
rename to src/examples/testCommon.h
similarity index 97%
rename from test/testMultiCanvas.cpp
rename to src/examples/testMultiCanvas.cpp
index d39898c..e8739af 100644 (file)
@@ -216,9 +216,9 @@ int main(int argc, char **argv)
         evas_object_smart_callback_add(win, "delete,request", win_del, 0);
 
         if (tvgEngine == tvg::CanvasEngine::Sw) {
-            eina_file_dir_list("./svgs", EINA_TRUE, tvgSwTest, win);
+            eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgSwTest, win);
         } else {
-            eina_file_dir_list("./svgs", EINA_TRUE, tvgGlTest, win);
+            eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, tvgGlTest, win);
         }
 
         evas_object_geometry_set(win, 0, 0, WIDTH, HEIGHT);
@@ -234,4 +234,4 @@ int main(int argc, char **argv)
         cout << "engine is not supported" << endl;
     }
     return 0;
-}
\ No newline at end of file
+}
similarity index 100%
rename from test/testPath.cpp
rename to src/examples/testPath.cpp
similarity index 96%
rename from test/testSvg.cpp
rename to src/examples/testSvg.cpp
index 7e3d775..7086127 100644 (file)
@@ -14,12 +14,10 @@ static std::vector<unique_ptr<tvg::Picture>> pictures;
 
 void svgDirCallback(const char* name, const char* path, void* data)
 {
-    tvg::Canvas* canvas = static_cast<tvg::Canvas*>(data);
-
     auto picture = tvg::Picture::gen();
 
     char buf[PATH_MAX];
-    sprintf(buf,"%s/%s", path, name);
+    sprintf(buf, "/%s/%s", path, name);
 
     if (picture->load(buf) != tvg::Result::Success) return;
 
@@ -61,7 +59,7 @@ void tvgDrawCmds(tvg::Canvas* canvas)
 
     if (canvas->push(move(shape)) != tvg::Result::Success) return;
 
-    eina_file_dir_list("./svgs", EINA_TRUE, svgDirCallback, canvas);
+    eina_file_dir_list(EXAMPLE_DIR, EINA_TRUE, svgDirCallback, canvas);
 
     /* This showcase shows you asynchrounous loading of svg.
        For this, pushing pictures at a certian sync time.
similarity index 100%
rename from test/testSvg2.cpp
rename to src/examples/testSvg2.cpp
index c32a993..8741ef2 100644 (file)
@@ -29,8 +29,6 @@ thorvg_lib = library(
        gnu_symbol_visibility  : 'hidden',
 )
 
-subdir('bin')
-
 thorvg_dep = declare_dependency(
        include_directories: headers,
        link_with : thorvg_lib
@@ -45,3 +43,10 @@ pkg_mod.generate(
        filebase     : 'thorvg',
        description  : 'A Thor library for rendering vector graphics'
 )
+
+subdir('bin')
+
+if get_option('examples') == true
+    message('Enable Examples')
+    subdir('examples')
+endif
diff --git a/test/makefile b/test/makefile
deleted file mode 100644 (file)
index b5028b1..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-all:
-       gcc -o testShape testShape.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testMultiShapes testMultiShapes.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testBoundary testBoundary.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testPath testPath.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testPathCopy testPathCopy.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testBlending testBlending.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testUpdate testUpdate.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testDirectUpdate testDirectUpdate.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testScene testScene.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testTransform testTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testCustomTransform testCustomTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testSceneTransform testSceneTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testStroke testStroke.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testStrokeLine testStrokeLine.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testLinearGradient testLinearGradient.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testRadialGradient testRadialGradient.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testGradientTransform testGradientTransform.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testSvg testSvg.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testSvg2 testSvg2.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testAsync testAsync.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testArc testArc.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testMultiCanvas testMultiCanvas.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testDuplicate testDuplicate.cpp -g -lstdc++ `pkg-config --cflags --libs elementary thorvg`
-       gcc -o testCapi testCapi.c -g `pkg-config --cflags --libs elementary thorvg`