DSInput: Add DSInputDevice's test cases 86/241586/1
authorjeon <jhyuni.kang@samsung.com>
Wed, 8 Jul 2020 07:13:29 +0000 (16:13 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 09:46:03 +0000 (18:46 +0900)
Change-Id: Ie0ac1c63b343a64b9f3260f37f8ded37f4d4ecb2

src/DSInput/DSInput.cpp
tests/DSInput-test.cpp

index 43b31d7..8fe740a 100644 (file)
@@ -24,8 +24,8 @@ DSInput::~DSInput()
 }
 
 DSInputDevice::DSInputDevice()
-       : __deviceName(nullptr),
-         __deviceIdentifier(nullptr),
+       : __deviceName(""),
+         __deviceIdentifier(""),
          __deviceClass(DSInput::DeviceClass::NoneClass),
          __deviceSubclass(DSInput::DeviceSubclass::NoneSubclass)
 {
index 3e4f18c..28aecb6 100644 (file)
@@ -25,3 +25,79 @@ TEST_F(DSInputTest, BasicMethods)
 
        EXPECT_TRUE(true);
 }
+
+class DSInputDeviceTest : public ::testing::Test
+{
+public:
+       void SetUp(void) override
+       {}
+       void TearDown(void) override
+       {}
+};
+
+TEST_F(DSInputDeviceTest, NewDSInputDevice)
+{
+       DSInputDevice *inputDevice = new DSInputDevice;
+       delete inputDevice;
+       inputDevice = new DSInputDevice("TestDevice", "virtual-0", DSInput::NoneClass, DSInput::NoneSubclass);
+       delete inputDevice;
+       ASSERT_TRUE(true);
+}
+
+TEST_F(DSInputDeviceTest, DSInputDeviceSetGetName)
+{
+       std::string tName = "TestDevice";
+       DSInputDevice *inputDevice = new DSInputDevice;
+       inputDevice->setName(tName);
+       std::string name = inputDevice->getName();
+       EXPECT_TRUE(name.compare(tName) ==  0);
+       delete inputDevice;
+}
+
+TEST_F(DSInputDeviceTest, DSInputDeviceSetGetIdentifier)
+{
+       std::string tIdentifier = "virtual-0";
+       DSInputDevice *inputDevice = new DSInputDevice;
+       inputDevice->setIdentifier(tIdentifier);
+       std::string identifier = inputDevice->getIdentifier();
+       EXPECT_TRUE(identifier.compare(tIdentifier) ==  0);
+       delete inputDevice;
+}
+
+TEST_F(DSInputDeviceTest, DSInputDeviceSetGetClass)
+{
+       DSInput::DeviceClass tDevClass;
+       DSInput::DeviceClass devClass;
+       DSInputDevice *inputDevice = new DSInputDevice;
+
+       tDevClass = DSInput::PointerClass;
+       inputDevice->setClass(tDevClass);
+       devClass = inputDevice->getClass();
+       EXPECT_TRUE(tDevClass == devClass);
+
+       tDevClass = DSInput::KeyboardClass;
+       inputDevice->setClass(tDevClass);
+       devClass = inputDevice->getClass();
+       EXPECT_TRUE(tDevClass == devClass);
+
+       tDevClass = DSInput::TouchClass;
+       inputDevice->setClass(tDevClass);
+       devClass = inputDevice->getClass();
+       EXPECT_TRUE(tDevClass == devClass);
+
+       delete inputDevice;
+}
+
+TEST_F(DSInputDeviceTest, DSInputDeviceSetGetSubclass)
+{
+       DSInput::DeviceSubclass tDevSubclass;
+       DSInputDevice *inputDevice = new DSInputDevice;
+
+       tDevSubclass = DSInput::NoneSubclass;
+       inputDevice->setSubclass(tDevSubclass);
+       DSInput::DeviceSubclass devSubclass = inputDevice->getSubclass();
+       EXPECT_TRUE(tDevSubclass == devSubclass);
+
+       delete inputDevice;
+}
+