Skip to content

Commit 8597346

Browse files
committed
Skip generation of redirect commands
1 parent 02f7e41 commit 8597346

File tree

5 files changed

+29
-117
lines changed

5 files changed

+29
-117
lines changed

cdtp-definition-builder/src/main/java/com/github/kklisura/cdtp/definition/builder/support/protocol/builder/CommandBuilder.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,9 @@ public Builder build(Domain domain, DomainTypeResolver domainTypeResolver) {
7979
List<Command> commands = domain.getCommands();
8080
if (CollectionUtils.isNotEmpty(commands)) {
8181
for (Command command : commands) {
82-
List<Property> parameters = command.getParameters();
83-
if (parameters == null) {
84-
parameters = new ArrayList<>();
85-
}
86-
87-
// Generate methods with mandatory params first
88-
List<Property> mandatoryParams = filterParameters(parameters, property ->
89-
!Boolean.TRUE.equals(property.getOptional()));
90-
command.setParameters(mandatoryParams);
91-
addCommand(command, domain, interfaceBuilder, domainTypeResolver, builders);
92-
93-
if (mandatoryParams.size() != parameters.size()) {
94-
// Generate methods with rest of the params
95-
command.setParameters(parameters);
96-
addCommand(command, domain, interfaceBuilder, domainTypeResolver, builders);
82+
// Do not generate commands with redirect value. Source https://github.com/ChromeDevTools/debugger-protocol-viewer/issues/26
83+
if (StringUtils.isEmpty(command.getRedirect())) {
84+
processCommand(command, domain, interfaceBuilder, domainTypeResolver, builders);
9785
}
9886
}
9987
}
@@ -105,6 +93,26 @@ public Builder build(Domain domain, DomainTypeResolver domainTypeResolver) {
10593
return new CombinedBuilders(builders);
10694
}
10795

96+
private void processCommand(Command command, Domain domain, JavaInterfaceBuilder interfaceBuilder,
97+
DomainTypeResolver domainTypeResolver, List<Builder> builders) {
98+
List<Property> parameters = command.getParameters();
99+
if (parameters == null) {
100+
parameters = new ArrayList<>();
101+
}
102+
103+
// Generate methods with mandatory params first
104+
List<Property> mandatoryParams = filterParameters(parameters, property ->
105+
!Boolean.TRUE.equals(property.getOptional()));
106+
command.setParameters(mandatoryParams);
107+
addCommand(command, domain, interfaceBuilder, domainTypeResolver, builders);
108+
109+
if (mandatoryParams.size() != parameters.size()) {
110+
// Generate methods with rest of the params
111+
command.setParameters(parameters);
112+
addCommand(command, domain, interfaceBuilder, domainTypeResolver, builders);
113+
}
114+
}
115+
108116
private void addCommand(Command command, Domain domain, JavaInterfaceBuilder interfaceBuilder,
109117
DomainTypeResolver domainTypeResolver, List<Builder> builders) {
110118
final String method = command.getName();

cdtp-definition-builder/src/test/java/com/github/kklisura/cdtp/definition/builder/support/protocol/builder/CommandBuilderTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ public void testBuildCommandWithSimpleMethod() {
122122
command2.setName("command2");
123123
command2.setDescription("command2 description");
124124

125-
domain.setCommands(Arrays.asList(command1, command2));
125+
final Command command3 = new Command();
126+
command3.setName("command3");
127+
command3.setDescription("command3 description");
128+
command3.setRedirect("Redirect");
129+
130+
domain.setCommands(Arrays.asList(command1, command2, command3));
126131

127132
expect(javaBuilderFactory.createInterfaceBuilder(BASE_PACKAGE_NAME, "DomainName"))
128133
.andReturn(interfaceBuilder);

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/protocol/commands/DOM.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,6 @@ public interface DOM {
162162
@Returns("nodeId")
163163
Integer requestNode(@ParamName("objectId") String objectId);
164164

165-
/**
166-
* Highlights given rectangle.
167-
*/
168-
void highlightRect();
169-
170-
/**
171-
* Highlights DOM node.
172-
*/
173-
void highlightNode();
174-
175-
/**
176-
* Hides any highlight.
177-
*/
178-
void hideHighlight();
179-
180165
/**
181166
* Requests that the node is sent to the caller given its path. // FIXME, use XPath
182167
*/

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/protocol/commands/Page.java

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
import com.github.kklisura.cdtp.protocol.annotations.ParamName;
66
import com.github.kklisura.cdtp.protocol.annotations.Returns;
77
import com.github.kklisura.cdtp.protocol.types.debugger.SearchMatch;
8-
import com.github.kklisura.cdtp.protocol.types.emulation.ScreenOrientation;
9-
import com.github.kklisura.cdtp.protocol.types.network.Cookie;
108
import com.github.kklisura.cdtp.protocol.types.page.AppManifest;
119
import com.github.kklisura.cdtp.protocol.types.page.Behavior;
12-
import com.github.kklisura.cdtp.protocol.types.page.Configuration;
1310
import com.github.kklisura.cdtp.protocol.types.page.Format;
1411
import com.github.kklisura.cdtp.protocol.types.page.FrameResourceTree;
1512
import com.github.kklisura.cdtp.protocol.types.page.LayoutMetrics;
@@ -114,19 +111,6 @@ public interface Page {
114111
@Experimental
115112
void navigateToHistoryEntry(@ParamName("entryId") Integer entryId);
116113

117-
/**
118-
* Returns all browser cookies. Depending on the backend support, will return detailed cookie information in the <code>cookies</code> field.
119-
*/
120-
@Experimental
121-
@Returns("cookies")
122-
List<Cookie> getCookies();
123-
124-
/**
125-
* Deletes browser cookie with given name, domain and path.
126-
*/
127-
@Experimental
128-
void deleteCookie(@ParamName("cookieName") String cookieName, @ParamName("url") String url);
129-
130114
/**
131115
* Returns present frame / resource tree structure.
132116
*/
@@ -160,63 +144,6 @@ public interface Page {
160144
@Experimental
161145
void setDocumentContent(@ParamName("frameId") String frameId, @ParamName("html") String html);
162146

163-
/**
164-
* Overrides the values of device screen dimensions (window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media query results).
165-
*/
166-
@Experimental
167-
void setDeviceMetricsOverride(@ParamName("width") Integer width, @ParamName("height") Integer height, @ParamName("deviceScaleFactor") Double deviceScaleFactor, @ParamName("mobile") Boolean mobile);
168-
169-
/**
170-
* Overrides the values of device screen dimensions (window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media query results).
171-
*/
172-
@Experimental
173-
void setDeviceMetricsOverride(@ParamName("width") Integer width, @ParamName("height") Integer height, @ParamName("deviceScaleFactor") Double deviceScaleFactor, @ParamName("mobile") Boolean mobile, @Optional @ParamName("scale") Double scale, @Optional @ParamName("screenWidth") Integer screenWidth, @Optional @ParamName("screenHeight") Integer screenHeight, @Optional @ParamName("positionX") Integer positionX, @Optional @ParamName("positionY") Integer positionY, @Optional @ParamName("dontSetVisibleSize") Boolean dontSetVisibleSize, @Optional @ParamName("screenOrientation") ScreenOrientation screenOrientation);
174-
175-
/**
176-
* Clears the overriden device metrics.
177-
*/
178-
@Experimental
179-
void clearDeviceMetricsOverride();
180-
181-
/**
182-
* Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
183-
*/
184-
void setGeolocationOverride();
185-
186-
/**
187-
* Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
188-
*/
189-
void setGeolocationOverride(@Optional @ParamName("latitude") Double latitude, @Optional @ParamName("longitude") Double longitude, @Optional @ParamName("accuracy") Double accuracy);
190-
191-
/**
192-
* Clears the overriden Geolocation Position and Error.
193-
*/
194-
void clearGeolocationOverride();
195-
196-
/**
197-
* Overrides the Device Orientation.
198-
*/
199-
@Experimental
200-
void setDeviceOrientationOverride(@ParamName("alpha") Double alpha, @ParamName("beta") Double beta, @ParamName("gamma") Double gamma);
201-
202-
/**
203-
* Clears the overridden Device Orientation.
204-
*/
205-
@Experimental
206-
void clearDeviceOrientationOverride();
207-
208-
/**
209-
* Toggles mouse event-based touch event emulation.
210-
*/
211-
@Experimental
212-
void setTouchEmulationEnabled(@ParamName("enabled") Boolean enabled);
213-
214-
/**
215-
* Toggles mouse event-based touch event emulation.
216-
*/
217-
@Experimental
218-
void setTouchEmulationEnabled(@ParamName("enabled") Boolean enabled, @Optional @ParamName("configuration") Configuration configuration);
219-
220147
/**
221148
* Capture page screenshot.
222149
*/

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/protocol/types/page/Configuration.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)