Add mockup packages to improve testability 84/232184/6
authorJunghoon Park <jh9216.park@samsung.com>
Wed, 29 Apr 2020 03:40:56 +0000 (12:40 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Mon, 18 May 2020 23:47:30 +0000 (08:47 +0900)
Change-Id: I4a0f6bf23cac38cd7c13de15d10b9464ef43aca9
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
16 files changed:
CMakeLists.txt
packaging/libscreen_connector.spec
screen_connector_remote_surface_evas_mock/CMakeLists.txt [new file with mode: 0644]
screen_connector_remote_surface_evas_mock/evas_event_interface.h [new file with mode: 0644]
screen_connector_remote_surface_evas_mock/evas_object.h [new file with mode: 0644]
screen_connector_remote_surface_evas_mock/remote_surface_evas.h [new file with mode: 0644]
screen_connector_remote_surface_evas_mock/remote_surface_watcher.h [new file with mode: 0644]
screen_connector_remote_surface_evas_mock/screen_connector_remote_surface_evas_mock.pc.in [new file with mode: 0644]
screen_connector_remote_surface_evas_mock/watcher_event_interface.h [new file with mode: 0644]
screen_connector_remote_surface_mock/CMakeLists.txt [new file with mode: 0644]
screen_connector_remote_surface_mock/buffer_event_interface.h [new file with mode: 0644]
screen_connector_remote_surface_mock/common.h [new file with mode: 0644]
screen_connector_remote_surface_mock/handle.h [new file with mode: 0644]
screen_connector_remote_surface_mock/remote_surface.h [new file with mode: 0644]
screen_connector_remote_surface_mock/screen_connector_remote_surface_mock.pc.in [new file with mode: 0644]
screen_connector_remote_surface_mock/trs_interface.h [new file with mode: 0644]

index 219e233..b2292a2 100644 (file)
@@ -5,7 +5,9 @@ ADD_SUBDIRECTORY(screen_connector_launcher_service_evas)
 ADD_SUBDIRECTORY(screen_connector_shared_widget_launch)
 ADD_SUBDIRECTORY(screen_connector_provider)
 ADD_SUBDIRECTORY(screen_connector_remote_surface)
+ADD_SUBDIRECTORY(screen_connector_remote_surface_mock)
 ADD_SUBDIRECTORY(screen_connector_remote_surface_evas)
+ADD_SUBDIRECTORY(screen_connector_remote_surface_evas_mock)
 ADD_SUBDIRECTORY(screen_connector_watcher)
 ADD_SUBDIRECTORY(screen_connector_watcher_evas)
 ADD_SUBDIRECTORY(unittest)
index 53876dc..f3a6d5e 100644 (file)
@@ -192,6 +192,23 @@ Header & package files to support development of the widget viewer applications.
 %attr(0644,root,root) %{_libdir}/%{name}_remote_surface.so
 
 #################################################
+# libscreen_connector_remote_surface_mock
+#################################################
+%package -n %{name}_remote_surface_mock
+Summary: Mockup header for developing the screen connector remote surface
+Group: Applications/Core Applications
+License: Apache-2.0
+
+%description -n %{name}_remote_surface_mock
+Provider APIs to develop unittests.
+
+%license LICENSE
+
+%files -n %{name}_remote_surface_mock
+%{_includedir}/screen_connector_remote_surface_mock/*.h
+%{_libdir}/pkgconfig/screen_connector_remote_surface_mock.pc
+
+#################################################
 # libscreen_connector_remote_surface_evas
 #################################################
 %package -n %{name}_remote_surface_evas
@@ -224,6 +241,23 @@ Header & package files to support development of the widget viewer applications.
 %{_libdir}/pkgconfig/screen_connector_remote_surface_evas.pc
 %attr(0644,root,root) %{_libdir}/%{name}_remote_surface_evas.so
 
+#################################################
+# libscreen_connector_remote_surface_evas_mock
+#################################################
+%package -n %{name}_remote_surface_evas_mock
+Summary: Mockup header for developing the screen connector remote surface evas
+Group: Applications/Core Applications
+Requires: %{name}_remote_surface_mock
+License: Apache-2.0
+
+%description -n %{name}_remote_surface_evas_mock
+Provider APIs to develop unittests.
+
+%license LICENSE
+
+%files -n %{name}_remote_surface_evas_mock
+%{_includedir}/screen_connector_remote_surface_evas_mock/*.h
+%{_libdir}/pkgconfig/screen_connector_remote_surface_evas_mock.pc
 
 #################################################
 # gtest-screen-connector
diff --git a/screen_connector_remote_surface_evas_mock/CMakeLists.txt b/screen_connector_remote_surface_evas_mock/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b203229
--- /dev/null
@@ -0,0 +1,22 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(screen_connector_remote_surface_evas_mock CXX)
+
+SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION_MAJOR 1)
+SET(VERSION "${VERSION_MAJOR}.0.0")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
+       PATTERN "*_internal.h"
+       PATTERN "*_implementation.h" EXCLUDE
+       PATTERN "*.h")
diff --git a/screen_connector_remote_surface_evas_mock/evas_event_interface.h b/screen_connector_remote_surface_evas_mock/evas_event_interface.h
new file mode 100644 (file)
index 0000000..3328f94
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_EVAS_EVENT_INTERFACE_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_EVAS_EVENT_INTERFACE_H_
+
+#include <string>
+
+#include <evas_object.h>
+
+namespace screen_connector {
+
+class IEvasEvent {
+ public:
+  virtual void OnEvasAdded(const std::string& appId, const std::string& instId,
+                           int pid,
+                           const EvasObject& image) = 0;
+  virtual void OnEvasRemoved(const std::string& appId,
+                             const std::string& instId,
+                             int pid,
+                             const EvasObject& image) = 0;
+  virtual void OnEvasChanged(const std::string& appId,
+                             const std::string& instId, int pid,
+                             const EvasObject& image) = 0;
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_EVAS_EVENT_INTERFACE_H_
diff --git a/screen_connector_remote_surface_evas_mock/evas_object.h b/screen_connector_remote_surface_evas_mock/evas_object.h
new file mode 100644 (file)
index 0000000..62572d8
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_EVAS_OBJECT_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_EVAS_OBJECT_H_
+
+#include <Elementary.h>
+
+#include <handle.h>
+
+namespace screen_connector {
+
+class EvasObject : public Handle<Evas_Object*> {
+ public:
+  EvasObject(Evas_Object* raw, bool owner)
+      : Handle<Evas_Object*>(raw, owner) {}
+  virtual ~EvasObject() {}
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_EVAS_OBJECT_H_
diff --git a/screen_connector_remote_surface_evas_mock/remote_surface_evas.h b/screen_connector_remote_surface_evas_mock/remote_surface_evas.h
new file mode 100644 (file)
index 0000000..47acf3c
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_REMOTE_SURFACE_EVAS_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_REMOTE_SURFACE_EVAS_H_
+
+#include <string>
+#include <memory>
+#include <map>
+
+#include <evas_object.h>
+#include <evas_event_interface.h>
+#include <remote_surface.h>
+
+
+namespace screen_connector {
+
+class RemoteSurfaceEvas : public RemoteSurface, public IEvasEvent {
+ public:
+  enum Visibility {
+    UNOBSCURED,
+    PARTIALLY_OBSCURED,
+    FULLY_OBSCURED,
+    UNKNOWN
+  };
+
+  RemoteSurfaceEvas(const std::string& id, RemoteSurface::Type type,
+      std::shared_ptr<EvasObject> viewerWin, bool mock = false)
+      : RemoteSurface(id, type, nullptr, mock) {}
+  RemoteSurfaceEvas(int rid, const std::string& id, RemoteSurface::Type type,
+      std::shared_ptr<EvasObject> viewerWin, bool mock = false)
+      : RemoteSurface(rid, id, type, nullptr, mock) {}
+
+  virtual void Bind(const EvasObject& win) {}
+  virtual bool IsVisibleArea() const { return false; }
+  virtual void SendMouseUp() {}
+  virtual Visibility GetVisibility() const { return UNOBSCURED; }
+  virtual void NotifyWindowVisibilityEvent(int type, void* event) {}
+
+ public:
+  void Unbind() override {}
+
+  virtual void SetAutoVisibility(bool enable) {}
+
+  void SetChangedEventFilter(RemoteSurface::ChangedEventFilter filter) override {}
+
+  void OnBufferAdded(const std::string& appId, const std::string& instId,
+                     int pid) override {}
+  void OnBufferRemoved(const std::string& appId, const std::string& instId,
+                       int pid) override {}
+  void OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm, int fd,
+                       uint32_t size, uint32_t time) override {}
+  void OnBind() override {}
+  void OnEvasAdded(const std::string& appId, const std::string& instId,
+                   int pid, const EvasObject& image) override {}
+  void OnEvasRemoved(const std::string& appId, const std::string& instId,
+                     int pid, const EvasObject& image) override {}
+  void OnEvasChanged(const std::string& appId, const std::string& instId,
+                     int pid, const EvasObject& image) override {}
+  virtual void ClearNoRenderTimer() {}
+  virtual void NoRenderPush(int timeout) {}
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_REMOTE_SURFACE_EVAS_H_
diff --git a/screen_connector_remote_surface_evas_mock/remote_surface_watcher.h b/screen_connector_remote_surface_evas_mock/remote_surface_watcher.h
new file mode 100644 (file)
index 0000000..0fce2d7
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_REMOTE_SURFACE_WATCHER_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_REMOTE_SURFACE_WATCHER_H_
+
+#include <string>
+#include <memory>
+#include <map>
+#include <list>
+
+#include <evas_object.h>
+#include <watcher_event_interface.h>
+#include <remote_surface.h>
+
+namespace screen_connector {
+class RemoteSurfaceWatcher : public IWatcherEvent {
+ public:
+  RemoteSurfaceWatcher(RemoteSurface::Type type,
+                       std::shared_ptr<EvasObject> viewerWin) {}
+  RemoteSurfaceWatcher(RemoteSurface::Type type,
+                       std::shared_ptr<EvasObject> viewerWin,
+                       bool watchFocusedOnly, bool mock = false) {}
+
+ public:
+  virtual void SetChangedEventFilter(RemoteSurface::ChangedEventFilter filter) {}
+  virtual int SetRemoteRender() { return 0; }
+  virtual int SetBlock(bool enable) { return 0; }
+  void OnWatcherAdded(const std::string& appId, const std::string& instId,
+                      const int pid) override {}
+  void OnWatcherChanged(const std::string& appId, const std::string& instId,
+                        const int pid, const EvasObject& image) override {}
+  void OnWatcherRemoved(const std::string& appId, const std::string& instId,
+                        const int pid) override {}
+  void OnWatcherFocusChanged(const std::string& appId,
+                        const std::string& instId, const int pid) override {}
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_REMOTE_SURFACE_WATCHER_H_
diff --git a/screen_connector_remote_surface_evas_mock/screen_connector_remote_surface_evas_mock.pc.in b/screen_connector_remote_surface_evas_mock/screen_connector_remote_surface_evas_mock.pc.in
new file mode 100644 (file)
index 0000000..ec32898
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: screen_connector_remote_surface_evas_mock
+Description: Support development of unittest
+Version: @VERSION@
+Requires: screen_connector_remote_surface_mock
+Cflags: -I${includedir}
+cppflags: -I${includedir}
diff --git a/screen_connector_remote_surface_evas_mock/watcher_event_interface.h b/screen_connector_remote_surface_evas_mock/watcher_event_interface.h
new file mode 100644 (file)
index 0000000..91f8812
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_WATCHER_EVENT_INTERFACE_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_WATCHER_EVENT_INTERFACE_H_
+
+#include <string>
+
+#include <evas_object.h>
+
+namespace screen_connector {
+
+class IWatcherEvent {
+ public:
+  virtual void OnWatcherAdded(const std::string& appId,
+                              const std::string& instId, int pid) = 0;
+  virtual void OnWatcherRemoved(const std::string& appId,
+                                const std::string& instId, int pid) = 0;
+  virtual void OnWatcherChanged(const std::string& appId,
+                                const std::string& instId, int pid,
+                                const EvasObject& image) = 0;
+  virtual void OnWatcherFocusChanged(const std::string& appId,
+                                     const std::string& instId, int pid) = 0;
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_WATCHER_EVENT_INTERFACE_H_
diff --git a/screen_connector_remote_surface_mock/CMakeLists.txt b/screen_connector_remote_surface_mock/CMakeLists.txt
new file mode 100644 (file)
index 0000000..32da7d9
--- /dev/null
@@ -0,0 +1,18 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(screen_connector_remote_surface_mock CXX)
+
+SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
+SET(PROJECT_NAME "${PROJECT_NAME}")
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}")
+SET(VERSION_MAJOR 1)
+SET(VERSION "${VERSION_MAJOR}.0.0")
+
+CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
+SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc")
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
+       PATTERN "*_internal.h"
+       PATTERN "*_implementation.h" EXCLUDE
+       PATTERN "*.h")
diff --git a/screen_connector_remote_surface_mock/buffer_event_interface.h b/screen_connector_remote_surface_mock/buffer_event_interface.h
new file mode 100644 (file)
index 0000000..c709250
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_BUFFER_EVENT_INTERFACE_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_BUFFER_EVENT_INTERFACE_H_
+
+#include <memory>
+#include <string>
+
+#include <handle.h>
+#include <common.h>
+
+namespace screen_connector {
+
+class IBufferEvent {
+ public:
+  virtual void OnBufferAdded(const std::string& appId,
+                             const std::string& instId, int pid) = 0;
+  virtual void OnBufferRemoved(const std::string& appId,
+                               const std::string& instId, int pid) = 0;
+  virtual void OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm, int fd,
+                               uint32_t size, uint32_t time) = 0;
+  virtual void OnBind() = 0;
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_BUFFER_EVENT_INTERFACE_H_
diff --git a/screen_connector_remote_surface_mock/common.h b/screen_connector_remote_surface_mock/common.h
new file mode 100644 (file)
index 0000000..a906730
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_COMMON_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_COMMON_H_
+
+#ifdef EXPORT_API
+#undef EXPORT_API
+#endif
+#define EXPORT_API __attribute__((visibility("default")))
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_COMMON_H_
diff --git a/screen_connector_remote_surface_mock/handle.h b/screen_connector_remote_surface_mock/handle.h
new file mode 100644 (file)
index 0000000..8fac6db
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_HANDLE_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_HANDLE_H_
+
+#include <Ecore_Wl2.h>
+#include <wayland-extension/tizen-extension-client-protocol.h>
+#include <tizen-remote-surface-client-protocol.h>
+#include <tbm_surface.h>
+#include <tbm_surface_internal.h>
+
+#include <common.h>
+
+namespace screen_connector {
+
+template <typename T>
+class Handle {
+ public:
+  Handle(T raw, bool owner) : raw_(raw), owner_(owner) { }
+  virtual ~Handle() { }
+
+  T GetRaw() const { return raw_; }
+  bool IsOwner() { return owner_; }
+  void SetIsOwner(bool owner) {
+    owner_ = owner;
+  }
+
+ private:
+  T raw_;
+  bool owner_;
+};
+
+class WlBuffer : public Handle<struct wl_buffer*> {
+ public:
+  WlBuffer(struct wl_buffer* raw, struct tizen_remote_surface* trs, bool owner)
+      : Handle<struct wl_buffer*>(raw, owner) {}
+
+  virtual ~WlBuffer() {}
+};
+
+class WlSurface : public Handle<struct wl_surface*> {
+ public:
+  WlSurface(struct wl_surface* raw, bool owner) :
+      Handle<struct wl_surface*>(raw, owner) { }
+
+  virtual ~WlSurface() { }
+};
+
+class TbmSurface : public Handle<tbm_surface_h> {
+ public:
+  TbmSurface(tbm_surface_h raw, bool owner) :
+      Handle<tbm_surface_h>(raw, owner) { }
+
+  virtual ~TbmSurface() {}
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_HANDLE_H_
diff --git a/screen_connector_remote_surface_mock/remote_surface.h b/screen_connector_remote_surface_mock/remote_surface.h
new file mode 100644 (file)
index 0000000..86ad8a5
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_REMOTE_SURFACE_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_REMOTE_SURFACE_H_
+
+#include <string>
+#include <memory>
+
+#include <buffer_event_interface.h>
+#include <trs_interface.h>
+#include <common.h>
+
+namespace screen_connector {
+
+class RemoteSurface : public IBufferEvent {
+ public:
+  enum Type {
+    WIDGET = 0x1,
+    WATCH = 0x2,
+    UI = 0x4,
+    ALL = WIDGET | WATCH | UI
+  };
+
+  enum ChangedEventFilter {
+    FILTER_NONE,
+    FILTER_TBM,
+    FILTER_IMAGE_FILE,
+    FILTER_ALL
+  };
+
+  enum InputType {
+    MOUSE_UP_DOWN,
+    MOUSE_MOVE_X,
+    MOUSE_MOVE_Y,
+    MOUSE_MOVE_X_Y,
+    MOUSE_WHEEL,
+    TOUCH_UP_DOWN,
+    TOUCH_MOVE_X,
+    TOUCH_MOVE_Y,
+    TOUCH_MOVE_X_Y,
+    TOUCH_CANCEL,
+    KEY
+  };
+
+  RemoteSurface(const std::string& id, Type type,
+      std::shared_ptr<WlSurface> wl_surface, bool mock = false) {}
+  RemoteSurface(int rid, const std::string& id, Type type,
+      std::shared_ptr<WlSurface> wl_surface, bool mock = false) {}
+  virtual ~RemoteSurface() {}
+
+  const std::string& GetAppId() const {
+    static std::string sAppid;
+    return sAppid;
+  }
+
+  const std::string& GetInstId() const {
+    static std::string sInstId;
+    return sInstId;
+  }
+
+  virtual int GetPid() const { return 0; }
+  virtual int GetRid() const { return 0; }
+  virtual Type GetType() const { return WIDGET; }
+  virtual bool IsFrozen() const { return false; }
+  virtual ITRS* GetRaw() { return nullptr; }
+  virtual ChangedEventFilter GetChangedEventFilter() const { return FILTER_NONE; }
+  virtual void SendVisibility(bool visible) {}
+  virtual void SendTouchCancel() {}
+  virtual void SendMouseUp(int x, int y, unsigned int timestamp) {}
+  virtual void Bind(std::shared_ptr<WlSurface> surface) {}
+  virtual void Freeze(bool visible) {}
+  virtual void Thaw() {}
+  virtual void SetChangedEventFilter(ChangedEventFilter filter) {};
+  virtual bool IsDisabledInput(InputType type) const { return false; }
+  virtual bool IsRemoteRender() const { return false; }
+  virtual void ClearRemoteRender() {}
+  virtual int SetRemoteRender() { return 0; }
+  virtual void SetBlock(bool is_block) {}
+  virtual void Unbind() {}
+  virtual bool IsBound() const { return false; }
+  void OnBufferAdded(const std::string& appId,
+                     const std::string& instId, int pid) override {}
+  void OnBufferRemoved(const std::string& appId,
+                       const std::string& instId, int pid) override {}
+  void OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm, int fd,
+                       uint32_t size, uint32_t time) override {}
+  void OnBind() override {}
+
+  static void SetDelayedResumingTime(uint32_t ms) {}
+  static void InitManager() {}
+  static void FiniManager() {}
+
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_REMOTE_SURFACE_H_
diff --git a/screen_connector_remote_surface_mock/screen_connector_remote_surface_mock.pc.in b/screen_connector_remote_surface_mock/screen_connector_remote_surface_mock.pc.in
new file mode 100644 (file)
index 0000000..18945fd
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: screen_connector_remote_surface_mock
+Description: Support development of the screen connector remote surface library
+Version: @VERSION@
+Cflags: -I${includedir}
+cppflags: -I${includedir}
diff --git a/screen_connector_remote_surface_mock/trs_interface.h b/screen_connector_remote_surface_mock/trs_interface.h
new file mode 100644 (file)
index 0000000..3a3a9c9
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_TRS_INTERFACE_H_
+#define SCREEN_CONNECTOR_REMOTE_SURFACE_TRS_INTERFACE_H_
+
+#include <tizen-remote-surface-client-protocol.h>
+
+#include <memory>
+#include <string>
+
+#include <common.h>
+
+namespace screen_connector {
+
+class ITRS {
+ public:
+  class IEventListener {
+   public:
+    virtual void OnRawBufferMissing() = 0;
+    virtual void OnRawBufferChanged(int type, std::shared_ptr<WlBuffer> tbm,
+                                    int fd, uint32_t size, uint32_t time) = 0;
+    virtual void OnInputFilterChanged(uint32_t event_filter) = 0;
+  };
+
+  virtual ~ITRS() = default;
+  virtual struct tizen_remote_surface* GetHandle() const = 0;
+  virtual void TransferVisibility(bool visible) = 0;
+  virtual void TransferTouchCancel() = 0;
+  virtual void TransferMouseUp(int x, int y, unsigned int timestamp) = 0;
+  virtual void SetRemoteRender(bool set) = 0;
+  virtual void SetChangedBufferEventFilter(int filter) = 0;
+  virtual void AddListener(IEventListener* listener) = 0;
+  virtual void Redirect() = 0;
+  virtual void TransferTouchEvent(uint32_t event_type, int32_t device,
+                                  int32_t button, int32_t x, int32_t y,
+                                  wl_fixed_t radius_x, wl_fixed_t radius_y,
+                                  wl_fixed_t pressure, wl_fixed_t angle,
+                                  uint32_t clas, uint32_t subclas,
+                                  const char *identifier, uint32_t time) = 0;
+  virtual void TransferMouseEvent(uint32_t event_type, int32_t device,
+                                  int32_t button, int32_t x, int32_t y,
+                                  wl_fixed_t radius_x, wl_fixed_t radius_y,
+                                  wl_fixed_t pressure, wl_fixed_t angle,
+                                  uint32_t clas, uint32_t subclas,
+                                  const char *identifier, uint32_t time) = 0;
+  virtual void TransferMouseWheel(uint32_t direction, int32_t z, uint32_t clas,
+                                  uint32_t subclas, const char *identifier,
+                                  uint32_t time) = 0;
+};
+
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_TRS_INTERFACE_H_