e_test_base: added createWindow private func and use it initial func 48/229748/1
authorJunseok, Kim <juns.kim@samsung.com>
Fri, 3 Apr 2020 06:59:14 +0000 (15:59 +0900)
committerJunseok, Kim <juns.kim@samsung.com>
Fri, 3 Apr 2020 06:59:14 +0000 (15:59 +0900)
Change-Id: I634d75b6f2882987def22ea603c37f8f65492186

src/e_test_base.cpp
src/e_test_base.h

index 73adad9..3027967 100644 (file)
@@ -57,25 +57,34 @@ etTCBase::initFakeWin()
 }
 
 etWin *
-etTCBase::initNormalWin(const char *name, Eina_Bool usr_geom)
+etTCBase::createWindow(Elm_Win_Type type, const char *name, Eina_Bool usr_geom, int x, int y, int w, int h)
 {
    Eina_Bool res = EINA_FALSE;
    etWin *tw = new etWin();
 
+   if (x+y+w+h <= 0)
+     {
+        x = y = 100*numGeomTw;
+        w = h = 400;
+        if (usr_geom)
+          numGeomTw++;
+     }
+
    res = tw->init(NULL,
-                  ELM_WIN_BASIC,
+                  type,
                   EINA_FALSE,
-                  name? name : "TCWin_Normal",
-                  (100*numGeomTw), (100*numGeomTw), 400, 400, usr_geom,
+                  name? name : "TCWin",
+                  x, y, w, h, usr_geom,
                   (E_TC_Win_Color) ((numTw % E_TC_WIN_COLOR_CYAN) + 2));
    EINA_SAFETY_ON_FALSE_GOTO(res, err);
+
    tw->native_win = etRunner::get().getWinId(tw->elm_win);
+   EINA_SAFETY_ON_FALSE_GOTO(tw->native_win, err);
 
    res = registerTCWin(tw);
    EINA_SAFETY_ON_FALSE_GOTO(res, err);
 
    numTw++;
-   if (usr_geom) numGeomTw++;
 
    tw_list = eina_list_append(tw_list, tw);
 
@@ -87,97 +96,39 @@ err:
 }
 
 etWin *
-etTCBase::initNormalWin(const char *name, int x, int y, int w, int h)
+etTCBase::initNormalWin(const char *name, Eina_Bool usr_geom)
 {
-   Eina_Bool res = EINA_FALSE;
-   etWin *tw = new etWin();
-
-   res = tw->init(NULL,
-                  ELM_WIN_BASIC,
-                  EINA_FALSE,
-                  name? name : "TCWin_Normal",
-                  x, y, w, h, EINA_TRUE,
-                  (E_TC_Win_Color) ((numTw % E_TC_WIN_COLOR_CYAN) + 2));
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
-   tw->native_win = etRunner::get().getWinId(tw->elm_win);
-
-   res = registerTCWin(tw);
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
-
-   numTw++;
-
-   tw_list = eina_list_append(tw_list, tw);
-
+   etWin *tw = createWindow(ELM_WIN_BASIC, name, usr_geom, 0, 0, 0, 0);
    return tw;
+}
 
-err:
-   delete tw;
-   return NULL;
+etWin *
+etTCBase::initNormalWin(const char *name, int x, int y, int w, int h)
+{
+   etWin *tw = createWindow(ELM_WIN_BASIC, name, EINA_TRUE, x, y, w, h);
+   return tw;
 }
 
 etWin *
 etTCBase::initNotiWin(const char *name, Eina_Bool usr_geom, Eina_Bool set_noti_level_normal)
 {
-   Eina_Bool res = EINA_FALSE;
-   etWin *tw = new etWin();
-
-   res = tw->init(NULL,
-                  ELM_WIN_NOTIFICATION,
-                  EINA_FALSE,
-                  name? name : "TCWin_Noti",
-                  (100*numGeomTw), (100*numGeomTw), 400, 400, usr_geom,
-                  (E_TC_Win_Color) ((numTw % E_TC_WIN_COLOR_CYAN) + 2));
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
-   tw->native_win = etRunner::get().getWinId(tw->elm_win);
+   etWin *tw = createWindow(ELM_WIN_NOTIFICATION, name, usr_geom, 0, 0, 0, 0);
 
    if (set_noti_level_normal)
      etRunner::get().setWinNotiLevel(tw, EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM);
 
-   res = registerTCWin(tw);
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
-
-   numTw++;
-   if (usr_geom) numGeomTw++;
-
-   tw_list = eina_list_append(tw_list, tw);
-
    return tw;
-
-err:
-   delete tw;
-   return NULL;
 }
 
 etWin *
 etTCBase::initNotiWin(const char *name, Eina_Bool set_noti_level_normal, int x, int y, int w, int h)
 {
-   Eina_Bool res = EINA_FALSE;
-   etWin *tw = new etWin();
-
-   res = tw->init(NULL,
-                  ELM_WIN_NOTIFICATION,
-                  EINA_FALSE,
-                  name? name : "TCWin_Noti",
-                  x, y, w, h, EINA_TRUE,
-                  (E_TC_Win_Color) ((numTw % E_TC_WIN_COLOR_CYAN) + 2));
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
-   tw->native_win = etRunner::get().getWinId(tw->elm_win);
+   etWin *tw = createWindow(ELM_WIN_NOTIFICATION, name, EINA_TRUE, x, y, w, h);
 
    if (set_noti_level_normal)
      etRunner::get().setWinNotiLevel(tw, EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM);
 
-   res = registerTCWin(tw);
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
-
-   numTw++;
-
-   tw_list = eina_list_append(tw_list, tw);
-
    return tw;
-
-err:
-   delete tw;
-   return NULL;
 }
 
 Eina_Bool
index a401776..c039239 100644 (file)
@@ -29,6 +29,8 @@ class etTCBase : public ::testing::Test
 
    int        numTw = 0;     // number of wins
    int        numGeomTw = 0; // number of wins using usr_geom
+
+   etWin     *createWindow(Elm_Win_Type type, const char *name, Eina_Bool usr_geom, int x, int y, int w, int h);
 };
 
 #endif // end of __ET_TESTCASE_BASE__