BuildRequires: pkgconfig(gmock)
BuildRequires: pkgconfig(appsvc)
BuildRequires: pkgconfig(capi-appfw-app-common)
+%if 0%{?gcov:1}
+BuildRequires: lcov
+%endif
%description
API for creating a new watchface complication and managing it.
cp %{SOURCE1003} .
%build
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DTZ_SYS_SHARE=/usr/share -DMAJORVER=${MAJORVER} -DFULLVER=%{version}
+
+%cmake . \
+ -DTZ_SYS_SHARE=/usr/share \
+ -DMAJORVER=${MAJORVER} \
+ -DFULLVER=%{version}
make %{?jobs:-j%jobs}
%install
rm -rf %{buildroot}
%make_install
-
#################################################
# libwatchface-complication
#################################################
INCLUDE(FindPkgConfig)
pkg_check_modules(gtest-watchface-complication REQUIRED
glib-2.0
+ dlog
gmock
)
${SOURCES}
)
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gtest-watchface-complication_LDFLAGS} watchface-complication watchface-complication-provider watchface-editor)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${gtest-watchface-complication_LDFLAGS}
+ ${pkgs_LDFLAGS}
+ ${pkgs_LIBRARIES}
+ gmock
+ watchface-complication
+ watchface-complication-provider
+ watchface-editor
+)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <stdbool.h>
+#include <stdexcept>
+#include <iostream>
+#include <glib.h>
+#include <dlog.h>
+
+#include <memory>
+#include <string>
+#include <list>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "watchface-complication/complication.h"
+#include "watchface-complication/include/watchface-complication.h"
+#include "watchface-complication/include/watchface-editable.h"
+
+using namespace std;
+using namespace watchface_complication;
+
+class WatchComplication : public Complication {
+ public:
+ WatchComplication(int id, int support_types,
+ const std::string& default_provider_id,
+ ComplicationType default_type,
+ std::shared_ptr<IEditable::Geometry> geo)
+ : Complication(id, support_types, default_provider_id, default_type, geo) {
+ SetCurDataIdx(0);
+ SetName("TestComplication");
+ SetShapeType(IEditable::EditableShapeType::Circle);
+ }
+
+ virtual ~WatchComplication() = default;
+};
+
+class WC : public ::testing::Test {
+ public:
+ WatchComplication* complication = NULL;
+ string providerId = "sample_provider";
+
+ virtual void SetUp() {
+ complication = new WatchComplication(0, 1, providerId.c_str(), ShortText,
+ std::shared_ptr<IEditable::Geometry>(new IEditable::Geometry(0, 0, 100, 100)));
+ }
+ virtual void TearDown() {
+ delete complication;
+ }
+};
+
+TEST_F(WC, Create)
+{
+ EXPECT_NE(WC::complication, nullptr);
+}
+
+TEST_F(WC, GetId)
+{
+ EXPECT_EQ(WC::complication->GetId(), 0);
+}
+
+TEST_F(WC, GetGeo)
+{
+ EXPECT_NE(WC::complication->GetGeo(), nullptr);
+ EXPECT_EQ(WC::complication->GetGeo()->GetX(), 0);
+ EXPECT_EQ(WC::complication->GetGeo()->GetY(), 0);
+ EXPECT_EQ(WC::complication->GetGeo()->GetW(), 100);
+ EXPECT_EQ(WC::complication->GetGeo()->GetH(), 100);
+}
+
+TEST_F(WC, GetCandidates)
+{
+ std::list<std::unique_ptr<Bundle>> const& list = WC::complication->GetCandidates();
+ EXPECT_NE(list.empty(), true);
+}
+
+TEST_F(WC, GetData)
+{
+ Bundle& curData = WC::complication->GetCurData();
+ Bundle& nthData = WC::complication->GetNthData(1);
+
+ EXPECT_NE(curData.GetRaw(), nullptr);
+ EXPECT_NE(nthData.GetRaw(), nullptr);
+}
+
+TEST_F(WC, GetCurDataIdx)
+{
+ EXPECT_EQ(WC::complication->GetCurDataIdx(),0);
+}
+
+TEST_F(WC, GetName)
+{
+ EXPECT_EQ(WC::complication->GetName(), "TestComplication");
+}
+
+TEST_F(WC, GetShapeType)
+{
+ EXPECT_EQ(WC::complication->GetShapeType(), IEditable::EditableShapeType::Circle);
+}
+
+class WFC : public ::testing::Test {
+ public:
+ complication_h complication;
+ virtual void SetUp() {
+ complication_create(0, "org.tizen.sample", COMPLICATION_SHORT_TEXT,
+ COMPLICATION_SHORT_TEXT, COMPLICATION_SHAPE_CIRCLE,
+ &complication);
+ }
+ virtual void TearDown() {
+ complication_destroy(complication);
+ }
+};
+
+int on_complication_update_cb(int complication_id, const char* provider_id,
+ complication_type type, const bundle* data,
+ void* user_data) {
+ return 0;
+}
+
+TEST_F(WFC, Create)
+{
+ EXPECT_NE(WFC::complication, nullptr);
+}
+
+TEST_F(WFC, Callback)
+{
+ EXPECT_EQ(complication_update_cb_add(WFC::complication, on_complication_update_cb, NULL), 0);
+ EXPECT_EQ(complication_send_update_request(WFC::complication), 0);
+ EXPECT_EQ(complication_update_cb_del(WFC::complication, on_complication_update_cb), 0);
+}
+
+TEST_F(WFC, Id)
+{
+ EXPECT_EQ(complication_set_provider("org.tizen.sample"), 0);
+ EXPECT_EQ(complication_get_id(WFC::complication), -1);
+}
+
+TEST_F(WFC, UpdateRequest)
+{
+ EXPECT_EQ(complication_send_update_request(WFC::complication), 0);
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <stdbool.h>
+#include <stdexcept>
+#include <iostream>
+#include <glib.h>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "watchface-complication-provider/complication-provider.h"
+#include "watchface-complication-provider/include/watchface-complication-provider.h"
+
+using namespace std;
+using namespace watchface_complication;
+
+string providerId = "org.tizen.sample";
+
+class WCP : public ::testing::Test {
+ public:
+ ComplicationProvider* provider;
+
+ virtual void SetUp(){
+ provider = new ComplicationProvider(providerId.c_str(), 1);
+ }
+ virtual void TearDown(){
+ delete provider;
+ }
+};
+
+int on_update_request_cb(const char *provider_id, const char *req_appid,
+ complication_type type, const bundle *context,
+ bundle *share_data, void *user_data) {
+ return 0;
+}
+
+TEST_F(WCP, Create)
+{
+ EXPECT_NE(WCP::provider, nullptr);
+}
+
+TEST_F(WCP, GetProviderId)
+{
+ EXPECT_EQ(WCP::provider->GetProviderId(), providerId.c_str());
+}
+
+TEST_F(WCP, UpdateRequestCb)
+{
+ EXPECT_EQ(complication_provider_update_request_cb_add(providerId.c_str(), on_update_request_cb, NULL), 0);
+ EXPECT_EQ(complication_provider_update_request_cb_del(providerId.c_str(), on_update_request_cb, NULL), 0);
+}
+
+TEST_F(WCP, GetSupportTypes)
+{
+ int types;
+ EXPECT_EQ(complication_provider_get_support_types(providerId.c_str(), &types), 0);
+}
+
+TEST_F(WCP, NotifyUpdate)
+{
+ EXPECT_EQ(complication_provider_notify_update(), 0);
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <stdbool.h>
+#include <stdexcept>
+#include <iostream>
+#include <glib.h>
+#include <dlog.h>
+
+#include <memory>
+#include <string>
+#include <list>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "watchface-complication/design-element.h"
+#include "watchface-complication/complication-bundle.h"
+
+using namespace std;
+using namespace watchface_complication;
+
+class Element : public DesignElement {
+ public:
+ Element(int id, int cur_data_idx,
+ std::list<std::unique_ptr<Bundle>> candidates_list,
+ std::shared_ptr<IEditable::Geometry> geo)
+ : DesignElement(id, cur_data_idx, std::move(candidates_list), geo){
+ SetName("Test");
+ SetShapeType(IEditable::EditableShapeType::Circle);
+ }
+
+ virtual ~Element() = default;
+};
+
+class DE : public ::testing::Test {
+ public:
+ Element* element = NULL;
+ std::list<std::unique_ptr<Bundle>> candidatesList;
+
+ virtual void SetUp() {
+ candidatesList.emplace_back(std::unique_ptr<Bundle>(new Bundle()));
+
+ element = new Element(0, 0, std::move(candidatesList),
+ std::shared_ptr<IEditable::Geometry>(new IEditable::Geometry(0, 0, 100, 100)));
+ }
+ virtual void TearDown() {
+ delete element;
+ }
+};
+
+TEST_F(DE, Create)
+{
+ EXPECT_NE(DE::element, nullptr);
+}
+
+TEST_F(DE, GetGeo)
+{
+ EXPECT_NE(DE::element->GetGeo(), nullptr);
+ EXPECT_EQ(DE::element->GetGeo()->GetX(), 0);
+ EXPECT_EQ(DE::element->GetGeo()->GetY(), 0);
+ EXPECT_EQ(DE::element->GetGeo()->GetW(), 100);
+ EXPECT_EQ(DE::element->GetGeo()->GetH(), 100);
+}
+
+TEST_F(DE, GetCandidates)
+{
+ std::list<std::unique_ptr<Bundle>> const& list = DE::element->GetCandidates();
+ EXPECT_NE(list.empty(), true);
+}
+
+TEST_F(DE, GetData)
+{
+ Bundle& curData = DE::element->GetCurData();
+ Bundle& nthData = DE::element->GetNthData(0);
+
+ EXPECT_NE(curData.GetRaw(), nullptr);
+ EXPECT_NE(nthData.GetRaw(), nullptr);
+}
+
+TEST_F(DE, GetCurDataIdx)
+{
+ EXPECT_EQ(DE::element->SetCurDataIdx(1), 0);
+ EXPECT_EQ(DE::element->GetCurDataIdx(), 1);
+}
+
+TEST_F(DE, GetName)
+{
+ EXPECT_EQ(DE::element->GetName(), "Test");
+}
+
+TEST_F(DE, GetShapeType)
+{
+ EXPECT_EQ(DE::element->GetShapeType(), IEditable::EditableShapeType::Circle);
+}
+
+TEST_F(DE, GetId)
+{
+ EXPECT_EQ(DE::element->GetId(), 0);
+}
+
+TEST_F(DE, OnEditableUpdated)
+{
+ const Bundle& updated_data = DE::element->GetCurData();
+
+ DE::element->OnEditableUpdated(IEditable::EditableState::OnGoing, updated_data);
+ DE::element->OnEditableUpdated(IEditable::EditableState::Complete, updated_data);
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <stdbool.h>
+#include <stdexcept>
+#include <iostream>
+#include <glib.h>
+#include <dlog.h>
+
+#include <memory>
+#include <string>
+#include <list>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "watchface-complication/editables-container.h"
+#include "watchface-complication/received-editable.h"
+#include "watchface-complication/include/watchface-complication.h"
+#include "watchface-complication/include/watchface-editable.h"
+
+using namespace std;
+using namespace watchface_complication;
+
+class EC : public ::testing::Test {
+ public:
+ EditablesContainer* container;
+ ReceivedEditable* received;
+
+ virtual void SetUp() {
+ int len = 0;
+ bundle* data;
+ bundle_raw* raw_data;
+
+ Bundle* candidate1 = new Bundle();
+ Bundle* candidate2 = new Bundle();
+ std::unique_ptr<const char*[]> array(new const char*[2]);
+
+ data = bundle_create();
+ bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
+ bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
+ bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
+ bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
+ bundle_add_str(data, "NAME", "sample");
+ bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
+
+ array.get()[0] = candidate1->ToString();
+ array.get()[1] = candidate2->ToString();
+
+ bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
+ bundle_encode(data, &raw_data, &len);
+
+ received = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)), "sample_provider");
+
+ container = new EditablesContainer();
+ }
+ virtual void TearDown() {
+ delete received;
+ delete container;
+ }
+};
+
+TEST_F(EC, Create)
+{
+ EXPECT_NE(EC::container, nullptr);
+}
+
+TEST_F(EC, AddRemove)
+{
+ int len = 0;
+ bundle* data;
+ bundle_raw* raw_data;
+
+ Bundle* candidate1 = new Bundle();
+ Bundle* candidate2 = new Bundle();
+ std::unique_ptr<const char*[]> array(new const char*[2]);
+
+ data = bundle_create();
+ bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
+ bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
+ bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
+ bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
+ bundle_add_str(data, "NAME", "sample");
+ bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
+ bundle_encode(data, &raw_data, &len);
+
+ array.get()[0] = candidate1->ToString();
+ array.get()[1] = candidate2->ToString();
+
+ bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
+
+ ReceivedEditable* re = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)), "sample_provider");
+ std::shared_ptr<IEditable> ed = static_cast<std::shared_ptr<IEditable>>(re);
+
+ EXPECT_EQ(EC::container->Add(ed), 0);
+ EXPECT_EQ(EC::container->Remove(ed), 0);
+}
+
+TEST_F(EC, RequestEdit)
+{
+ EXPECT_EQ(EC::container->RequestEdit("Editor"), 0);
+}
+
+TEST_F(EC, AddDesignElement)
+{
+ GList* candidatelist = NULL;
+ bundle* data = bundle_create();;
+ editable_geo geo = {0, 0, 100, 100};
+
+ candidatelist = g_list_append(candidatelist, data);
+
+ EXPECT_EQ(editable_add_design_element(EC::container, 0, 0, candidatelist, geo, "sample_editor"), 0);
+
+ bundle_free(data);
+ g_list_free(candidatelist);
+}
+
+TEST_F(EC, AddComplication)
+{
+ complication_h complication;
+ editable_geo geo = {0, 0, 100, 100};
+
+ complication_create(0, "org.tizen.sample", COMPLICATION_SHORT_TEXT,
+ COMPLICATION_SHORT_TEXT, COMPLICATION_SHAPE_CIRCLE,
+ &complication);
+ EXPECT_EQ(editable_add_complication(EC::container, 0, complication, geo, "sample_editor"), 0);
+
+ complication_destroy(complication);
+}
+
+int on_editable_update_cb(const editable_h handle,
+ int selected_idx,
+ const editable_edit_state state,
+ void *user_data) {
+ return 0;
+}
+
+TEST_F(EC, RequestEdit_c)
+{
+ int len = 0;
+ bundle* data;
+ bundle_raw* raw_data;
+
+ Bundle* candidate1 = new Bundle();
+ Bundle* candidate2 = new Bundle();
+ std::unique_ptr<const char*[]> array(new const char*[2]);
+
+ data = bundle_create();
+ bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
+ bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
+ bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
+ bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
+ bundle_add_str(data, "NAME", "sample");
+ bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
+ bundle_encode(data, &raw_data, &len);
+
+ array.get()[0] = candidate1->ToString();
+ array.get()[1] = candidate2->ToString();
+
+ bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
+
+ ReceivedEditable* re = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)), "sample_provider");
+ std::shared_ptr<IEditable> ed = static_cast<std::shared_ptr<IEditable>>(re);
+
+ EXPECT_EQ(EC::container->Add(ed), 0);
+
+ EXPECT_EQ(editable_request_edit(EC::container, "sample_provider", on_editable_update_cb, NULL), 0);
+}
+
+int on_edit_ready_cb(editable_container_h handle, const char *editor_appid, void *user_data) {
+ return 0;
+}
+
+TEST_F(EC, EditReadyCb)
+{
+ EXPECT_EQ(editable_on_edit_ready_cb_add(on_edit_ready_cb, NULL), 0);
+ EXPECT_EQ(editable_on_edit_ready_cb_del(on_edit_ready_cb), 0);
+}
+
+TEST_F(EC, GetData)
+{
+ int idx = 1;
+ int idx_check;
+ int id;
+ bundle* data = nullptr;
+ bundle* nthdata = nullptr;
+ editable_geo geo;
+ GList* list;
+ const char* set_editable_name = "sample_editor";
+ const char* get_editable_name = NULL;
+
+ EXPECT_EQ(editable_set_cur_data_idx(EC::received, idx), 0);
+ EXPECT_EQ(editable_get_cur_data_idx(EC::received, &idx_check), 0);
+ EXPECT_EQ(idx, idx_check);
+
+ EXPECT_EQ(editable_get_cur_data(EC::received, &data), 0);
+ EXPECT_EQ(editable_get_nth_data(EC::received, 1, &nthdata), 0);
+ EXPECT_EQ(editable_get_editable_id(EC::received, &id), 0);
+ EXPECT_EQ(id, 0);
+
+ EXPECT_EQ(editable_get_geometry(EC::received, &geo), 0);
+ EXPECT_EQ(editable_get_candidates_list(EC::received, &list), 0);
+
+ EXPECT_EQ(editable_set_editable_name(EC::received, set_editable_name), 0);
+ EXPECT_EQ(editable_get_editable_name(EC::received, &get_editable_name), 0);
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <stdbool.h>
+#include <stdexcept>
+#include <iostream>
+#include <glib.h>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "watchface-editor/editables-editor.h"
+#include "watchface-complication/received-editable.h"
+#include "watchface-complication/include/watchface-editable.h"
+#include "watchface-editor/include/watchface-editor.h"
+
+using namespace std;
+using namespace watchface_complication;
+
+class WE : public ::testing::Test {
+ public:
+ EditablesEditor* editor;
+
+ virtual void SetUp(){
+ editor = new EditablesEditor();
+ }
+ virtual void TearDown(){
+ delete editor;
+ }
+};
+
+int on_request_edit_cb(const char *appid, editable_list_h list_h, void *user_data) {
+ return 0;
+}
+
+TEST_F(WE, Create)
+{
+ EXPECT_NE(WE::editor, nullptr);
+}
+
+TEST_F(WE, UpdateCurDataIdx)
+{
+ int cur_data_idx = 1;
+ int len = 0;
+ bundle* data;
+ bundle_raw* raw_data;
+
+ data = bundle_create();
+ bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
+ bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
+ bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
+ bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
+ bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
+ bundle_add_str(data, "NAME", "sample");
+ bundle_encode(data, &raw_data, &len);
+
+ ReceivedEditable* re = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)), "sample_provider");
+ IEditable* ed = static_cast<IEditable*>(re);
+ EXPECT_EQ(WE::editor->UpdateCurDataIdx(*ed, cur_data_idx, IEditable::EditableState::OnGoing), 0);
+ EXPECT_EQ(WE::editor->UpdateCurDataIdx(*ed, cur_data_idx, IEditable::EditableState::Complete), 0);
+ delete re;
+}
+
+TEST_F(WE, NotifyEditReady)
+{
+ EXPECT_EQ(WE::editor->NotifyEditReady("sample_provider"), 0);
+}
+
+TEST_F(WE, RequestEditCb)
+{
+ EXPECT_EQ(editor_on_request_edit_cb_add(on_request_edit_cb, NULL), 0);
+ EXPECT_EQ(editor_on_request_edit_cb_del(on_request_edit_cb), 0);
+}
+
+class WEL : public ::testing::Test {
+ public:
+ GList* editables = NULL;
+ ReceivedEditable* received;
+ bundle_raw* raw_data;
+ int len = 0;
+
+ virtual void SetUp(){
+ Bundle* candidate1 = new Bundle();
+ Bundle* candidate2 = new Bundle();
+ std::unique_ptr<const char*[]> array(new const char*[2]);
+
+ bundle* data = bundle_create();
+ bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
+ bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
+ bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
+ bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
+ bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
+ bundle_add_str(data, "NAME", "sample");
+
+ array.get()[0] = candidate1->ToString();
+ array.get()[1] = candidate2->ToString();
+
+ bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
+
+ bundle_encode(data, &raw_data, &len);
+ received = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)), "sample_appid");
+ editables = g_list_append(editables, received);
+
+ }
+ virtual void TearDown(){
+ delete received;
+ g_list_free(editables);
+ }
+};
+
+int _editable_list_foreach_cb(const editable_h handle, void *user_data) {
+ return 0;
+}
+
+TEST_F(WEL, UpdataCurDataIdx)
+{
+ IEditable* ed = static_cast<IEditable*>(WEL::received);
+ EXPECT_EQ(editor_update_cur_data_idx(ed, 0, EDITABLE_EDIT_STATE_FINISH), 0);
+}
+
+TEST_F(WEL, EditReady)
+{
+ EXPECT_EQ(editor_notify_edit_ready("sample_provide"), 0);
+}
+
+TEST_F(WEL, EditableList)
+{
+ GList* duplist = nullptr;
+ editable_h nthEditor = nullptr;
+ const bundle* data = nullptr;
+
+ EXPECT_EQ(editor_foreach_editable_list(WEL::editables, _editable_list_foreach_cb, NULL), 0);
+
+ EXPECT_NE(duplist = editor_editable_list_dup(WEL::editables), nullptr);
+ EXPECT_GT(editor_editable_list_size(WEL::editables), 0);
+
+ EXPECT_NE(nthEditor = editor_editable_list_nth(WEL::editables, 0), nullptr);
+ EXPECT_GT(editor_editable_candidate_list_size(nthEditor), 0);
+
+ EXPECT_NE(data = editor_editable_candidate_list_nth(nthEditor, 0), nullptr);
+
+ EXPECT_EQ(editor_editable_list_destroy(duplist), 0);
+}
+/*
+ * Copyright (c) 2018 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 <gmock/gmock.h>
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <stdbool.h>
+#include <stdexcept>
+#include <iostream>
+#include <glib.h>
+#include <dlog.h>
+#include <bundle.h>
+
+#include <memory>
+#include <string>
+#include <list>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "watchface-complication/received-editable.h"
+
+using namespace std;
+using namespace watchface_complication;
+
+class RE : public ::testing::Test {
+ public:
+ ReceivedEditable* received;
+ bundle* data;
+ bundle_raw* raw_data;
+ int len = 0;
+
+ virtual void SetUp() {
+ Bundle* candidate1 = new Bundle();
+ Bundle* candidate2 = new Bundle();
+ std::unique_ptr<const char*[]> array(new const char*[2]);
+
+ data = bundle_create();
+
+ bundle_add_str(data, "GEO_X", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_Y", std::to_string(0).c_str());
+ bundle_add_str(data, "GEO_W", std::to_string(100).c_str());
+ bundle_add_str(data, "GEO_H", std::to_string(100).c_str());
+ bundle_add_str(data, "SHAPE_TYPE", std::to_string(IEditable::EditableShapeType::Circle).c_str());
+ bundle_add_str(data, "CUR_DATA_IDX", std::to_string(0).c_str());
+ bundle_add_str(data, "EDITABLE_ID", std::to_string(0).c_str());
+ bundle_add_str(data, "NAME", "sample");
+
+ array.get()[0] = candidate1->ToString();
+ array.get()[1] = candidate2->ToString();
+
+ bundle_add_str_array(data, "CANDIDATES_LIST", array.get(), 2);
+
+ bundle_encode(data, &raw_data, &len);
+ received = new ReceivedEditable(std::string(reinterpret_cast<char*>(raw_data)), "sample_appid");
+ }
+ virtual void TearDown() {
+ delete received;
+ }
+};
+
+TEST_F(RE, Create)
+{
+ EXPECT_NE(RE::received, nullptr);
+}
+
+TEST_F(RE, GetGeo)
+{
+ EXPECT_NE(RE::received->GetGeo(), nullptr);
+ EXPECT_EQ(RE::received->GetGeo()->GetX(), 0);
+ EXPECT_EQ(RE::received->GetGeo()->GetY(), 0);
+ EXPECT_EQ(RE::received->GetGeo()->GetW(), 100);
+ EXPECT_EQ(RE::received->GetGeo()->GetH(), 100);
+}
+
+TEST_F(RE, GetCandidates)
+{
+ std::list<std::unique_ptr<Bundle>> const& list = RE::received->GetCandidates();
+ EXPECT_NE(list.empty(), true);
+}
+
+TEST_F(RE, GetData)
+{
+ Bundle& curData = RE::received->GetCurData();
+ Bundle& nthData = RE::received->GetNthData(1);
+
+ EXPECT_NE(curData.GetRaw(), nullptr);
+ EXPECT_NE(nthData.GetRaw(), nullptr);
+}
+
+TEST_F(RE, GetCurDataIdx)
+{
+ EXPECT_EQ(RE::received->GetCurDataIdx(), 0);
+}
+
+TEST_F(RE, GetName)
+{
+ EXPECT_EQ(RE::received->GetName(), "sample");
+}
+
+TEST_F(RE, GetShapeType)
+{
+ EXPECT_EQ(RE::received->GetShapeType(), IEditable::EditableShapeType::Circle);
+}
+
+TEST_F(RE, GetId)
+{
+ EXPECT_EQ(RE::received->GetId(), 0);
+}
+
+TEST_F(RE, GetOwnerAppid)
+{
+ EXPECT_EQ(RE::received->GetOwnerAppid(), "sample_appid");
+}
+
+TEST_F(RE, OnEditableUpdated)
+{
+ const Bundle& updated_data = RE::received->GetCurData();
+
+ RE::received->OnEditableUpdated(IEditable::EditableState::OnGoing, updated_data);
+ RE::received->OnEditableUpdated(IEditable::EditableState::Complete, updated_data);
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 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 <stdbool.h>
+#include <stdexcept>
+#include <iostream>
+#include <glib.h>
+#include <dlog.h>
+
+#include <memory>
+#include <string>
+#include <list>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "watchface-complication/complication-bundle.h"
+#include "watchface-complication/complication-connector.h"
+
+using namespace std;
+using namespace watchface_complication;
+
+class BUNDLE : public ::testing::Test {
+ public:
+ Bundle *b = nullptr;
+ virtual void SetUp(){
+ b = new Bundle();
+ }
+ virtual void TearDown(){
+ delete b;
+ }
+};
+
+
+TEST_F(BUNDLE, Create1)
+{
+ EXPECT_NE(BUNDLE::b, nullptr);
+}
+
+TEST_F(BUNDLE, Create2)
+{
+ int len = 0;
+ bundle *data;
+ bundle_raw *raw_data;
+
+ data = bundle_create();
+ bundle_encode(data, &raw_data, &len);
+
+ Bundle *b = new Bundle(std::string(reinterpret_cast<char*>(raw_data)));
+ EXPECT_NE(b, nullptr);
+
+ bundle_free(data);
+ delete b;
+}
+
+TEST_F(BUNDLE, Create3)
+{
+ bundle *data;
+
+ data = bundle_create();
+
+ Bundle *b = new Bundle(data);
+ EXPECT_NE(b, nullptr);
+
+ bundle_free(data);
+ delete b;
+}
+
+TEST_F(BUNDLE, GetRaw)
+{
+ EXPECT_NE(BUNDLE::b->GetConstRaw(), nullptr);
+ EXPECT_NE(BUNDLE::b->GetRaw(), nullptr);
+}
+
+TEST_F(BUNDLE, ToString)
+{
+ EXPECT_NE(BUNDLE::b->ToString(), "");
+}
+++ /dev/null
-#include <stdbool.h>
-#include <stdexcept>
-#include <iostream>
-#include <glib.h>
-
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "watchface-complication/complication.h"
-
-using namespace std;
-using ::testing::AtLeast;
-
-class Complication : public ::testing::Test {
-protected:
- virtual void SetUp(){}
- virtual void TearDown(){}
-};
-
-TEST_F(Complication, test)
-{
- EXPECT_EQ(0,0);
-}
FOREACH(flag ${watchface-complication-provider_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -std=c++11")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline -std=c++11 -fprofile-arcs -ftest-coverage")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
PATTERN "*-internal.h" EXCLUDE
PATTERN "*-implementation.h" EXCLUDE
- PATTERN "*.h")
\ No newline at end of file
+ PATTERN "*.h")
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
PATTERN "*-internal.h" EXCLUDE
PATTERN "*-implementation.h" EXCLUDE
- PATTERN "*.h")
\ No newline at end of file
+ PATTERN "*.h")
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
PATTERN "*-internal.h" EXCLUDE
PATTERN "*-implementation.h" EXCLUDE
- PATTERN "*.h")
\ No newline at end of file
+ PATTERN "*.h")