Switch mixed-up ScreenshotRequest parameters

They often happened to be the same number (e.g. in unit test), so we
missed that they were switched. Modified test to fail if they're
swapped.

Bug: 251438230
Test: atest RequestProcessorTest
Test: adb shell input keyevent SYSRQ (with screenshot processor and work
      profile flags enabled)
Change-Id: I0b4bc8e4007f0a78a033f9266f5189739f0a295d
This commit is contained in:
Matt Casey
2022-10-06 15:26:49 +00:00
parent f4ceebbadd
commit 9b2e5991ce
2 changed files with 3 additions and 2 deletions

View File

@@ -76,7 +76,7 @@ class RequestProcessor @Inject constructor(
)
} else {
// Create a new request of the same type which includes the top component
ScreenshotRequest(request.source, request.type, info.component)
ScreenshotRequest(request.type, request.source, info.component)
}
}

View File

@@ -99,13 +99,14 @@ class RequestProcessorTest {
policy.getDefaultDisplayId(),
DisplayContentInfo(component, bounds, UserHandle.of(USER_ID), TASK_ID))
val request = ScreenshotRequest(TAKE_SCREENSHOT_FULLSCREEN, SCREENSHOT_KEY_CHORD)
val request = ScreenshotRequest(TAKE_SCREENSHOT_FULLSCREEN, SCREENSHOT_OTHER)
val processor = RequestProcessor(imageCapture, policy, flags, scope)
val processedRequest = processor.process(request)
// Request has topComponent added, but otherwise unchanged.
assertThat(processedRequest.type).isEqualTo(TAKE_SCREENSHOT_FULLSCREEN)
assertThat(processedRequest.source).isEqualTo(SCREENSHOT_OTHER)
assertThat(processedRequest.topComponent).isEqualTo(component)
}