rpc-port
capi-base-common
gmock
+ capi-appfw-app-manager
+ cynara-client
+ cynara-session
)
FOREACH(flag ${pkgs_CFLAGS})
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../common AUTOFILL_COMMON_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../client AUTOFILL_CLIENT_SOURCES)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../service_lib AUTOFILL_SERVICE_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../manager AUTOFILL_MANAGER_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../privilege_checker AUTOFILL_PRIVILEGE_SOURCES)
ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"")
${AUTOFILL_COMMON_SOURCES}
${AUTOFILL_CLIENT_SOURCES}
${AUTOFILL_SERVICE_SOURCES}
+ ${AUTOFILL_MANAGER_SOURCES}
+ ${AUTOFILL_PRIVILEGE_SOURCES}
${SOURCES}
)
TARGET_LINK_LIBRARIES(${UTC_AUTOFILL} ${GTEST_LIBRARIES} ${pkgs_LDFLAGS} ${EXTRA_LDFLAGS})
+SET_TARGET_PROPERTIES(${UTC_AUTOFILL} PROPERTIES
+ COMPILE_FLAGS "-fPIE"
+ #Never add any space for LINKFLAGS
+ LINK_FLAGS "-Wl,\
+--wrap=cynara_initialize,\
+--wrap=cynara_finish,\
+--wrap=cynara_session_from_pid,\
+--wrap=cynara_check")
INSTALL(TARGETS ${UTC_AUTOFILL} DESTINATION /usr/bin)
--- /dev/null
+//
+// Copyright (c) 2014 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 <gtest/gtest.h>
+#include <autofill_manager.h>
+#include <glib.h>
+#include <Ecore.h>
+
+#include "cynara_mock.h"
+
+//& set: CapiUi-autofill-manager
+
+static autofill_manager_h g_amh = NULL;
+
+class AutofillManagerDeniedTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ ecore_init();
+
+ cynara_check_set_result(CYNARA_API_ACCESS_DENIED);
+
+ autofill_manager_create(&g_amh);
+ }
+ virtual void TearDown() {
+ if (g_amh) {
+ autofill_manager_destroy(g_amh);
+ }
+
+ g_amh = NULL;
+ ecore_shutdown();
+ }
+};
+
+/**
+ * @testcase utc_autofill_manager_denied_create_p
+ * @since_tizen 5.5
+ * @description Positive UTC of the function that creates autofill manager instance.
+ */
+TEST_F(AutofillManagerDeniedTest, utc_autofill_manager_denied_create_p)
+{
+ autofill_manager_h amh = NULL;
+ int ret = autofill_manager_create(&amh);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_PERMISSION_DENIED);
+
+ autofill_manager_destroy(amh);
+}
+
+/**
+ * @testcase utc_autofill_manager_denied_create_n
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that creates autofill manager instance.
+ */
+TEST_F(AutofillManagerDeniedTest, utc_autofill_manager_denied_create_n)
+{
+ int ret = autofill_manager_create(NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_PERMISSION_DENIED);
+}
+
+/**
+ * @testcase utc_autofill_manager_denied_destroy
+ * @since_tizen 5.5
+ * @description Positive UTC of the function that destroys autofill manager instance.
+ */
+TEST_F(AutofillManagerDeniedTest, utc_autofill_manager_denied_destroy)
+{
+ int ret = autofill_manager_destroy(NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_PERMISSION_DENIED);
+}
+
+/**
+ * @testcase utc_autofill_manager_denied_connect_n
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that connects to autofill daemon.
+ */
+TEST_F(AutofillManagerDeniedTest, utc_autofill_manager_denied_connect_n)
+{
+ int ret = autofill_manager_connect(NULL, NULL, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_PERMISSION_DENIED);
+}
+
+/**
+ * @testcase utc_autofill_manager_denied_foreach_autofill_service_n1
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that retrieves each autofill service app id.
+ */
+TEST_F(AutofillManagerDeniedTest, utc_autofill_manager_denied_foreach_autofill_service_n)
+{
+ int ret = autofill_manager_foreach_autofill_service(NULL, NULL, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_PERMISSION_DENIED);
+}
+
+/**
+ * @testcase utc_autofill_manager_denied_get_autofill_service_n1
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that gets the current used autofill service app id.
+ */
+TEST_F(AutofillManagerDeniedTest, utc_autofill_manager_denied_get_autofill_service_n)
+{
+ int ret = autofill_manager_get_autofill_service(NULL, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_PERMISSION_DENIED);
+}
+
+/**
+ * @testcase utc_autofill_manager_denied_set_autofill_service_n1
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that sets which autofill service to use.
+ */
+TEST_F(AutofillManagerDeniedTest, utc_autofill_manager_denied_set_autofill_service_n)
+{
+ int ret = autofill_manager_set_autofill_service(NULL, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_PERMISSION_DENIED);
+}
--- /dev/null
+//
+// Copyright (c) 2014 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 <gtest/gtest.h>
+#include <autofill_manager.h>
+#include <app_manager.h>
+#include <glib.h>
+#include <Ecore.h>
+
+#include "cynara_mock.h"
+
+//& set: CapiUi-autofill-manager
+
+static autofill_manager_h g_amh = NULL;
+
+static bool autofill_service_info_cb(const char* app_id, void* user_data)
+{
+ app_info_h app_h;
+ char *label = NULL;
+
+ app_info_create(app_id, &app_h);
+ app_info_get_label(app_h, &label);
+
+ if (label)
+ free(label);
+
+ app_info_destroy(app_h);
+
+ return true;
+}
+
+class AutofillManagerTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ ecore_init();
+
+ cynara_check_set_result(CYNARA_API_ACCESS_ALLOWED);
+
+ autofill_manager_create(&g_amh);
+ }
+ virtual void TearDown() {
+ if (g_amh) {
+ autofill_manager_destroy(g_amh);
+ }
+
+ g_amh = NULL;
+ ecore_shutdown();
+ }
+};
+
+/**
+ * @testcase utc_autofill_manager_create_p
+ * @since_tizen 5.5
+ * @description Positive UTC of the function that creates autofill manager instance.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_create_p)
+{
+ autofill_manager_h amh = NULL;
+ int ret = autofill_manager_create(&amh);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_NONE);
+
+ autofill_manager_destroy(amh);
+}
+
+/**
+ * @testcase utc_autofill_manager_create_n
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that creates autofill manager instance.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_create_n)
+{
+ int ret = autofill_manager_create(NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase utc_autofill_manager_destroy_p
+ * @since_tizen 5.5
+ * @description Positive UTC of the function that destroys autofill manager instance.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_destroy_p)
+{
+ autofill_manager_h amh = NULL;
+ int ret = autofill_manager_create(&amh);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_NONE);
+
+ ret = autofill_manager_destroy(amh);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_NONE);
+}
+
+/**
+ * @testcase utc_autofill_manager_destroy_n
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that destroys autofill manager instance.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_destroy_n)
+{
+ int ret = autofill_manager_destroy(NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase utc_autofill_manager_connect_n
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that connects to autofill daemon.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_connect_n)
+{
+ int ret = autofill_manager_connect(NULL, NULL, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase utc_autofill_manager_foreach_autofill_service_n1
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that retrieves each autofill service app id.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_foreach_autofill_service_n1)
+{
+ int ret = autofill_manager_foreach_autofill_service(NULL, NULL, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase utc_autofill_manager_foreach_autofill_service_n2
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that retrieves each autofill service app id.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_foreach_autofill_service_n2)
+{
+ int ret = autofill_manager_foreach_autofill_service(g_amh, autofill_service_info_cb, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_OPERATION_FAILED);
+}
+
+/**
+ * @testcase utc_autofill_manager_get_autofill_service_n1
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that gets the current used autofill service app id.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_get_autofill_service_n1)
+{
+ int ret = autofill_manager_get_autofill_service(NULL, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase utc_autofill_manager_get_autofill_service_n2
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that gets the current used autofill service app id.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_get_autofill_service_n2)
+{
+ char *active_autofill_service_appid = NULL;
+
+ int ret = autofill_manager_get_autofill_service(g_amh, &active_autofill_service_appid);
+ if (active_autofill_service_appid)
+ {
+ free(active_autofill_service_appid);
+ }
+ EXPECT_EQ(ret, AUTOFILL_ERROR_OPERATION_FAILED);
+}
+
+/**
+ * @testcase utc_autofill_manager_set_autofill_service_n1
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that sets which autofill service to use.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_set_autofill_service_n1)
+{
+ int ret = autofill_manager_set_autofill_service(NULL, NULL);
+ EXPECT_EQ(ret, AUTOFILL_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase utc_autofill_manager_set_autofill_service_n2
+ * @since_tizen 5.5
+ * @description Negative UTC of the function that sets which autofill service to use.
+ */
+TEST_F(AutofillManagerTest, utc_autofill_manager_set_autofill_service_n2)
+{
+ int ret = autofill_manager_set_autofill_service(g_amh, "org.tizen.autofill-service");
+ EXPECT_EQ(ret, AUTOFILL_ERROR_OPERATION_FAILED);
+}
\ No newline at end of file
--- /dev/null
+#include "cynara_mock.h"
+#include <string.h>
+#include <stdio.h>
+#include <tizen.h>
+
+static int check_result = CYNARA_API_ACCESS_ALLOWED;
+
+void cynara_check_set_result(int result)
+{
+ check_result = result;
+}
+
+EXPORT_API int __wrap_cynara_initialize(cynara** c, const cynara_configuration* conf)
+{
+ *c = (void *)0x1;
+ return 0;
+}
+
+EXPORT_API int __wrap_cynara_finish(cynara* c)
+{
+ return 0;
+}
+
+EXPORT_API int __wrap_cynara_check(cynara* c, const char* client, const char* client_session,
+ const char* user,
+ const char* privilege)
+{
+ return check_result;
+}
+
+EXPORT_API char *__wrap_cynara_session_from_pid(pid_t pid)
+{
+ return strdup("session");
+}
--- /dev/null
+#ifndef MOCK_CYNARA_H_
+#define MOCK_CYNARA_H_
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void cynara;
+typedef void* cynara_configuration;
+
+/*! \brief indicating that API call was interrupted by user*/
+#define CYNARA_API_INTERRUPTED 4
+
+/*! \brief indicating access that cannot be resolved without further actions*/
+#define CYNARA_API_ACCESS_NOT_RESOLVED 3
+
+/*! \brief indicating access that was checked is allowed */
+#define CYNARA_API_ACCESS_ALLOWED 2
+
+/*! \brief indicating that access that was checked is denied */
+#define CYNARA_API_ACCESS_DENIED 1
+
+/*! \brief indicating the result of the one specific API is successful */
+#define CYNARA_API_SUCCESS 0
+
+/*! \brief indicating that value is not present in cache */
+#define CYNARA_API_CACHE_MISS -1
+
+/*! \brief indicating that pending requests reached maximum */
+#define CYNARA_API_MAX_PENDING_REQUESTS -2
+
+/*! \brief indicating system is running out of memory state */
+#define CYNARA_API_OUT_OF_MEMORY -3
+
+/*! \brief indicating the API's parameter is malformed */
+#define CYNARA_API_INVALID_PARAM -4
+
+/*! \brief indicating that service is not available */
+#define CYNARA_API_SERVICE_NOT_AVAILABLE -5
+
+/*! \brief indicating that provided method is not supported by library */
+#define CYNARA_API_METHOD_NOT_SUPPORTED -6
+
+/*! \brief cynara service does not allow to perform requested operation */
+#define CYNARA_API_OPERATION_NOT_ALLOWED -7
+
+/*! \brief cynara service failed to perform requested operation */
+#define CYNARA_API_OPERATION_FAILED -8
+
+/*! \brief cynara service hasn't found requested bucket */
+#define CYNARA_API_BUCKET_NOT_FOUND -9
+
+/*! \brief indicating an unknown error */
+#define CYNARA_API_UNKNOWN_ERROR -10
+
+/*! \brief indicating configuration error */
+#define CYNARA_API_CONFIGURATION_ERROR -11
+
+/*! \brief indicating invalid parameter in command-line */
+#define CYNARA_API_INVALID_COMMANDLINE_PARAM -12
+
+/*! \brief indicating that provided buffer is too short */
+#define CYNARA_API_BUFFER_TOO_SHORT -13
+
+/*! \brief indicating that database is corrupted */
+#define CYNARA_API_DATABASE_CORRUPTED -14
+
+/*! \brief indicating that user doesn't have enough permission to perform action */
+#define CYNARA_API_PERMISSION_DENIED -15
+
+void cynara_check_set_result(int result);
+
+int __wrap_cynara_initialize(cynara** c, const cynara_configuration* conf);
+int __wrap_cynara_finish(cynara* c);
+int __wrap_cynara_check(cynara* c, const char* client, const char* client_session,
+ const char* user,
+ const char* privilege);
+
+char *__wrap_cynara_session_from_pid(pid_t pid);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* MOCK_CYNARA_H_ */