diff options
author | Ralf Ertzinger <rockbox@camperquake.de> | 2013-06-22 10:08:23 +0100 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2013-11-10 18:41:24 +0100 |
commit | b170c73f922e3457b923b4e7fcbec794a8885c77 (patch) | |
tree | 89fbdbd8c25af5101a29a1ede3b896332a4e205c /tools/iap/device-ipod.t | |
parent | 500b137308a6ee5c2aba873734a8956d70472f56 (diff) | |
download | rockbox-b170c73f922e3457b923b4e7fcbec794a8885c77.tar.gz rockbox-b170c73f922e3457b923b4e7fcbec794a8885c77.zip |
Updated IAP commands.
Originally written and uploaded by Lalufu (Ralf Ertzinger) in Feb 2012.
They have been condensed into a single patch and some further additions
by Andy Potter.
Currently includes Authentication V2 support from iPod to Accessory,
RF/BlueTooth transmitter support, selecting a playlist and selecting a
track from the current playlist. Does not support uploading Album Art
or podcasts. Has been tested on the following iPods,
4th Gen Grayscale, 4th Gen Color/Photo, Mini 2nd Gen, Nano 1st Gen and
Video 5.5Gen.
Change-Id: Ie8fc098361844132f0228ecbe3c48da948726f5e
Co-Authored by: Andy Potter <liveboxandy@gmail.com>
Reviewed-on: http://gerrit.rockbox.org/533
Reviewed-by: Frank Gevaerts <frank@gevaerts.be>
Diffstat (limited to 'tools/iap/device-ipod.t')
-rw-r--r-- | tools/iap/device-ipod.t | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tools/iap/device-ipod.t b/tools/iap/device-ipod.t new file mode 100644 index 0000000000..607184e331 --- /dev/null +++ b/tools/iap/device-ipod.t | |||
@@ -0,0 +1,74 @@ | |||
1 | use Test::More qw( no_plan ); | ||
2 | use strict; | ||
3 | |||
4 | BEGIN { use_ok('Device::iPod'); } | ||
5 | require_ok('Device::iPod'); | ||
6 | |||
7 | my $ipod = Device::iPod->new(); | ||
8 | my $m; | ||
9 | my ($l, $c, $p); | ||
10 | |||
11 | isa_ok($ipod, 'Device::iPod'); | ||
12 | |||
13 | # Frame a short command | ||
14 | $m = $ipod->_frame_cmd("\x00\x02\x00\x06"); | ||
15 | ok(defined($m) && ($m eq "\xFF\x55\x04\x00\x02\x00\x06\xF4"), "Framed command valid"); | ||
16 | |||
17 | # Frame a long command | ||
18 | $m = $ipod->_frame_cmd("\x00" x 1024); | ||
19 | ok(defined($m) && ($m eq "\xFF\x55\x00\x04\x00" . ("\x00" x 1024) . "\xFC"), "Long framed command valid"); | ||
20 | |||
21 | # Frame an overly long command | ||
22 | $m = $ipod->_frame_cmd("\x00" x 65537); | ||
23 | ok(!defined($m) && ($ipod->error() =~ 'Command too long'), "Overly long command failed"); | ||
24 | |||
25 | # Unframe a short command | ||
26 | ($l, $c, $p) = $ipod->_unframe_cmd("\xFF\x55\x04\x00\x02\x00\x06\xF4"); | ||
27 | ok(defined($l) && ($l == 0x00) && ($c == 0x02) && ($p eq "\x00\x06"), "Unframed short command"); | ||
28 | |||
29 | # Unframe a long command | ||
30 | ($l, $c, $p) = $ipod->_unframe_cmd("\xFF\x55\x00\x04\x00" . ("\x00" x 1024) . "\xFC"); | ||
31 | ok(defined($l) && ($l == 0x00) && ($c == 0x00) && ($p eq "\x00" x 1022), "Unframed long command"); | ||
32 | |||
33 | # Frame without sync byte | ||
34 | ($l, $c, $p) = $ipod->_unframe_cmd("\x00"); | ||
35 | ok(!defined($l) && ($ipod->error() =~ /Could not unframe data/), "Frame without sync byte failed"); | ||
36 | |||
37 | # Frame without SOP byte | ||
38 | ($l, $c, $p) = $ipod->_unframe_cmd("\xFF"); | ||
39 | ok(!defined($l) && ($ipod->error() =~ /Could not unframe data/), "Frame without SOP byte failed"); | ||
40 | |||
41 | # Frame with length 0 | ||
42 | ($l, $c, $p) = $ipod->_unframe_cmd("\xFF\x55\x00\x00\x00"); | ||
43 | ok(!defined($l) && ($ipod->error() =~ /Length is 0/), "Frame with length 0 failed"); | ||
44 | |||
45 | # Too short frame | ||
46 | ($l, $c, $p) = $ipod->_unframe_cmd("\xFF\x55\x03\x00\x00"); | ||
47 | ok(!defined($l) && ($ipod->error() =~ /Could not unframe data/), "Too short frame failed"); | ||
48 | |||
49 | # Invalid checksum | ||
50 | ($l, $c, $p) = $ipod->_unframe_cmd("\xFF\x55\x03\x00\x00\x00\x00"); | ||
51 | ok(!defined($l) && ($ipod->error() =~ /Invalid checksum/), "Invalid checksum failed"); | ||
52 | |||
53 | # Find a message in a string | ||
54 | $ipod->{-inbuf} = "\x00\xFF\x55\x00\xFF\xFF\xFF\x55\x04\x00\x02\x00\x06\xF4"; | ||
55 | ($c, $l) = $ipod->_message_in_buffer(); | ||
56 | ok(defined($l) && ($c == 6) && ($l == 8), "Found message in buffer"); | ||
57 | |||
58 | # Return message from a string | ||
59 | $ipod->{-inbuf} = "\x00\xFF\x55\x00\xFF\xFF\xFF\x55\x04\x00\x02\x00\x06\xF4\x00"; | ||
60 | $m = $ipod->_message(); | ||
61 | ok(defined($m) && ($ipod->{-inbuf} eq "\x00"), "Retrieved message from buffer"); | ||
62 | |||
63 | # Return two messages from buffer | ||
64 | $ipod->{-inbuf} = "\xffU\x04\x00\x02\x00\x13\xe7\xffU\x02\x00\x14\xea"; | ||
65 | $m = $ipod->_message(); | ||
66 | subtest "First message" => sub { | ||
67 | ok(defined($m), "Message received"); | ||
68 | is($m, "\xffU\x04\x00\x02\x00\x13\xe7"); | ||
69 | }; | ||
70 | $m = $ipod->_message(); | ||
71 | subtest "Second message" => sub { | ||
72 | ok(defined($m), "Message received"); | ||
73 | is($m, "\xffU\x02\x00\x14\xea"); | ||
74 | }; | ||