1 package com.atlassian.webtest.ui.keys;
2
3 import java.util.Collections;
4 import java.util.List;
5 import java.util.Set;
6
7 /**
8 * <p>
9 * Enumeration of {@link SpecialKey}s used within tests.
10 *
11 * <p>
12 * This enumeration also implements the {@link KeySequence} interface for convenient usage.
13 *
14 * <p>
15 * NOTE: Some of the keys may be actually represented as Unicode/ASCII characters, nevertheless they should be
16 * supported by implementing frameworks for the convenience of API clients.
17 *
18 *
19 * @see Key
20 * @see KeySequence
21 */
22 public enum SpecialKeys implements SpecialKey, KeySequence
23 {
24 ENTER,
25 ESC,
26 BACKSPACE,
27 DELETE,
28 SPACE,
29 ARROW_LEFT,
30 ARROW_RIGHT,
31 ARROW_UP,
32 ARROW_DOWN;
33
34 // TODO add other if necessary
35
36 private final List<Key> keys;
37
38 private SpecialKeys()
39 {
40 this.keys = Collections.singletonList((Key)this);
41 }
42
43
44 // @Override
45 public List<Key> keys()
46 {
47 return keys;
48 }
49
50 // @Override
51 public Set<ModifierKey> withPressed()
52 {
53 return Collections.emptySet();
54 }
55
56 /**
57 * Construct key sequence consisting of this special key with given key events to invoke
58 *
59 * @param events key events to invoke for the created sequence
60 * @return new key sequence representing this key
61 */
62 public KeySequence withEvents(KeyEventType... events)
63 {
64 return Sequences.keysBuilder(this).keyEvents(events).build();
65 }
66
67 }