2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
27 #include <dali-test-suite-utils.h>
31 void utc_dali_adaptor_key_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_adaptor_key_cleanup(void)
38 test_return_value = TET_PASS;
41 // Copied from key-impl.cpp
44 const char* keyName; ///< X string representation
45 const int daliKeyCode; ///< Dali Enum Representation
46 const bool deviceButton; ///< Whether the key is from a button on the device
50 #define KEY_VOLUMEUP "XF86AudioRaiseVolume" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Volume Up' key */
51 #define KEY_VOLUMEDOWN "XF86AudioLowerVolume" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Volume Down' key */
53 #define KEY_CAMERA "XF86WebCam" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Half-Press of Camera' key */
54 #define KEY_CONFIG "XF86Pictures" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Full-Press of Camera' key */
56 #define KEY_POWER "XF86PowerOff" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Power' key */
57 #define KEY_PAUSE "XF86Standby" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Pause' key */
58 #define KEY_CANCEL "Cancel" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Cancel' key */
60 // Earjack/BT Headset/Multimedia keys
61 #define KEY_PLAYCD "XF86AudioPlay" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Play Audio' key */
62 #define KEY_STOPCD "XF86AudioStop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Stop Audio' key */
63 #define KEY_PAUSECD "XF86AudioPause" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Pause Audio' key */
64 #define KEY_NEXTSONG "XF86AudioNext" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Next Song' key */
65 #define KEY_PREVIOUSSONG "XF86AudioPrev" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Previous Song' key */
66 #define KEY_REWIND "XF86AudioRewind" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Rewind Song' key */
67 #define KEY_FASTFORWARD "XF86AudioForward" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Forward Song' key */
68 #define KEY_MEDIA "XF86AudioMedia" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Media' key */
69 #define KEY_PLAYPAUSE "XF86AudioPlayPause" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'PlayPause' key */
70 #define KEY_MUTE "XF86AudioMute" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Mute' key */
73 #define KEY_SEND "XF86Send" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Send' key */
74 #define KEY_SELECT "XF86Phone" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Home' key */
75 #define KEY_END "XF86Stop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'End' key */
77 // Renamed 3-Touch key
78 #define KEY_MENU "XF86Send" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Send' key */
79 #define KEY_HOME "XF86Phone" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Home' key */
80 #define KEY_BACK "XF86Stop" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'End' key */
82 //Other functions keys
83 #define KEY_HOMEPAGE "XF86HomePage" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'HomePage' key */
84 #define KEY_WEBPAGE "XF86WWW" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'WWW' key */
85 #define KEY_MAIL "XF86Mail" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Mail' key */
86 #define KEY_SCREENSAVER "XF86ScreenSaver" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'ScreenSaver' key */
87 #define KEY_BRIGHTNESSUP "XF86MonBrightnessUp" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'BrightnessUp' key */
88 #define KEY_BRIGHTNESSDOWN "XF86MonBrightnessDown" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'BrightnessDown' key */
89 #define KEY_SOFTKBD "XF86MenuKB" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Soft keyboard(toggle)' key */
90 #define KEY_QUICKPANEL "XF86Tools" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Quick panel(toggle)' key */
91 #define KEY_TASKSWITCH "XF86TaskPane" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Task switcher(toggle)' key */
92 #define KEY_APPS "XF86Launch0" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Apptray(toggle)' key */
93 #define KEY_SEARCH "XF86Search" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Search(toggle)' key */
94 #define KEY_VOICE "XF86Launch2" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Voice(toggle)' key */
95 #define KEY_LANGUAGE "Hangul" /**< this macro means the XKeySym (XServer Key Symbol) corresponds to 'Language(toggle)' key */
97 // Taken from key-impl.cpp
98 KeyLookup KeyLookupTable[]=
100 // KeyName DALi Equivalent true if device key
101 { "Escape", DALI_KEY_ESCAPE, false },
102 { "Menu", DALI_KEY_MENU, false },
103 { KEY_CAMERA, DALI_KEY_CAMERA, false },
104 { KEY_CONFIG, DALI_KEY_CONFIG, false },
105 { KEY_POWER, DALI_KEY_POWER, true },
106 { KEY_PAUSE, DALI_KEY_PAUSE, false },
107 { KEY_CANCEL, DALI_KEY_CANCEL, false },
108 { KEY_PLAYCD, DALI_KEY_PLAY_CD, false },
109 { KEY_STOPCD, DALI_KEY_STOP_CD, false },
110 { KEY_PAUSECD, DALI_KEY_PAUSE_CD, false },
111 { KEY_NEXTSONG, DALI_KEY_NEXT_SONG, false },
112 { KEY_PREVIOUSSONG, DALI_KEY_PREVIOUS_SONG, false },
113 { KEY_REWIND, DALI_KEY_REWIND, false },
114 { KEY_FASTFORWARD, DALI_KEY_FASTFORWARD, false },
115 { KEY_MEDIA, DALI_KEY_MEDIA, false },
116 { KEY_PLAYPAUSE, DALI_KEY_PLAY_PAUSE, false },
117 { KEY_MUTE, DALI_KEY_MUTE, false },
118 { KEY_SEND, DALI_KEY_SEND, true },
119 { KEY_SELECT, DALI_KEY_SELECT, true },
120 { KEY_END, DALI_KEY_END, true },
121 { KEY_MENU, DALI_KEY_MENU, true },
122 { KEY_HOME, DALI_KEY_HOME, true },
123 { KEY_BACK, DALI_KEY_BACK, true },
124 { KEY_HOMEPAGE, DALI_KEY_HOMEPAGE, false },
125 { KEY_WEBPAGE, DALI_KEY_WEBPAGE, false },
126 { KEY_MAIL, DALI_KEY_MAIL, false },
127 { KEY_SCREENSAVER, DALI_KEY_SCREENSAVER, false },
128 { KEY_BRIGHTNESSUP, DALI_KEY_BRIGHTNESS_UP, false },
129 { KEY_BRIGHTNESSDOWN, DALI_KEY_BRIGHTNESS_DOWN, false },
130 { KEY_SOFTKBD, DALI_KEY_SOFT_KBD, false },
131 { KEY_QUICKPANEL, DALI_KEY_QUICK_PANEL, false },
132 { KEY_TASKSWITCH, DALI_KEY_TASK_SWITCH, false },
133 { KEY_APPS, DALI_KEY_APPS, false },
134 { KEY_SEARCH, DALI_KEY_SEARCH, false },
135 { KEY_VOICE, DALI_KEY_VOICE, false },
136 { KEY_LANGUAGE, DALI_KEY_LANGUAGE, false },
137 { KEY_VOLUMEUP, DALI_KEY_VOLUME_UP, true },
138 { KEY_VOLUMEDOWN, DALI_KEY_VOLUME_DOWN, true },
140 const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
143 // Generate a KeyPressEvent to send to Core
144 Dali::KeyEvent GenerateKeyPress( const std::string& keyName )
147 keyPress.keyPressedName = keyName;
151 int UtcDaliKeyIsKey(void)
153 TestApplication application;
155 for ( std::size_t i = 0; i < KEY_LOOKUP_COUNT; ++i )
157 tet_printf( "Checking %s", KeyLookupTable[i].keyName );
158 DALI_TEST_CHECK( IsKey( GenerateKeyPress( KeyLookupTable[i].keyName ), KeyLookupTable[i].daliKeyCode ) );
163 int UtcDaliKeyIsKeyNegative(void)
165 TestApplication application;
168 DALI_TEST_CHECK( IsKey( GenerateKeyPress( "invalid-key-name" ), DALI_KEY_MUTE ) == false );
170 // Compare with another key value
171 for ( std::size_t i = 0; i < KEY_LOOKUP_COUNT; ++i )
173 tet_printf( "Checking %s", KeyLookupTable[i].keyName );
174 DALI_TEST_CHECK( IsKey( GenerateKeyPress( KeyLookupTable[i].keyName ), KeyLookupTable[ ( i + 1 ) % KEY_LOOKUP_COUNT ].daliKeyCode ) == false );