Skip to content

Commit db95636

Browse files
Debug chart color tests
1 parent 0950221 commit db95636

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

t/mail/dashboard-jschart.t

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,55 @@ is( $imager->bits, 8, 'Image bit depth is 8' );
102102
# Here we test if each channel is in range
103103
my $bar_color = $imager->getpixel( x => 300, y => 200 );
104104

105+
# --- Temporary diagnostics for the chromium-rendering investigation ----------
106+
# The retest cycle is long, so gather everything in one run: image geometry,
107+
# PNG tags (gamma/color-profile), the color landscape around and across the
108+
# sampled point, and the raw PNG (base64) so the chart can be reconstructed.
109+
{
110+
my $px = sub { # "r/g/b" for a pixel, or "oob" if out of bounds
111+
my ( $x, $y ) = @_;
112+
my $p = $imager->getpixel( x => $x, y => $y );
113+
return defined $p ? sprintf( '%d/%d/%d', ( $p->rgba )[ 0, 1, 2 ] ) : 'oob';
114+
};
115+
116+
diag sprintf( 'Image: %dx%d channels=%d bits=%d type=%s',
117+
$imager->getwidth, $imager->getheight, $imager->getchannels,
118+
$imager->bits, $imager->type );
119+
120+
diag 'PNG tags:';
121+
for my $t ( $imager->tags ) {
122+
diag sprintf( ' %s = %s',
123+
$t->[0], defined $t->[1] ? $t->[1] : '(undef)' );
124+
}
125+
126+
diag sprintf( 'Sampled pixel (300,200): %s '
127+
. '(expected ~166/206/227; ranges red 150-180, green 190-220, blue 210-240)',
128+
$px->( 300, 200 ) );
129+
130+
# Neighborhood around the sample point.
131+
for my $y ( 180, 190, 200, 210, 220 ) {
132+
diag join ' ', "neighborhood y=$y:",
133+
map { "x=$_:" . $px->( $_, $y ) } ( 260, 280, 300, 320, 340 );
134+
}
135+
136+
# Horizontal scan across the middle row to locate the bars.
137+
for ( my $x = 0 ; $x < $imager->getwidth ; $x += 25 ) {
138+
diag sprintf( 'hscan y=200 x=%d: %s', $x, $px->( $x, 200 ) );
139+
}
140+
141+
# Vertical scan down x=300 to see the bar's height/position.
142+
for ( my $y = 0 ; $y < $imager->getheight ; $y += 25 ) {
143+
diag sprintf( 'vscan x=300 y=%d: %s', $y, $px->( 300, $y ) );
144+
}
145+
146+
# Raw PNG as a single base64 line between sentinels. To recover the image:
147+
# grep -o 'PNGB64 [A-Za-z0-9+/=]*' log | awk '{print $2}' | base64 -d > chart.png
148+
require MIME::Base64;
149+
diag 'PNGB64 '
150+
. MIME::Base64::encode_base64( $mail_image->bodyhandle->as_string, '' );
151+
}
152+
# -----------------------------------------------------------------------------
153+
105154
ok( $bar_color->red >= 150 && $bar_color->red <= 180, 'Image bar red channel is in range' );
106155
ok( $bar_color->green >= 190 && $bar_color->green <= 220, 'Image bar green channel is in range' );
107156
ok( $bar_color->blue >= 210 && $bar_color->blue <= 240, 'Image bar blue channel is in range' );

0 commit comments

Comments
 (0)