e-tizen-testcase: bug fixes due to unerased timer 82/171982/2
authorJunSeok, Kim <juns.kim@samsung.com>
Thu, 8 Mar 2018 10:54:32 +0000 (19:54 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Thu, 8 Mar 2018 12:01:39 +0000 (12:01 +0000)
There was a bug in 0001_easy testcase and 0006_tzsh testcase due to a
timer was not cleared.
This patch fixes this problem.

Change-Id: I35e479b8b3532a5627610b5271993bf97ad06968

src/e_test_event.cpp
src/e_test_event.h
src/testcase/0001_easy.cpp
src/testcase/0002_base_operation.cpp
src/testcase/0003_base_operation_multi_wins.cpp
src/testcase/0004_transient_for.cpp
src/testcase/0005_notification.cpp
src/testcase/0006_tzsh.cpp
src/testcase/0007_rotation.cpp
src/testcase/0008_focus.cpp

index be51cfb..56639f9 100644 (file)
@@ -50,7 +50,8 @@ static const struct tizen_resource_listener _e_test_tizen_resource_listener =
 EtEventLoop::EtEventLoop()
 {
    this->log_dom_ = -1;
-   this->time_for_wait_work_ = E_TEST_WORK_TIME;
+   this->Worker.work_timer_ = NULL;
+   this->Worker.time_for_wait_work_ = E_TEST_WORK_TIME;
 
    this->tizen_policy_ = NULL;
    this->tizen_surface_ = NULL;
@@ -614,10 +615,21 @@ finish:
 void EtEventLoop::Work()
 {
    /* give a turn to deal with deferred job for E_TEST_WORK_TIME */
-   ecore_timer_add(time_for_wait_work_, _cb_work_timeout, NULL);
+   this->Worker.work_timer_ = ecore_timer_add(this->Worker.time_for_wait_work_, _cb_work_timeout, this);
    elm_run();
 }
 
+void EtEventLoop::FinishWork()
+{
+   if (this->Worker.work_timer_)
+     {
+        ecore_timer_del(this->Worker.work_timer_);
+        this->Worker.work_timer_ = NULL;
+     }
+
+   elm_exit();
+}
+
 void EtEventLoop::PrintWinInfoList()
 {
    EtWin *tw = NULL;
@@ -648,19 +660,19 @@ void EtEventLoop::PrintWinInfoList()
 
 void EtEventLoop::DelTimer()
 {
-   if (this->Ev.expire_timer)
+   if (this->Worker.work_timer_)
      {
-        ecore_timer_del(this->Ev.expire_timer);
-        this->Ev.expire_timer = NULL;
+        ecore_timer_del(this->Worker.work_timer_);
+        this->Worker.work_timer_ = NULL;
      }
 }
 
 void EtEventLoop::RunTimer()
 {
-   if (this->Ev.expire_timer)
+   if (this->Worker.work_timer_)
      this->DelTimer();
 
-   this->Ev.expire_timer = ecore_timer_add(this->time_for_wait_work_, _cb_work_timeout, NULL);
+   this->Worker.work_timer_ = ecore_timer_add(this->Worker.time_for_wait_work_, _cb_work_timeout, this);
 }
 
 void EtEventLoop::WaitForDestroy()
@@ -1051,7 +1063,10 @@ finish:
 
 static Eina_Bool _cb_work_timeout(void *data)
 {
-   elm_exit();
+   EtEventLoop *ev_loop = (EtEventLoop *)data;
+
+   ev_loop->FinishWork();
+
    return ECORE_CALLBACK_CANCEL;
 }
 
index c7210a1..7972382 100644 (file)
@@ -16,7 +16,6 @@ class EtEventLoop
     struct tizen_surface *tizen_surface_ = NULL;
 
     int log_dom_ = -1;
-    double time_for_wait_work_ = 0.0;
 
     struct
       {
@@ -27,6 +26,12 @@ class EtEventLoop
 
     struct
       {
+         Ecore_Timer *work_timer_;
+         double time_for_wait_work_;
+      } Worker;
+
+    struct
+      {
          Eldbus_Connection *conn;
          Eldbus_Proxy *proxy;
          Eldbus_Object *obj;
@@ -75,8 +80,9 @@ class EtEventLoop
     Eina_Bool     Init();
     void          Shutdown();
     void          Work();
+    void          FinishWork();
     void          PrintWinInfoList();
-    void          SetWaitWorkTime(double time) { this->time_for_wait_work_ = time; };
+    void          SetWaitWorkTime(double time) { this->Worker.time_for_wait_work_ = time; };
     void          DelTimer();
     void          RunTimer();
     void          WaitForDestroy();
index 5650f7e..d94415b 100644 (file)
@@ -9,6 +9,16 @@ extern EtEventLoop *gLoop;
 
 class EtTestEasy : public ::testing::Test
 {
+ public:
+    EtTestEasy()
+      {
+      };
+    ~EtTestEasy()
+      {
+         if (HasFailure())
+           gLoop->WaitForDestroy();
+      };
+
  protected:
     static void SetUpTestCase() {};
     static void TearDownTestCase() {};
@@ -57,7 +67,7 @@ finish:
    if (*result == EINA_FALSE)
      ERR("errname:%s errmsg:%s\n", name, text);
 
-   elm_exit();
+   gLoop->FinishWork();
 }
 
 static void
@@ -99,7 +109,7 @@ finish:
         ERR("errname:%s errmsg:%s\n", name, text);
      }
 
-   elm_exit();
+   gLoop->FinishWork();
 }
 
 TEST_F(EtTestEasy, base_pass)
@@ -131,7 +141,6 @@ TEST_F(EtTestEasy, introspect)
    ASSERT_TRUE(p != NULL);
 
    gLoop->Work();
-
    ASSERT_TRUE(result);
 }
 
index b48eced..e46c926 100644 (file)
@@ -13,7 +13,8 @@ class EtTestBaseOperation : public ::testing::Test
       };
     ~EtTestBaseOperation()
       {
-         gLoop->WaitForDestroy();
+         if (HasFailure())
+           gLoop->WaitForDestroy();
 
          if (tw)
            {
index db1c5fc..35dc9a3 100644 (file)
@@ -13,7 +13,8 @@ class EtTestBaseMulti : public ::testing::Test
       };
     ~EtTestBaseMulti()
       {
-         gLoop->WaitForDestroy();
+         if (HasFailure())
+           gLoop->WaitForDestroy();
 
          if (tw_register)
            gLoop->DeregisterWin(tw_register);
index fc74766..5b8c468 100644 (file)
@@ -12,7 +12,8 @@ class EtTestTransientFor : public ::testing::Test
       };
     ~EtTestTransientFor()
       {
-         gLoop->WaitForDestroy();
+         if (HasFailure())
+           gLoop->WaitForDestroy();
 
          if (tw_register)
            gLoop->DeregisterWin(tw_register);
index 8dd06f4..8b94839 100644 (file)
@@ -13,7 +13,8 @@ class EtTestNotification : public ::testing::Test
       };
     ~EtTestNotification()
       {
-         gLoop->WaitForDestroy();
+         if (HasFailure())
+           gLoop->WaitForDestroy();
 
          if (tw_register)
            gLoop->DeregisterWin(tw_register);
index 05ff65e..7ded964 100644 (file)
@@ -31,7 +31,8 @@ class EtTestTzsh : public :: testing::Test
       };
     ~EtTestTzsh()
       {
-         gLoop->WaitForDestroy();
+         if (HasFailure())
+           gLoop->WaitForDestroy();
 
          if (tz_scrsaver_mng)
            tzsh_screensaver_manager_service_destroy(tz_scrsaver_mng);
@@ -115,7 +116,7 @@ _cb_state_change(void *data,
 
         tc_data->chk_timeout_val_ = EINA_TRUE;
 
-        elm_exit();
+        gLoop->FinishWork();
      }
    else
      {
index 05b589a..a72a486 100644 (file)
@@ -12,7 +12,8 @@ class EtTestRotation : public ::testing::Test
       };
     ~EtTestRotation()
       {
-         gLoop->WaitForDestroy();
+         if (HasFailure())
+           gLoop->WaitForDestroy();
 
          if (tw_register)
            gLoop->DeregisterWin(tw_register);
index dd29786..9465080 100644 (file)
@@ -12,7 +12,8 @@ class EtTestFocus : public ::testing::Test
       };
     ~EtTestFocus()
       {
-         gLoop->WaitForDestroy();
+         if (HasFailure())
+           gLoop->WaitForDestroy();
 
          if (this->tw_register)
            {