Changeset 30424 in vbox
- Timestamp:
- Jun 24, 2010 12:12:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/glue/tests/TestVBox.java
r30207 r30424 13 13 import org.virtualbox_3_3.*; 14 14 import java.util.List; 15 import java.util.Arrays; 15 16 import java.math.BigInteger; 16 17 … … 180 181 } catch (Exception e) { 181 182 e.printStackTrace(); 182 } finally { 183 } finally { 183 184 mgr.closeMachineSession(session); 184 185 } 185 186 mgr.unregisterGlobalCallback(vbox, cbs); 187 } 188 189 190 static void processEvent(IEvent ev) 191 { 192 System.out.println("got event: " + ev); 193 194 VBoxEventType type = ev.getType(); 195 System.out.println("type = "+type); 196 197 switch (type) 198 { 199 case OnMachineStateChange: 200 IMachineStateChangeEvent mcse = IMachineStateChangeEvent.queryInterface(ev); 201 if (mcse == null) 202 System.out.println("Cannot query an interface"); 203 else 204 System.out.println("mid="+mcse.getMachineId()); 205 break; 206 } 207 } 208 209 static void testEvents(VirtualBoxManager mgr, IEventSource es) 210 { 211 IEventListener listener = es.createListener(); 212 213 es.registerListener(listener, Arrays.asList(VBoxEventType.Any), false); 214 215 try { 216 for (int i=0; i<100; i++) 217 { 218 IEvent ev = es.getEvent(listener, 1000); 219 System.out.print("."); 220 if (ev != null) 221 { 222 processEvent(ev); 223 es.eventProcessed(listener, ev); 224 } 225 } 226 } catch (Exception e) { 227 e.printStackTrace(); 228 } 229 230 es.unregisterListener(listener); 186 231 } 187 232 … … 217 262 testEnumeration(mgr, vbox); 218 263 testStart(mgr, vbox); 219 testCallbacks(mgr, vbox); 264 //testCallbacks(mgr, vbox); 265 testEvents(mgr, vbox.getEventSource()); 220 266 221 267 System.out.println("done, press Enter...");
Note:
See TracChangeset
for help on using the changeset viewer.