Block top app surface feature 43/231843/4
authorDaehyeon Jung <darrenh.jung@samsung.com>
Fri, 24 Apr 2020 11:17:03 +0000 (20:17 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Mon, 27 Apr 2020 03:38:33 +0000 (12:38 +0900)
Change-Id: I2828980a34209279594ba146e98d62aab8cbd1c2
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
ambient-viewer/src/ambient-viewer.cc
ambient-viewer/src/ambient-viewer.hh
ambient-viewer/src/stub.cc
unittest/src/test_ambient_viewer.cc
unittest/src/test_ambient_viewer_stub.cc

index 56a06c0..56f4951 100644 (file)
@@ -95,9 +95,13 @@ void AmbientViewer::OnChangedSignal(keynode_t *node, void *user_data) {
   }
 }
 
-void AmbientViewer::Monitor() {
-  top_app_surface_ = CreateTopAppSurface(
-      make_shared<screen_connector::EvasObject>(win_, false), this);
+void AmbientViewer::Monitor(bool full) {
+
+  if (full) {
+    top_app_surface_ = CreateTopAppSurface(
+        make_shared<screen_connector::EvasObject>(win_, false), this);
+  }
+
   if (vconf_notify_key_changed(
       VCONFKEY_WATCH_CURRENT_WATCH_INFO, OnChangedSignal, this) != 0) {
     LOGE("failed to listen on changed signal");
index bd643ea..a4172c1 100644 (file)
@@ -53,7 +53,7 @@ class EXPORT_API AmbientViewer : public IAmbientViewer {
  public:
   AmbientViewer(Evas_Object* win);
   virtual ~AmbientViewer();
-  void Monitor();
+  void Monitor(bool full = false);
   void Unmonitor();
   virtual void OnReceived(EventType ev, std::string sender, tizen_base::Bundle extra) = 0;
   int NotifyAmbientEvent(bool enter, Direction dir, tizen_base::Bundle extra);
index bfb6dcd..be81a29 100644 (file)
@@ -246,6 +246,28 @@ extern "C" EXPORT_API int ambient_viewer_monitor(ambient_viewer_h handle,
   return AMBIENT_VIEWER_ERROR_NONE;
 }
 
+extern "C" int ambient_viewer_monitor_full(ambient_viewer_h handle,
+    ambient_viewer_lifecycle_s lifecycle, void *user_data) {
+  if (handle == nullptr) {
+    LOGE("Invalid parameter");
+    return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
+  }
+
+  AmbientViewerStub* stub = static_cast<AmbientViewerStub*>(handle);
+
+  unique_ptr<MonitorCallbackInfo> info(
+    new (nothrow) MonitorCallbackInfo(lifecycle, user_data));
+  if (info.get() == nullptr) {
+    LOGE("out of memory");
+    return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY;
+  }
+
+  stub->SetMonitorCallbackInfo(move(info));
+  stub->Monitor(true);
+
+  return AMBIENT_VIEWER_ERROR_NONE;
+}
+
 extern "C" EXPORT_API int ambient_viewer_unmonitor(ambient_viewer_h handle) {
   if (handle == nullptr) {
     LOGE("Invalid parameter");
index 87c4471..5f693a4 100644 (file)
@@ -357,7 +357,7 @@ TEST_F(AmbientViewerTest, AmbientViewer_OnReceived) {
 }
 
 TEST_F(AmbientViewerTest, TopAppSurface_IsWatch) {
-  stub->Monitor();
+  stub->Monitor(true);
   const auto& ws = AmbientViewerTest::stub->GetTopAppSurface();
   ASSERT_NE(&ws, nullptr);
 
@@ -367,7 +367,7 @@ TEST_F(AmbientViewerTest, TopAppSurface_IsWatch) {
 }
 
 TEST_F(AmbientViewerTest, TopAppSurface_GetAppId) {
-  stub->Monitor();
+  stub->Monitor(true);
   const auto& ws = AmbientViewerTest::stub->GetTopAppSurface();
   ASSERT_NE(&ws, nullptr);
   TopAppSurfaceMock* mock = const_cast<TopAppSurfaceMock*>(
@@ -380,7 +380,7 @@ TEST_F(AmbientViewerTest, TopAppSurface_GetAppId) {
 }
 
 TEST_F(AmbientViewerTest, TopAppSurface_GetInstId) {
-  stub->Monitor();
+  stub->Monitor(true);
   const auto& ws = AmbientViewerTest::stub->GetTopAppSurface();
   ASSERT_NE(&ws, nullptr);
   TopAppSurfaceMock* mock = const_cast<TopAppSurfaceMock*>(
@@ -396,7 +396,7 @@ TEST_F(AmbientViewerTest, TopAppSurface_GetInstId) {
 }
 
 TEST_F(AmbientViewerTest, TopAppSurface_GetOpr) {
-  stub->Monitor();
+  stub->Monitor(true);
   const auto& ws = AmbientViewerTest::stub->GetTopAppSurface();
   ASSERT_NE(&ws, nullptr);
   TopAppSurfaceMock* mock = const_cast<TopAppSurfaceMock*>(
@@ -411,7 +411,7 @@ TEST_F(AmbientViewerTest, TopAppSurface_GetOpr) {
 }
 
 TEST_F(AmbientViewerTest, AmbientViewer_OnReceived2) {
-  stub->Monitor();
+  stub->Monitor(true);
   const auto& ws = AmbientViewerTest::stub->GetWatchSurface();
   ASSERT_NE(&ws, nullptr);
   stub->received_ = false;
index 3739b86..426d83a 100644 (file)
@@ -23,6 +23,8 @@
 
 extern "C" int ambient_viewer_create_mock(Evas_Object *win,
     ambient_viewer_h *handle);
+extern "C" int ambient_viewer_monitor_full(ambient_viewer_h handle,
+    ambient_viewer_lifecycle_s lifecycle, void *user_data);
 
 namespace {
 
@@ -160,7 +162,7 @@ TEST_F(AmbientViewerStubTest, ambient_viewer_get_top_app_surface) {
     &handle), AMBIENT_VIEWER_ERROR_NONE);
   ASSERT_NE(handle, nullptr);
   ambient_viewer_lifecycle_s lifecycle = { 0, };
-  ASSERT_EQ(ambient_viewer_monitor(handle, lifecycle, nullptr),
+  ASSERT_EQ(ambient_viewer_monitor_full(handle, lifecycle, nullptr),
       AMBIENT_VIEWER_ERROR_NONE);
 
   EXPECT_EQ(ambient_viewer_get_top_app_surface(handle, &surface),
@@ -180,7 +182,7 @@ class AmbientViewerStubSurfaceTest : public ::testing::Test {
       &__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),
+    ASSERT_EQ(ambient_viewer_monitor_full(handle_, lifecycle, nullptr),
         AMBIENT_VIEWER_ERROR_NONE);
 
     ASSERT_EQ(ambient_viewer_get_top_app_surface(handle_, &surface_),