| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#ifndef UNITTEST_GUNIT_XPLUGIN_XPL_MOCK_COMPONENT_SERVICES_H_ |
| 27 |
#define UNITTEST_GUNIT_XPLUGIN_XPL_MOCK_COMPONENT_SERVICES_H_ |
| 28 |
|
| 29 |
#include <assert.h> |
| 30 |
#include <gmock/gmock.h> |
| 31 |
#include <gtest/gtest.h> |
| 32 |
|
| 33 |
|
| 34 |
#include "mysql/components/services/mysql_admin_session.h" |
| 35 |
#include "mysql/service_plugin_registry.h" |
| 36 |
|
| 37 |
namespace xpl { |
| 38 |
namespace test { |
| 39 |
namespace mock { |
| 40 |
|
| 41 |
class Mysql_plugin_registry { |
| 42 |
public: |
| 43 |
Mysql_plugin_registry(); |
| 44 |
~Mysql_plugin_registry(); |
| 45 |
|
| 46 |
MOCK_METHOD(int, mysql_plugin_registry_release, (SERVICE_TYPE(registry) *)); |
| 47 |
MOCK_METHOD(SERVICE_TYPE(registry) *, mysql_plugin_registry_acquire, ()); |
| 48 |
|
| 49 |
static xpl::test::mock::Mysql_plugin_registry *m_mysql_plugin_registry; |
| 50 |
}; |
| 51 |
|
| 52 |
class Service_registry { |
| 53 |
public: |
| 54 |
Service_registry(); |
| 55 |
~Service_registry(); |
| 56 |
|
| 57 |
MOCK_METHOD2(acquire, mysql_service_status_t(const char *service_name, |
| 58 |
my_h_service *out_service)); |
| 59 |
MOCK_METHOD3(acquire_related, |
| 60 |
mysql_service_status_t(const char *service_name, |
| 61 |
my_h_service service, |
| 62 |
my_h_service *out_service)); |
| 63 |
MOCK_METHOD(mysql_service_status_t, release, (my_h_service service)); |
| 64 |
|
| 65 |
SERVICE_TYPE_NO_CONST(registry) * get() { return &m_registry; } |
| 66 |
|
| 67 |
private: |
| 68 |
static xpl::test::mock::Service_registry *m_this; |
| 69 |
|
| 70 |
SERVICE_TYPE_NO_CONST(registry) |
| 71 |
m_registry = {[](const char *service_name, my_h_service *out_service) { |
| 72 |
return m_this->acquire(service_name, out_service); |
| 73 |
}, |
| 74 |
[](const char *service_name, my_h_service service, |
| 75 |
my_h_service *out_service) { |
| 76 |
return m_this->acquire_related(service_name, service, |
| 77 |
out_service); |
| 78 |
}, |
| 79 |
[](my_h_service service) { return m_this->release(service); }}; |
| 80 |
}; |
| 81 |
|
| 82 |
class Service_admin_session { |
| 83 |
public: |
| 84 |
Service_admin_session(); |
| 85 |
~Service_admin_session(); |
| 86 |
|
| 87 |
MOCK_METHOD(MYSQL_SESSION, open, (srv_session_error_cb, void *)); |
| 88 |
SERVICE_TYPE_NO_CONST(mysql_admin_session) * get() { |
| 89 |
return &m_admin_session; |
| 90 |
} |
| 91 |
|
| 92 |
private: |
| 93 |
static xpl::test::mock::Service_admin_session *m_this; |
| 94 |
|
| 95 |
SERVICE_TYPE_NO_CONST(mysql_admin_session) |
| 96 |
m_admin_session = {[](srv_session_error_cb error_cb, void *ctxt) { |
| 97 |
return m_this->open(error_cb, ctxt); |
| 98 |
}}; |
| 99 |
}; |
| 100 |
|
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
#endif |