{}
};
+class MockInput : public DSObject
+{
+public:
+ MockInput()
+ : device(std::make_shared<DSInputDevice>("None", "None", DSInput::NoneClass, DSInput::NoneSubclass))
+ {}
+ ~MockInput()
+ {}
+
+ void slotDeviceAdded(std::shared_ptr<DSInputDevice> device) {
+ this->device.reset();
+ this->device = device;
+ }
+
+ void slotDeviceRemoved(std::shared_ptr<DSInputDevice> device) {
+ this->device.reset();
+ this->device = device;
+ }
+
+ std::shared_ptr<DSInputDevice> device;
+};
+
+
TEST_F(DSInputTest, NewDSInput)
{
DSInput *input = new DSInput;
ASSERT_TRUE(true);
}
-TEST_F(DSInputTest, BasicMethods)
+TEST_F(DSInputTest, DSInputInit)
{
- DSInput input;
+ DSInput *input = new DSInput;
+
+ input->Init();
+ delete input;
EXPECT_TRUE(true);
}
+TEST_F(DSInputTest, DSInputDeviceAddedRemoved)
+{
+ DSInput *input = new DSInput;
+ DSInputDevice *device = new DSInputDevice("MockTestDevice", "MockTest", DSInput::KeyboardClass, DSInput::NoneSubclass);
+ MockInput *mockInput = new MockInput;
+ MockInput *mockInput2 = new MockInput;
+
+ input->Init();
+
+ input->registerCallbackDeviceAdd(mockInput, std::bind(&MockInput::slotDeviceAdded, mockInput, std::placeholders::_1));
+ input->deviceAdd(device->getName(), device->getIdentifier(), device->getClass(), device->getSubclass());
+ EXPECT_TRUE(*(mockInput->device.get()) == *device);
+
+ input->registerCallbackDeviceAdd(mockInput2, std::bind(&MockInput::slotDeviceAdded, mockInput2, std::placeholders::_1));
+ input->deviceAdd(device->getName(), device->getIdentifier(), device->getClass(), device->getSubclass());
+ EXPECT_FALSE(*(mockInput2->device.get()) == *device);
+
+ input->registerCallbackDeviceRemove(mockInput, std::bind(&MockInput::slotDeviceRemoved, mockInput, std::placeholders::_1));
+ input->deviceRemove(device->getName(), device->getIdentifier(), device->getClass(), device->getSubclass());
+ EXPECT_TRUE(*(mockInput->device.get()) == *device);
+
+ input->registerCallbackDeviceRemove(mockInput2, std::bind(&MockInput::slotDeviceRemoved, mockInput2, std::placeholders::_1));
+ input->deviceRemove(device->getName(), device->getIdentifier(), device->getClass(), device->getSubclass());
+
+ EXPECT_FALSE(*(mockInput2->device.get()) == *device);
+
+ delete mockInput2;
+ delete mockInput;
+ delete device;
+ delete input;
+}
+
+
class DSInputDeviceTest : public ::testing::Test
{
public: