Fix wrong size issue 35/242235/2
authorhyunho <hhstark.kang@samsung.com>
Tue, 25 Aug 2020 06:18:41 +0000 (15:18 +0900)
committerhyunho <hhstark.kang@samsung.com>
Tue, 25 Aug 2020 08:14:03 +0000 (17:14 +0900)
Change-Id: Ic145586c908a4fb7cdb508e18f545dda0a5852d2
Signed-off-by: hyunho <hhstark.kang@samsung.com>
test/unit_tests/test_widget_app.cc

index e6a2264..3966a4f 100644 (file)
@@ -52,6 +52,10 @@ typedef struct _widget_base_instance_data {
   void* user_data;
 } widget_base_instance_data;
 
+struct _widget_context {
+  int context;
+};
+
 class Mocks : public ::testing::NiceMock<GioMock>,
               public ::testing::NiceMock<MultiWindowBaseMock>,
               public ::testing::NiceMock<AppCommonMock>,
@@ -276,8 +280,9 @@ TEST_F(WidgetAppTest, widget_app_exit) {
 
 TEST_F(WidgetAppTest, widget_app_terminate_context) {
   widget_context_h context =
-      (widget_context_h)calloc(1, sizeof(widget_context_h));
+      (widget_context_h)calloc(1, sizeof(struct _widget_context));
   int ret = widget_app_terminate_context(context);
+  free(context);
   EXPECT_EQ(WIDGET_ERROR_NONE, ret);
 }
 
@@ -320,13 +325,14 @@ TEST_F(WidgetAppTest, widget_app_remove_event_handler) {
 
 TEST_F(WidgetAppTest, widget_app_get_id) {
   widget_context_h context =
-      (widget_context_h)calloc(1, sizeof(widget_context_h));
+      (widget_context_h)calloc(1, sizeof(struct _widget_context));
 
   EXPECT_CALL(GetMock<MultiWindowBaseMock>(),
       appcore_multiwindow_base_instance_get_id(_)).
           WillOnce(Return("test"));
 
   const char *id = widget_app_get_id(context);
+  free(context);
   EXPECT_STREQ(id, "test");
 }
 
@@ -349,19 +355,20 @@ TEST_F(WidgetAppTest, widget_app_class_create) {
 
 TEST_F(WidgetAppTest, widget_app_context_set_tag) {
   widget_context_h context =
-      (widget_context_h)calloc(1, sizeof(widget_context_h));
+      (widget_context_h)calloc(1, sizeof(struct _widget_context));
 
   EXPECT_CALL(GetMock<MultiWindowBaseMock>(),
       appcore_multiwindow_base_instance_get_extra(_)).
       WillOnce(Invoke(__appcore_multiwindow_base_instance_get_extra_fake));
 
   int ret = widget_app_context_set_tag(context, (void*)"test");
+  free(context);
   EXPECT_EQ(WIDGET_ERROR_NONE, ret);
 }
 
 TEST_F(WidgetAppTest, widget_app_context_get_tag) {
   widget_context_h context =
-      (widget_context_h)calloc(1, sizeof(widget_context_h));
+      (widget_context_h)calloc(1, sizeof(struct _widget_context));
 
   EXPECT_CALL(GetMock<MultiWindowBaseMock>(),
       appcore_multiwindow_base_instance_get_extra(_)).
@@ -369,12 +376,13 @@ TEST_F(WidgetAppTest, widget_app_context_get_tag) {
 
   void* tag;
   int ret = widget_app_context_get_tag(context, &tag);
+  free(context);
   EXPECT_EQ(WIDGET_ERROR_NONE, ret);
 }
 
 TEST_F(WidgetAppTest, widget_app_context_set_content_info) {
   widget_context_h context =
-      (widget_context_h)calloc(1, sizeof(widget_context_h));
+      (widget_context_h)calloc(1, sizeof(struct _widget_context));
 
   EXPECT_CALL(GetMock<MultiWindowBaseMock>(),
       appcore_multiwindow_base_instance_get_extra(_)).
@@ -390,26 +398,25 @@ TEST_F(WidgetAppTest, widget_app_context_set_content_info) {
 
   bundle* content_info = bundle_create();
   int ret = widget_app_context_set_content_info(context, content_info);
+  free(context);
   EXPECT_EQ(WIDGET_ERROR_NONE, ret);
 }
 
 TEST_F(WidgetAppTest, widget_app_context_set_title) {
   widget_context_h context =
-      (widget_context_h)calloc(1, sizeof(widget_context_h));
+      (widget_context_h)calloc(1, sizeof(struct _widget_context));
 
   EXPECT_CALL(GetMock<MultiWindowBaseMock>(),
       appcore_multiwindow_base_instance_get_extra(_)).
       WillRepeatedly(Invoke(__appcore_multiwindow_base_instance_get_extra_fake));
 
   int ret = widget_app_context_set_title(context, "title");
+  free(context);
   EXPECT_EQ(WIDGET_ERROR_NONE, ret);
 }
 
 TEST_F(WidgetAppTest, widget_app_class_add) {
   widget_instance_lifecycle_callback_s lifecycle;
-  widget_class_h cls = widget_app_class_add(
-      nullptr, "test", lifecycle, nullptr);
-
   lifecycle.create = __instance_create_cb;
   lifecycle.destroy = __instance_destroy_cb;
   lifecycle.pause = __instance_pause_cb;
@@ -417,6 +424,9 @@ TEST_F(WidgetAppTest, widget_app_class_add) {
   lifecycle.resize = __instance_resize_cb;
   lifecycle.update = __instance_update_cb;
 
+  widget_class_h cls = widget_app_class_add(
+      nullptr, "test", lifecycle, nullptr);
+
   EXPECT_CALL(GetMock<MultiWindowBaseMock>(),
       appcore_multiwindow_base_class_add(_)).
       WillOnce(Invoke(__appcore_multiwindow_base_class_add_fake));
@@ -459,8 +469,9 @@ TEST_F(WidgetAppTest, widget_app_class_add) {
 TEST_F(WidgetAppTest, widget_app_get_elm_win_negative) {
   Evas_Object* win;
   widget_context_h context =
-      (widget_context_h)calloc(1, sizeof(widget_context_h));
+      (widget_context_h)calloc(1, sizeof(struct _widget_context));
   int ret = widget_app_get_elm_win(context, &win);
+  free(context);
   EXPECT_EQ(WIDGET_ERROR_FAULT, ret);
 }
 
@@ -495,7 +506,8 @@ TEST_F(WidgetAppTest, widget_app_get_elm_win) {
 
   Evas_Object* win;
   widget_context_h context =
-      (widget_context_h)calloc(1, sizeof(widget_context_h));
+      (widget_context_h)calloc(1, sizeof(struct _widget_context));
   int ret = widget_app_get_elm_win(context, &win);
+  free(context);
   EXPECT_EQ(WIDGET_ERROR_NONE, ret);
 }