Add unittest for ambient viewer 21/231821/2
authorJunghoon Park <jh9216.park@samsung.com>
Fri, 24 Apr 2020 09:29:12 +0000 (18:29 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Fri, 24 Apr 2020 09:29:19 +0000 (09:29 +0000)
Change-Id: I1d41523b77f390e42a3d91238596cf346c6d0f95
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
ambient-viewer/src/stub.cc
unittest/src/test_ambient_viewer.cc
unittest/src/test_ambient_viewer_stub.cc [new file with mode: 0644]

index a0f9665..bfb6dcd 100644 (file)
@@ -65,7 +65,9 @@ class ReceiveCallbackInfo {
 
   void InvokeReceiveCallback(AmbientViewer::EventType event, std::string sender,
       Bundle extra) {
-    bundle *b;
+    if (!cb_)
+      return;
+    bundle* b;
     b = extra.GetHandle();
     cb_(static_cast<ambient_event_type_e>(event), sender.c_str(), b,
         user_data_);
@@ -78,23 +80,31 @@ class ReceiveCallbackInfo {
 
 class AmbientViewerStub : public AmbientViewer {
  public:
-  AmbientViewerStub(Evas_Object* win)
-    : AmbientViewer(win) {
+  AmbientViewerStub(Evas_Object* win, bool mock = false)
+    : AmbientViewer(win), mock_(mock) {
   }
 
   void OnAdded(const ISurface& surface) {
+    if (monitor_cb_.get() == nullptr)
+      return;
     monitor_cb_->InvokeAdded(surface);
   }
 
   void OnUpdated(const ISurface& surface) {
+    if (monitor_cb_.get() == nullptr)
+      return;
     monitor_cb_->InvokeUpdated(surface);
   }
 
   void OnRemoved(const ISurface& surface) {
+    if (monitor_cb_.get() == nullptr)
+      return;
     monitor_cb_->InvokeRemoved(surface);
   }
 
   void OnReceived(EventType ev, string sender, Bundle extra) {
+    if (event_cb_.get() == nullptr)
+      return;
     event_cb_->InvokeReceiveCallback(ev, sender, extra);
   }
 
@@ -118,11 +128,44 @@ class AmbientViewerStub : public AmbientViewer {
     return AMBIENT_VIEWER_ERROR_NONE;
   }
 
+ protected:
+  std::shared_ptr<ISurface> CreateWatchSurface(int rid, std::string id,
+      std::string appid, Evas_Object* viewer_win, IAmbientViewer* listener,
+      bool mock = false) override {
+    return AmbientViewer::CreateWatchSurface(rid, id, appid, viewer_win,
+        listener, mock_);
+  }
+
+  std::shared_ptr<ISurface> CreateTopAppSurface(
+      std::shared_ptr<screen_connector::EvasObject> surface,
+      IAmbientViewer* listener, bool mock = false) override {
+    return AmbientViewer::CreateTopAppSurface(surface, listener, mock_);
+  }
+
  private:
   unique_ptr<MonitorCallbackInfo> monitor_cb_;
   unique_ptr<ReceiveCallbackInfo> event_cb_;
+  bool mock_ = false;
 };
 
+extern "C" int ambient_viewer_create_mock(Evas_Object *win,
+    ambient_viewer_h *handle) {
+  if (win == nullptr || handle == nullptr) {
+    LOGE("Invalid parameter");
+    return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+  }
+
+  AmbientViewerStub* h = new (nothrow) AmbientViewerStub(win, true);
+  if (h == nullptr) {
+    LOGE("out of memory");
+    return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY;
+  }
+
+  *handle = static_cast<ambient_viewer_h>(h);
+
+  return AMBIENT_VIEWER_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int ambient_viewer_create(Evas_Object *win,
     ambient_viewer_h *handle) {
   if (win == nullptr || handle == nullptr) {
@@ -191,7 +234,7 @@ extern "C" EXPORT_API int ambient_viewer_monitor(ambient_viewer_h handle,
   AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
 
   unique_ptr<MonitorCallbackInfo> info(
-    new (nothrow)MonitorCallbackInfo(lifecycle, user_data));
+    new (nothrow) MonitorCallbackInfo(lifecycle, user_data));
   if (info.get() == nullptr) {
     LOGE("out of memory");
     return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY;
index 48ac824..87c4471 100644 (file)
@@ -36,31 +36,33 @@ using namespace std;
 using namespace ambient_viewer;
 using namespace tizen_base;
 
-static gchar __not_null;
-static app_com_cb __app_com_callback;
-static void* __app_com_user_data;
-static Evas_Native_Surface __fake_ns;
-static tbm_surface_info_s __fake_surf_info;
-static int __fake_buf[100][100];
-
-static int __system_info_get_platform_bool(const char* key, bool* value) {
+namespace {
+
+gchar __not_null;
+app_com_cb __app_com_callback;
+void* __app_com_user_data;
+Evas_Native_Surface __fake_ns;
+tbm_surface_info_s __fake_surf_info;
+int __fake_buf[100][100];
+
+int __system_info_get_platform_bool(const char* key, bool* value) {
   *value = true;
   return 0;
 }
 
-static void __evas_object_geometry_get(const Evas_Object *eo_obj, Evas_Coord *x,
+void __evas_object_geometry_get(const Evas_Object *eo_obj, Evas_Coord *x,
     Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) {
   *w = 100;
   *h = 100;
 }
 
-static Evas_Native_Surface* __evas_object_image_native_surface_get(
+Evas_Native_Surface* __evas_object_image_native_surface_get(
     const Evas_Object *eo_obj) {
   __fake_ns.data.tbm.buffer = &__not_null;
   return &__fake_ns;
 }
 
-static int __tbm_surface_map(tbm_surface_h surface, int opt,
+int __tbm_surface_map(tbm_surface_h surface, int opt,
     tbm_surface_info_s *info) {
   __fake_surf_info.planes[0].ptr = reinterpret_cast<unsigned char*>(
       &__fake_buf[0][0]);
@@ -68,18 +70,18 @@ static int __tbm_surface_map(tbm_surface_h surface, int opt,
   return TBM_SURFACE_ERROR_NONE;
 }
 
-static int __tbm_surface_unmap(tbm_surface_h surface) {
+int __tbm_surface_unmap(tbm_surface_h surface) {
   return TBM_SURFACE_ERROR_NONE;
 }
 
-static void __receive_fake_message() {
+void __receive_fake_message() {
   Bundle b;
   b.Add("__APP_AMBIENT_EVENT__", "1");
   b.Add("__APP_AMBIENT_SENDER__", "test");
   __app_com_callback("", AUL_APP_COM_R_OK, b.GetHandle(), __app_com_user_data);
 }
 
-static int __aul_app_com_create(const char *endpoint,
+int __aul_app_com_create(const char *endpoint,
     aul_app_com_permission_h permission, app_com_cb callback, void *user_data,
     aul_app_com_connection_h *connection) {
   __app_com_callback = callback;
@@ -87,15 +89,15 @@ static int __aul_app_com_create(const char *endpoint,
   return 0;
 }
 
-static int __aul_app_com_leave(aul_app_com_connection_h connection) {
+int __aul_app_com_leave(aul_app_com_connection_h connection) {
   return 0;
 }
 
-static int __aul_app_com_send(const char *endpoint, bundle *envelope) {
+int __aul_app_com_send(const char *endpoint, bundle *envelope) {
   return 0;
 }
 
-static char* __vconf_get_str(const char* key) {
+char* __vconf_get_str(const char* key) {
   if (!key)
     return nullptr;
 
@@ -109,12 +111,12 @@ static char* __vconf_get_str(const char* key) {
   return nullptr;
 }
 
-static int __vconf_notify_key_changed(const char* key, vconf_callback_fn cb,
+int __vconf_notify_key_changed(const char* key, vconf_callback_fn cb,
     void* user_data) {
   return 0;
 }
 
-static int __vconf_ignore_key_changed(const char* key, vconf_callback_fn cb) {
+int __vconf_ignore_key_changed(const char* key, vconf_callback_fn cb) {
   return 0;
 }
 
@@ -242,6 +244,8 @@ class AmbientViewerTest : public ::testing::Test {
   }
 };
 
+} // namespace
+
 TEST_F(AmbientViewerTest, create) {
   EXPECT_NE(AmbientViewerTest::stub, nullptr);
 }
@@ -417,136 +421,3 @@ TEST_F(AmbientViewerTest, AmbientViewer_OnReceived2) {
 
   stub->Unmonitor();
 }
-
-class AmbientViewerStubTest : public ::testing::Test {
- public:
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_create_n) {
-  EXPECT_EQ(ambient_viewer_create(nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_create) {
-  ambient_viewer_h handle = nullptr;
-
-  EXPECT_EQ(ambient_viewer_create(reinterpret_cast<Evas_Object*>(&__not_null),
-    &handle), AMBIENT_VIEWER_ERROR_NONE);
-  EXPECT_NE(handle, nullptr);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_destroy_n) {
-  EXPECT_EQ(ambient_viewer_destroy(nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_destroy) {
-  ambient_viewer_h handle = nullptr;
-  ASSERT_EQ(ambient_viewer_create(reinterpret_cast<Evas_Object*>(&__not_null),
-    &handle), AMBIENT_VIEWER_ERROR_NONE);
-  ASSERT_NE(handle, nullptr);
-
-  EXPECT_EQ(ambient_viewer_destroy(handle),
-      AMBIENT_VIEWER_ERROR_NONE);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_notify_ambient_event_n) {
-  EXPECT_EQ(ambient_viewer_notify_ambient_event(nullptr, true,
-      AMBIENT_VIEWER_DIRECTION_ALL, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_block_update_n) {
-  EXPECT_EQ(ambient_viewer_block_update(nullptr, true),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_monitor_n) {
-  ambient_viewer_lifecycle_s lifecycle;
-  EXPECT_EQ(ambient_viewer_monitor(nullptr, lifecycle, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_unmonitor_n) {
-  EXPECT_EQ(ambient_viewer_unmonitor(nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_set_event_listener_n) {
-  EXPECT_EQ(ambient_viewer_set_event_listener(nullptr, nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-static void __ambient_viewer_event_cb(ambient_event_type_e event,
-    const char *sender, bundle *extra, void *user_data) {
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_set_event_listener) {
-  ambient_viewer_h handle = nullptr;
-  ASSERT_EQ(ambient_viewer_create(reinterpret_cast<Evas_Object*>(&__not_null),
-    &handle), AMBIENT_VIEWER_ERROR_NONE);
-  ASSERT_NE(handle, nullptr);
-
-  EXPECT_EQ(ambient_viewer_set_event_listener(handle, __ambient_viewer_event_cb,
-      nullptr), AMBIENT_VIEWER_ERROR_NONE);
-
-  ASSERT_EQ(ambient_viewer_destroy(handle),
-      AMBIENT_VIEWER_ERROR_NONE);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_unset_event_listener_n) {
-  EXPECT_EQ(ambient_viewer_unset_event_listener(nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_unset_event_listener) {
-  ambient_viewer_h handle = nullptr;
-  ASSERT_EQ(ambient_viewer_create(reinterpret_cast<Evas_Object*>(&__not_null),
-    &handle), AMBIENT_VIEWER_ERROR_NONE);
-  ASSERT_NE(handle, nullptr);
-  ASSERT_EQ(ambient_viewer_set_event_listener(handle, __ambient_viewer_event_cb,
-      nullptr), AMBIENT_VIEWER_ERROR_NONE);
-
-  EXPECT_EQ(ambient_viewer_unset_event_listener(handle),
-      AMBIENT_VIEWER_ERROR_NONE);
-
-  ASSERT_EQ(ambient_viewer_destroy(handle),
-      AMBIENT_VIEWER_ERROR_NONE);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_get_watch_surface_n) {
-  EXPECT_EQ(ambient_viewer_get_watch_surface(nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_get_top_app_surface_n) {
-  EXPECT_EQ(ambient_viewer_get_top_app_surface(nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_surface_get_cur_image_n) {
-  EXPECT_EQ(ambient_viewer_surface_get_cur_image(nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_surface_is_watch_n) {
-  EXPECT_EQ(ambient_viewer_surface_is_watch(nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_surface_get_app_id_n) {
-  EXPECT_EQ(ambient_viewer_surface_get_app_id(nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_surface_get_inst_id_n) {
-  EXPECT_EQ(ambient_viewer_surface_get_inst_id(nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(AmbientViewerStubTest, ambient_viewer_surface_get_opr_n) {
-  EXPECT_EQ(ambient_viewer_surface_get_opr(nullptr, nullptr),
-      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
-}
diff --git a/unittest/src/test_ambient_viewer_stub.cc b/unittest/src/test_ambient_viewer_stub.cc
new file mode 100644 (file)
index 0000000..3739b86
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "ambient-viewer/include/ambient_viewer.h"
+#include "ambient-viewer/include/ambient_viewer_common.h"
+
+extern "C" int ambient_viewer_create_mock(Evas_Object *win,
+    ambient_viewer_h *handle);
+
+namespace {
+
+gchar __not_null;
+
+void __ambient_viewer_event_cb(ambient_event_type_e event,
+    const char *sender, bundle *extra, void *user_data) {
+}
+
+} // namespace
+
+class AmbientViewerStubTest : public ::testing::Test {
+ public:
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_create_n) {
+  EXPECT_EQ(ambient_viewer_create(nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_create) {
+  ambient_viewer_h handle = nullptr;
+
+  EXPECT_EQ(ambient_viewer_create(reinterpret_cast<Evas_Object*>(&__not_null),
+    &handle), AMBIENT_VIEWER_ERROR_NONE);
+  EXPECT_NE(handle, nullptr);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_destroy_n) {
+  EXPECT_EQ(ambient_viewer_destroy(nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_destroy) {
+  ambient_viewer_h handle = nullptr;
+  ASSERT_EQ(ambient_viewer_create(reinterpret_cast<Evas_Object*>(&__not_null),
+    &handle), AMBIENT_VIEWER_ERROR_NONE);
+  ASSERT_NE(handle, nullptr);
+
+  EXPECT_EQ(ambient_viewer_destroy(handle),
+      AMBIENT_VIEWER_ERROR_NONE);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_notify_ambient_event_n) {
+  EXPECT_EQ(ambient_viewer_notify_ambient_event(nullptr, true,
+      AMBIENT_VIEWER_DIRECTION_ALL, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_block_update_n) {
+  EXPECT_EQ(ambient_viewer_block_update(nullptr, true),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_monitor_n) {
+  ambient_viewer_lifecycle_s lifecycle;
+  EXPECT_EQ(ambient_viewer_monitor(nullptr, lifecycle, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_unmonitor_n) {
+  EXPECT_EQ(ambient_viewer_unmonitor(nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_set_event_listener_n) {
+  EXPECT_EQ(ambient_viewer_set_event_listener(nullptr, nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_set_event_listener) {
+  ambient_viewer_h handle = nullptr;
+  ASSERT_EQ(ambient_viewer_create(reinterpret_cast<Evas_Object*>(&__not_null),
+    &handle), AMBIENT_VIEWER_ERROR_NONE);
+  ASSERT_NE(handle, nullptr);
+
+  EXPECT_EQ(ambient_viewer_set_event_listener(handle, __ambient_viewer_event_cb,
+      nullptr), AMBIENT_VIEWER_ERROR_NONE);
+
+  ASSERT_EQ(ambient_viewer_destroy(handle),
+      AMBIENT_VIEWER_ERROR_NONE);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_unset_event_listener_n) {
+  EXPECT_EQ(ambient_viewer_unset_event_listener(nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_unset_event_listener) {
+  ambient_viewer_h handle = nullptr;
+  ASSERT_EQ(ambient_viewer_create(reinterpret_cast<Evas_Object*>(&__not_null),
+    &handle), AMBIENT_VIEWER_ERROR_NONE);
+  ASSERT_NE(handle, nullptr);
+  ASSERT_EQ(ambient_viewer_set_event_listener(handle, __ambient_viewer_event_cb,
+      nullptr), AMBIENT_VIEWER_ERROR_NONE);
+
+  EXPECT_EQ(ambient_viewer_unset_event_listener(handle),
+      AMBIENT_VIEWER_ERROR_NONE);
+
+  ASSERT_EQ(ambient_viewer_destroy(handle),
+      AMBIENT_VIEWER_ERROR_NONE);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_get_watch_surface_n) {
+  EXPECT_EQ(ambient_viewer_get_watch_surface(nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_get_watch_surface) {
+  ambient_viewer_h handle = nullptr;
+  ambient_viewer_surface_h surface = nullptr;
+  ASSERT_EQ(ambient_viewer_create_mock(reinterpret_cast<Evas_Object*>(&__not_null),
+    &handle), AMBIENT_VIEWER_ERROR_NONE);
+  ASSERT_NE(handle, nullptr);
+
+  EXPECT_EQ(ambient_viewer_get_watch_surface(handle, &surface),
+      AMBIENT_VIEWER_ERROR_NONE);
+  EXPECT_EQ(surface, nullptr);
+
+  ASSERT_EQ(ambient_viewer_destroy(handle),
+      AMBIENT_VIEWER_ERROR_NONE);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_get_top_app_surface_n) {
+  EXPECT_EQ(ambient_viewer_get_top_app_surface(nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubTest, ambient_viewer_get_top_app_surface) {
+  ambient_viewer_h handle = nullptr;
+  ambient_viewer_surface_h surface = nullptr;
+  ASSERT_EQ(ambient_viewer_create_mock(reinterpret_cast<Evas_Object*>(&__not_null),
+    &handle), AMBIENT_VIEWER_ERROR_NONE);
+  ASSERT_NE(handle, nullptr);
+  ambient_viewer_lifecycle_s lifecycle = { 0, };
+  ASSERT_EQ(ambient_viewer_monitor(handle, lifecycle, nullptr),
+      AMBIENT_VIEWER_ERROR_NONE);
+
+  EXPECT_EQ(ambient_viewer_get_top_app_surface(handle, &surface),
+      AMBIENT_VIEWER_ERROR_NONE);
+  EXPECT_NE(surface, nullptr);
+
+  ASSERT_EQ(ambient_viewer_unmonitor(handle),
+      AMBIENT_VIEWER_ERROR_NONE);
+  ASSERT_EQ(ambient_viewer_destroy(handle),
+      AMBIENT_VIEWER_ERROR_NONE);
+}
+
+class AmbientViewerStubSurfaceTest : public ::testing::Test {
+ public:
+  virtual void SetUp() {
+    ASSERT_EQ(ambient_viewer_create_mock(reinterpret_cast<Evas_Object*>(
+      &__not_null), &handle_), AMBIENT_VIEWER_ERROR_NONE);
+    ASSERT_NE(handle_, nullptr);
+    ambient_viewer_lifecycle_s lifecycle = { 0, };
+    ASSERT_EQ(ambient_viewer_monitor(handle_, lifecycle, nullptr),
+        AMBIENT_VIEWER_ERROR_NONE);
+
+    ASSERT_EQ(ambient_viewer_get_top_app_surface(handle_, &surface_),
+        AMBIENT_VIEWER_ERROR_NONE);
+    ASSERT_NE(surface_, nullptr);
+  }
+
+  virtual void TearDown() {
+    ASSERT_EQ(ambient_viewer_unmonitor(handle_),
+      AMBIENT_VIEWER_ERROR_NONE);
+    ASSERT_EQ(ambient_viewer_destroy(handle_),
+      AMBIENT_VIEWER_ERROR_NONE);
+  }
+
+  ambient_viewer_h handle_ = nullptr;
+  ambient_viewer_surface_h surface_ = nullptr;
+};
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_get_cur_image_n) {
+  EXPECT_EQ(ambient_viewer_surface_get_cur_image(nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_get_cur_image) {
+  Evas_Object* obj = nullptr;
+  EXPECT_EQ(ambient_viewer_surface_get_cur_image(surface_, &obj),
+      AMBIENT_VIEWER_ERROR_NONE);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_is_watch_n) {
+  EXPECT_EQ(ambient_viewer_surface_is_watch(nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_is_watch) {
+  bool watch = false;
+  EXPECT_EQ(ambient_viewer_surface_is_watch(surface_, &watch),
+      AMBIENT_VIEWER_ERROR_NONE);
+  EXPECT_FALSE(watch);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_get_app_id_n) {
+  EXPECT_EQ(ambient_viewer_surface_get_app_id(nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_get_app_id) {
+  char* id = nullptr;
+  EXPECT_EQ(ambient_viewer_surface_get_app_id(surface_, &id),
+      AMBIENT_VIEWER_ERROR_NONE);
+  EXPECT_EQ(id, nullptr);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_get_inst_id_n) {
+  EXPECT_EQ(ambient_viewer_surface_get_inst_id(nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_get_inst_id) {
+  char* id = nullptr;
+  EXPECT_EQ(ambient_viewer_surface_get_inst_id(surface_, &id),
+      AMBIENT_VIEWER_ERROR_NONE);
+  EXPECT_EQ(id, nullptr);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_get_opr_n) {
+  EXPECT_EQ(ambient_viewer_surface_get_opr(nullptr, nullptr),
+      AMBIENT_VIEWER_ERROR_INVALID_PARAMETER);
+}
+
+TEST_F(AmbientViewerStubSurfaceTest, ambient_viewer_surface_get_opr) {
+  float opr;
+  EXPECT_EQ(ambient_viewer_surface_get_opr(surface_, &opr),
+      AMBIENT_VIEWER_ERROR_NONE);
+}