added libtest.
This commit is contained in:
@@ -77,4 +77,22 @@
|
||||
</target>
|
||||
|
||||
|
||||
|
||||
<target type="Program" name="libtest" >
|
||||
<includes type="c" >
|
||||
$(gwenhywfar_cflags)
|
||||
-I$(topsrcdir)/src/lib
|
||||
-I$(topbuilddir)/src/lib
|
||||
-I$(topbuilddir)
|
||||
-I$(topsrcdir)
|
||||
-I$(srcdir)
|
||||
</includes>
|
||||
|
||||
<setVar name="local/cflags">$(visibility_cflags)</setVar>
|
||||
<sources>libtest.c</sources>
|
||||
<useTargets>aqdiagram</useTargets>
|
||||
<libraries>$(gwenhywfar_libs)</libraries>
|
||||
</target>
|
||||
|
||||
|
||||
</gwbuild>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/***************************************************************************
|
||||
begin : Thut Oct 07 2020
|
||||
copyright : (C) 2020 by Martin Preuss
|
||||
copyright : (C) 2023 by Martin Preuss
|
||||
email : martin@libchipcard.de
|
||||
|
||||
***************************************************************************
|
||||
@@ -12,136 +12,57 @@
|
||||
#endif
|
||||
|
||||
#include <aqdiagram/aqdiagram.h>
|
||||
#include <aqdiagram/draw/context_cairo.h>
|
||||
#include <aqdiagram/graph/dataset.h>
|
||||
#include <aqdiagram/graph/graph.h>
|
||||
#include <aqdiagram/placement/o_hlayout-t.h>
|
||||
|
||||
#include <gwenhywfar/gwenhywfar.h>
|
||||
#include <gwenhywfar/cgui.h>
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
|
||||
int testGraph1()
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
AQDG_DRAW_CONTEXT *g;
|
||||
int graphWidth=1024;
|
||||
int graphHeight=768;
|
||||
int rv;
|
||||
GWEN_GUI *gui;
|
||||
GWEN_TEST_FRAMEWORK *tf;
|
||||
|
||||
g=AQDB_ContextCairo_Png_new(outFile, graphWidth, graphHeight);
|
||||
if (g) {
|
||||
AF_GRAPH *gr;
|
||||
AF_GRAPH_DATASET *ds;
|
||||
GWEN_DB_NODE *dbConfig;
|
||||
GWEN_DB_NODE *dbT;
|
||||
|
||||
ds=AQDG_Graph_DataSet_new();
|
||||
|
||||
AQDG_Graph_DataSet_SetTitle(ds, "Test Title");
|
||||
AQDG_Graph_DataSet_SetSubTitle(ds, "Subtitle");
|
||||
|
||||
AQDG_Graph_DataSet_SetDataTypeX(ds, AQDG_Graph_DataSet_DataType_Date);
|
||||
AQDG_Graph_DataSet_SetLabelX(ds, "Date");
|
||||
|
||||
AQDG_Graph_DataSet_SetDataTypeY(ds, AQDG_Graph_DataSet_DataType_Double);
|
||||
AQDG_Graph_DataSet_SetLabelY(ds, "EUR");
|
||||
AQDG_Graph_DataSet_SetPrecisionY(ds, 2);
|
||||
|
||||
AQDG_Graph_DataSet_AdjustXRange(ds);
|
||||
AQDG_Graph_DataSet_AdjustYRange(ds);
|
||||
AQDG_Graph_DataSet_AddTicks(ds);
|
||||
|
||||
dbConfig=GWEN_DB_Group_new("config");
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "penTitle");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "frontColour", (int)0x00000000);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "lineWidth", 1);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "dashType", 0);
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "penSubTitle");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "frontColour", (int)0xff000000);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "lineWidth", 1);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "dashType", 0);
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "penAxisLable");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "frontColour", (int)0xff000000);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "lineWidth", 1);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "dashType", 0);
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "penAxis");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "frontColour", (int)0x0000ff00);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "lineWidth", 1);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "dashType", 0);
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "penGraph");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "frontColour", (int)0x00ff0000);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "lineWidth", 1);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "dashType", 0);
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "penGraphBackground");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "frontColour", (int)0xffec5b00);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "lineWidth", 1);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "dashType", 0);
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "penGrid");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "frontColour", (int)0xc0c0c000);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "lineWidth", 1);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "dashType", 1);
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "penBackground");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "frontColour", (int)0xffffff00);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "lineWidth", 1);
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "dashType", 0);
|
||||
|
||||
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "fontTitle");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontSize", 20);
|
||||
GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontSlant", "none");
|
||||
GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontWeight", "bold");
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "fontSubTitle");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontSize", 16);
|
||||
GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontSlant", "italic");
|
||||
GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontWeight", "none");
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "fontAxisLabel");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontSize", 12);
|
||||
GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontSlant", "none");
|
||||
GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontWeight", "none");
|
||||
|
||||
dbT=GWEN_DB_GetGroup(dbConfig, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "fontTickLabel");
|
||||
GWEN_DB_SetIntValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontSize", 9);
|
||||
GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontSlant", "none");
|
||||
GWEN_DB_SetCharValue(dbT, GWEN_DB_FLAGS_OVERWRITE_VARS, "fontWeight", "none");
|
||||
|
||||
GWEN_DB_SetCharValue(dbConfig, GWEN_DB_FLAGS_OVERWRITE_VARS, "flags", "grid");
|
||||
|
||||
|
||||
AQDB_Context_Attach(g);
|
||||
|
||||
gr=AQDG_Graph_new(ds, g, graphWidth, graphHeight);
|
||||
rv=AQDG_Graph_Init_fromDb(gr, dbConfig);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(0, "Error on AQDG_Graph_Init_fromDb(): %d", rv);
|
||||
return 2;
|
||||
}
|
||||
|
||||
rv=AQDG_Graph_Draw(gr);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(0, "Error on AQDG_Graph_Draw(): %d", rv);
|
||||
return 2;
|
||||
}
|
||||
|
||||
AQDG_Graph_Fini(gr);
|
||||
AQDG_Graph_free(gr);
|
||||
|
||||
AQDB_Context_Finish(g);
|
||||
|
||||
AQDB_Context_free(g);
|
||||
rv=GWEN_Init();
|
||||
if (rv) {
|
||||
DBG_ERROR_ERR(0, rv);
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
DBG_ERROR(0, "Error creating graphics context");
|
||||
|
||||
gui=GWEN_Gui_CGui_new();
|
||||
//GWEN_Gui_SetCharSet(gui, "ISO-8859-15");
|
||||
GWEN_Gui_SetGui(gui);
|
||||
GWEN_Logger_SetLevel(AQDG_LOGDOMAIN, GWEN_LoggerLevel_Info);
|
||||
|
||||
tf=TestFramework_new();
|
||||
|
||||
rv=AQDG_HLayoutObject_AddTests(TestFramework_GetModulesRoot(tf));
|
||||
if (rv) {
|
||||
fprintf(stderr, "FAILED: test_db_factory()\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
rv=TestFramework_Run(tf, argc, argv);
|
||||
if (rv) {
|
||||
fprintf(stderr, "SomeError in tests failed.\n");
|
||||
GWEN_Gui_SetGui(NULL);
|
||||
GWEN_Gui_free(gui);
|
||||
return 2;
|
||||
}
|
||||
TestFramework_free(tf);
|
||||
|
||||
|
||||
rv=GWEN_Fini();
|
||||
if (rv) {
|
||||
DBG_ERROR_ERR(0, rv);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user