AutoTest: Re-use established code

Instead of "parsing", modifying and highlighting the text
after it has been added use existing code to get formatted
code beforehand.

Change-Id: I33be2950f9b9a6910ad80b10b132089f4e5f0b1c
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2019-11-14 14:11:34 +01:00
parent c893fdffb6
commit f188622704
9 changed files with 59 additions and 241 deletions

View File

@@ -573,7 +573,7 @@ QList<int> StyleHelper::availableImageResolutions(const QString &fileName)
return result;
}
static double luminance(const QColor &color)
double StyleHelper::luminance(const QColor &color)
{
// calculate the luminance based on
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
@@ -595,7 +595,7 @@ static double contrastRatio(const QColor &color1, const QColor &color2)
{
// calculate the contrast ratio based on
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef
auto contrast = (luminance(color1) + 0.05) / (luminance(color2) + 0.05);
auto contrast = (StyleHelper::luminance(color1) + .05) / (StyleHelper::luminance(color2) + .05);
if (contrast < 1)
return 1 / contrast;
return contrast;