Dali 3D User Interface Engine
utc-Dali-Key.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 
18 // EXTERNAL INCLUDES
19 #include <map>
20 #include <string.h>
21 #include <iostream>
22 
23 // CLASS HEADER
24 #include <stdlib.h>
25 #include <iostream>
26 #include <dali.h>
27 #include <dali-test-suite-utils.h>
28 
29 using namespace Dali;
30 
32 {
34 }
35 
37 {
39 }
40 
41 // Copied from key-impl.h
42 struct KeyLookup
43 {
44  const char* keyName;
46  const bool deviceButton;
47 };
48 
49 // Common keys for all platforms
51 {
52  { "Escape", DALI_KEY_ESCAPE, false }, // item not defined in utilX
53  { "Menu", DALI_KEY_MENU, false }, // item not defined in utilX
54 
55  // Now the key names are used as literal string not defined symbols,
56  // since these definition in utilX.h is deprecated and we're guided not to use them
57  { "XF86Camera", DALI_KEY_CAMERA, false },
58  { "XF86Camera_Full", DALI_KEY_CONFIG, false },
59  { "XF86PowerOff", DALI_KEY_POWER, true },
60  { "XF86Standby", DALI_KEY_PAUSE, false },
61  { "Cancel", DALI_KEY_CANCEL, false },
62  { "XF86AudioPlay", DALI_KEY_PLAY_CD, false },
63  { "XF86AudioStop", DALI_KEY_STOP_CD, false },
64  { "XF86AudioPause", DALI_KEY_PAUSE_CD, false },
65  { "XF86AudioNext", DALI_KEY_NEXT_SONG, false },
66  { "XF86AudioPrev", DALI_KEY_PREVIOUS_SONG, false },
67  { "XF86AudioRewind", DALI_KEY_REWIND, false },
68  { "XF86AudioForward", DALI_KEY_FASTFORWARD, false },
69  { "XF86AudioMedia", DALI_KEY_MEDIA, false },
70  { "XF86AudioPlayPause", DALI_KEY_PLAY_PAUSE, false },
71  { "XF86AudioMute", DALI_KEY_MUTE, false },
72  { "XF86Menu", DALI_KEY_MENU, true },
73  { "XF86Home", DALI_KEY_HOME, true },
74  { "XF86Back", DALI_KEY_BACK, true },
75  { "XF86HomePage", DALI_KEY_HOMEPAGE, false },
76  { "XF86WWW", DALI_KEY_WEBPAGE, false },
77  { "XF86Mail", DALI_KEY_MAIL, false },
78  { "XF86ScreenSaver", DALI_KEY_SCREENSAVER, false },
79  { "XF86MonBrightnessUp", DALI_KEY_BRIGHTNESS_UP, false },
80  { "XF86MonBrightnessDown", DALI_KEY_BRIGHTNESS_DOWN, false },
81  { "XF86SoftKBD", DALI_KEY_SOFT_KBD, false },
82  { "XF86QuickPanel", DALI_KEY_QUICK_PANEL, false },
83  { "XF86TaskPane", DALI_KEY_TASK_SWITCH, false },
84  { "XF86Apps", DALI_KEY_APPS, false },
85  { "XF86Search", DALI_KEY_SEARCH, false },
86  { "XF86Voice", DALI_KEY_VOICE, false },
87  { "Hangul", DALI_KEY_LANGUAGE, false },
88  { "XF86AudioRaiseVolume", DALI_KEY_VOLUME_UP, true },
89  { "XF86AudioLowerVolume", DALI_KEY_VOLUME_DOWN, true },
90 };
91 const std::size_t KEY_LOOKUP_COUNT = (sizeof( KeyLookupTable))/ (sizeof(KeyLookup));
92 
93 
94 // Generate a KeyPressEvent to send to Core
95 Dali::KeyEvent GenerateKeyPress( const std::string& keyName )
96 {
97  KeyEvent keyPress;
98  keyPress.keyPressedName = keyName;
99  return keyPress;
100 }
101 
103 {
104  TestApplication application;
105 
106  for ( std::size_t i = 0; i < KEY_LOOKUP_COUNT; ++i )
107  {
108  tet_printf( "Checking %s", KeyLookupTable[i].keyName );
109  DALI_TEST_CHECK( IsKey( GenerateKeyPress( KeyLookupTable[i].keyName ), KeyLookupTable[i].daliKeyCode ) );
110  }
111  END_TEST;
112 }
113 
115 {
116  TestApplication application;
117 
118  // Random value
119  DALI_TEST_CHECK( IsKey( GenerateKeyPress( "invalid-key-name" ), DALI_KEY_MUTE ) == false );
120 
121  // Compare with another key value
122  for ( std::size_t i = 0; i < KEY_LOOKUP_COUNT; ++i )
123  {
124  tet_printf( "Checking %s", KeyLookupTable[i].keyName );
125  DALI_TEST_CHECK( IsKey( GenerateKeyPress( KeyLookupTable[i].keyName ), KeyLookupTable[ ( i + 1 ) % KEY_LOOKUP_COUNT ].daliKeyCode ) == false );
126  }
127  END_TEST;
128 }
Dali Docs Home
Read more about Dali