1 /**************************************************************************
3 * Copyright 2022 Samsung Electronics co., Ltd. All Rights Reserved.
5 * Contact: SooChan Lim <sc1.lim@samsung.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #include "mockclient.h"
31 #include <gtest/gtest.h>
33 MockClient::MockClient()
35 display = wl_display_connect("test-ds-tizen");
37 ds_err("wl_display_connect() filed.");
39 registry = wl_display_get_registry(display);
41 ds_err("wl_display_get_registry() filed.");
44 MockClient::MockClient(const struct wl_registry_listener *registry_listener, void *data)
47 display = wl_display_connect("test-ds-tizen");
49 ds_err("wl_display_connect() filed.");
51 registry = wl_display_get_registry(display);
53 ds_err("wl_display_get_registry() filed.");
55 ret = wl_registry_add_listener(registry, registry_listener, data);
57 ds_err("wl_registry_add_listener() filed.");
59 wl_display_roundtrip(display);
62 MockClient::~MockClient()
64 wl_registry_destroy(registry);
65 wl_display_disconnect(display);
68 void MockClient::RoundTrip()
70 wl_display_roundtrip(display);
73 void MockClient::ExpectNoError()
75 const struct wl_interface *interface;
80 int err = wl_display_get_error(this->display);
83 errcode = wl_display_get_protocol_error(this->display, &interface,
85 FAIL() << "Expected no error, but got error(" << err << ") interface("
86 << interface->name << ") errcode(" << errcode << ")";
90 void MockClient::ExpectProtocolError(const struct wl_interface *intf,
95 int err = wl_display_get_error(this->display);
97 ASSERT_NE(err, 0) << "Expected protocol error but nothing came";
98 ASSERT_EQ(err, EPROTO)
99 << "Expected protocol error but got local error";
101 const struct wl_interface *interface;
102 uint32_t errcode = wl_display_get_protocol_error(this->display,
105 ASSERT_EQ(errcode, code)
106 << "Should get error code " << code << " but got " << errcode;
108 ASSERT_STREQ(intf->name, interface->name)
109 << "Should get interface '" << intf->name << "' but got '"
110 << interface->name << "'";
113 struct wl_display * MockClient::GetWlDisplay()