Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 120 lines (106 sloc) 3.633 kB
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in…
kthakore authored
1 #!/usr/bin/perl -w
2 use strict;
3 use SDL;
4
e6e146e @kthakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
5 BEGIN {
4979eb1 @jtpalmer perltidy
jtpalmer authored
6 use Test::More;
7 use lib 't/lib';
8 use SDL::TestTool;
b417e52 added tests for CD/CDROM/CDTrack
Tobias Leich authored
9
4979eb1 @jtpalmer perltidy
jtpalmer authored
10 plan( skip_all => 'Failed to init cdrom' )
11 unless SDL::TestTool->init(SDL_INIT_CDROM);
b417e52 added tests for CD/CDROM/CDTrack
Tobias Leich authored
12 }
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in…
kthakore authored
13
54b3c65 Constants exported by default now (again)
Tobias Leich authored
14 use SDL::CD;
b417e52 added tests for CD/CDROM/CDTrack
Tobias Leich authored
15 use SDL::CDROM;
54b3c65 Constants exported by default now (again)
Tobias Leich authored
16 use SDL::CDTrack;
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in…
kthakore authored
17
328ac18 fixed constants for cd
Tobias Leich authored
18 is( CD_ERROR, -1, 'CD_ERROR should be imported' );
19 is( CD_ERROR(), -1, 'CD_ERROR() should also be available' );
20 is( CD_PAUSED, 3, 'CD_PAUSED should be imported' );
21 is( CD_PAUSED(), 3, 'CD_PAUSED() should also be available' );
22 is( CD_PLAYING, 2, 'CD_PLAYING should be imported' );
23 is( CD_PLAYING(), 2, 'CD_PLAYING() should also be available' );
24 is( CD_STOPPED, 1, 'CD_STOPPED should be imported' );
25 is( CD_STOPPED(), 1, 'CD_STOPPED() should also be available' );
26 is( CD_TRAYEMPTY, 0, 'CD_TRAYEMPTY should be imported' );
27 is( CD_TRAYEMPTY(), 0, 'CD_TRAYEMPTY() should also be available' );
28
e6e146e @kthakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
29 is( SDL_AUDIO_TRACK, 0, 'SDL_AUDIO_TRACK should be imported' );
30 is( SDL_AUDIO_TRACK(), 0, 'SDL_AUDIO_TRACK() should also be available' );
31 is( SDL_DATA_TRACK, 4, 'SDL_DATA_TRACK should be imported' );
32 is( SDL_DATA_TRACK(), 4, 'SDL_DATA_TRACK() should also be available' );
328ac18 fixed constants for cd
Tobias Leich authored
33
b417e52 added tests for CD/CDROM/CDTrack
Tobias Leich authored
34 my $num_drives = SDL::CDROM::num_drives();
35 ok( $num_drives >= 0, "[SDL::CDROM::num_drives] is $num_drives" );
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in…
kthakore authored
36
b417e52 added tests for CD/CDROM/CDTrack
Tobias Leich authored
37 SKIP:
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in…
kthakore authored
38 {
4979eb1 @jtpalmer perltidy
jtpalmer authored
39 skip( "no drives available or SDL_RELEASE_TESTING not set", 17 )
40 if $num_drives <= 0 || !$ENV{SDL_RELEASE_TESTING};
41 for ( 0 .. $num_drives - 1 ) {
42 my $name = SDL::CDROM::name($_);
43 ok( $name, "[SDL::CDROM::name] for drive $_ is $name" );
44 }
45 my $cd = SDL::CD->new(0);
46 isa_ok( $cd, 'SDL::CD', "[SDL::CD->new]" );
47 my $status = $cd->status();
48 my %states = (
49 -1 => 'CD_ERROR',
50 0 => 'CD_TRAYEMPTY',
51 1 => 'CD_STOPPED',
52 2 => 'CD_PLAYING',
53 3 => 'CD_PAUSED'
54 );
55 my %types = (
56 0 => 'SDL_AUDIO_TRACK',
57 1 => 'SDL_DATA_TRACK'
58 );
59 ok( defined $states{$status},
60 "[SDL::CD->status] is " . ( defined $states{$status} ? $states{$status} : 'undefined' )
61 );
62 SKIP:
63 {
64 skip( "CD should be in CD_STOPPED state", 14 )
65 unless $status == CD_STOPPED;
66 my $track = $cd->track(3);
67 isa_ok( $track, 'SDL::CDTrack', "[SDL::CD->track]" );
68 my $id = $cd->id();
69 ok( $id >= 0, "[SDL::CD->id] is $id" );
70 my $num_tracks = $cd->num_tracks();
71 ok( $num_tracks >= 0, "[SDL::CD->num_tracks] is $num_tracks" );
e6e146e @kthakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
72
4979eb1 @jtpalmer perltidy
jtpalmer authored
73 is( $cd->play_tracks( 4, 0, 5, 0 ),
74 0, "[SDL::CD->play_tracks] playing track 4"
75 );
76 SDL::delay(2000);
77 is( $cd->pause(), 0, "[SDL::CD->pause] succeeded" );
78 SDL::delay(2000);
79 SKIP:
80 {
81 skip( "I have no idea why cur_track and cur_frame are 0.", 2 );
82 is( $cd->cur_track(), 4, "[SDL::CD->cur_track] is 4" );
83 my $frame = $cd->cur_frame();
84 ok( $frame, "[SDL::CD->cur_frame] is $frame" );
85 }
e6e146e @kthakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
86
4979eb1 @jtpalmer perltidy
jtpalmer authored
87 my $t_id = $track->id();
88 ok( $t_id, "[SDL::CDTrack->id] is $t_id" );
89 my $t_type = $track->type();
90 ok( defined $types{$t_type},
91 "[SDL::CDTrack->type] is " . ( defined $types{$t_type} ? $types{$t_type} : 'undefined' )
92 );
93 my $t_length = $track->length();
94 ok( $t_length > 0, "[SDL::CDTrack->length] is $t_length" );
95 my $t_offset = $track->offset();
96 ok( $t_offset > 0, "[SDL::CDTrack->offset] is $t_offset" );
e6e146e @kthakore Did perl tidy. Stole rc from padre. bricas++
kthakore authored
97
4979eb1 @jtpalmer perltidy
jtpalmer authored
98 is( $cd->resume(), 0, "[SDL::CD->resume] succeeded" );
99 SDL::delay(2000);
100 is( $cd->stop(), 0, "[SDL::CD->stop] succeeded" );
101 SDL::delay(2000);
102 is( $cd->play( CD_FPS * 30, CD_FPS * 2 ),
103 0, "[SDL::CD->play] succeeded"
104 );
105 SDL::delay(2000);
106 }
107 SKIP:
108 {
109 skip( "CD should be in CD_STOPPED or CD_TRAYEMPTY state", 1 )
110 unless $status == CD_STOPPED || $status == CD_TRAYEMPTY;
443a88b @kthakore We need at least 1 cdrom to test and can eject when the tray is empty
kthakore authored
111
4979eb1 @jtpalmer perltidy
jtpalmer authored
112 is( $cd->eject(), 0, "[SDL::CD->eject] succeeded" )
113 unless SDL::delay(2000);
114 }
ba85b2c @kthakore Added todo tests for remaining components of SDL. Removed WM build in…
kthakore authored
115 }
116
117 done_testing;
b417e52 added tests for CD/CDROM/CDTrack
Tobias Leich authored
118
119 sleep(1);
Something went wrong with that request. Please try again.