diff options
Diffstat (limited to 'tests/mock')
-rw-r--r-- | tests/mock/app_common_mock.cc | 6 | ||||
-rw-r--r-- | tests/mock/app_common_mock.hh (renamed from tests/mock/app_common_mock.h) | 2 | ||||
-rw-r--r-- | tests/mock/aul_mock.cc | 28 | ||||
-rw-r--r-- | tests/mock/aul_mock.hh (renamed from tests/mock/glib_mock.h) | 31 | ||||
-rw-r--r-- | tests/mock/glib_mock.cc | 72 | ||||
-rw-r--r-- | tests/mock/glib_mock.hh | 66 | ||||
-rw-r--r-- | tests/mock/mock_hook.hh (renamed from tests/mock/mock_hook.h) | 0 | ||||
-rw-r--r-- | tests/mock/module_mock.hh (renamed from tests/mock/module_mock.h) | 0 | ||||
-rw-r--r-- | tests/mock/package_manager_mock.cc | 37 | ||||
-rw-r--r-- | tests/mock/package_manager_mock.hh | 37 | ||||
-rw-r--r-- | tests/mock/security_manager_mock.cc | 6 | ||||
-rw-r--r-- | tests/mock/security_manager_mock.hh (renamed from tests/mock/security_manager_mock.h) | 2 | ||||
-rw-r--r-- | tests/mock/smack_mock.cc | 6 | ||||
-rw-r--r-- | tests/mock/smack_mock.hh (renamed from tests/mock/smack_mock.h) | 2 | ||||
-rw-r--r-- | tests/mock/socket_mock.cc | 24 | ||||
-rw-r--r-- | tests/mock/socket_mock.hh | 33 | ||||
-rw-r--r-- | tests/mock/sqlite_mock.cc | 87 | ||||
-rw-r--r-- | tests/mock/sqlite_mock.hh | 48 | ||||
-rw-r--r-- | tests/mock/test_fixture.cc | 2 | ||||
-rw-r--r-- | tests/mock/test_fixture.hh (renamed from tests/mock/test_fixture.h) | 2 | ||||
-rw-r--r-- | tests/mock/tzplatform_config_mock.cc | 6 | ||||
-rw-r--r-- | tests/mock/tzplatform_config_mock.hh (renamed from tests/mock/tzplatform_config_mock.h) | 2 |
22 files changed, 461 insertions, 38 deletions
diff --git a/tests/mock/app_common_mock.cc b/tests/mock/app_common_mock.cc index 2a49180..ef5ba69 100644 --- a/tests/mock/app_common_mock.cc +++ b/tests/mock/app_common_mock.cc @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "app_common_mock.h" +#include "app_common_mock.hh" -#include "mock_hook.h" -#include "test_fixture.h" +#include "mock_hook.hh" +#include "test_fixture.hh" extern "C" int app_get_name(char** arg1) { return MOCK_HOOK_P1(AppCommonMock, app_get_name, arg1); diff --git a/tests/mock/app_common_mock.h b/tests/mock/app_common_mock.hh index 18bcbc8..c1b85bc 100644 --- a/tests/mock/app_common_mock.h +++ b/tests/mock/app_common_mock.hh @@ -20,7 +20,7 @@ #include <gmock/gmock.h> #include <app_common.h> -#include "module_mock.h" +#include "module_mock.hh" class AppCommonMock : public virtual ModuleMock { public: diff --git a/tests/mock/aul_mock.cc b/tests/mock/aul_mock.cc new file mode 100644 index 0000000..7c6efbc --- /dev/null +++ b/tests/mock/aul_mock.cc @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022 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. + */ + +#include "aul_mock.hh" + +#include "mock_hook.hh" +#include "test_fixture.hh" + +extern "C" int aul_app_get_appid_bypid(int pid, char* appid, int len) { + return MOCK_HOOK_P3(AulMock, aul_app_get_appid_bypid, pid, appid, len); +} + +extern "C" int aul_app_get_pkgid_bypid(int pid, char* pkgid, int len) { + return MOCK_HOOK_P3(AulMock, aul_app_get_pkgid_bypid, pid, pkgid, len); +} diff --git a/tests/mock/glib_mock.h b/tests/mock/aul_mock.hh index 03688ad..2c3ea83 100644 --- a/tests/mock/glib_mock.h +++ b/tests/mock/aul_mock.hh @@ -14,28 +14,25 @@ * limitations under the License. */ -#ifndef UNIT_TESTS_MOCK_GLIB_MOCK_H_ -#define UNIT_TESTS_MOCK_GLIB_MOCK_H_ +#ifndef UNIT_TESTS_MOCK_AUL_MOCK_H_ +#define UNIT_TESTS_MOCK_AUL_MOCK_H_ -#include <gio/gio.h> -#include <glib.h> #include <gmock/gmock.h> +#include <aul.h> +#include <aul_app_event.h> +#include <aul_app_group.h> +#include <aul_app_manager.h> +#include <aul_svc.h> +#include <aul_window.h> -#include "module_mock.h" +#include "module_mock.hh" -class GlibMock : public virtual ModuleMock { +class AulMock : public virtual ModuleMock { public: - GlibMock() { - using ::testing::_; - using ::testing::Return; - using ::testing::Invoke; - } + virtual ~AulMock() {} - MOCK_METHOD1(g_file_new_for_path, GFile* (const char*)); - MOCK_METHOD2(g_file_query_exists, gboolean (GFile*, GCancellable*)); - MOCK_METHOD3(g_file_make_directory, gboolean (GFile*, GCancellable*, GError**)); - - MOCK_METHOD2(access, int (const char*, int)); + MOCK_METHOD3(aul_app_get_appid_bypid, int(int, char*, int)); + MOCK_METHOD3(aul_app_get_pkgid_bypid, int(int, char*, int)); }; -#endif // UNIT_TESTS_MOCK_GLIB_MOCK_H_ +#endif // UNIT_TESTS_MOCK_AUL_MOCK_H_ diff --git a/tests/mock/glib_mock.cc b/tests/mock/glib_mock.cc index 15569ac..2e99040 100644 --- a/tests/mock/glib_mock.cc +++ b/tests/mock/glib_mock.cc @@ -14,10 +14,14 @@ * limitations under the License. */ -#include "glib_mock.h" +#include "glib_mock.hh" -#include "mock_hook.h" -#include "test_fixture.h" +#include "mock_hook.hh" +#include "test_fixture.hh" + +extern "C" uid_t getuid() { + return 5001; +} extern "C" GFile* g_file_new_for_path(const char* arg1) { return MOCK_HOOK_P1(GlibMock, g_file_new_for_path, arg1); @@ -35,3 +39,65 @@ extern "C" gboolean g_file_make_directory(GFile* arg1, GCancellable* arg2, extern "C" int access(const char* arg1, int arg2) { return MOCK_HOOK_P2(GlibMock, access, arg1, arg2); } + +extern "C" ssize_t read(int fd, void *buf, size_t count) { + return MOCK_HOOK_P3(GlibMock, read, fd, buf, count); +} + +extern "C" GDBusConnection* g_bus_get_sync(GBusType type, + GCancellable* cancellable, GError** error) { + return MOCK_HOOK_P3(GlibMock, g_bus_get_sync, type, cancellable, error); +} + +extern "C" GDBusMessage* g_dbus_connection_send_message_with_reply_sync( + GDBusConnection* conn, GDBusMessage* msg, GDBusSendMessageFlags flags, + gint timeout, volatile guint32* out_serial, GCancellable* cancellable, + GError** error) { + return MOCK_HOOK_P7(GlibMock, g_dbus_connection_send_message_with_reply_sync, + conn, msg, flags, timeout, out_serial, cancellable, error); +} + +extern "C" GVariant* g_dbus_message_get_body(GDBusMessage* arg0) { + return MOCK_HOOK_P1(GlibMock, g_dbus_message_get_body, arg0); +} + +extern "C" GList* g_list_append (GList* list, gpointer data) { + return MOCK_HOOK_P2(GlibMock, g_list_append, list, data); +} + +extern "C" guint g_dbus_connection_signal_subscribe(GDBusConnection* arg0, + const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4, + const gchar* arg5, GDBusSignalFlags arg6, GDBusSignalCallback arg7, + gpointer arg8, GDestroyNotify arg9) { + return MOCK_HOOK_P10(GlibMock, g_dbus_connection_signal_subscribe, + arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); +} + +extern "C" gboolean g_dbus_connection_emit_signal(GDBusConnection* arg0, + const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4, + GVariant* arg5, GError** arg6) { + return MOCK_HOOK_P7(GlibMock, g_dbus_connection_emit_signal, + arg0, arg1, arg2, arg3, arg4, arg5, arg6); +} + +extern "C" gboolean g_dbus_connection_flush_sync(GDBusConnection* arg0, + GCancellable* arg1, GError** arg2) { + return MOCK_HOOK_P3(GlibMock, g_dbus_connection_flush_sync, arg0, arg1, arg2); +} + +extern "C" const gchar* g_dbus_connection_get_unique_name(GDBusConnection* connection) { + return MOCK_HOOK_P1(GlibMock, g_dbus_connection_get_unique_name, connection); +} + +extern "C" guint g_bus_watch_name (GBusType bus_type, const gchar* name, GBusNameWatcherFlags flags, + GBusNameAppearedCallback name_appeared_handler, GBusNameVanishedCallback name_vanished_handler, + gpointer user_data, GDestroyNotify user_data_free_func) { + return MOCK_HOOK_P7(GlibMock, g_bus_watch_name, bus_type, name, flags, name_appeared_handler, + name_vanished_handler, user_data, user_data_free_func); +} + +extern "C" GDBusMessage* g_dbus_message_new_method_call(const gchar* arg0, + const gchar* arg1, const gchar* arg2, const gchar* arg3) { + return MOCK_HOOK_P4(GlibMock, g_dbus_message_new_method_call, arg0, arg1, arg2, + arg3); +} diff --git a/tests/mock/glib_mock.hh b/tests/mock/glib_mock.hh new file mode 100644 index 0000000..06331fd --- /dev/null +++ b/tests/mock/glib_mock.hh @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022 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 UNIT_TESTS_MOCK_GLIB_MOCK_H_ +#define UNIT_TESTS_MOCK_GLIB_MOCK_H_ + +#include <gio/gio.h> +#include <glib.h> +#include <gmock/gmock.h> + +#include "module_mock.hh" + +class GlibMock : public virtual ModuleMock { + public: + GlibMock() { + using ::testing::_; + using ::testing::Return; + using ::testing::Invoke; + } + + MOCK_METHOD0(getuid, uid_t()); + MOCK_METHOD1(g_file_new_for_path, GFile* (const char*)); + MOCK_METHOD2(g_file_query_exists, gboolean (GFile*, GCancellable*)); + MOCK_METHOD3(g_file_make_directory, gboolean (GFile*, GCancellable*, GError**)); + + MOCK_METHOD2(access, int (const char*, int)); + MOCK_METHOD3(read, size_t(int , void*, size_t)); + + MOCK_METHOD3(g_bus_get_sync, GDBusConnection*(GBusType, GCancellable*, GError**)); + + MOCK_METHOD7(g_dbus_connection_send_message_with_reply_sync, + GDBusMessage*(GDBusConnection*, GDBusMessage*, GDBusSendMessageFlags, + gint, volatile guint32*, GCancellable*, GError**)); + + MOCK_METHOD1(g_dbus_message_get_body, GVariant*(GDBusMessage*)); + MOCK_METHOD2(g_list_append, GList*(GList*, gpointer)); + MOCK_METHOD10(g_dbus_connection_signal_subscribe, + guint(GDBusConnection*, const gchar*, const gchar*, const gchar*, + const gchar*, const gchar*, GDBusSignalFlags, GDBusSignalCallback, + gpointer, GDestroyNotify)); + MOCK_METHOD7(g_dbus_connection_emit_signal, + gboolean(GDBusConnection*, const gchar*, const gchar*, const gchar*, + const gchar*, GVariant*, GError**)); + MOCK_METHOD3(g_dbus_connection_flush_sync, + gboolean(GDBusConnection*, GCancellable*, GError**)); + MOCK_METHOD1(g_dbus_connection_get_unique_name, const gchar*(GDBusConnection*)); + MOCK_METHOD7(g_bus_watch_name, guint(GBusType, const gchar*, GBusNameWatcherFlags, + GBusNameAppearedCallback, GBusNameVanishedCallback, gpointer, GDestroyNotify)); + MOCK_METHOD4(g_dbus_message_new_method_call, + GDBusMessage*(const gchar*, const gchar*, const gchar*, const gchar*)); +}; + +#endif // UNIT_TESTS_MOCK_GLIB_MOCK_H_ diff --git a/tests/mock/mock_hook.h b/tests/mock/mock_hook.hh index 29b0932..29b0932 100644 --- a/tests/mock/mock_hook.h +++ b/tests/mock/mock_hook.hh diff --git a/tests/mock/module_mock.h b/tests/mock/module_mock.hh index 9b19d89..9b19d89 100644 --- a/tests/mock/module_mock.h +++ b/tests/mock/module_mock.hh diff --git a/tests/mock/package_manager_mock.cc b/tests/mock/package_manager_mock.cc new file mode 100644 index 0000000..e6e5e98 --- /dev/null +++ b/tests/mock/package_manager_mock.cc @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022 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. + */ + +#include "package_manager_mock.hh" + +#include "mock_hook.hh" +#include "test_fixture.hh" + +extern "C" int package_info_create(const char *package, package_info_h *package_info) { + return MOCK_HOOK_P2(PackageManagerMock, package_info_create, package, package_info); +} + +extern "C" int package_info_get_root_path(package_info_h package_info, char **path) { + return MOCK_HOOK_P2(PackageManagerMock, package_info_get_root_path, package_info, path); +} + +extern "C" int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, + uid_t uid, pkgmgrinfo_appinfo_h *handle) { + return MOCK_HOOK_P3(PackageManagerMock, pkgmgrinfo_appinfo_get_usr_appinfo, appid, uid, handle); +} + +extern "C" int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label) { + return MOCK_HOOK_P2(PackageManagerMock, pkgmgrinfo_appinfo_get_label, handle, label); +} diff --git a/tests/mock/package_manager_mock.hh b/tests/mock/package_manager_mock.hh new file mode 100644 index 0000000..8cca951 --- /dev/null +++ b/tests/mock/package_manager_mock.hh @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022 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 UNIT_TESTS_MOCK_PACKAGE_MANAGER_MOCK_H_ +#define UNIT_TESTS_MOCK_PACKAGE_MANAGER_MOCK_H_ + +#include <gmock/gmock.h> +#include <package_manager.h> +#include <pkgmgr-info.h> +#include <pkgmgrinfo_basic.h> + +#include "module_mock.hh" + +class PackageManagerMock : public virtual ModuleMock { + public: + virtual ~PackageManagerMock() {} + + MOCK_METHOD2(package_info_create, int(const char*, package_info_h*)); + MOCK_METHOD2(package_info_get_root_path, int(package_info_h, char**)); + MOCK_METHOD3(pkgmgrinfo_appinfo_get_usr_appinfo, int(const char*, uid_t, pkgmgrinfo_appinfo_h*)); + MOCK_METHOD2(pkgmgrinfo_appinfo_get_label, int(pkgmgrinfo_appinfo_h, char**)); +}; + +#endif // UNIT_TESTS_MOCK_PACKAGE_MANAGER_MOCK_H_ diff --git a/tests/mock/security_manager_mock.cc b/tests/mock/security_manager_mock.cc index 85710d6..67c2dad 100644 --- a/tests/mock/security_manager_mock.cc +++ b/tests/mock/security_manager_mock.cc @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "security_manager_mock.h" +#include "security_manager_mock.hh" -#include "mock_hook.h" -#include "test_fixture.h" +#include "mock_hook.hh" +#include "test_fixture.hh" extern "C" int security_manager_private_sharing_req_new(private_sharing_req** arg1) { return MOCK_HOOK_P1(SecurityManagerMock, security_manager_private_sharing_req_new, arg1); diff --git a/tests/mock/security_manager_mock.h b/tests/mock/security_manager_mock.hh index c5424fd..cc35956 100644 --- a/tests/mock/security_manager_mock.h +++ b/tests/mock/security_manager_mock.hh @@ -20,7 +20,7 @@ #include <security-manager.h> #include <gmock/gmock.h> -#include "module_mock.h" +#include "module_mock.hh" class SecurityManagerMock : public virtual ModuleMock { public: diff --git a/tests/mock/smack_mock.cc b/tests/mock/smack_mock.cc index 4b8388d..28aae23 100644 --- a/tests/mock/smack_mock.cc +++ b/tests/mock/smack_mock.cc @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "smack_mock.h" +#include "smack_mock.hh" -#include "mock_hook.h" -#include "test_fixture.h" +#include "mock_hook.hh" +#include "test_fixture.hh" extern "C" ssize_t smack_new_label_from_path(const char* arg1, const char* arg2, int arg3, char** arg4) { diff --git a/tests/mock/smack_mock.h b/tests/mock/smack_mock.hh index 2517c16..4ebdf44 100644 --- a/tests/mock/smack_mock.h +++ b/tests/mock/smack_mock.hh @@ -20,7 +20,7 @@ #include <gmock/gmock.h> #include <sys/smack.h> -#include "module_mock.h" +#include "module_mock.hh" class SmackMock : public virtual ModuleMock { public: diff --git a/tests/mock/socket_mock.cc b/tests/mock/socket_mock.cc new file mode 100644 index 0000000..ea5c46c --- /dev/null +++ b/tests/mock/socket_mock.cc @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "socket_mock.hh" + +#include "mock_hook.hh" +#include "test_fixture.hh" + +extern "C" int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen) { + return MOCK_HOOK_P5(SocketMock, getsockopt, sockfd, level, optname, optval, optlen); +} diff --git a/tests/mock/socket_mock.hh b/tests/mock/socket_mock.hh new file mode 100644 index 0000000..9bbbb40 --- /dev/null +++ b/tests/mock/socket_mock.hh @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 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 UNIT_TESTS_MOCK_SOCKET_MOCK_H_ +#define UNIT_TESTS_MOCK_SOCKET_MOCK_H_ + +#include <gmock/gmock.h> +#include <sys/types.h> +#include <sys/socket.h> + +#include "module_mock.hh" + +class SocketMock : public virtual ModuleMock { + public: + virtual ~SocketMock() {} + + MOCK_METHOD5(getsockopt, int(int, int, int, void*, socklen_t*)); +}; + +#endif // UNIT_TESTS_MOCK_SOCKET_MOCK_H_ diff --git a/tests/mock/sqlite_mock.cc b/tests/mock/sqlite_mock.cc new file mode 100644 index 0000000..b031493 --- /dev/null +++ b/tests/mock/sqlite_mock.cc @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 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. + */ + +#include "sqlite_mock.hh" + +#include "mock_hook.hh" +#include "test_fixture.hh" + +typedef int(*execcb)(void*, int, char**, char**); +typedef void(*bindcb)(void*); + +extern "C" int sqlite3_open_v2(const char* arg0, + sqlite3** arg1, int arg2, const char* arg3) { + return MOCK_HOOK_P4(SqliteMock, sqlite3_open_v2, arg0, arg1, arg2, arg3); +} + +extern "C" int sqlite3_close(sqlite3* arg0) { + return MOCK_HOOK_P1(SqliteMock, sqlite3_close, arg0); +} + +extern "C" int sqlite3_changes(sqlite3* arg0) { + return MOCK_HOOK_P1(SqliteMock, sqlite3_changes, arg0); +} + +extern "C" int sqlite3_exec(sqlite3* arg0, const char* arg1, + execcb arg2, void* arg3, char** arg4) { + return MOCK_HOOK_P5(SqliteMock, sqlite3_exec, arg0, arg1, arg2, arg3, arg4); +} + +extern "C" int sqlite3_prepare_v2(sqlite3* arg0, const char* arg1, + int arg2, sqlite3_stmt** arg3, const char** arg4) { + return MOCK_HOOK_P5(SqliteMock, sqlite3_prepare_v2, arg0, arg1, arg2, arg3, arg4); +} + +extern "C" int sqlite3_step(sqlite3_stmt* arg0) { + return MOCK_HOOK_P1(SqliteMock, sqlite3_step, arg0); +} + +extern "C" const unsigned char* sqlite3_column_text(sqlite3_stmt* arg0, int arg1) { + return MOCK_HOOK_P2(SqliteMock, sqlite3_column_text, arg0, arg1); +} + +extern "C" int sqlite3_get_table(sqlite3 *db, const char *zSql, char ***pazResult, + int *pnRow, int *pnColumn, char **pzErrmsg) { + return MOCK_HOOK_P6(SqliteMock, sqlite3_get_table, db, zSql, pazResult, pnRow, pnColumn, pzErrmsg); +} + +extern "C" int sqlite3_bind_int(sqlite3_stmt* arg0, int arg1, int arg2) { + return MOCK_HOOK_P3(SqliteMock, sqlite3_bind_int, arg0, arg1, arg2); +} + +extern "C" int sqlite3_bind_double(sqlite3_stmt* arg0, int arg1, double arg2) { + return MOCK_HOOK_P3(SqliteMock, sqlite3_bind_double, arg0, arg1, arg2); +} + +extern "C" int sqlite3_bind_text(sqlite3_stmt* arg0, int arg1, const char* arg2, int arg3, bindcb arg4) { + return MOCK_HOOK_P5(SqliteMock, sqlite3_bind_text, arg0, arg1, arg2, arg3, arg4); +} + +extern "C" int sqlite3_finalize(sqlite3_stmt* arg0) { + return MOCK_HOOK_P1(SqliteMock, sqlite3_finalize, arg0); +} + +extern "C" void sqlite3_free(void* arg0) { + return MOCK_HOOK_P1(SqliteMock, sqlite3_free, arg0); +} + +extern "C" int sqlite3_column_int(sqlite3_stmt* stmt, int iCol) { + return MOCK_HOOK_P2(SqliteMock, sqlite3_column_int, stmt, iCol); +} + +extern "C" double sqlite3_column_double(sqlite3_stmt* stmt, int iCol) { + return MOCK_HOOK_P2(SqliteMock, sqlite3_column_double, stmt, iCol); +} diff --git a/tests/mock/sqlite_mock.hh b/tests/mock/sqlite_mock.hh new file mode 100644 index 0000000..0c9cfb5 --- /dev/null +++ b/tests/mock/sqlite_mock.hh @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 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 UNIT_TESTS_MOCK_SQLITE_MOCK_H_ +#define UNIT_TESTS_MOCK_SQLITE_MOCK_H_ + +#include <gmock/gmock.h> +#include <sqlite3.h> + +#include "module_mock.hh" + +class SqliteMock : public virtual ModuleMock { + public: + virtual ~SqliteMock() {} + + MOCK_METHOD1(sqlite3_close, int(sqlite3*)); + MOCK_METHOD1(sqlite3_changes, int(sqlite3*)); + MOCK_METHOD4(sqlite3_open_v2, int(const char*, sqlite3**, int, const char*)); + MOCK_METHOD5(sqlite3_exec, int(sqlite3*, const char*, + int(*)(void*, int, char**, char**), void*, char**)); + MOCK_METHOD5(sqlite3_prepare_v2, int(sqlite3*, const char*, + int, sqlite3_stmt**, const char**)); + MOCK_METHOD1(sqlite3_step, int(sqlite3_stmt*)); + MOCK_METHOD2(sqlite3_column_text, const unsigned char*(sqlite3_stmt*, int)); + MOCK_METHOD6(sqlite3_get_table, int(sqlite3*, const char*, char***, int* , int*, char**)); + MOCK_METHOD3(sqlite3_bind_int, int(sqlite3_stmt*, int, int)); + MOCK_METHOD3(sqlite3_bind_double, int(sqlite3_stmt*, int, double)); + MOCK_METHOD5(sqlite3_bind_text, int(sqlite3_stmt*, int, const char*, int, void(*)(void*))); + MOCK_METHOD1(sqlite3_finalize, int(sqlite3_stmt*)); + MOCK_METHOD1(sqlite3_free, void(void*)); + MOCK_METHOD2(sqlite3_column_int, int(sqlite3_stmt*, int)); + MOCK_METHOD2(sqlite3_column_double, double(sqlite3_stmt*, int)); +}; + +#endif // UNIT_TESTS_MOCK_SQLITE_MOCK_H_ diff --git a/tests/mock/test_fixture.cc b/tests/mock/test_fixture.cc index 27f5666..50f39e9 100644 --- a/tests/mock/test_fixture.cc +++ b/tests/mock/test_fixture.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "test_fixture.h" +#include "test_fixture.hh" #include <memory> diff --git a/tests/mock/test_fixture.h b/tests/mock/test_fixture.hh index 1ea3b8f..0bf58d1 100644 --- a/tests/mock/test_fixture.h +++ b/tests/mock/test_fixture.hh @@ -24,7 +24,7 @@ #include <string> #include <utility> -#include "module_mock.h" +#include "module_mock.hh" class TestFixture : public ::testing::Test { public: diff --git a/tests/mock/tzplatform_config_mock.cc b/tests/mock/tzplatform_config_mock.cc index e6b3cbd..6094654 100644 --- a/tests/mock/tzplatform_config_mock.cc +++ b/tests/mock/tzplatform_config_mock.cc @@ -14,10 +14,10 @@ * limitations under the License. */ -#include "tzplatform_config_mock.h" +#include "tzplatform_config_mock.hh" -#include "mock_hook.h" -#include "test_fixture.h" +#include "mock_hook.hh" +#include "test_fixture.hh" extern "C" const char* tzplatform_getenv(enum tzplatform_variable arg1) { return MOCK_HOOK_P1(TzplatformConfigMock, tzplatform_getenv, arg1); diff --git a/tests/mock/tzplatform_config_mock.h b/tests/mock/tzplatform_config_mock.hh index b6c75e4..43d1ac1 100644 --- a/tests/mock/tzplatform_config_mock.h +++ b/tests/mock/tzplatform_config_mock.hh @@ -20,7 +20,7 @@ #include <tzplatform_config.h> #include <gmock/gmock.h> -#include "module_mock.h" +#include "module_mock.hh" class TzplatformConfigMock : public virtual ModuleMock { public: |