haikuwebkit/LayoutTests/resources/platform-helper.js

49 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

function isGtk()
{
[GTK] media/muted-video-is-playing-audio.html is timing out https://bugs.webkit.org/show_bug.cgi?id=208321 Reviewed by Xabier Rodriguez-Calvar. Source/WebCore: Added setPageMediaVolume() API to set the Page mediaVolume. This was 0 by default and a way to set it to a non-zero value was needed in order to prevent a zero effectiveVolume in HTMLMediaElement. * testing/Internals.cpp: (WebCore::Internals::setPageMediaVolume): Set the Page mediaVolume. * testing/Internals.h: Added setPageMediaVolume(). * testing/Internals.idl: Ditto. Tools: Set the WebKitTestRunnerWPE application name on user-agent to ease the detection of the WPE port from the layout tests using the isWPE() function in platform-helper.js. * WebKitTestRunner/wpe/TestControllerWPE.cpp: (WTR::TestController::platformConfigureViewForTest): Set WebKitTestRunnerWPE application name on user-agent. LayoutTests: Changed the test to set a non-zero mediaVolume, because a zero one (default value set by TestController::resetStateToConsistentValues()) would multiply any other volume in HTMLMediaElement::effectiveVolume(), cause a zero effectiveVolume (being considered in practice as "no audio" by HTMLMediaElement::mediaState()) and prevent the IsPlayingAudio MediaState being set. Also, adapted the test to still expect IsPlayingAudio after mute on the glib ports (GTK & WPE), since on those ports a muted video is expected to report IsPlayingAudio, as per the HTMLMediaElement::mediaState() source code comments. * media/muted-video-is-playing-audio.html: Test changed as described above. * platform/glib/media/muted-video-is-playing-audio-expected.txt: Added expectation for glib port. * resources/platform-helper.js: (isGtk): Clarified where the GTK user-agent string comes from. (isWPE): New function to check if a WPE port is being used. Canonical link: https://commits.webkit.org/239103@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-24 09:31:16 +00:00
// Set in Tools/WebKitTestRunner/gtk/TestControllerGTK.cpp.
return navigator.userAgent.includes("WebKitTestRunnerGTK");
}
[GTK] media/muted-video-is-playing-audio.html is timing out https://bugs.webkit.org/show_bug.cgi?id=208321 Reviewed by Xabier Rodriguez-Calvar. Source/WebCore: Added setPageMediaVolume() API to set the Page mediaVolume. This was 0 by default and a way to set it to a non-zero value was needed in order to prevent a zero effectiveVolume in HTMLMediaElement. * testing/Internals.cpp: (WebCore::Internals::setPageMediaVolume): Set the Page mediaVolume. * testing/Internals.h: Added setPageMediaVolume(). * testing/Internals.idl: Ditto. Tools: Set the WebKitTestRunnerWPE application name on user-agent to ease the detection of the WPE port from the layout tests using the isWPE() function in platform-helper.js. * WebKitTestRunner/wpe/TestControllerWPE.cpp: (WTR::TestController::platformConfigureViewForTest): Set WebKitTestRunnerWPE application name on user-agent. LayoutTests: Changed the test to set a non-zero mediaVolume, because a zero one (default value set by TestController::resetStateToConsistentValues()) would multiply any other volume in HTMLMediaElement::effectiveVolume(), cause a zero effectiveVolume (being considered in practice as "no audio" by HTMLMediaElement::mediaState()) and prevent the IsPlayingAudio MediaState being set. Also, adapted the test to still expect IsPlayingAudio after mute on the glib ports (GTK & WPE), since on those ports a muted video is expected to report IsPlayingAudio, as per the HTMLMediaElement::mediaState() source code comments. * media/muted-video-is-playing-audio.html: Test changed as described above. * platform/glib/media/muted-video-is-playing-audio-expected.txt: Added expectation for glib port. * resources/platform-helper.js: (isGtk): Clarified where the GTK user-agent string comes from. (isWPE): New function to check if a WPE port is being used. Canonical link: https://commits.webkit.org/239103@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@279217 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-24 09:31:16 +00:00
function isWPE()
{
// Set in Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp.
return navigator.userAgent.includes("WebKitTestRunnerWPE");
}
function videoCanvasPixelComparisonTolerance()
{
[WebRTC][GStreamer] fast/mediastream/resize-trim.html is failing https://bugs.webkit.org/show_bug.cgi?id=192888 Patch by Philippe Normand <pnormand@igalia.com> on 2021-05-04 Reviewed by Xabier Rodriguez-Calvar. Source/WebCore: The test was failing because the GStreamer mock video source was producing garbled frames and the pixel test in the canvas was failing to detect gray. The frame was garbled because the test asked "exact" video width that was inferior to the capture video width and we were not taking this into account when creating a MediaSample from the video frame. MediaSampleGStreamer::createImageSample() can now optionally resize the video frame according to the destinationSize, if it was specified. * html/HTMLCanvasElement.cpp: (WebCore::HTMLCanvasElement::toMediaSample): * platform/graphics/gstreamer/MediaSampleGStreamer.cpp: (WebCore::MediaSampleGStreamer::createImageSample): * platform/graphics/gstreamer/MediaSampleGStreamer.h: (WebCore::MediaSampleGStreamer::createImageSample): * platform/mediastream/gstreamer/MockRealtimeVideoSourceGStreamer.cpp: (WebCore::MockRealtimeVideoSourceGStreamer::updateSampleBuffer): * platform/mock/MockRealtimeVideoSource.h: LayoutTests: * platform/glib/TestExpectations: Unflag test. * resources/platform-helper.js: Remove EFL cruft. (videoCanvasPixelComparisonTolerance): (isEfl): Deleted. Canonical link: https://commits.webkit.org/237286@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-04 11:13:37 +00:00
if (isGtk())
return 6;
return 2;
}
function checkPixelColorWithTolerance(pixel, r, g, b, a)
{
const tolerance = videoCanvasPixelComparisonTolerance();
return Math.abs(pixel[0] - r) <= tolerance
&& Math.abs(pixel[1] - g) <= tolerance
&& Math.abs(pixel[2] - b) <= tolerance
&& Math.abs(pixel[3] - a) <= tolerance;
}
function isPixelBlack(pixel)
{
return checkPixelColorWithTolerance(pixel, 0, 0, 0, 255);
}
function isPixelTransparent(pixel)
{
return checkPixelColorWithTolerance(pixel, 0, 0, 0, 0);
}
function isPixelWhite(pixel)
{
return checkPixelColorWithTolerance(pixel, 255, 255, 255, 255);
}
function isPixelGray(pixel)
{
return checkPixelColorWithTolerance(pixel, 128, 128, 128, 255);
}