1 package net.avcompris.guixer.core;
2
3 import static com.google.common.base.Preconditions.checkNotNull;
4 import static net.avcompris.guixer.core.LoggerUtils.escape;
5 import static net.avcompris.guixer.core.LoggerUtils.formatKeys;
6
7 import java.io.IOException;
8
9 import javax.annotation.Nullable;
10
11 final class Skip implements Command {
12
13 private final AbstractCommandLoggerImpl underlyingCommand;
14 private final Logger logger;
15
16 public Skip(
17 final AbstractCommandLoggerImpl underlyingCommand,
18 final Logger logger) throws IOException {
19
20 this.underlyingCommand = checkNotNull(underlyingCommand, "underlyingCommand");
21 this.logger = checkNotNull(logger, "logger");
22 }
23
24 @Override
25 public Command get() throws IOException {
26
27 logger.startStep("skip(" + escape("get()") + ")");
28
29 logger.endStep();
30
31 return underlyingCommand;
32 }
33
34 @Override
35 public Command takeScreenshot() throws IOException {
36
37 logger.startStep("skip(" + escape("takeScreenshot()") + ")");
38
39 logger.endStep();
40
41 return underlyingCommand;
42 }
43
44 @Override
45 public Command takeScreenshot(final String label) throws IOException {
46
47 logger.startStep("skip(" + escape("takeScreenshot(" + escape(label) + ")") + ")");
48
49 logger.endStep();
50
51 return underlyingCommand;
52 }
53
54 @Override
55 public Command sleep(final int ms) throws IOException {
56
57 logger.startStep("skip(" + escape("sleep(" + ms + ")") + ")");
58
59 logger.endStep();
60
61 return underlyingCommand;
62 }
63
64 @Override
65 public Command waitFor(final String locator) throws IOException {
66
67 logger.startStep("skip(" + escape("waitFor(" + escape(locator) + ")") + ")");
68
69 logger.endStep();
70
71 return underlyingCommand;
72 }
73
74 @Override
75 public Command waitFor(final String locator, final int timeOutSeconds) throws IOException {
76
77 logger.startStep("skip(" + escape("waitFor(" + escape(locator) + ", " + timeOutSeconds + ")") + ")");
78
79 logger.endStep();
80
81 return underlyingCommand;
82 }
83
84 @Override
85 public Command waitForVisible(final String locator) throws IOException {
86
87 logger.startStep("skip(" + escape("waitForVisible(" + escape(locator) + ")") + ")");
88
89 logger.endStep();
90
91 return underlyingCommand;
92 }
93
94 @Override
95 public Command waitForVisible(final String locator, final int timeOutSeconds) throws IOException {
96
97 logger.startStep("skip(" + escape("waitForVisible(" + escape(locator) + ", " + timeOutSeconds + ")") + ")");
98
99 logger.endStep();
100
101 return underlyingCommand;
102 }
103
104 @Override
105 public SwitchTo switchTo() throws IOException {
106
107 logger.startStep("skip(" + escape("switchTo()") + ")");
108
109 logger.endStep();
110
111 return new SwitchToNullImpl(underlyingCommand);
112 }
113
114 @Override
115 public Command log(@Nullable final String text) throws IOException {
116
117 logger.startStep("skip(" + escape("log(" + escape(text) + ")") + ")");
118
119 logger.endStep();
120
121 return underlyingCommand;
122 }
123
124 @Override
125 public Command clear(final String locator) throws IOException {
126
127 logger.startStep("skip(" + escape("clear(" + escape(locator) + ")") + ")");
128
129 logger.endStep();
130
131 return underlyingCommand;
132 }
133
134 @Override
135 public Command click(final String locator) throws IOException {
136
137 logger.startStep("skip(" + escape("click(" + escape(locator) + ")") + ")");
138
139 logger.endStep();
140
141 return underlyingCommand;
142 }
143
144 @Override
145 public Command submit(final String locator) throws IOException {
146
147 logger.startStep("skip(" + escape("submit(" + escape(locator) + ")") + ")");
148
149 logger.endStep();
150
151 return underlyingCommand;
152 }
153
154 @Override
155 public Command select(final String locator, final int value) throws IOException {
156
157 logger.startStep("skip(" + escape("select(" + escape(locator) + ", " + value + ")") + ")");
158
159 logger.endStep();
160
161 return underlyingCommand;
162 }
163
164 @Override
165 public Command select(final String locator, final String value) throws IOException {
166
167 logger.startStep("skip(" + escape("select(" + escape(locator) + ", " + escape(value) + ")") + ")");
168
169 logger.endStep();
170
171 return underlyingCommand;
172 }
173
174 @Override
175 public Command assertHasClass(final String locator, final String className) throws IOException {
176
177 logger.startStep("skip(" + escape("assertHasClass(" + escape(locator) + ", " + escape(className) + ")") + ")");
178
179 logger.endStep();
180
181 return underlyingCommand;
182 }
183
184 @Override
185 public Command assertDoesntHaveClass(final String locator, final String className) throws IOException {
186
187 logger.startStep(
188 "skip(" + escape("assertDoesntHaveClass(" + escape(locator) + ", " + escape(className) + ")") + ")");
189
190 logger.endStep();
191
192 return underlyingCommand;
193 }
194
195 @Override
196 public Command sendKeys(final String locator, final CharSequence... keys) throws IOException {
197
198 logger.startStep("skip(" + escape("sendKeys(" + escape(locator) + "" + formatKeys(keys) + ")") + ")");
199
200 logger.endStep();
201
202 return underlyingCommand;
203 }
204
205 @Override
206 public Command sendKeysSecret(final String locator, final String secret) throws IOException {
207
208 logger.startStep("skip(" + escape("sendKeysSecret(" + escape(locator) + ", ***)") + ")");
209
210 logger.endStep();
211
212 return underlyingCommand;
213 }
214
215 @Override
216 public Command when(final String label, final boolean condition) throws IOException {
217
218 throw new IllegalStateException("Illegal syntax: skip().when()");
219 }
220
221 @Override
222 public Command when(final boolean condition) throws IOException {
223
224 throw new IllegalStateException("Illegal syntax: skip().when()");
225 }
226
227 @Override
228 public Command skip() throws IOException {
229
230 throw new IllegalStateException("Illegal syntax: skip().skip()");
231 }
232 }