elm_map: set route loaded status as precondition of route APIs 79/155479/1
authorSungtaek Hong <sth253.hong@samsung.com>
Fri, 13 Oct 2017 08:02:09 +0000 (17:02 +0900)
committerSungtaek Hong <sth253.hong@samsung.com>
Fri, 13 Oct 2017 08:02:09 +0000 (17:02 +0900)
Change-Id: I90caa1a0b3b0db199cd279aafd5af2bde246b584
Signed-off-by: Sungtaek Hong <sth253.hong@samsung.com>
TC/elementary/map/utc_elm_map_route_node_get.c
TC/elementary/map/utc_elm_map_route_waypoint_get.c

index dde3316e6d9b6e8e85b43d71e4a4f179086f8797..f2bcfa63d934963196b579260eea3ed6c6096f7a 100644 (file)
@@ -4,11 +4,17 @@
 Evas_Object *main_win = NULL;
 Evas_Object *map = NULL;
 Elm_Map_Route *route = NULL;
-const char *nodes = NULL;
+
+static void _route_loaded_fail(void* data, Evas_Object* obj, void* event_info)
+{
+   elm_exit();
+}
 
 static void _route_loaded(void* data, Evas_Object* obj, void* event_info)
 {
-   nodes = elm_map_route_node_get(route);
+   Eina_Bool *load_success = data;
+
+   *load_success = EINA_TRUE;
    elm_exit();
 }
 
@@ -28,10 +34,13 @@ static Eina_Bool _elm_exit(void* data)
  * @step 2 Create and show main window
  * @step 3 Add a new map widget to the main window
  * @step 4 Add a new route
+ * @step 5 Load a route information
  */
 static void
 setup(void)
 {
+   Eina_Bool load_success = EINA_FALSE;
+
    printf(" ============ Startup ============ \n");
    elm_init(0, NULL);
    main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
@@ -50,6 +59,16 @@ setup(void)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Unable to create a route..", __FILE__, __LINE__);
      }
+
+   evas_object_smart_callback_add(map, "route,loaded", _route_loaded, &load_success);
+   evas_object_smart_callback_add(map, "route,loaded,fail", _route_loaded_fail, NULL);
+
+   ecore_timer_add(10, _elm_exit, NULL);
+   elm_run();
+   if (load_success == EINA_FALSE)
+     {
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Unable to load route..", __FILE__, __LINE__);
+     }
 }
 
 static void
@@ -72,22 +91,22 @@ teardown(void)
  * @n Input Data: the route object
  *
  * @procedure
- * @step 1 Register _elm_exit callback to be run 4 second after main loop start
- * @step 2 Run the elementary main loop
- * @step 3 Get the information of route nodes on _route_loaded call
+ * @step 1 Get the information of route nodes from loaded route
  *
  * @passcondition Returned string is not NULL and there is no segmentation fault
  * @}
  */
 START_TEST(utc_elm_map_route_node_get_p)
 {
+   const char *nodes = NULL;
+
    if (route == NULL)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
      }
-   ecore_timer_add(10.0, _elm_exit, NULL);
-   evas_object_smart_callback_add(map, "route,loaded", _route_loaded, NULL);
-   elm_run();
+
+   nodes = elm_map_route_node_get(route);
+
    if (nodes == NULL)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
index f5b78419f8e82468e5eca0d24739464b014b2fcc..819cdf34686791882ba12c892b60bd18a7e36328 100644 (file)
@@ -4,8 +4,6 @@
 Evas_Object *main_win = NULL;
 Evas_Object *map = NULL;
 Elm_Map_Route *route = NULL;
-const char *waypoint = NULL;
-Eina_Bool load_success = EINA_FALSE;
 
 static void _route_loaded_fail(void* data, Evas_Object* obj, void* event_info)
 {
@@ -14,8 +12,9 @@ static void _route_loaded_fail(void* data, Evas_Object* obj, void* event_info)
 
 static void _route_loaded(void* data, Evas_Object* obj, void* event_info)
 {
-   load_success = EINA_TRUE;
-   waypoint = elm_map_route_waypoint_get(route);
+   Eina_Bool *load_success = data;
+
+   *load_success = EINA_TRUE;
    elm_exit();
 }
 
@@ -35,10 +34,13 @@ static Eina_Bool _elm_exit(void* data)
  * @step 2 Create and show main window
  * @step 3 Add a new map widget to the main window
  * @step 4 Add a new route
+ * @step 5 Load a route information
  */
 static void
 setup(void)
 {
+   Eina_Bool load_success = EINA_FALSE;
+
    printf(" ============ Startup ============ \n");
    elm_init(0, NULL);
    main_win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
@@ -57,7 +59,16 @@ setup(void)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Unable to create a route..", __FILE__, __LINE__);
      }
-   load_success = EINA_FALSE;
+
+   evas_object_smart_callback_add(map, "route,loaded", _route_loaded, &load_success);
+   evas_object_smart_callback_add(map, "route,loaded,fail", _route_loaded_fail, NULL);
+
+   ecore_timer_add(10, _elm_exit, NULL);
+   elm_run();
+   if (load_success == EINA_FALSE)
+     {
+        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Unable to load route..", __FILE__, __LINE__);
+     }
 }
 
 static void
@@ -80,31 +91,27 @@ teardown(void)
  * @n Input Data: the route object
  *
  * @procedure
- * @step 1 Register _elm_exit callback to be run 4 second after main loop start
- * @step 2 Run the elementary main loop
- * @step 3 Get the information of route waypoint on _route_loaded call
+ * @step 1 Get the information of route waypoint from loaded route
  *
  * @passcondition Returned string is not NULL and there is no segmentation fault
  * @}
  */
 START_TEST(utc_elm_map_route_waypoint_get_p)
 {
+   const char *waypoint = NULL;
+
    if (route == NULL)
      {
         ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
      }
-   evas_object_smart_callback_add(map, "route,loaded", _route_loaded, NULL);
-   evas_object_smart_callback_add(map, "route,loaded,fail", _route_loaded_fail, NULL);
-   ecore_timer_add(10, _elm_exit, NULL);
-   elm_run();
-   if (load_success == EINA_FALSE)
-     {
-        ck_abort_msg("[TEST_FAIL]:: %s[%d] : Unable to load route..", __FILE__, __LINE__);
-     }
+
+   waypoint = elm_map_route_waypoint_get(route);
+
    if (waypoint == NULL)
      {
         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