Skip to content

Commit 7021679

Browse files
ASPS002Ujjwal Srivastava
andauthored
Stop calls to addGifFrameAsyncDelay to prevent collection of screenshots (#688)
<!-- Please provide brief information about the PR, what it contains & its purpose, new behaviours after the change. And let us know here if you need any help: https://github.com/microsoft/HydraLab/issues/new --> ## Description This Pull request makes use of `disableGifEncoder ` to avoid calls to `addGifFrameAsyncDelay` to completely prevent any capture of Screenshots. It disables the collection of screenshots during the test runs when `disableGifEncoder ` is set to true. ### Linked GitHub issue ID: # ## Pull Request Checklist <!-- Put an x in the boxes that apply. This is simply a reminder of what we are going to look for before merging your code. --> - [ ] Tests for the changes have been added (for bug fixes / features) - [x] Code compiles correctly with all tests are passed. - [x] I've read the [contributing guide](https://github.com/microsoft/HydraLab/blob/main/CONTRIBUTING.md#making-changes-to-the-code) and followed the recommended practices. - [ ] [Wikis](https://github.com/microsoft/HydraLab/wiki) or [README](https://github.com/microsoft/HydraLab/blob/main/README.md) have been reviewed and added / updated if needed (for bug fixes / features) ### Does this introduce a breaking change? *If this introduces a breaking change for Hydra Lab users, please describe the impact and migration path.* - [ ] Yes - [x] No ## How you tested it *Please make sure the change is tested, you can test it by adding UTs, do local test and share the screenshots, etc.* Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Technical design - [ ] Build related changes - [ ] Refactoring (no functional changes, no api changes) - [ ] Code style update (formatting, renaming) or Documentation content changes - [ ] Other (please describe): ### Feature UI screenshots or Technical design diagrams *If this is a relatively large or complex change, kick it off by drawing the tech design with PlantUML and explaining why you chose the solution you did and what alternatives you considered, etc...* --------- Co-authored-by: Ujjwal Srivastava <ujsrivastava@Mac.lan>
1 parent 35c3027 commit 7021679

14 files changed

Lines changed: 72 additions & 30 deletions

File tree

agent/src/main/java/com/microsoft/hydralab/agent/runner/TestRunner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ public void setup(TestTask testTask, TestRun testRun) throws Exception {
261261
testRunDeviceOrchestrator.grantAllTaskNeededPermissions(testRunDevice, testTask, testRun.getLogger());
262262

263263
checkTestTaskCancel(testTask);
264-
testRunDeviceOrchestrator.getScreenShot(testRunDevice, agentManagementService.getScreenshotDir(), testRun.getLogger());
264+
if (!testTask.isDisableGifEncoder()) {
265+
testRunDeviceOrchestrator.getScreenShot(testRunDevice, agentManagementService.getScreenshotDir(), testRun.getLogger());
266+
}
265267

266268
if (performanceTestManagementService != null && testTask.getInspectionStrategies() != null) {
267269
for (InspectionStrategy strategy : testTask.getInspectionStrategies()) {

agent/src/main/java/com/microsoft/hydralab/agent/runner/appium/AppiumListener.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ public void testStarted(Description description) {
129129

130130
testRun.addNewTestUnit(ongoingTestUnit);
131131

132-
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
132+
if (!testTask.isDisableGifEncoder()) {
133+
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
134+
}
133135
performanceTestListener.testStarted(ongoingTestUnit.getTitle());
134136
}
135137

agent/src/main/java/com/microsoft/hydralab/agent/runner/appium/AppiumRunner.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ protected File runAndGetGif(File appiumJarFile, String appiumCommand, TestRunDev
110110
checkTestTaskCancel(testTask);
111111
startJunit5(appiumJarFile, appiumCommand, junit5Listener, reportLogger);
112112
checkTestTaskCancel(testTask);
113-
gifFile = junit5Listener.getGifFile();
113+
if (!testTask.isDisableGifEncoder()) {
114+
gifFile = junit5Listener.getGifFile();
115+
}
114116
} else {
115117
/** xml report: parse listener */
116118
reportLogger.info("Start init listener");
@@ -124,7 +126,9 @@ protected File runAndGetGif(File appiumJarFile, String appiumCommand, TestRunDev
124126
checkTestTaskCancel(testTask);
125127
startJunit(appiumJarFile, appiumCommand, listener, reportLogger);
126128
checkTestTaskCancel(testTask);
127-
gifFile = listener.getGifFile();
129+
if (!testTask.isDisableGifEncoder()) {
130+
gifFile = listener.getGifFile();
131+
}
128132
}
129133
/** set paths */
130134
String absoluteReportPath = deviceTestResultFolder.getAbsolutePath();

agent/src/main/java/com/microsoft/hydralab/agent/runner/appium/Junit5Listener.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ public void executionStarted(TestIdentifier testIdentifier) {
191191

192192
testRun.addNewTestUnit(ongoingTestUnit);
193193

194-
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
194+
if (!testTask.isDisableGifEncoder()) {
195+
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
196+
}
195197

196198
performanceTestListener.testStarted(ongoingTestUnit.getTitle());
197199
}

agent/src/main/java/com/microsoft/hydralab/agent/runner/espresso/EspressoRunner.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ public void processNewLines(@NotNull String[] lines) {
110110
String absoluteReportPath = listener.getAbsoluteReportPath();
111111
testRun.setTestXmlReportPath(
112112
agentManagementService.getTestBaseRelPathInUrl(new File(absoluteReportPath)));
113-
File gifFile = listener.getGifFile();
114-
if (gifFile.exists() && gifFile.length() > 0) {
115-
testRun.setTestGifPath(agentManagementService.getTestBaseRelPathInUrl(gifFile));
113+
114+
if (!testTask.isDisableGifEncoder()) {
115+
File gifFile = listener.getGifFile();
116+
if (gifFile.exists() && gifFile.length() > 0) {
117+
testRun.setTestGifPath(agentManagementService.getTestBaseRelPathInUrl(gifFile));
118+
}
116119
}
117120

118121
} finally {

agent/src/main/java/com/microsoft/hydralab/agent/runner/espresso/EspressoTestInfoProcessorListener.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ public void testStarted(TestIdentifier test) {
153153

154154
testRun.addNewTestUnit(ongoingTestUnit);
155155

156-
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
156+
if (!testTask.isDisableGifEncoder()) {
157+
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
158+
}
157159

158160
performanceTestListener.testStarted(ongoingTestUnit.getTitle());
159161
}

agent/src/main/java/com/microsoft/hydralab/agent/runner/maestro/MaestroListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public void testRunStarted() {
5656
testRunDeviceOrchestrator.setRunningTestName(testRunDevice, "MaestroTest.testRunStarted");
5757
performanceTestListener.testRunStarted();
5858
performanceTestListener.testStarted("MaestroTestCase" + index);
59-
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
59+
if (!testTask.isDisableGifEncoder()) {
60+
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
61+
}
6062
}
6163

6264
private void initUnitCase(String caseName, int testSeconds) {
@@ -75,7 +77,9 @@ private void initUnitCase(String caseName, int testSeconds) {
7577
testRun.addNewTimeTag(unitIndex + ". " + ongoingTestUnit.getTitle(),
7678
System.currentTimeMillis() - testSeconds * 1000 - recordingStartTimeMillis);
7779
testRunDeviceOrchestrator.setRunningTestName(testRunDevice, ongoingTestUnit.getTitle());
78-
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
80+
if (!testTask.isDisableGifEncoder()) {
81+
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
82+
}
7983
performanceTestListener.testStarted("MaestroTestCase" + index);
8084
}
8185

agent/src/main/java/com/microsoft/hydralab/agent/runner/maestro/MaestroRunner.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ protected void run(TestRunDevice testRunDevice, TestTask testTask, TestRun testR
7171
/* set paths */
7272
testRun.setTestXmlReportPath(
7373
agentManagementService.getTestBaseRelPathInUrl(xmlFile));
74-
File gifFile = maestroListener.getGifFile();
75-
if (gifFile.exists() && gifFile.length() > 0) {
76-
testRun.setTestGifPath(agentManagementService.getTestBaseRelPathInUrl(gifFile));
74+
if (!testTask.isDisableGifEncoder()) {
75+
File gifFile = maestroListener.getGifFile();
76+
if (gifFile.exists() && gifFile.length() > 0) {
77+
testRun.setTestGifPath(agentManagementService.getTestBaseRelPathInUrl(gifFile));
78+
}
7779
}
7880
} catch (Exception e) {
7981
logger.error("Maestro test failed", e);

agent/src/main/java/com/microsoft/hydralab/agent/runner/monkey/AdbMonkeyRunner.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ protected void run(TestRunDevice testRunDevice, TestTask testTask, TestRun testR
8080
/* set paths */
8181
String absoluteReportPath = testRun.getResultFolder().getAbsolutePath();
8282
testRun.setTestXmlReportPath(agentManagementService.getTestBaseRelPathInUrl(new File(absoluteReportPath)));
83-
File gifFile = testRunDevice.getGifFile();
84-
if (gifFile.exists() && gifFile.length() > 0) {
85-
testRun.setTestGifPath(agentManagementService.getTestBaseRelPathInUrl(gifFile));
83+
if (!testTask.isDisableGifEncoder()) {
84+
File gifFile = testRunDevice.getGifFile();
85+
if (gifFile.exists() && gifFile.length() > 0) {
86+
testRun.setTestGifPath(agentManagementService.getTestBaseRelPathInUrl(gifFile));
87+
}
8688
}
8789

8890
}
@@ -124,7 +126,9 @@ public long runMonkeyTestOnce(TestRunDevice testRunDevice, TestTask testTask, Te
124126
testRun.addNewTestUnit(ongoingMonkeyTest);
125127

126128
logger.info(ongoingMonkeyTest.getTitle());
127-
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 2, logger);
129+
if (!testTask.isDisableGifEncoder()) {
130+
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 2, logger);
131+
}
128132
//run monkey test
129133
testRun.addNewTimeTag(unitIndex + ". " + ongoingMonkeyTest.getTitle(),
130134
System.currentTimeMillis() - testRun.getTestStartTimeMillis());

agent/src/main/java/com/microsoft/hydralab/agent/runner/monkey/AppiumMonkeyRunner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ protected File runAndGetGif(File appiumJarFile, String appiumCommand, TestRunDev
7272
testRun.addNewTimeTag(1 + ". " + ongoingMonkeyTest.getTitle(),
7373
System.currentTimeMillis() - recordingStartTimeMillis);
7474
testRunDeviceOrchestrator.setRunningTestName(testRunDevice, ongoingMonkeyTest.getTitle());
75-
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
75+
if (!testTask.isDisableGifEncoder()) {
76+
testRunDeviceOrchestrator.addGifFrameAsyncDelay(testRunDevice, agentManagementService.getScreenshotDir(), 5, logger);
77+
}
7678
testRun.setTestStartTimeMillis(System.currentTimeMillis());
7779

7880
performanceTestManagementService.testStarted(ongoingMonkeyTest.getTitle());

0 commit comments

Comments
 (0)