--- /dev/null
+/*
+ * Copyright (c) 2019 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 <dlog.h>
+
+#include "notification-ex/abstract_action.h"
+#include "notification-ex/abstract_action_implementation.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define ABSTRACT_ACTION_IS_LOCAL_KEY "__ABSTRACT_ACTION_IS_LOCAL_KEY__"
+#define ABSTRACT_ACTION_EXTRA_KEY "__ABSTRACT_ACTION_EXTRA_KEY__"
+
+namespace notification {
+namespace item {
+AbstractAction::AbstractAction(bool isLocal)
+ : impl_(new Impl(this, isLocal)) {
+}
+
+AbstractAction::AbstractAction(bool isLocal, std::string extra)
+ : impl_(new Impl(this, isLocal, extra)) {
+}
+
+AbstractAction::Impl::Impl(AbstractAction* parent, bool isLocal)
+ : parent_(parent) , isLocal_(isLocal) {
+ LOGI("Action created");
+}
+
+AbstractAction::Impl::Impl(AbstractAction* parent, bool isLocal, std::string extra)
+ : parent_(parent) , isLocal_(isLocal), extra_(extra) {
+ LOGI("Action created");
+}
+
+AbstractAction::~AbstractAction() = default;
+AbstractAction::Impl::~Impl() = default;
+
+Bundle AbstractAction::Serialize() {
+ Bundle b;
+
+ b.Add(ABSTRACT_ACTION_IS_LOCAL_KEY, std::to_string(impl_->isLocal_));
+ if (!impl_->extra_.empty())
+ b.Add(ABSTRACT_ACTION_EXTRA_KEY ,impl_->extra_);
+ return b;
+}
+
+void AbstractAction::Deserialize(Bundle b) {
+ impl_->isLocal_ = std::stoi(b.GetString(ABSTRACT_ACTION_IS_LOCAL_KEY));
+ impl_->extra_ = b.GetString(ABSTRACT_ACTION_EXTRA_KEY);
+}
+
+bool AbstractAction::IsLocal() const {
+ return impl_->isLocal_;
+}
+
+void AbstractAction::Execute(std::shared_ptr<AbstractItem> item) {
+}
+
+std::string AbstractAction::GetExtra() const {
+ return impl_->extra_;
+}
+
+} // namespace item
+} // namespace notification
#ifndef NOTIFICATION_EX_ABSTRACT_ACTION_H_
#define NOTIFICATION_EX_ABSTRACT_ACTION_H_
-#include <app_control.h>
-
#include <memory>
#include <string>
class AbstractItem;
class EXPORT_API AbstractAction {
public:
- virtual bool IsLocal() const = 0;
- virtual void Execute(std::shared_ptr<AbstractItem> item) = 0;
+ AbstractAction(bool isLocal);
+ AbstractAction(bool isLocal, std::string extra);
+ virtual ~AbstractAction();
+
virtual Bundle Serialize() = 0;
virtual void Deserialize(Bundle b) = 0;
+ virtual bool IsLocal() const = 0;
+ virtual void Execute(std::shared_ptr<AbstractItem> item) = 0;
virtual std::string GetExtra() const = 0;
+
+ private:
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace item
* limitations under the License.
*/
+#ifndef NOTIFICATION_EX_ABSTRACT_ACTION_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_ABSTRACT_ACTION_IMPLEMENTATION_H_
+
#include <string>
#include <memory>
-#include "notification-ex/action.h"
-#include "notification-ex/ex_bundle.h"
-#include "notification-ex/exception.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "NOTIFICATION_EX"
+#include "notification-ex/abstract_action.h"
namespace notification {
namespace item {
-AppControlAction::AppControlAction(app_control_h control)
- : control_(control) {
-}
-
-AppControlAction::~AppControlAction() {
-}
-
-ReplyAction::ReplyAction() {
-}
+class AbstractAction::Impl {
+ public:
+ virtual ~Impl();
-ReplyAction::~ReplyAction() {
-}
+ private:
+ friend class AbstractAction;
+ Impl(AbstractAction* parent, bool isLocal);
+ Impl(AbstractAction* parent, bool isLocal, std::string extra);
-VisibilityAction::VisibilityAction() {
-}
+ private:
+ AbstractAction* parent_;
-VisibilityAction::~VisibilityAction() {
-}
+ bool isLocal_ = true;
+ std::string extra_;
+};
+} // namespace item
+} // namespace notification
-} //namespace item
-} //namespace notification
+#endif // NOTIFICATION_EX_ABSTRACT_ACTION_IMPLEMENTATION_H_
+++ /dev/null
-/*
- * Copyright (c) 2019 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 NOTIFICATION_EX_ACTION_H_
-#define NOTIFICATION_EX_ACTION_H_
-
-#include <app_control.h>
-
-#include <memory>
-#include <string>
-
-#include "notification-ex/abstract_action.h"
-#include "notification-ex/ex_bundle.h"
-
-namespace notification {
-namespace item {
-
-class EXPORT_API AppControlAction : public AbstractAction {
- public:
- explicit AppControlAction(app_control_h control);
- virtual ~AppControlAction();
-
- bool IsLocal() const override {
- return true;
- }
-
- void Execute(std::shared_ptr<AbstractItem> item) override {
- }
-
- Bundle Serialize() override {
- Bundle b;
- return b;
- }
-
- void Deserialize(Bundle b) override {
- }
-
- void SetAppControl(app_control_h control) {
- }
-
- app_control_h GetAppControl() const {
- return control_;
- }
-
- private:
- app_control_h control_ = nullptr;
-};
-
-class EXPORT_API ReplyAction : public AbstractAction {
- public:
- ReplyAction();
- virtual ~ReplyAction();
-
- bool IsLocal() const override {
- return true;
- }
-
- void Execute(std::shared_ptr<AbstractItem> item) override {
- }
-
- Bundle Serialize() override {
- Bundle b;
- return b;
- }
-
- void Deserialize(Bundle b) override {
- }
-};
-
-class EXPORT_API VisibilityAction : public AbstractAction {
- public:
- VisibilityAction();
- virtual ~VisibilityAction();
-
- bool IsLocal() const override {
- return true;
- }
-
- void Execute(std::shared_ptr<AbstractItem> item) override {
- }
-
- Bundle Serialize() override {
- Bundle b;
- return b;
- }
-
- void Deserialize(Bundle b) override {
- }
-
- void SetVisibility(std::string id, bool visible) {
- id_ = id;
- visible_ = visible;
- }
-
- private:
- std::string id_;
- bool visible_ = false;
-};
-
-} // namespace item
-} // namespace notification
-
-#endif // NOTIFICATION_EX_ACTION_H_
--- /dev/null
+/*
+ * Copyright (c) 2019 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 <dlog.h>
+#include <app_control_internal.h>
+
+#include "notification-ex/app_control_action.h"
+#include "notification-ex/app_control_action_implementation.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define APPCONTROL_ACTION_KEY "__APPCONTROL_ACTION_KEY__"
+
+namespace notification {
+namespace item {
+
+AppControlAction::AppControlAction(app_control_h app_control)
+ : AbstractAction(true), impl_(new Impl(this)) {
+ app_control_h control_;
+ app_control_clone(&control_, app_control);
+ impl_->control_ = control_;
+}
+
+AppControlAction::AppControlAction(app_control_h app_control, std::string extra)
+ : AbstractAction(true, extra), impl_(new Impl(this)) {
+ app_control_h control_;
+ app_control_clone(&control_, app_control);
+ impl_->control_ = control_;
+}
+
+AppControlAction::Impl::Impl(AppControlAction* parent)
+ : parent_(parent) {
+ LOGI("AppControlAction created");
+}
+
+AppControlAction::~AppControlAction() = default;
+AppControlAction::Impl::~Impl() {
+ if (control_)
+ app_control_destroy(control_);
+}
+
+Bundle AppControlAction::Serialize() {
+ Bundle b;
+ bundle* control_b = NULL;
+ bundle_raw* control_raw;
+ int len = 0;
+
+ app_control_export_as_bundle(impl_->control_, &control_b);
+ if (control_b == NULL) {
+ LOGE("failed to get bundle from app_control");
+ return nullptr;
+ }
+
+ bundle_encode(control_b, &control_raw, &len);
+ if (len <= 0) {
+ LOGE("bundle encode failed");
+ return nullptr;
+ }
+
+ b = AbstractAction::Serialize();
+ b.Add(APPCONTROL_ACTION_KEY,
+ std::string(reinterpret_cast<const char*>(control_raw)));
+
+ bundle_free(control_b);
+ free(control_raw);
+ return b;
+}
+
+void AppControlAction::Deserialize(Bundle b) {
+ app_control_h app_control = nullptr;
+ bundle* b_ = nullptr;
+ std::string control_str;
+
+ AbstractAction::Deserialize(b);
+
+ control_str = b.GetString(APPCONTROL_ACTION_KEY);
+
+ b_ = bundle_decode((bundle_raw*)control_str.c_str(), control_str.length());
+ if (b_ == nullptr) {
+ LOGE("bundle_decode failed");
+ return;
+ }
+
+ app_control_create(&app_control);
+ if (app_control == nullptr) {
+ LOGE("failed to create app_control");
+ return;
+ }
+
+ app_control_import_from_bundle(app_control, b_);
+ if (app_control == nullptr) {
+ LOGE("failed to make app_control from bundle");
+ return;
+ }
+
+ impl_->control_ = app_control;
+}
+
+bool AppControlAction::IsLocal() const {
+ return AbstractAction::IsLocal();
+}
+
+void AppControlAction::Execute(std::shared_ptr<AbstractItem> item) {
+ app_control_send_launch_request(impl_->control_, NULL, NULL);
+}
+
+std::string AppControlAction::GetExtra() const {
+ return AbstractAction::GetExtra();
+}
+
+void AppControlAction::SetAppControl(app_control_h app_control) {
+ if (impl_->control_ != nullptr)
+ app_control_destroy(impl_->control_);
+
+ app_control_h control_;
+ app_control_clone(&control_, app_control);
+
+ impl_->control_ = control_;
+}
+
+app_control_h AppControlAction::GetAppControl() const {
+ return impl_->control_;
+}
+
+} //namespace item
+} //namespace notification
--- /dev/null
+/*
+ * Copyright (c) 2019 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 NOTIFICATION_EX_APP_CONTROL_ACTION_H_
+#define NOTIFICATION_EX_APP_CONTROL_ACTION_H_
+
+#include <app_control.h>
+
+#include "notification-ex/abstract_action.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API AppControlAction : public AbstractAction {
+ public:
+ AppControlAction(app_control_h app_control);
+ AppControlAction(app_control_h app_control, std::string extra);
+ virtual ~AppControlAction();
+
+ Bundle Serialize() override;
+ void Deserialize(Bundle b) override;
+ bool IsLocal() const override;
+ void Execute(std::shared_ptr<AbstractItem> item) override;
+ std::string GetExtra() const override;
+ void SetAppControl(app_control_h app_control);
+ app_control_h GetAppControl() const;
+
+ private:
+ class Impl;
+ std::unique_ptr<Impl> impl_;
+};
+
+} // namespace item
+} // namespace notification
+
+#endif // NOTIFICATION_EX_APP_CONTROL_ACTION_H_
+
--- /dev/null
+/*
+ * Copyright (c) 2019 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 NOTIFICATION_EX_APP_CONTROL_ACTION_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_APP_CONTROL_ACTION_IMPLEMENTATION_H_
+
+#include "notification-ex/app_control_action.h"
+
+namespace notification {
+namespace item {
+
+class AppControlAction::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class AppControlAction;
+ Impl(AppControlAction* parent);
+
+ private:
+ AppControlAction* parent_;
+
+ app_control_h control_ = nullptr;
+};
+
+} // namespace item
+} // namespace notification
+
+#endif // NOTIFICATION_EX_APP_CONTROL_ACTION_IMPLEMENTATION_H_
+
--- /dev/null
+/*
+ * Copyright (c) 2019 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 "notification-ex/abstract_item.h"
+#include "notification-ex/visibility_action.h"
+#include "notification-ex/visibility_action_implementation.h"
+#include "notification-ex/exception.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "NOTIFICATION_EX"
+#define VISIBILITY_ACTION_ENTITY_KEY "__VISIBILITY_ACTION_VISIBLE_KEY__"
+#define VISIBILITY_ACTION_ENTITY_SIZE_KEY "__VISIBILITY_ACTION_ENTITY_SIZE_KEY__"
+
+namespace notification {
+namespace item {
+
+VisibilityAction::VisibilityAction()
+ : AbstractAction(true), impl_(new Impl(this)) {
+}
+
+VisibilityAction::VisibilityAction(std::string extra)
+ : AbstractAction(true, extra), impl_(new Impl(this)) {
+}
+
+VisibilityAction::Impl::Impl(VisibilityAction* parent)
+ : parent_(parent) {
+ LOGI("VisibilityAction created");
+}
+
+VisibilityAction::~VisibilityAction() = default;
+VisibilityAction::Impl::~Impl() = default;
+
+Bundle VisibilityAction::Serialize() {
+ char buf_key[128];
+ char buf_data[128];
+ Bundle b;
+ int i = 0;
+
+ b = AbstractAction::Serialize();
+
+ std::list<std::unique_ptr<Impl::VisibilityEntity>>::iterator it;
+
+ for (it = impl_->entities_.begin(); it != impl_->entities_.end(); it++) {
+ buf_key[0] = '\0';
+ buf_data[0] = '\0';
+
+ snprintf(buf_key, sizeof(buf_key), "%s:%d",
+ VISIBILITY_ACTION_ENTITY_SIZE_KEY, i);
+
+ snprintf(buf_data, sizeof(buf_data), "%s:%d",
+ (*it)->id_.c_str(), (*it)->visibility_);
+
+ b.Add(std::string(buf_key), std::string(buf_data));
+ i++;
+ }
+
+ b.Add(VISIBILITY_ACTION_ENTITY_SIZE_KEY, std::to_string(i));
+ return b;
+}
+
+void VisibilityAction::Deserialize(Bundle b) {
+ char buf_key[128];
+ int size;
+ std::size_t pos;
+
+ AbstractAction::Deserialize(b);
+
+ size = std::stoi(b.GetString(VISIBILITY_ACTION_ENTITY_SIZE_KEY));
+
+ for (int i = 0; i < size; i++) {
+ buf_key[0] = '\0';
+
+ snprintf(buf_key, sizeof(buf_key), "%s:%d",
+ VISIBILITY_ACTION_ENTITY_SIZE_KEY, i);
+
+ std::string str = b.GetString(std::string(buf_key));
+
+ pos = str.find(":");
+ std::string id = str.substr(0, pos);
+ bool visible = std::stoi(str.substr(pos+1));
+
+ impl_->entities_.emplace_back(new VisibilityAction::Impl::VisibilityEntity(
+ id, visible));
+ }
+}
+
+bool VisibilityAction::IsLocal() const {
+ return AbstractAction::IsLocal();
+}
+
+void VisibilityAction::Execute(std::shared_ptr<AbstractItem> item) {
+ std::string id = item->GetId();
+ std::list<std::unique_ptr<Impl::VisibilityEntity>>::iterator it;
+
+ for (it = impl_->entities_.begin(); it != impl_->entities_.end(); it++) {
+ if (id == (*it)->id_) {
+ if ((*it)->visibility_)
+ (*it)->visibility_ = false;
+ else
+ (*it)->visibility_ = true;
+ }
+ }
+}
+
+std::string VisibilityAction::GetExtra() const {
+ return AbstractAction::GetExtra();
+}
+
+void VisibilityAction::SetVisibility(std::string id, bool visible) {
+ impl_->entities_.emplace_back(new VisibilityAction::Impl::VisibilityEntity(id,
+ visible));
+}
+
+} //namespace item
+} //namespace notification
--- /dev/null
+/*
+ * Copyright (c) 2019 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 NOTIFICATION_EX_VISIBILITY_ACTION_H_
+#define NOTIFICATION_EX_VISIBILITY_ACTION_H_
+
+#include "notification-ex/abstract_action.h"
+
+namespace notification {
+namespace item {
+
+class EXPORT_API VisibilityAction : public AbstractAction {
+ public:
+ VisibilityAction();
+ VisibilityAction(std::string extra);
+ virtual ~VisibilityAction();
+
+ Bundle Serialize() override;
+ void Deserialize(Bundle b) override;
+ bool IsLocal() const override;
+ void Execute(std::shared_ptr<AbstractItem> item) override;
+ std::string GetExtra() const override;
+ void SetVisibility(std::string id, bool visible);
+
+ private:
+ class Impl;
+ std::unique_ptr<Impl> impl_;
+};
+
+} // namespace item
+} // namespace notification
+
+#endif // NOTIFICATION_EX_VISIBILITY_ACTION_H_
--- /dev/null
+/*
+ * Copyright (c) 2019 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 NOTIFICATION_EX_VISIBILITY_ACTION_IMPLEMENTATION_H_
+#define NOTIFICATION_EX_VISIBILITY_ACTION_IMPLEMENTATION_H_
+
+#include <list>
+
+#include "notification-ex/visibility_action.h"
+
+namespace notification {
+namespace item {
+
+class VisibilityAction::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class VisibilityAction;
+ Impl(VisibilityAction* parent);
+
+ class VisibilityEntity {
+ public:
+ std::string id_;
+ bool visibility_;
+ public:
+ VisibilityEntity(std::string id, bool visibility)
+ : id_(id), visibility_(visibility) {
+ }
+ };
+
+ private:
+ VisibilityAction* parent_;
+ std::list<std::unique_ptr<VisibilityEntity>> entities_;
+};
+
+} // namespace item
+} // namespace notification
+
+#endif // NOTIFICATION_EX_VISIBILITY_ACTION_IMPLEMENTATION_H_
--- /dev/null
+/*
+ * Copyright (c) 2019 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>
+
+#include "notification-ex/app_control_action.h"
+
+using namespace notification;
+using namespace notification::item;
+
+class AppControlActionTest : public ::testing::Test {
+ public:
+ AppControlAction* action;
+ app_control_h app_control;
+ const char* app_id = "test_appid";
+
+ virtual void SetUp() {
+ app_control_create(&app_control);
+ app_control_set_app_id(app_control, app_id);
+
+ action = new AppControlAction(app_control);
+ }
+ virtual void TearDown() {
+ delete action;
+ app_control_destroy(app_control);
+ }
+};
+
+TEST_F(AppControlActionTest, create) {
+ EXPECT_NE(AppControlActionTest::action, nullptr);
+}
+
+TEST_F(AppControlActionTest, IsLocal) {
+ ASSERT_EQ(AppControlActionTest::action->IsLocal(), 1);
+}
+
+TEST_F(AppControlActionTest, SerializeDeserialize) {
+ char* app_id = NULL;
+
+ Bundle b = AppControlActionTest::action->Serialize();
+ AppControlActionTest::action->Deserialize(b);
+
+ app_control_get_app_id(AppControlActionTest::action->GetAppControl(), &app_id);
+ ASSERT_STREQ(AppControlActionTest::app_id, app_id);
+}
+
+TEST_F(AppControlActionTest, AppControl) {
+ const char* app_id = "new_appid";
+ char* app_id_ = NULL;
+ app_control_h app_control;
+ app_control_h app_control_;
+
+ app_control_create(&app_control);
+ app_control_set_app_id(app_control, app_id);
+
+ AppControlActionTest::action->SetAppControl(app_control);
+ app_control_ = AppControlActionTest::action->GetAppControl();
+ app_control_get_app_id(app_control_, &app_id_);
+
+ EXPECT_STREQ(app_id, app_id_);
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 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 <string>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "notification-ex/visibility_action.h"
+
+using namespace notification;
+using namespace notification::item;
+
+class VisibilityActionTest : public ::testing::Test {
+ public:
+ VisibilityAction* visibility;
+ std::string id = "visibility_id";
+ bool visible = true;
+
+ virtual void SetUp() {
+ visibility = new VisibilityAction();
+ visibility->SetVisibility("visibility_id", visible);
+ }
+ virtual void TearDown() {
+ delete visibility;
+ }
+};
+
+TEST_F(VisibilityActionTest, create) {
+ EXPECT_NE(VisibilityActionTest::visibility, nullptr);
+}
+
+TEST_F(VisibilityActionTest, IsLocal) {
+ ASSERT_EQ(VisibilityActionTest::visibility->IsLocal(), 1);
+}
+
+TEST_F(VisibilityActionTest, SerializeDeserialize) {
+ Bundle b = VisibilityActionTest::visibility->Serialize();
+ VisibilityActionTest::visibility->Deserialize(b);
+}
+
+TEST_F(VisibilityActionTest, SetVisibility) {
+ VisibilityActionTest::visibility->SetVisibility("test_id", true);
+}