+++ /dev/null
-#include <check.h>
-#include <Eina.h>
-#include <Evas.h>
-#include <Ecore_Evas.h>
-#include <Ecore_File.h>
-#include <Ecore_Getopt.h>
-#include <Ecore.h>
-
-#include "../../utc_negative_unitest.h"
-
-#define TEMP_FILE_NAME "temp_file.dat"
-
-static Eina_Bool startup_status = EINA_FALSE;
-
-/**
- * @addtogroup ecore_getopt
- * @{
- * @defgroup ecore_getopt_callback_ecore_evas_list_engines ecore_getopt_callback_ecore_evas_list_engines()
- *
- *
- * @precondition
- * @step 1 Initialize with ecore_evas_init()
- * @step 2 Initialize with ecore_file_init()
- */
-
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- if (ecore_evas_init() > 0)
- {
- if (ecore_file_init() > 0)
- {
- startup_status = EINA_TRUE;
- }
- }
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- ecore_file_shutdown();
- ecore_evas_shutdown();
-}
-
-Eina_Bool check_data_file(const char *filename)
-{
- const int n = 256;
- int i;
- FILE *file = NULL;
- char buffer[256];
-
- for (i = 0; i < n; i++)
- {
- buffer[i] = NULL;
- }
- file = fopen(TEMP_FILE_NAME, "rb");
- if (file == NULL)
- {
- return EINA_FALSE;
- }
- if (fread(&buffer[0], 1, n-1, file) <= 0)
- {
- fclose(file);
- return EINA_FALSE;
- }
- fclose(file);
- if (buffer[0] == NULL)
- {
- return EINA_FALSE;
- }
- if (strlen(buffer) <= 0)
- {
- return EINA_FALSE;
- }
-
- return EINA_TRUE;
-}
-
-/**
- * @addtogroup ecore_getopt_callback_ecore_evas_list_engines
- * @{
- * @objective Positive test case checks that the tested function gets the engines list and writes this list to buffer.
- * @n Input Data:
- * @li NULL (not used);
- * @li NULL (not used);
- * @li NULL (not used);
- * @li address of buffer (in this case the file stream is used as buffer);
- * @li address of storage.
- *
- * @procedure
- * @step 1 Open a new file for writing.
- * @step 2 Call tested function with using of 1) handle of created file as fourth argument and 2) address of the given storage as fifth argument.
- * @step 3 Close created file.
- * @step 4 Check that the tested function returns value equal to 1.
- * @step 5 Check that the some information is contained in file which was used as buffer.
- * @step 6 Remove file.
- *
- * @passcondition
- * @li tested function must return 1;
- * @li file which was used as buffer at the tested function call must contains some information;
- * @li there is no segmentation fault.
- * @}
- */
-
-START_TEST(utc_ecore_getopt_callback_ecore_evas_list_engines_p)
-{
- if (startup_status != EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (startup was been executed unsuccessfully)..", __FILE__, __LINE__);
- }
-
- FILE *file = NULL;
- Ecore_Getopt_Value storage = { .boolp = 0 };
- unsigned char res = 0;
- Eina_Bool ok = EINA_FALSE;
-
- file = fopen(TEMP_FILE_NAME, "w");
- if (file == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (the data file cannot be created)..", __FILE__, __LINE__);
- }
- res = ecore_getopt_callback_ecore_evas_list_engines(NULL, NULL, NULL, (void *)file, &storage);
- fclose(file);
- if (res == 1)
- {
- if (check_data_file(TEMP_FILE_NAME) == EINA_TRUE)
- {
- ok = EINA_TRUE;
- }
- }
- ecore_file_remove(TEMP_FILE_NAME);
-
- if (ok != EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup ecore_getopt_callback_ecore_evas_list_engines
- * @{
- * @objective Negative test case checks situation if last argument (address of storage) is NULL.
- * @n Input Data:
- * @li NULL (not used);
- * @li NULL (not used);
- * @li NULL (not used);
- * @li NULL (optional);
- * @li address of storage (it will be replaced by NULL in the universal macro).
- *
- * @procedure
- * @step 1 Use CREATE_CHECKED_ARGS_ARRAY macro for defining arguments of tested function which are subject to substitution for NULL.
- * @step 2 Use UNITEST_FUNC_NEG_CA_RET for negative testing.
- *
- * @passcondition
- * Function must return 0, and there is no segmentation fault.
- * @}
- */
-
-START_TEST(utc_ecore_getopt_callback_ecore_evas_list_engines_n)
-{
- if (startup_status != EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed (startup was been executed unsuccessfully)..", __FILE__, __LINE__);
- }
-
- Ecore_Getopt_Value storage = { .boolp = 0 };
-
- CREATE_CHECKED_ARGS_ARRAY(0,0,0,0,1);
- UNITEST_FUNC_NEG_CA_RET(0, ecore_getopt_callback_ecore_evas_list_engines, NULL, NULL, NULL, NULL, &storage);
-
- if (result_of_testing != TEST_PASS)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-
-}
-END_TEST
-
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_ecore_getopt_callback_ecore_evas_list_engines");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_ecore_getopt_callback_ecore_evas_list_engines_p);
- tcase_add_test(tcase, utc_ecore_getopt_callback_ecore_evas_list_engines_n);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_ecore_getopt_callback_ecore_evas_list_engines.log");
- srunner_set_xml(srunner, "utc_ecore_getopt_callback_ecore_evas_list_engines.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}