END_TEST;
}
+int UtcDaliKeyEventAssignment(void)
+{
+ // Test Assignment operator
+ KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0, KeyEvent::Down); // set name to test, key string to i and modifier to shift
+
+ DALI_TEST_EQUALS(TEST_STRING_1, event.keyPressedName, TEST_LOCATION); // check key name
+ DALI_TEST_EQUALS("i", event.keyPressed, TEST_LOCATION); // check key string
+ DALI_TEST_EQUALS(99, event.keyCode, TEST_LOCATION); // check keyCode
+ DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check modifier
+ DALI_TEST_EQUALS(KeyEvent::Down, event.state, TEST_LOCATION); // check state
+
+ KeyEvent event2(TEST_STRING_1,"j", 88, CTRL_MODIFIER, 0, KeyEvent::Up); // set name to test, key string to i and modifier to shift
+
+ DALI_TEST_EQUALS(TEST_STRING_1, event2.keyPressedName, TEST_LOCATION); // check key name
+ DALI_TEST_EQUALS("j", event2.keyPressed, TEST_LOCATION); // check key string
+ DALI_TEST_EQUALS(88, event2.keyCode, TEST_LOCATION); // check keyCode
+ DALI_TEST_EQUALS(CTRL_MODIFIER, event2.keyModifier, TEST_LOCATION); // check modifier
+ DALI_TEST_EQUALS(KeyEvent::Up, event2.state, TEST_LOCATION); // check state
+
+ event = event2;
+
+ DALI_TEST_EQUALS(TEST_STRING_1, event.keyPressedName, TEST_LOCATION); // check key name
+ DALI_TEST_EQUALS("j", event.keyPressed, TEST_LOCATION); // check key string
+ DALI_TEST_EQUALS(88, event.keyCode, TEST_LOCATION); // check keyCode
+ DALI_TEST_EQUALS(CTRL_MODIFIER, event.keyModifier, TEST_LOCATION); // check modifier
+ DALI_TEST_EQUALS(KeyEvent::Up, event.state, TEST_LOCATION); // check state
+
+ END_TEST;
+}
+
+int UtcDaliKeyEventCopy(void)
+{
+ // Test Assignment operator
+ KeyEvent event(TEST_STRING_1,"i", 99, SHIFT_MODIFIER, 0, KeyEvent::Down); // set name to test, key string to i and modifier to shift
+
+ DALI_TEST_EQUALS(TEST_STRING_1, event.keyPressedName, TEST_LOCATION); // check key name
+ DALI_TEST_EQUALS("i", event.keyPressed, TEST_LOCATION); // check key string
+ DALI_TEST_EQUALS(99, event.keyCode, TEST_LOCATION); // check keyCode
+ DALI_TEST_EQUALS(SHIFT_MODIFIER, event.keyModifier, TEST_LOCATION); // check modifier
+ DALI_TEST_EQUALS(KeyEvent::Down, event.state, TEST_LOCATION); // check state
+
+ KeyEvent event2( event );
+
+ DALI_TEST_EQUALS(TEST_STRING_1, event2.keyPressedName, TEST_LOCATION); // check key name
+ DALI_TEST_EQUALS("i", event2.keyPressed, TEST_LOCATION); // check key string
+ DALI_TEST_EQUALS(99, event2.keyCode, TEST_LOCATION); // check keyCode
+ DALI_TEST_EQUALS(SHIFT_MODIFIER, event2.keyModifier, TEST_LOCATION); // check modifier
+ DALI_TEST_EQUALS(KeyEvent::Down, event2.state, TEST_LOCATION); // check state
+
+ END_TEST;
+}
+
// Positive test case for a method
int UtcDaliKeyEventIsShiftModifier(void)
{
struct KeyEventImpl
{
+ KeyEventImpl()
+ :deviceName("")
+ {
+ };
+
+ KeyEventImpl& operator=( const KeyEventImpl& rhs )
+ {
+ if( this != &rhs )
+ {
+ deviceName = rhs.deviceName;
+ }
+
+ return *this;
+ }
+
+ KeyEventImpl( const KeyEventImpl& rhs )
+ {
+ deviceName = rhs.deviceName;
+ }
+
std::string deviceName;
};
-typedef std::map< KeyEvent*, KeyEventImpl*> KeyEventMap;
+typedef std::map< const KeyEvent*, KeyEventImpl*> KeyEventMap;
typedef KeyEventMap::const_iterator KeyEventMapIter;
time(timeStamp),
state(keyState)
{
- KeyEventImpl* impl = new KeyEventImpl;
- keyEventImplMap[this] = impl;
+ keyEventImplMap[this] = new KeyEventImpl;
+}
+
+KeyEvent::KeyEvent( const KeyEvent& rhs )
+: keyPressedName( rhs.keyPressedName ),
+ keyPressed( rhs.keyPressed ),
+ keyCode( rhs.keyCode ),
+ keyModifier( rhs.keyModifier ),
+ time( rhs.time ),
+ state( rhs.state )
+{
+ keyEventImplMap[this] = new KeyEventImpl( *keyEventImplMap[ &rhs ] );
+}
+
+KeyEvent& KeyEvent::operator=( const KeyEvent& rhs )
+{
+ if( this != &rhs )
+ {
+ keyPressedName = rhs.keyPressedName;
+ keyPressed = rhs.keyPressed;
+ keyCode = rhs.keyCode;
+ keyModifier = rhs.keyModifier;
+ time = rhs.time;
+ state = rhs.state;
+
+ *keyEventImplMap[ this ] = *keyEventImplMap[ &rhs ];
+ }
+
+ return *this;
}
KeyEvent::~KeyEvent()
return false;
}
-std::string DevelKeyEvent::GetDeviceName( KeyEvent& keyEvent )
+std::string DevelKeyEvent::GetDeviceName( const KeyEvent& keyEvent )
{
- KeyEventMapIter search;
-
- search = keyEventImplMap.find( &keyEvent );
-
- std::string result = "";
+ KeyEventMapIter search = keyEventImplMap.find( &keyEvent );
if( search != keyEventImplMap.end())
{
- result = search->second->deviceName;
+ return search->second->deviceName;
}
- return result;
+ return std::string("");
}
-void DevelKeyEvent::SetDeviceName( KeyEvent& keyEvent, std::string deviceName )
+void DevelKeyEvent::SetDeviceName( KeyEvent& keyEvent, const std::string& deviceName )
{
KeyEventMapIter search = keyEventImplMap.find( &keyEvent );