--- /dev/null
+/*
+ * Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <gtest/gtest.h>
+
+#include "CommandFinder.h"
+
+using namespace std;
+
+namespace {
+
+class CommandFinderTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ ClickableItem item1;
+ item1.coordX = 10;
+ item1.coordY = 10;
+ item1.width = 10;
+ item1.height = 10;
+ item1.objectId = "id1";
+ item1.label = "test1";
+ item1.index = 1;
+
+ ClickableItem item2;
+ item2.coordX = 20;
+ item2.coordY = 20;
+ item2.width = 10;
+ item2.height = 10;
+ item2.objectId = "id2";
+ item2.label = "test2";
+ item2.index = 2;
+
+ ClickableItem item3;
+ item3.coordX = 30;
+ item3.coordY = 30;
+ item3.width = 10;
+ item3.height = 10;
+ item3.objectId = "id3";
+ item3.label = "";
+ item3.index = 3;
+
+ commands.push_back(make_shared<ClickableItem>(item1));
+ commands.push_back(make_shared<ClickableItem>(item2));
+ commands.push_back(make_shared<ClickableItem>(item3));
+ }
+
+ virtual void TearDown() {
+ commands.clear();
+ }
+
+ public:
+ list<shared_ptr<ClickableItem>> commands;
+};
+
+TEST_F(CommandFinderTest, utc_CommandFinder_Constructor)
+{
+ string target = "test1";
+ auto finder1 = new(nothrow) CommandFinder(target, commands);
+ auto finder2 = new(nothrow) CommandFinder(1, commands);
+
+ EXPECT_NE(finder1, nullptr);
+ EXPECT_NE(finder2, nullptr);
+
+ delete finder1;
+ delete finder2;
+}
+
+TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p)
+{
+ string target = "test1";
+ auto finder_p = new(nothrow) CommandFinder(target, commands);
+ ASSERT_NE(finder_p, nullptr);
+
+ auto command = finder_p->findCommand();
+ ASSERT_NE(command, nullptr);
+ EXPECT_STREQ(command->objectId.c_str(), "id1");
+
+ delete finder_p;
+}
+
+TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p2)
+{
+ string target = "text1";
+ auto finder_p = new(nothrow) CommandFinder(target, commands);
+ ASSERT_NE(finder_p, nullptr);
+
+ auto command = finder_p->findCommand();
+ ASSERT_NE(command, nullptr);
+ EXPECT_STREQ(command->objectId.c_str(), "id1");
+
+ delete finder_p;
+}
+
+TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_p3)
+{
+ auto finder_p = new(nothrow) CommandFinder(1, commands);
+ ASSERT_NE(finder_p, nullptr);
+
+ auto command = finder_p->findCommand();
+ ASSERT_NE(command, nullptr);
+ EXPECT_STREQ(command->objectId.c_str(), "id1");
+
+ delete finder_p;
+}
+
+TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_n)
+{
+ string target = "no matched text";
+ auto finder_n = new(nothrow) CommandFinder(target, commands);
+ ASSERT_NE(finder_n, nullptr);
+
+ auto command = finder_n->findCommand();
+ EXPECT_EQ(command, nullptr);
+
+ delete finder_n;
+}
+
+TEST_F(CommandFinderTest, utc_CommandFinder_findCommand_n2)
+{
+ auto finder_n = new(nothrow) CommandFinder(-1, commands);
+ ASSERT_NE(finder_n, nullptr);
+
+ auto command = finder_n->findCommand();
+ EXPECT_EQ(command, nullptr);
+
+ delete finder_n;
+}
+
+} // namespace
--- /dev/null
+/*
+ * Copyright © 2021 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <gtest/gtest.h>
+
+#include "CommandManager.h"
+
+using namespace std;
+
+namespace {
+
+class CommandManagerTest : public testing::Test {
+ public:
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+
+ public:
+ list<shared_ptr<ClickableItem>> commands;
+};
+
+TEST_F(CommandManagerTest, utc_CommandManager_Constructor)
+{
+ auto manager = new(nothrow) CommandManager();
+
+ EXPECT_NE(manager, nullptr);
+
+ delete manager;
+}
+
+TEST_F(CommandManagerTest, utc_CommandManager_addCommand)
+{
+ auto manager = new(nothrow) CommandManager();
+
+ ASSERT_NE(manager, nullptr);
+
+ ClickableItem item1;
+ item1.coordX = 10;
+ item1.coordY = 10;
+ item1.width = 10;
+ item1.height = 10;
+ item1.objectId = "id1";
+ item1.label = "test1";
+ item1.index = 1;
+
+ manager->addCommand(item1);
+
+ delete manager;
+}
+
+TEST_F(CommandManagerTest, utc_CommandFinder_findCommand)
+{
+ auto manager = new(nothrow) CommandManager();
+
+ ASSERT_NE(manager, nullptr);
+
+ ClickableItem item1;
+ item1.coordX = 10;
+ item1.coordY = 10;
+ item1.width = 10;
+ item1.height = 10;
+ item1.objectId = "id1";
+ item1.label = "test1";
+ item1.index = 1;
+
+ ClickableItem item2;
+ item2.coordX = 20;
+ item2.coordY = 20;
+ item2.width = 10;
+ item2.height = 10;
+ item2.objectId = "id2";
+ item2.label = "test2";
+ item2.index = 2;
+
+ manager->addCommand(item1);
+ manager->addCommand(item2);
+
+ string target1 = "test1";
+ auto command1 = manager->findCommand(target1, false);
+ ASSERT_NE(command1, nullptr);
+ EXPECT_STREQ(command1->objectId.c_str(), "id1");
+ command1 = nullptr;
+
+ string target2 = "2";
+ auto command2 = manager->findCommand(target2, true);
+ ASSERT_NE(command2, nullptr);
+ EXPECT_STREQ(command2->objectId.c_str(), "id2");
+ command2 = nullptr;
+
+ delete manager;
+}
+
+TEST_F(CommandManagerTest, utc_CommandFinder_clearCommand)
+{
+ auto manager = new(nothrow) CommandManager();
+
+ ASSERT_NE(manager, nullptr);
+
+ ClickableItem item1;
+ item1.coordX = 10;
+ item1.coordY = 10;
+ item1.width = 10;
+ item1.height = 10;
+ item1.objectId = "id1";
+ item1.label = "test1";
+ item1.index = 1;
+
+ ClickableItem item2;
+ item2.coordX = 20;
+ item2.coordY = 20;
+ item2.width = 10;
+ item2.height = 10;
+ item2.objectId = "id2";
+ item2.label = "test2";
+ item2.index = 2;
+
+ manager->addCommand(item1);
+ manager->addCommand(item2);
+
+ string target1 = "test1";
+ auto command1 = manager->findCommand(target1, false);
+ ASSERT_NE(command1, nullptr);
+ EXPECT_STREQ(command1->objectId.c_str(), "id1");
+ command1 = nullptr;
+
+ manager->cleanCommands();
+
+ auto command2 = manager->findCommand(target1, false);
+ EXPECT_EQ(command2, nullptr);
+
+ delete manager;
+}
+
+} // namespace