#!/usr/bin/perl use strict; use warnings; use English qw(-no_match_vars); use Test::More; # each value is an arrayref with 3 elements, indexed by file name: # - expected output from find_edid_in_string function # - expected output from parse_edid function # - expected output from check_parsed_edid function my %tests = ( sample1 => [ [ binary('00ffffffffffff0006af14a10000000001120103901a10780a50c59858528e2725505400000001010101010101010101010101010101ea1a007e502010303020360005a31000001aea1a007e502010303020360005a31000001a000000fe00593734374480423132314557300000000000000000000000000001010a202000a5') ], { 'serial_number' => 0, 'ratio_precision' => 'mm', 'feature_support' => { 'GTF_compliance' => 0, 'sRGB_compliance' => 0, 'rgb' => 0, 'DPMS_suspend' => 0, 'has_preferred_timing' => 1, 'DPMS_active_off' => 0, 'DPMS_standby' => 0 }, 'checksum' => 165, 'video_input_definition' => { 'voltage_level' => 0, 'digital' => 1, 'composite_sync' => 0, 'separate_sync' => 0, 'sync_on_green' => 1 }, 'established_timings' => [], 'max_size_precision' => 'mm', 'product_code' => 41236, 'ratio' => '1.60122699386503', 'standard_timings' => [], 'monitor_details' => '', 'week' => 1, 'monitor_text' => [ "Y747D\x80B121EW0" ], 'detailed_timings' => [ { 'vertical_dpi' => '124.662576687117', 'vertical_sync_offset' => 3, 'pixel_clock' => '68.9', 'horizontal_border' => 0, 'stereo' => 0, 'interlaced' => 0, 'horizontal_blanking' => 126, 'digital_composite' => 3, 'vertical_sync_pulse_width' => 6, 'horizontal_active' => 1280, 'vertical_sync_positive' => 1, 'horizontal_sync_pulse_width' => 32, 'horizontal_dpi' => '124.567049808429', 'horizontal_sync_positive' => 0, 'vertical_border' => 0, 'preferred' => 1, 'horizontal_sync_offset' => 48, 'ModeLine' => '"1280x800" 68.9 1280 1328 1360 1406 800 803 809 816 -hsync +vsync', 'vertical_image_size' => 163, 'horizontal_image_size' => 261, 'ModeLine_comment' => '# Monitor preferred modeline (60.1 Hz vsync, 49.0 kHz hsync, ratio 16/10, 124 dpi)', 'vertical_blanking' => 16, 'vertical_active' => 800 }, { 'vertical_dpi' => '124.662576687117', 'vertical_sync_offset' => 3, 'pixel_clock' => '68.9', 'horizontal_border' => 0, 'stereo' => 0, 'interlaced' => 0, 'horizontal_blanking' => 126, 'digital_composite' => 3, 'vertical_sync_pulse_width' => 6, 'horizontal_active' => 1280, 'vertical_sync_positive' => 1, 'horizontal_sync_pulse_width' => 32, 'horizontal_dpi' => '124.567049808429', 'horizontal_sync_positive' => 0, 'vertical_border' => 0, 'horizontal_sync_offset' => 48, 'ModeLine' => '"1280x800" 68.9 1280 1328 1360 1406 800 803 809 816 -hsync +vsync', 'vertical_image_size' => 163, 'horizontal_image_size' => 261, 'ModeLine_comment' => '# Monitor supported modeline (60.1 Hz vsync, 49.0 kHz hsync, ratio 16/10, 124 dpi)', 'vertical_blanking' => 16, 'vertical_active' => 800 } ], 'extension_flag' => 0, 'gamma' => 120, 'diagonal_size' => '12.1148583788498', 'ratio_name' => '16/10', 'edid_revision' => 3, 'EISA_ID' => 'AUOa114', 'max_size_horizontal' => '26.1', 'max_size_vertical' => '16.3', 'edid_version' => 1, 'year' => 2008, 'manufacturer_name' => 'AUO' }, '' ] ); plan tests => 1 + (3 * scalar keys %tests); use_ok('Parse::EDID'); foreach my $test (keys %tests) { my $string = read_file("t/$test"); my @edids = find_edid_in_string($string); is_deeply( \@edids, $tests{$test}->[0], "$test: edid extraction" ); my $edid = parse_edid($edids[0]); is_deeply( $edid, $tests{$test}->[1], "$test: edid parsing" ); my $message = check_parsed_edid($edid); is( $message, $tests{$test}->[2], "$test: edid checking" ); } sub read_file { my ($file) = @_; local $RS; open (my $handle, '<', $file) or die "Can't open $file: $ERRNO"; my $content = <$handle>; close $handle; return $content; } sub binary { my ($string) = @_; return pack("C*", map { hex($_) } $string =~ /(..)/g); }