1 package org.minetti.astrodevice.server.usb.jni;
2
3 import static org.junit.Assert.*;
4 import org.junit.Test;
5
6
7
8
9 public final class UsbLibraryTest {
10
11 protected final class MockUsbDeviceTreeBuilder
12 implements UsbDeviceTreeBuilder {
13
14
15
16
17 private int level = 0;
18
19
20
21
22
23 public void down () {
24 this.level++;
25 }
26
27
28
29
30
31 public void up () {
32 this.level--;
33 }
34
35
36
37
38
39
40
41 public void addHostController (final String description) {
42 for (int i = 0; i < this.level; i++) {
43 System.out.print(" ");
44 }
45 System.out.println("=> " + description);
46 }
47
48
49
50
51
52 public void addRootHub () {
53 for (int i = 0; i < this.level; i++) {
54 System.out.print(" ");
55 }
56 System.out.println("=> Root hub");
57 }
58
59
60
61
62
63
64 public void addHub (final int vendorId, final int productId, final String manufacturerName, final String productDescription, final int productVersion,
65 final String serialNumber, final short deviceClass, final short deviceSubClass, final short deviceProtocol) {
66 for (int i = 0; i < this.level; i++) {
67 System.out.print(" ");
68 }
69 System.out.format("=> hub %04X:%04X %s - %s v%04X - S/N %s - class/protocol %02X/%02X/%02X\n", new Integer(vendorId), new Integer(productId),
70 manufacturerName, productDescription, new Integer(productVersion), serialNumber, new Short(deviceClass), new Short(deviceSubClass), new Short(
71 deviceProtocol));
72 }
73
74
75
76
77
78
79 public void add (final int vendorId, final int productId, final String manufacturerName, final String productDescription, final int productVersion,
80 final String serialNumber, final short deviceClass, final short deviceSubClass, final short deviceProtocol) {
81 for (int i = 0; i < this.level; i++) {
82 System.out.print(" ");
83 }
84 System.out.format("=> %04X:%04X %s - %s v%04X - S/N %s - class/protocol %02X/%02X/%02X\n", new Integer(vendorId), new Integer(productId),
85 manufacturerName, productDescription, new Integer(productVersion), serialNumber, new Short(deviceClass), new Short(deviceSubClass), new Short(
86 deviceProtocol));
87 }
88
89 }
90
91
92
93
94
95 @Test
96 public void testStartPlugMonitoring () {
97 fail("Not yet implemented");
98 }
99
100
101
102
103
104 @Test
105 public void testStopPlugMonitoring () {
106 fail("Not yet implemented");
107 }
108
109
110
111
112
113
114 @Test
115 public void testLoadDeviceTree () {
116 final UsbLibrary usbLibrary = new UsbLibrary();
117 UsbDeviceTreeBuilder builder = new MockUsbDeviceTreeBuilder();
118 usbLibrary.loadDeviceTree(builder);
119 }
120
121 }