-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ TEST_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/lib/ TEST_LIB_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/server/ TEST_SERVER_SRCS)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
ENABLE_TESTING()
-SET(TARGET_TEST "app2sd-test")
+SET(TARGET_LIB_TEST "app2sd-lib-test")
+SET(TARGET_SERVER_TEST "app2sd-server-test")
-ADD_EXECUTABLE(${TARGET_TEST} ${TEST_SRCS})
+ADD_EXECUTABLE(${TARGET_LIB_TEST} ${TEST_LIB_SRCS})
+ADD_EXECUTABLE(${TARGET_SERVER_TEST} ${TEST_SERVER_SRCS})
-APPLY_PKG_CONFIG(${TARGET_TEST} PUBLIC
+APPLY_PKG_CONFIG(${TARGET_LIB_TEST} PUBLIC
app2ext_libpkgs
GMOCK_DEPS
)
-ADD_TEST(${TARGET_TEST} ${TARGET_TEST})
-TARGET_LINK_LIBRARIES(${TARGET_TEST} app2ext "${${TARGET_TEST}_LDFLAGS}" dl gobject-2.0)
\ No newline at end of file
+APPLY_PKG_CONFIG(${TARGET_SERVER_TEST} PUBLIC
+ app2ext_libpkgs
+ GMOCK_DEPS
+)
+
+ADD_TEST(${TARGET_LIB_TEST} ${TARGET_LIB_TEST})
+ADD_TEST(${TARGET_SERVER_TEST} ${TARGET_SERVER_TEST})
+TARGET_LINK_LIBRARIES(${TARGET_LIB_TEST} app2ext "${${TARGET_LIB_TEST}_LDFLAGS}" dl gobject-2.0)
+TARGET_LINK_LIBRARIES(${TARGET_SERVER_TEST} app2ext "${${TARGET_SERVER_TEST}_LDFLAGS}" dl gobject-2.0)
\ No newline at end of file
--- /dev/null
+/*
+ * app2sd-unittest
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <dlfcn.h>
+#include <gio/gio.h>
+#include <gmock/gmock.h>
+#include "inc/app2ext_interface.h"
+
+static GVariant* __last_parameters;
+static gchar* __last_method_name;
+
+extern "C" GDBusConnection* g_bus_get_sync(GBusType type,
+ GCancellable* cancellable, GError** error) {
+ gpointer dummy = g_object_new(G_TYPE_OBJECT, nullptr);
+ return (GDBusConnection*)dummy;
+}
+
+extern "C" GDBusProxy* g_dbus_proxy_new_sync(GDBusConnection* connection,
+ GDBusProxyFlags flags, GDBusInterfaceInfo* info, const gchar* name,
+ const gchar* object_path, const gchar* interface_name,
+ GCancellable* cancellable, GError** error) {
+ gpointer dummy = g_object_new(G_TYPE_OBJECT, nullptr);
+ return (GDBusProxy*)dummy;
+}
+
+extern "C" GVariant* g_dbus_proxy_call_sync(GDBusProxy* proxy,
+ const gchar* method_name, GVariant* parameters, GDBusCallFlags flags,
+ gint timeout_msec, GCancellable* cancellable, GError** error) {
+ GVariant* gv = g_variant_new("(i)", 0);
+
+ if (parameters != nullptr) {
+ if (__last_parameters)
+ g_variant_unref(__last_parameters);
+ __last_parameters = g_variant_ref(parameters);
+ }
+
+ if (__last_method_name)
+ g_free(__last_method_name);
+
+ __last_method_name = g_strdup(method_name);
+ return gv;
+}
+
+namespace {
+const ::testing::Environment* env = nullptr;
+
+class App2extInterfaceTest : public ::testing::Test {
+ protected:
+ void SetUp() override {}
+
+ void TearDown() override {
+ if (__last_parameters) {
+ g_variant_unref(__last_parameters);
+ __last_parameters = nullptr;
+ }
+ if (__last_method_name) {
+ g_free(__last_method_name);
+ __last_method_name = nullptr;
+ }
+ }
+};
+
+TEST_F(App2extInterfaceTest, Init) {
+ app2ext_handle* handle = app2ext_init(APP2EXT_INTERNAL_MEM);
+ EXPECT_THAT(handle, testing::Eq(nullptr));
+ handle = app2ext_init(APP2EXT_SD_CARD);
+ ASSERT_TRUE(handle != nullptr);
+ EXPECT_THAT(handle->type, testing::Eq(APP2EXT_SD_CARD));
+ app2ext_deinit(handle);
+}
+
+TEST_F(App2extInterfaceTest, EnableDisableExternalPkgs) {
+ // wrong parameters
+ int ret = app2ext_enable_external_pkg(nullptr);
+ EXPECT_THAT(ret, testing::Eq(-1));
+ ret = app2ext_disable_external_pkg(nullptr);
+ EXPECT_THAT(ret, testing::Eq(-1));
+
+ // normal
+ ret = app2ext_enable_external_pkg("not.exists.package");
+ EXPECT_THAT(ret, testing::Eq(0));
+ EXPECT_THAT(__last_method_name, testing::StrEq("OndemandSetupInit"));
+ gchar* pkgid;
+ gint uid;
+ g_variant_get(__last_parameters, "(si)", &pkgid, &uid);
+ EXPECT_THAT(pkgid, testing::StrEq("not.exists.package"));
+ g_free(pkgid);
+
+ ret = app2ext_disable_external_pkg("not.exists.package");
+ EXPECT_THAT(ret, testing::Eq(0));
+ EXPECT_THAT(__last_method_name, testing::StrEq("OndemandSetupExit"));
+ g_variant_get(__last_parameters, "(si)", &pkgid, &uid);
+ EXPECT_THAT(pkgid, testing::StrEq("not.exists.package"));
+ g_free(pkgid);
+
+ ret = app2ext_enable_all_external_pkgs();
+ EXPECT_THAT(ret, testing::Eq(0));
+ EXPECT_THAT(__last_method_name, testing::StrEq("EnableFullPkg"));
+
+ ret = app2ext_disable_all_external_pkgs();
+ EXPECT_THAT(ret, testing::Eq(0));
+ EXPECT_THAT(__last_method_name, testing::StrEq("DisableFullPkg"));
+}
+
+TEST_F(App2extInterfaceTest, Cleanup) {
+ // wrong parameters
+ int ret = app2ext_force_clean_pkg(nullptr);
+ EXPECT_THAT(ret, testing::Eq(-1));
+
+ // normal
+ ret = app2ext_force_clean_pkg("not.exists.package");
+ EXPECT_THAT(ret, testing::Eq(0));
+ EXPECT_THAT(__last_method_name, testing::StrEq("ForceClean"));
+ gchar* pkgid;
+ gint uid;
+ g_variant_get(__last_parameters, "(si)", &pkgid, &uid);
+ EXPECT_THAT(pkgid, testing::StrEq("not.exists.package"));
+ g_free(pkgid);
+}
+
+TEST_F(App2extInterfaceTest, Migrate) {
+ int ret = app2ext_migrate_legacy_all();
+ EXPECT_THAT(ret, testing::Eq(0));
+ EXPECT_THAT(__last_method_name, testing::StrEq("MigrateLegacyAll"));
+}
+
+TEST_F(App2extInterfaceTest, Get) {
+ // wrong parameter
+ char* ret = app2ext_usr_getname_image(nullptr, 0);
+ EXPECT_THAT(ret, testing::Eq(nullptr));
+ ret = app2ext_usr_get_image_path(nullptr, 0);
+ EXPECT_THAT(ret, testing::Eq(nullptr));
+
+ ret = app2ext_usr_getname_image("not.exists.package", 0);
+ EXPECT_TRUE(ret != nullptr);
+}
+
+}
+
+namespace app2sd {
+
+extern "C" void* dlopen(const char* path, int flag) {
+ return dlmopen(LM_ID_BASE, "libapp2sd.so", flag);
+}
+
+class App2sdEnvironment : public ::testing::Environment {
+ public:
+ void SetUp() override {
+ dl_handle_ = dlopen("/usr/bin/libapp2sd.so", RTLD_LAZY|RTLD_GLOBAL);
+ if (dl_handle_ == nullptr)
+ abort();
+ }
+
+ void TearDown() override {
+ dlclose(dl_handle_);
+ }
+
+ void* dl_handle_;
+};
+
+} // namespace app2sd
+
+int main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::env = testing::AddGlobalTestEnvironment(new app2sd::App2sdEnvironment);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+/*
+ * app2sd-unittest
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 <gmock/gmock.h>
+
+namespace {
+const ::testing::Environment* env = nullptr;
+}
+
+namespace {
+
+class App2sdServerTest : public ::testing::Test {
+ protected:
+ void SetUp() override {}
+
+ void TearDown() override {}
+};
+
+TEST_F(App2sdServerTest, Init) {
+ EXPECT_TRUE(true);
+}
+
+}
+
+namespace app2sd {
+
+class App2sdEnvironment : public ::testing::Environment {
+ public:
+ void SetUp() override {}
+
+ void TearDown() override {}
+};
+
+} // namespace app2sd
+
+int main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+ ::env = testing::AddGlobalTestEnvironment(new app2sd::App2sdEnvironment);
+ return RUN_ALL_TESTS();
+}
+++ /dev/null
-/*
- * app2sd-unittest
- *
- * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <gio/gio.h>
-#include <gmock/gmock.h>
-#include "inc/app2ext_interface.h"
-
-static GVariant* __last_parameters;
-static gchar* __last_method_name;
-
-extern "C" GDBusConnection* g_bus_get_sync(GBusType type,
- GCancellable* cancellable, GError** error) {
- gpointer dummy = g_object_new(G_TYPE_OBJECT, nullptr);
- return (GDBusConnection*)dummy;
-}
-
-extern "C" GDBusProxy* g_dbus_proxy_new_sync(GDBusConnection* connection,
- GDBusProxyFlags flags, GDBusInterfaceInfo* info, const gchar* name,
- const gchar* object_path, const gchar* interface_name,
- GCancellable* cancellable, GError** error) {
- gpointer dummy = g_object_new(G_TYPE_OBJECT, nullptr);
- return (GDBusProxy*)dummy;
-}
-
-extern "C" GVariant* g_dbus_proxy_call_sync(GDBusProxy* proxy,
- const gchar* method_name, GVariant* parameters, GDBusCallFlags flags,
- gint timeout_msec, GCancellable* cancellable, GError** error) {
- GVariant* gv = g_variant_new("(i)", 0);
-
- if (parameters != nullptr) {
- if (__last_parameters)
- g_variant_unref(__last_parameters);
- __last_parameters = g_variant_ref(parameters);
- }
-
- if (__last_method_name)
- g_free(__last_method_name);
-
- __last_method_name = g_strdup(method_name);
- return gv;
-}
-
-namespace {
-class App2extInterfaceTest : public ::testing::Test {
- protected:
- void SetUp() override {}
-
- void TearDown() override {
- if (__last_parameters) {
- g_variant_unref(__last_parameters);
- __last_parameters = nullptr;
- }
- if (__last_method_name) {
- g_free(__last_method_name);
- __last_method_name = nullptr;
- }
- }
-};
-
-TEST_F(App2extInterfaceTest, Init) {
- app2ext_handle* handle = app2ext_init(APP2EXT_INTERNAL_MEM);
- EXPECT_THAT(handle, testing::Eq(nullptr));
- handle = app2ext_init(APP2EXT_SD_CARD);
- ASSERT_TRUE(handle != nullptr);
- EXPECT_THAT(handle->type, testing::Eq(APP2EXT_SD_CARD));
- app2ext_deinit(handle);
-}
-
-TEST_F(App2extInterfaceTest, EnableDisableExternalPkgs) {
- // wrong parameters
- int ret = app2ext_enable_external_pkg(nullptr);
- EXPECT_THAT(ret, testing::Eq(-1));
- ret = app2ext_disable_external_pkg(nullptr);
- EXPECT_THAT(ret, testing::Eq(-1));
-
- // normal
- ret = app2ext_enable_external_pkg("not.exists.package");
- EXPECT_THAT(ret, testing::Eq(0));
- EXPECT_THAT(__last_method_name, testing::StrEq("OndemandSetupInit"));
- gchar* pkgid;
- gint uid;
- g_variant_get(__last_parameters, "(si)", &pkgid, &uid);
- EXPECT_THAT(pkgid, testing::StrEq("not.exists.package"));
- g_free(pkgid);
-
- ret = app2ext_disable_external_pkg("not.exists.package");
- EXPECT_THAT(ret, testing::Eq(0));
- EXPECT_THAT(__last_method_name, testing::StrEq("OndemandSetupExit"));
- g_variant_get(__last_parameters, "(si)", &pkgid, &uid);
- EXPECT_THAT(pkgid, testing::StrEq("not.exists.package"));
- g_free(pkgid);
-
- ret = app2ext_enable_all_external_pkgs();
- EXPECT_THAT(ret, testing::Eq(0));
- EXPECT_THAT(__last_method_name, testing::StrEq("EnableFullPkg"));
-
- ret = app2ext_disable_all_external_pkgs();
- EXPECT_THAT(ret, testing::Eq(0));
- EXPECT_THAT(__last_method_name, testing::StrEq("DisableFullPkg"));
-}
-
-TEST_F(App2extInterfaceTest, Cleanup) {
- // wrong parameters
- int ret = app2ext_force_clean_pkg(nullptr);
- EXPECT_THAT(ret, testing::Eq(-1));
-
- // normal
- ret = app2ext_force_clean_pkg("not.exists.package");
- EXPECT_THAT(ret, testing::Eq(0));
- EXPECT_THAT(__last_method_name, testing::StrEq("ForceClean"));
- gchar* pkgid;
- gint uid;
- g_variant_get(__last_parameters, "(si)", &pkgid, &uid);
- EXPECT_THAT(pkgid, testing::StrEq("not.exists.package"));
- g_free(pkgid);
-}
-
-TEST_F(App2extInterfaceTest, Migrate) {
- int ret = app2ext_migrate_legacy_all();
- EXPECT_THAT(ret, testing::Eq(0));
- EXPECT_THAT(__last_method_name, testing::StrEq("MigrateLegacyAll"));
-}
-
-TEST_F(App2extInterfaceTest, Get) {
- // wrong parameter
- char* ret = app2ext_usr_getname_image(nullptr, 0);
- EXPECT_THAT(ret, testing::Eq(nullptr));
- ret = app2ext_usr_get_image_path(nullptr, 0);
- EXPECT_THAT(ret, testing::Eq(nullptr));
-
- ret = app2ext_usr_getname_image("not.exists.package", 0);
- EXPECT_TRUE(ret != nullptr);
-}
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * app2sd-unittest
- *
- * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * 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 <dlfcn.h>
-#include <gmock/gmock.h>
-
-namespace {
-const ::testing::Environment* env = nullptr;
-}
-
-namespace app2sd {
-
-extern "C" void* dlopen(const char* path, int flag) {
- return dlmopen(LM_ID_BASE, "libapp2sd.so", flag);
-}
-
-class App2sdEnvironment : public ::testing::Environment {
- public:
- void SetUp() override {
- dl_handle_ = dlopen("/usr/bin/libapp2sd.so", RTLD_LAZY|RTLD_GLOBAL);
- if (dl_handle_ == nullptr)
- abort();
- }
-
- void TearDown() override {
- dlclose(dl_handle_);
- }
-
- void* dl_handle_;
-};
-
-} // namespace app2sd
-
-int main(int argc, char* argv[]) {
- ::testing::InitGoogleTest(&argc, argv);
- ::env = testing::AddGlobalTestEnvironment(new app2sd::App2sdEnvironment);
- return RUN_ALL_TESTS();
-}