aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Rousse <guillomovitch@mageia.org>2012-05-23 23:00:10 +0000
committerGuillaume Rousse <guillomovitch@mageia.org>2012-05-23 23:00:10 +0000
commitb513778bb2d701236d9b42ac4e417599ac17fbfb (patch)
treefbb354c84cf544c8d041b73e7e17a8eebe73d99d
parentbdaab3440fdea542e31e0a65949a2192f4608afd (diff)
downloadperl-Parse-EDID-b513778bb2d701236d9b42ac4e417599ac17fbfb.tar
perl-Parse-EDID-b513778bb2d701236d9b42ac4e417599ac17fbfb.tar.gz
perl-Parse-EDID-b513778bb2d701236d9b42ac4e417599ac17fbfb.tar.bz2
perl-Parse-EDID-b513778bb2d701236d9b42ac4e417599ac17fbfb.tar.xz
perl-Parse-EDID-b513778bb2d701236d9b42ac4e417599ac17fbfb.zip
real usage tests
-rw-r--r--t/sample135
-rw-r--r--t/test.t154
2 files changed, 189 insertions, 0 deletions
diff --git a/t/sample1 b/t/sample1
new file mode 100644
index 0000000..3e0e193
--- /dev/null
+++ b/t/sample1
@@ -0,0 +1,35 @@
+Screen 0: minimum 320 x 200, current 1280 x 800, maximum 8192 x 8192
+LVDS1 connected 1280x800+0+0 (normal left inverted right x axis y axis) 261mm x 163mm
+ EDID:
+ 00ffffffffffff0006af14a100000000
+ 01120103901a10780a50c59858528e27
+ 25505400000001010101010101010101
+ 010101010101ea1a007e502010303020
+ 360005a31000001aea1a007e50201030
+ 3020360005a31000001a000000fe0059
+ 37343744804231323145573000000000
+ 00000000000000000001010a202000a5
+ BACKLIGHT: 4 (0x00000004) range: (0,15)
+ Backlight: 4 (0x00000004) range: (0,15)
+ scaling mode: Full aspect
+ supported: None Full Center Full aspect
+ 1280x800 60.1*+
+ 1024x768 60.0
+ 800x600 60.3 56.2
+ 640x480 59.9
+VGA1 disconnected (normal left inverted right x axis y axis)
+HDMI1 disconnected (normal left inverted right x axis y axis)
+ Broadcast RGB: Full
+ supported: Full Limited 16:2
+ audio: auto
+ supported: off auto on
+DP1 disconnected (normal left inverted right x axis y axis)
+ Broadcast RGB: Full
+ supported: Full Limited 16:2
+ audio: auto
+ supported: off auto on
+DP2 disconnected (normal left inverted right x axis y axis)
+ Broadcast RGB: Full
+ supported: Full Limited 16:2
+ audio: auto
+ supported: off auto on
diff --git a/t/test.t b/t/test.t
new file mode 100644
index 0000000..a7dd2a7
--- /dev/null
+++ b/t/test.t
@@ -0,0 +1,154 @@
+#!/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);
+}