mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add a test for the built in default report invoice define
This commit is contained in:
parent
ec7cc27d6d
commit
c2242f769c
@ -1,4 +1,6 @@
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
set (gnc_gnome_noinst_HEADERS
|
||||
assistant-acct-period.h
|
||||
assistant-hierarchy.h
|
||||
|
35
gnucash/gnome/test/CMakeLists.txt
Normal file
35
gnucash/gnome/test/CMakeLists.txt
Normal file
@ -0,0 +1,35 @@
|
||||
set(MODULEPATH ${CMAKE_SOURCE_DIR}/gnucash/gnome/)
|
||||
|
||||
set(GNOME_TEST_INCLUDE_DIRS
|
||||
${CMAKE_BINARY_DIR}/common # for config.h
|
||||
${CMAKE_SOURCE_DIR}/common/test-core
|
||||
${CMAKE_SOURCE_DIR}/gnucash/gnome/
|
||||
${CMAKE_SOURCE_DIR}/gnucash/gnome-utils/
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
${GTK3_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(GNOME_TEST_LIBS
|
||||
gnc-gnome
|
||||
gnc-test-engine
|
||||
test-core
|
||||
${GUILE_LDFLAGS})
|
||||
|
||||
macro(add_gnome_test _TARGET _SOURCE_FILES)
|
||||
gnc_add_test(${_TARGET} "${_SOURCE_FILES}" GNOME_TEST_INCLUDE_DIRS GNOME_TEST_LIBS)
|
||||
endmacro()
|
||||
|
||||
gnc_add_test_with_guile(test-invoice-report-buitin-default test-invoice-report-buitin-default.cpp
|
||||
GNOME_TEST_INCLUDE_DIRS GNOME_TEST_LIBS
|
||||
)
|
||||
|
||||
set(GUILE_DEPENDS
|
||||
scm-core-utils
|
||||
)
|
||||
|
||||
set_dist_list(test_app_utils_DIST
|
||||
CMakeLists.txt
|
||||
test-invoice-buitin-default.cpp
|
||||
${test_gnome_scheme_SOURCES}
|
||||
${test_gnome_SOURCES}
|
||||
)
|
110
gnucash/gnome/test/test-invoice-report-buitin-default.cpp
Normal file
110
gnucash/gnome/test/test-invoice-report-buitin-default.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "gnc-ui-util.h"
|
||||
|
||||
#include "test-stuff.h"
|
||||
|
||||
#include "guile-mappings.h"
|
||||
#include "gnc-guile-utils.h"
|
||||
|
||||
#include "../business-gnome-utils.h"
|
||||
|
||||
static void
|
||||
test_basic()
|
||||
{
|
||||
do_test(g_strcmp0(gnc_get_builtin_default_invoice_print_report (),
|
||||
"5123a759ceb9483abf2182d01c140e8d") == 0,
|
||||
"built in invoice report define does not match guid");
|
||||
}
|
||||
|
||||
static void
|
||||
test_list()
|
||||
{
|
||||
GSList *invoice_list = nullptr;
|
||||
SCM template_menu_name = scm_c_eval_string ("gnc:report-template-menu-name/report-guid");
|
||||
SCM get_rpt_guids = scm_c_eval_string ("gnc:custom-report-invoice-template-guids");
|
||||
int number_of_defined_invoice_templates = 5;
|
||||
int i = 0;
|
||||
gboolean printable_found = false;
|
||||
gboolean builtin_default_found = false;
|
||||
const char *builtin_default = gnc_get_builtin_default_invoice_print_report ();
|
||||
|
||||
if (scm_is_procedure (get_rpt_guids))
|
||||
{
|
||||
SCM reportlist = scm_call_0 (get_rpt_guids);
|
||||
SCM rpt_guids = reportlist;
|
||||
|
||||
if (scm_is_list (rpt_guids))
|
||||
{
|
||||
for (i; !scm_is_null (rpt_guids); i++)
|
||||
{
|
||||
gchar *guid_str = scm_to_utf8_string (SCM_CAR(rpt_guids));
|
||||
gchar *name = gnc_scm_to_utf8_string (scm_call_2(template_menu_name,
|
||||
SCM_CAR(rpt_guids), SCM_BOOL_F));
|
||||
|
||||
if (g_strcmp0 (guid_str, builtin_default) == 0)
|
||||
{
|
||||
if (g_strcmp0 (name, "Printable Invoice") == 0)
|
||||
printable_found = true;
|
||||
|
||||
builtin_default_found = true;
|
||||
}
|
||||
g_free (guid_str);
|
||||
g_free (name);
|
||||
|
||||
rpt_guids = SCM_CDR(rpt_guids);
|
||||
}
|
||||
}
|
||||
}
|
||||
do_test(i == number_of_defined_invoice_templates, "number of built in invoice templates does not match");
|
||||
do_test(builtin_default_found == true, "built in default invoice guid not found");
|
||||
do_test(printable_found == true, "built in Printable Invoice not found with default guid");
|
||||
}
|
||||
|
||||
static void
|
||||
real_main(void *closure, int argc, char **argv)
|
||||
{
|
||||
g_setenv ("GNC_UNINSTALLED", "1", TRUE);
|
||||
qof_init();
|
||||
gnc_engine_init(0, NULL);
|
||||
|
||||
scm_c_use_module ("gnucash reports");
|
||||
scm_c_use_module ("gnucash report report-core");
|
||||
|
||||
test_basic();
|
||||
test_list();
|
||||
|
||||
print_test_results();
|
||||
exit(get_rv());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* do things this way so we can test scheme function calls from expressions */
|
||||
scm_boot_guile(argc, argv, real_main, NULL);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user