mmi-keyboard-provider-tests : add keyboard provider testcase in tests/keyboard-provid... 22/264222/1
authordyamy-lee <dyamy.lee@samsung.com>
Tue, 14 Sep 2021 09:57:09 +0000 (18:57 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Tue, 14 Sep 2021 12:15:13 +0000 (21:15 +0900)
Change-Id: I42bb64238623c4e75c6af4cf99fb5ae891a5988e

tests/keyboard-provider/main.cpp [new file with mode: 0644]
tests/keyboard-provider/main.h [new file with mode: 0644]
tests/keyboard-provider/mmi-keyboard-provider-tests.cpp [new file with mode: 0644]

diff --git a/tests/keyboard-provider/main.cpp b/tests/keyboard-provider/main.cpp
new file mode 100644 (file)
index 0000000..960d73c
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+* 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 "main.h"
+
+int main(int argc, char **argv)
+{
+       auto testResults = false;
+
+       try
+       {
+               ::testing::InitGoogleMock(&argc, argv);
+               ::testing::FLAGS_gtest_death_test_style = "fast";
+       }
+       catch ( ... )
+       {
+               PRINT("Error occurred while trying to initialize GoogleTest.\n");
+               exit(EXIT_FAILURE);
+       }
+
+       try
+       {
+               testResults = (RUN_ALL_TESTS() == 0) ? true : false;
+       }
+       catch (const ::testing::internal::GoogleTestFailureException &e)
+       {
+               testResults = false;
+               PRINT("GoogleTestFailureException has been thrown: %s\n", e.what());
+       }
+
+       return testResults;
+}
+
diff --git a/tests/keyboard-provider/main.h b/tests/keyboard-provider/main.h
new file mode 100644 (file)
index 0000000..79bfac7
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+* 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.
+*/
+
+#ifndef __MMI_KEYBOARD_PROVIDER_TESTS_H__
+#define __MMI_KEYBOARD_PROVIDER_TESTS_H__
+
+#include <stdio.h>
+#include <gmock/gmock.h>
+#include <Ecore.h>
+
+#define PRINT printf
+
+using ::testing::TestWithParam;
+using ::testing::Bool;
+using ::testing::Values;
+using ::testing::Combine;
+
+#endif //__MMI_KEYBOARD_PROVIDER_TESTS_H__
diff --git a/tests/keyboard-provider/mmi-keyboard-provider-tests.cpp b/tests/keyboard-provider/mmi-keyboard-provider-tests.cpp
new file mode 100644 (file)
index 0000000..9fa88d8
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+* 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 "main.h"
+
+extern "C" {
+#include "mmi-keyboard-provider.h"
+}
+
+#include <Ecore.h>
+#include <string.h>
+#include <gtest/gtest.h>
+
+class MMIKeyboardProviderTest : public ::testing::Test
+{
+public:
+       void SetUp(void) override
+       {
+               ecore_init();
+       }
+
+       void TearDown(void) override
+       {
+               ecore_shutdown();
+       }
+};
+
+
+TEST_F(MMIKeyboardProviderTest, MMIKeyboardProviderSetGetMode)
+{
+       bool r = false;
+       mmi_provider_op_mode op_mode = MODALITY_PROVIDER_MODE_NONE;
+
+       r = keyboard_set_mode(MODALITY_PROVIDER_MODE_PROPAGATE_EVENT);
+       EXPECT_EQ(r, true);
+
+       op_mode = keyboard_get_mode();
+       EXPECT_EQ(op_mode, MODALITY_PROVIDER_MODE_PROPAGATE_EVENT);
+}
+
+TEST_F(MMIKeyboardProviderTest, MMIKeyboardProviderSetModeFail)
+{
+       bool r = false;
+
+       r = keyboard_set_mode(MODALITY_PROVIDER_MODE_NONE);
+       EXPECT_EQ(r, false);
+}
\ No newline at end of file