Test for EntryNameModalPresenter 44/218744/8 accepted/tizen/unified/20191206.121303 submit/tizen/20191203.210336 submit/tizen/20191204.213652 submit/tizen/20191205.205324
authorTomasz Okoniewski <t.okoniewski@partner.samsung.com>
Wed, 27 Nov 2019 14:54:16 +0000 (15:54 +0100)
committerTomasz Okoniewski <t.okoniewski@partner.samsung.com>
Tue, 3 Dec 2019 11:27:28 +0000 (12:27 +0100)
Change-Id: I1cab7f944a46a3ab3315c736decf7c54ff25ab86

tests/no-ui-scenarios/EntryNameModalPresenterTest.cpp [new file with mode: 0644]

diff --git a/tests/no-ui-scenarios/EntryNameModalPresenterTest.cpp b/tests/no-ui-scenarios/EntryNameModalPresenterTest.cpp
new file mode 100644 (file)
index 0000000..21e9a6e
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2017  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 "EntryNameModalPresenter.hpp"
+
+#include <gtest/gtest.h>
+
+TEST(EntryNameModalPresenter, testConstructor)
+{
+       auto enmp = std::make_unique<EntryNameModalPresenter>("testSwitchID");
+       EXPECT_STRCASEEQ("IDS_ACCS_UNIVERSAL_SWITCH_ADD_SWITCH", enmp->getTitle().c_str());
+}
+
+TEST(EntryNameModalPresenter, testAction)
+{
+       auto enmp = std::make_unique<EntryNameModalPresenter>("testSwitchID");
+
+       auto modal_action = enmp->getAction("modalEntry");
+       ASSERT_NE(modal_action, nullptr);
+       EXPECT_EQ(modal_action->actionId_, std::string("modalEntry"));
+       EXPECT_EQ(modal_action->title_.value(), std::string("IDS_ACCS_UNIVERSAL_SWITCH_ADD_SWITCH_NAME"));
+       EXPECT_TRUE(modal_action->enabled_.value());
+       EXPECT_FALSE(modal_action->state_.value());
+
+       auto cancel_action = enmp->getAction("cancelAction");
+
+       ASSERT_NE(cancel_action, nullptr);
+       EXPECT_EQ(cancel_action->actionId_, std::string("cancelAction"));
+       EXPECT_EQ(cancel_action->title_.value(), std::string("IDS_ACCS_UNIVERSAL_SWITCH_CANCEL"));
+       EXPECT_TRUE(cancel_action->enabled_.value());
+       EXPECT_FALSE(cancel_action->state_.value());
+
+       auto save_action = enmp->getAction("doneAction");
+
+       ASSERT_NE(save_action, nullptr);
+       EXPECT_EQ(save_action->actionId_, std::string("doneAction"));
+       EXPECT_EQ(save_action->title_.value(), std::string("IDS_ACCS_UNIVERSAL_SWITCH_SAVE"));
+       EXPECT_FALSE(save_action->enabled_.value());
+       EXPECT_FALSE(save_action->state_.value());
+       if (modal_action->onInvoke_)
+               modal_action->onInvoke_(modal_action);
+       EXPECT_TRUE(save_action->enabled_.value());
+}
+
+int main(int argc, char *argv[])
+{
+       try {
+               ::testing::InitGoogleTest(&argc, argv);
+               return RUN_ALL_TESTS();
+       } catch (...) {
+               return 1;
+       }
+}