Skip to content

Commit 5575b89

Browse files
authored
Merge pull request #24 from kklisura/return-types
Return types
2 parents b2621d6 + dc84ebc commit 5575b89

File tree

440 files changed

+1269
-527
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

440 files changed

+1269
-527
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.github.kklisura.cdt.examples;
2+
3+
import com.github.kklisura.cdt.launch.ChromeLauncher;
4+
import com.github.kklisura.cdt.protocol.commands.Network;
5+
import com.github.kklisura.cdt.protocol.commands.Page;
6+
import com.github.kklisura.cdt.protocol.commands.Performance;
7+
import com.github.kklisura.cdt.protocol.types.performance.Metric;
8+
import com.github.kklisura.cdt.services.ChromeDevToolsService;
9+
import com.github.kklisura.cdt.services.ChromeService;
10+
import com.github.kklisura.cdt.services.types.ChromeTab;
11+
12+
import java.util.List;
13+
14+
/**
15+
* Metric example
16+
*
17+
* @author Kenan Klisura
18+
*/
19+
public class PerformanceMetricsExample {
20+
public static void main(String[] args) {
21+
// Create chrome launcher.
22+
final ChromeLauncher launcher = new ChromeLauncher();
23+
24+
// Launch chrome either as headless (true) or regular (false).
25+
final ChromeService chromeService = launcher.launch(false);
26+
27+
// Create empty tab ie about:blank.
28+
final ChromeTab tab = chromeService.createTab();
29+
30+
// Get DevTools service to this tab
31+
final ChromeDevToolsService devToolsService = chromeService.createDevToolsService(tab);
32+
33+
// Get individual commands
34+
final Page page = devToolsService.getPage();
35+
final Network network = devToolsService.getNetwork();
36+
final Performance performance = devToolsService.getPerformance();
37+
38+
performance.enable();
39+
network.onLoadingFinished(
40+
event -> {
41+
// Close the tab and close the browser when loading finishes.
42+
List<Metric> metrics = performance.getMetrics();
43+
try {
44+
for (Metric metric : metrics) {
45+
System.out.println(metric.getName() + ": " + metric.getValue());
46+
}
47+
} catch (Exception e) {
48+
System.out.println(e.getMessage());
49+
}
50+
chromeService.closeTab(tab);
51+
launcher.close();
52+
});
53+
54+
// Enable network events.
55+
network.enable();
56+
57+
// Navigate to github.com.
58+
page.navigate("https://www.github.com");
59+
60+
devToolsService.waitUntilClosed();
61+
}
62+
}

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/ChromeDevTools.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/commands/Accessibility.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import com.github.kklisura.cdt.protocol.support.annotations.Experimental;
2424
import com.github.kklisura.cdt.protocol.support.annotations.Optional;
2525
import com.github.kklisura.cdt.protocol.support.annotations.ParamName;
26+
import com.github.kklisura.cdt.protocol.support.annotations.ReturnTypeParameter;
2627
import com.github.kklisura.cdt.protocol.support.annotations.Returns;
2728
import com.github.kklisura.cdt.protocol.types.accessibility.AXNode;
2829
import java.util.List;
@@ -35,6 +36,7 @@ public interface Accessibility {
3536
*/
3637
@Experimental
3738
@Returns("nodes")
39+
@ReturnTypeParameter(AXNode.class)
3840
List<AXNode> getPartialAXTree();
3941

4042
/**
@@ -49,6 +51,7 @@ public interface Accessibility {
4951
*/
5052
@Experimental
5153
@Returns("nodes")
54+
@ReturnTypeParameter(AXNode.class)
5255
List<AXNode> getPartialAXTree(
5356
@Optional @ParamName("nodeId") Integer nodeId,
5457
@Optional @ParamName("backendNodeId") Integer backendNodeId,

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/commands/Animation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/commands/ApplicationCache.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import com.github.kklisura.cdt.protocol.support.annotations.EventName;
2626
import com.github.kklisura.cdt.protocol.support.annotations.Experimental;
2727
import com.github.kklisura.cdt.protocol.support.annotations.ParamName;
28+
import com.github.kklisura.cdt.protocol.support.annotations.ReturnTypeParameter;
2829
import com.github.kklisura.cdt.protocol.support.annotations.Returns;
2930
import com.github.kklisura.cdt.protocol.support.types.EventHandler;
3031
import com.github.kklisura.cdt.protocol.support.types.EventListener;
@@ -52,6 +53,7 @@ public interface ApplicationCache {
5253
* associated with some application cache.
5354
*/
5455
@Returns("frameIds")
56+
@ReturnTypeParameter(FrameWithManifest.class)
5557
List<FrameWithManifest> getFramesWithManifests();
5658

5759
/**

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/commands/Audits.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/commands/Browser.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import com.github.kklisura.cdt.protocol.support.annotations.Experimental;
2424
import com.github.kklisura.cdt.protocol.support.annotations.Optional;
2525
import com.github.kklisura.cdt.protocol.support.annotations.ParamName;
26+
import com.github.kklisura.cdt.protocol.support.annotations.ReturnTypeParameter;
2627
import com.github.kklisura.cdt.protocol.support.annotations.Returns;
2728
import com.github.kklisura.cdt.protocol.types.browser.Bounds;
2829
import com.github.kklisura.cdt.protocol.types.browser.Histogram;
@@ -45,11 +46,13 @@ public interface Browser {
4546
*/
4647
@Experimental
4748
@Returns("arguments")
49+
@ReturnTypeParameter(String.class)
4850
List<String> getBrowserCommandLine();
4951

5052
/** Get Chrome histograms. */
5153
@Experimental
5254
@Returns("histograms")
55+
@ReturnTypeParameter(Histogram.class)
5356
List<Histogram> getHistograms();
5457

5558
/**
@@ -61,6 +64,7 @@ public interface Browser {
6164
*/
6265
@Experimental
6366
@Returns("histograms")
67+
@ReturnTypeParameter(Histogram.class)
6468
List<Histogram> getHistograms(
6569
@Optional @ParamName("query") String query, @Optional @ParamName("delta") Boolean delta);
6670

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/commands/CSS.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
2828
import com.github.kklisura.cdt.protocol.support.annotations.EventName;
2929
import com.github.kklisura.cdt.protocol.support.annotations.Experimental;
3030
import com.github.kklisura.cdt.protocol.support.annotations.ParamName;
31+
import com.github.kklisura.cdt.protocol.support.annotations.ReturnTypeParameter;
3132
import com.github.kklisura.cdt.protocol.support.annotations.Returns;
3233
import com.github.kklisura.cdt.protocol.support.types.EventHandler;
3334
import com.github.kklisura.cdt.protocol.support.types.EventListener;
@@ -77,6 +78,7 @@ CSSRule addRule(
7778
* @param styleSheetId
7879
*/
7980
@Returns("classNames")
81+
@ReturnTypeParameter(String.class)
8082
List<String> collectClassNames(@ParamName("styleSheetId") String styleSheetId);
8183

8284
/**
@@ -116,6 +118,7 @@ void forcePseudoState(
116118
* @param nodeId
117119
*/
118120
@Returns("computedStyle")
121+
@ReturnTypeParameter(CSSComputedStyleProperty.class)
119122
List<CSSComputedStyleProperty> getComputedStyleForNode(@ParamName("nodeId") Integer nodeId);
120123

121124
/**
@@ -135,6 +138,7 @@ void forcePseudoState(
135138

136139
/** Returns all media queries parsed by the rendering engine. */
137140
@Returns("medias")
141+
@ReturnTypeParameter(CSSMedia.class)
138142
List<CSSMedia> getMediaQueries();
139143

140144
/**
@@ -144,6 +148,7 @@ void forcePseudoState(
144148
* @param nodeId
145149
*/
146150
@Returns("fonts")
151+
@ReturnTypeParameter(PlatformFontUsage.class)
147152
List<PlatformFontUsage> getPlatformFontsForNode(@ParamName("nodeId") Integer nodeId);
148153

149154
/**
@@ -222,6 +227,7 @@ String setStyleSheetText(
222227
* @param edits
223228
*/
224229
@Returns("styles")
230+
@ReturnTypeParameter(CSSStyle.class)
225231
List<CSSStyle> setStyleTexts(@ParamName("edits") List<StyleDeclarationEdit> edits);
226232

227233
/** Enables the selector recording. */
@@ -232,13 +238,15 @@ String setStyleSheetText(
232238
* `takeCoverageDelta` (or since start of coverage instrumentation)
233239
*/
234240
@Returns("ruleUsage")
241+
@ReturnTypeParameter(RuleUsage.class)
235242
List<RuleUsage> stopRuleUsageTracking();
236243

237244
/**
238245
* Obtain list of rules that became used since last call to this method (or since start of
239246
* coverage instrumentation)
240247
*/
241248
@Returns("coverage")
249+
@ReturnTypeParameter(RuleUsage.class)
242250
List<RuleUsage> takeCoverageDelta();
243251

244252
/**

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/commands/CacheStorage.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
2222

2323
import com.github.kklisura.cdt.protocol.support.annotations.Experimental;
2424
import com.github.kklisura.cdt.protocol.support.annotations.ParamName;
25+
import com.github.kklisura.cdt.protocol.support.annotations.ReturnTypeParameter;
2526
import com.github.kklisura.cdt.protocol.support.annotations.Returns;
2627
import com.github.kklisura.cdt.protocol.types.cachestorage.Cache;
2728
import com.github.kklisura.cdt.protocol.types.cachestorage.CachedResponse;
@@ -52,6 +53,7 @@ public interface CacheStorage {
5253
* @param securityOrigin Security origin.
5354
*/
5455
@Returns("caches")
56+
@ReturnTypeParameter(Cache.class)
5557
List<Cache> requestCacheNames(@ParamName("securityOrigin") String securityOrigin);
5658

5759
/**

cdt-java-client/src/main/java/com/github/kklisura/cdt/protocol/commands/Console.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* #%L
55
* cdt-java-client
66
* %%
7-
* Copyright (C) 2018 Kenan Klisura
7+
* Copyright (C) 2018 - 2019 Kenan Klisura
88
* %%
99
* Licensed under the Apache License, Version 2.0 (the "License");
1010
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)