Fix wayland mock 36/271236/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 17 Feb 2022 04:13:49 +0000 (13:13 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 17 Feb 2022 05:16:05 +0000 (14:16 +0900)
The wayland API is modified. The mockup functions that are
wl_proxy_marshal_flags() and wl_proxy_get_version() add needed.

Change-Id: I68f6523e958040ef54f70cb13d03c78c82d0e693
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
unittests/mock/wayland_mock.cc
unittests/mock/wayland_mock.h

index 9040e03..3fef8cd 100644 (file)
 #include "mock/mock_hook.h"
 #include "mock/test_fixture.h"
 
-extern "C" wl_display* wl_display_connect(const char *name) {
+extern "C" struct wl_display* wl_display_connect(const char *name) {
   return MOCK_HOOK_P1(WaylandMock, wl_display_connect, name);
 }
 
-extern "C" void wl_display_disconnect(wl_display* display) {
+extern "C" void wl_display_disconnect(struct wl_display* display) {
   MOCK_HOOK_P1(WaylandMock, wl_display_disconnect, display);
 }
 
-extern "C" wl_proxy* wl_proxy_marshal_constructor(wl_proxy* proxy, uint32_t opcode,
-    const wl_interface* interface, ...) {
+extern "C" wl_proxy* wl_proxy_marshal_constructor(struct wl_proxy* proxy,
+    uint32_t opcode, const struct wl_interface* interface, ...) {
   static int dummy;
-  return (wl_proxy*)&dummy;
+  return (struct wl_proxy*)&dummy;
 }
 
-extern "C" int wl_proxy_add_listener(wl_proxy *proxy,
+extern "C" int wl_proxy_add_listener(struct wl_proxy *proxy,
     void (**implementation)(void), void *data) {
   return MOCK_HOOK_P3(WaylandMock, wl_proxy_add_listener, proxy,
       implementation, data);
 }
 
-extern "C" int wl_display_roundtrip(wl_display* display) {
+extern "C" int wl_display_roundtrip(struct wl_display* display) {
   return MOCK_HOOK_P1(WaylandMock, wl_display_roundtrip, display);
 }
 
-extern "C" void wl_proxy_marshal(wl_proxy *proxy, uint32_t opcode, ...) {
+extern "C" void wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) {
 }
 
-extern "C" void wl_proxy_destroy(wl_proxy *proxy) {
+extern "C" void wl_proxy_destroy(struct wl_proxy *proxy) {
+}
+
+extern "C" struct wl_proxy* wl_proxy_marshal_flags(struct wl_proxy* proxy,
+    uint32_t opcode, const struct wl_interface* interface, uint32_t version,
+    uint32_t flags, ...) {
+  static int dummy;
+  return (struct wl_proxy*)&dummy;
+}
+
+extern "C" uint32_t wl_proxy_get_version(struct wl_proxy* proxy) {
+  return 7;
 }
index 91ca2fe..08a3c99 100644 (file)
@@ -18,9 +18,6 @@
 #define UNIT_TESTS_MOCK_WAYLAND_MOCK_H_
 
 #include <gmock/gmock.h>
-#include <wayland-client.h>
-#include <wayland-tbm-client.h>
-#include <tizen-extension-client-protocol.h>
 
 #include "mock/module_mock.h"
 
@@ -31,16 +28,22 @@ class WaylandMock : public virtual ModuleMock {
     using ::testing::Invoke;
 
     ON_CALL(*this, wl_display_connect(_))
-      .WillByDefault(Invoke([&](const char*) -> wl_display* {
-        static int dummy;
-        return (wl_display*)&dummy;
-      }));
+        .WillByDefault(Invoke([&](const char*) -> struct wl_display* {
+          static int dummy;
+          return (wl_display*)&dummy;
+        }));
+    ON_CALL(*this, wl_proxy_add_listener(_, _, _))
+        .WillByDefault(Invoke([&](
+            struct wl_proxy*, void (**)(void), void*) -> int {
+          return 0;
+        }));
   }
 
-  MOCK_METHOD1(wl_display_connect, wl_display* (const char*));
-  MOCK_METHOD1(wl_display_disconnect, void (wl_display*));
-  MOCK_METHOD3(wl_proxy_add_listener, int (wl_proxy*, void (**)(void), void*));
-  MOCK_METHOD1(wl_display_roundtrip, int (wl_display*));
+  MOCK_METHOD1(wl_display_connect, struct wl_display* (const char*));
+  MOCK_METHOD1(wl_display_disconnect, void (struct wl_display*));
+  MOCK_METHOD3(wl_proxy_add_listener,
+      int (struct wl_proxy*, void (**)(void), void*));
+  MOCK_METHOD1(wl_display_roundtrip, int (struct wl_display*));
 };
 
 #endif  // UNIT_TESTS_MOCK_WAYLAND_MOCK_H_