velir_virtualbox 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.yardopts +3 -0
- data/Gemfile +16 -0
- data/LICENSE +19 -0
- data/Rakefile +37 -0
- data/Readme.md +70 -0
- data/docs/GettingStarted.md +196 -0
- data/docs/WhatsNew.md +12 -0
- data/features/README.md +33 -0
- data/features/global.feature +19 -0
- data/features/global_extra_data.feature +27 -0
- data/features/step_definitions/abstract_model_steps.rb +39 -0
- data/features/step_definitions/extra_data_steps.rb +36 -0
- data/features/step_definitions/global_steps.rb +29 -0
- data/features/step_definitions/nat_engine_steps.rb +76 -0
- data/features/step_definitions/network_adapter_steps.rb +38 -0
- data/features/step_definitions/shared_folder_steps.rb +76 -0
- data/features/step_definitions/snapshot_steps.rb +74 -0
- data/features/step_definitions/storage_controller_steps.rb +16 -0
- data/features/step_definitions/virtualbox_steps.rb +17 -0
- data/features/step_definitions/vm_steps.rb +50 -0
- data/features/support/env.rb +61 -0
- data/features/support/helpers.rb +38 -0
- data/features/support/hooks.rb +30 -0
- data/features/support/ordered_hash.rb +49 -0
- data/features/support/vboxmanage.rb +191 -0
- data/features/version.feature +16 -0
- data/features/vm.feature +13 -0
- data/features/vm_bios.feature +29 -0
- data/features/vm_cpu.feature +29 -0
- data/features/vm_extra_data.feature +35 -0
- data/features/vm_hw_virt.feature +29 -0
- data/features/vm_nat_engine.feature +57 -0
- data/features/vm_network_adapters.feature +27 -0
- data/features/vm_shared_folders.feature +42 -0
- data/features/vm_snapshots.feature +29 -0
- data/features/vm_storage_controllers.feature +11 -0
- data/lib/virtualbox.rb +11 -0
- data/lib/virtualbox/abstract_model.rb +281 -0
- data/lib/virtualbox/abstract_model/attributable.rb +290 -0
- data/lib/virtualbox/abstract_model/dirty.rb +177 -0
- data/lib/virtualbox/abstract_model/interface_attributes.rb +98 -0
- data/lib/virtualbox/abstract_model/relatable.rb +332 -0
- data/lib/virtualbox/abstract_model/validatable.rb +167 -0
- data/lib/virtualbox/abstract_model/version_matcher.rb +35 -0
- data/lib/virtualbox/appliance.rb +62 -0
- data/lib/virtualbox/audio_adapter.rb +52 -0
- data/lib/virtualbox/bios.rb +50 -0
- data/lib/virtualbox/com.rb +23 -0
- data/lib/virtualbox/com/abstract_enum.rb +43 -0
- data/lib/virtualbox/com/abstract_implementer.rb +45 -0
- data/lib/virtualbox/com/abstract_interface.rb +167 -0
- data/lib/virtualbox/com/base_interface.rb +38 -0
- data/lib/virtualbox/com/ffi/interface.rb +150 -0
- data/lib/virtualbox/com/ffi/interfaces.rb +63 -0
- data/lib/virtualbox/com/ffi/util.rb +121 -0
- data/lib/virtualbox/com/ffi/vboxxpcomc.rb +31 -0
- data/lib/virtualbox/com/ffi_interface.rb +96 -0
- data/lib/virtualbox/com/implementer/base.rb +59 -0
- data/lib/virtualbox/com/implementer/ffi.rb +381 -0
- data/lib/virtualbox/com/implementer/mscom.rb +189 -0
- data/lib/virtualbox/com/implementer/nil.rb +10 -0
- data/lib/virtualbox/com/interface/3.1.x/access_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/appliance.rb +22 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_adapter.rb +15 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/audio_driver_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/bios_boot_menu_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/bios_settings.rb +21 -0
- data/lib/virtualbox/com/interface/3.1.x/clipboard_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/console.rb +50 -0
- data/lib/virtualbox/com/interface/3.1.x/cpu_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/device_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/dhcp_server.rb +22 -0
- data/lib/virtualbox/com/interface/3.1.x/firmware_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/guest_os_type.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/host.rb +42 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface.rb +30 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_status.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_network_interface_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/host_usb_device.rb +13 -0
- data/lib/virtualbox/com/interface/3.1.x/host_usb_device_filter.rb +13 -0
- data/lib/virtualbox/com/interface/3.1.x/hw_virt_ex_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/machine.rb +105 -0
- data/lib/virtualbox/com/interface/3.1.x/machine_state.rb +14 -0
- data/lib/virtualbox/com/interface/3.1.x/medium.rb +50 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_attachment.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_format.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/medium_variant.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/network_adapter.rb +30 -0
- data/lib/virtualbox/com/interface/3.1.x/network_adapter_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/network_attachment_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/nsiexception.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/nsisupports.rb +15 -0
- data/lib/virtualbox/com/interface/3.1.x/parallel_port.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/port_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/progress.rb +63 -0
- data/lib/virtualbox/com/interface/3.1.x/serial_port.rb +19 -0
- data/lib/virtualbox/com/interface/3.1.x/session.rb +18 -0
- data/lib/virtualbox/com/interface/3.1.x/session_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/session_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/shared_folder.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/snapshot.rb +20 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_bus.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_controller.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/storage_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/system_properties.rb +37 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_controller.rb +20 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device.rb +24 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_filter.rb +23 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_filter_action.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/usb_device_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_box_error_info.rb +17 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description.rb +19 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_type.rb +14 -0
- data/lib/virtualbox/com/interface/3.1.x/virtual_system_description_value_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/virtualbox.rb +67 -0
- data/lib/virtualbox/com/interface/3.1.x/vrdp_auth_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.1.x/vrdp_server.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/access_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/appliance.rb +22 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_adapter.rb +15 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/audio_driver_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/bios_boot_menu_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/bios_settings.rb +21 -0
- data/lib/virtualbox/com/interface/3.2.x/clipboard_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/console.rb +50 -0
- data/lib/virtualbox/com/interface/3.2.x/cpu_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/device_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/dhcp_server.rb +22 -0
- data/lib/virtualbox/com/interface/3.2.x/firmware_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/guest.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/guest_os_type.rb +33 -0
- data/lib/virtualbox/com/interface/3.2.x/host.rb +43 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface.rb +30 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_status.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_network_interface_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/host_usb_device.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/host_usb_device_filter.rb +13 -0
- data/lib/virtualbox/com/interface/3.2.x/hw_virt_ex_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/keyboard_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/machine.rb +118 -0
- data/lib/virtualbox/com/interface/3.2.x/machine_state.rb +14 -0
- data/lib/virtualbox/com/interface/3.2.x/medium.rb +51 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_attachment.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_format.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/medium_variant.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_alias_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_engine.rb +27 -0
- data/lib/virtualbox/com/interface/3.2.x/nat_protocol.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/network_adapter.rb +34 -0
- data/lib/virtualbox/com/interface/3.2.x/network_adapter_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/network_attachment_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/nsiexception.rb +23 -0
- data/lib/virtualbox/com/interface/3.2.x/nsisupports.rb +15 -0
- data/lib/virtualbox/com/interface/3.2.x/parallel_port.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/pointing_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/port_mode.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/progress.rb +63 -0
- data/lib/virtualbox/com/interface/3.2.x/serial_port.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/session.rb +18 -0
- data/lib/virtualbox/com/interface/3.2.x/session_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/session_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/shared_folder.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/snapshot.rb +20 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_bus.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_controller.rb +24 -0
- data/lib/virtualbox/com/interface/3.2.x/storage_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/system_properties.rb +42 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_controller.rb +21 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device.rb +24 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_filter.rb +23 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_filter_action.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/usb_device_state.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_box_error_info.rb +17 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description.rb +19 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_type.rb +14 -0
- data/lib/virtualbox/com/interface/3.2.x/virtual_system_description_value_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/virtualbox.rb +67 -0
- data/lib/virtualbox/com/interface/3.2.x/vrdp_auth_type.rb +11 -0
- data/lib/virtualbox/com/interface/3.2.x/vrdp_server.rb +21 -0
- data/lib/virtualbox/com/interface/4.0.x/access_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/appliance.rb +23 -0
- data/lib/virtualbox/com/interface/4.0.x/audio_adapter.rb +15 -0
- data/lib/virtualbox/com/interface/4.0.x/audio_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/audio_driver_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/auth_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/bios_boot_menu_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/bios_settings.rb +21 -0
- data/lib/virtualbox/com/interface/4.0.x/cleanup_mode.rb +12 -0
- data/lib/virtualbox/com/interface/4.0.x/clipboard_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/console.rb +50 -0
- data/lib/virtualbox/com/interface/4.0.x/cpu_property_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/device_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/dhcp_server.rb +22 -0
- data/lib/virtualbox/com/interface/4.0.x/event_source.rb +13 -0
- data/lib/virtualbox/com/interface/4.0.x/fault_tolerance_state.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/firmware_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/guest.rb +13 -0
- data/lib/virtualbox/com/interface/4.0.x/guest_os_type.rb +33 -0
- data/lib/virtualbox/com/interface/4.0.x/host.rb +43 -0
- data/lib/virtualbox/com/interface/4.0.x/host_network_interface.rb +30 -0
- data/lib/virtualbox/com/interface/4.0.x/host_network_interface_medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/host_network_interface_status.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/host_network_interface_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/host_usb_device.rb +13 -0
- data/lib/virtualbox/com/interface/4.0.x/host_usb_device_filter.rb +13 -0
- data/lib/virtualbox/com/interface/4.0.x/hw_virt_ex_property_type.rb +12 -0
- data/lib/virtualbox/com/interface/4.0.x/keyboard_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/lock_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/machine.rb +132 -0
- data/lib/virtualbox/com/interface/4.0.x/machine_state.rb +14 -0
- data/lib/virtualbox/com/interface/4.0.x/medium.rb +53 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_attachment.rb +18 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_format.rb +18 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_state.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/medium_variant.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/nat_alias_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/nat_engine.rb +27 -0
- data/lib/virtualbox/com/interface/4.0.x/nat_protocol.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/network_adapter.rb +35 -0
- data/lib/virtualbox/com/interface/4.0.x/network_adapter_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/network_attachment_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/nsiexception.rb +23 -0
- data/lib/virtualbox/com/interface/4.0.x/nsisupports.rb +15 -0
- data/lib/virtualbox/com/interface/4.0.x/parallel_port.rb +17 -0
- data/lib/virtualbox/com/interface/4.0.x/pointing_hid_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/port_mode.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/progress.rb +64 -0
- data/lib/virtualbox/com/interface/4.0.x/serial_port.rb +19 -0
- data/lib/virtualbox/com/interface/4.0.x/session.rb +18 -0
- data/lib/virtualbox/com/interface/4.0.x/session_state.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/session_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/shared_folder.rb +17 -0
- data/lib/virtualbox/com/interface/4.0.x/snapshot.rb +20 -0
- data/lib/virtualbox/com/interface/4.0.x/storage_bus.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/storage_controller.rb +24 -0
- data/lib/virtualbox/com/interface/4.0.x/storage_controller_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/system_properties.rb +42 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_controller.rb +21 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_device.rb +24 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_device_filter.rb +23 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_device_filter_action.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/usb_device_state.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/virtual_box_error_info.rb +17 -0
- data/lib/virtualbox/com/interface/4.0.x/virtual_system_description.rb +19 -0
- data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_type.rb +14 -0
- data/lib/virtualbox/com/interface/4.0.x/virtual_system_description_value_type.rb +11 -0
- data/lib/virtualbox/com/interface/4.0.x/virtualbox.rb +50 -0
- data/lib/virtualbox/com/interface/4.0.x/vrde_server.rb +23 -0
- data/lib/virtualbox/com/mscom_interface.rb +44 -0
- data/lib/virtualbox/com/nil_interface.rb +7 -0
- data/lib/virtualbox/com/util.rb +32 -0
- data/lib/virtualbox/cpu.rb +61 -0
- data/lib/virtualbox/dhcp_server.rb +89 -0
- data/lib/virtualbox/dvd.rb +27 -0
- data/lib/virtualbox/exceptions.rb +39 -0
- data/lib/virtualbox/ext/byte_normalizer.rb +17 -0
- data/lib/virtualbox/ext/glob_loader.rb +35 -0
- data/lib/virtualbox/ext/logger.rb +38 -0
- data/lib/virtualbox/ext/platform.rb +31 -0
- data/lib/virtualbox/ext/subclass_listing.rb +24 -0
- data/lib/virtualbox/extra_data.rb +127 -0
- data/lib/virtualbox/forwarded_port.rb +222 -0
- data/lib/virtualbox/global.rb +96 -0
- data/lib/virtualbox/hard_drive.rb +246 -0
- data/lib/virtualbox/host.rb +71 -0
- data/lib/virtualbox/host_network_interface.rb +137 -0
- data/lib/virtualbox/hw_virtualization.rb +64 -0
- data/lib/virtualbox/lib.rb +84 -0
- data/lib/virtualbox/media.rb +20 -0
- data/lib/virtualbox/medium.rb +145 -0
- data/lib/virtualbox/medium_attachment.rb +61 -0
- data/lib/virtualbox/nat_engine.rb +71 -0
- data/lib/virtualbox/nat_forwarded_port.rb +171 -0
- data/lib/virtualbox/network_adapter.rb +166 -0
- data/lib/virtualbox/proxies/collection.rb +57 -0
- data/lib/virtualbox/shared_folder.rb +220 -0
- data/lib/virtualbox/snapshot.rb +185 -0
- data/lib/virtualbox/storage_controller.rb +160 -0
- data/lib/virtualbox/system_properties.rb +73 -0
- data/lib/virtualbox/usb_controller.rb +59 -0
- data/lib/virtualbox/usb_device_filter.rb +74 -0
- data/lib/virtualbox/version.rb +36 -0
- data/lib/virtualbox/virtual_system_description.rb +47 -0
- data/lib/virtualbox/vm.rb +649 -0
- data/lib/virtualbox/vrde_server.rb +57 -0
- data/test/test_helper.rb +18 -0
- data/test/virtualbox/abstract_model/attributable_test.rb +269 -0
- data/test/virtualbox/abstract_model/dirty_test.rb +83 -0
- data/test/virtualbox/abstract_model/interface_attributes_test.rb +194 -0
- data/test/virtualbox/abstract_model/relatable_test.rb +348 -0
- data/test/virtualbox/abstract_model/validatable_test.rb +308 -0
- data/test/virtualbox/abstract_model/version_matcher_test.rb +41 -0
- data/test/virtualbox/abstract_model_test.rb +462 -0
- data/test/virtualbox/appliance_test.rb +159 -0
- data/test/virtualbox/audio_adapter_test.rb +83 -0
- data/test/virtualbox/bios_test.rb +83 -0
- data/test/virtualbox/com/abstract_enum_test.rb +49 -0
- data/test/virtualbox/com/abstract_implementer_test.rb +40 -0
- data/test/virtualbox/com/abstract_interface_test.rb +140 -0
- data/test/virtualbox/com/ffi/interface_test.rb +249 -0
- data/test/virtualbox/com/ffi/util_test.rb +108 -0
- data/test/virtualbox/com/ffi_interface_test.rb +42 -0
- data/test/virtualbox/com/implementer/base_test.rb +38 -0
- data/test/virtualbox/com/implementer/ffi_test.rb +527 -0
- data/test/virtualbox/com/implementer/mscom_test.rb +247 -0
- data/test/virtualbox/com/mscom_interface_test.rb +17 -0
- data/test/virtualbox/com/util_test.rb +17 -0
- data/test/virtualbox/cpu_test.rb +103 -0
- data/test/virtualbox/dhcp_server_test.rb +165 -0
- data/test/virtualbox/dvd_test.rb +28 -0
- data/test/virtualbox/ext/byte_normalizer_test.rb +34 -0
- data/test/virtualbox/ext/platform_test.rb +50 -0
- data/test/virtualbox/ext/subclass_listing_test.rb +25 -0
- data/test/virtualbox/extra_data_test.rb +155 -0
- data/test/virtualbox/forwarded_port_test.rb +286 -0
- data/test/virtualbox/global_test.rb +46 -0
- data/test/virtualbox/hard_drive_test.rb +141 -0
- data/test/virtualbox/host_network_interface_test.rb +255 -0
- data/test/virtualbox/host_test.rb +94 -0
- data/test/virtualbox/hw_virtualization_test.rb +103 -0
- data/test/virtualbox/lib_test.rb +93 -0
- data/test/virtualbox/medium_attachment_test.rb +147 -0
- data/test/virtualbox/medium_test.rb +192 -0
- data/test/virtualbox/nat_engine_test.rb +106 -0
- data/test/virtualbox/nat_forwarded_port_test.rb +222 -0
- data/test/virtualbox/network_adapter_test.rb +191 -0
- data/test/virtualbox/proxies/collection_test.rb +102 -0
- data/test/virtualbox/shared_folder_test.rb +219 -0
- data/test/virtualbox/snapshot_test.rb +231 -0
- data/test/virtualbox/storage_controller_test.rb +197 -0
- data/test/virtualbox/system_properties_test.rb +87 -0
- data/test/virtualbox/usb_controller_test.rb +112 -0
- data/test/virtualbox/usb_device_filter_test.rb +93 -0
- data/test/virtualbox/version_test.rb +59 -0
- data/test/virtualbox/virtual_system_description_test.rb +61 -0
- data/test/virtualbox/vm_test.rb +633 -0
- data/test/virtualbox/vrde_server_test.rb +83 -0
- data/test/virtualbox_test.rb +11 -0
- data/virtualbox.gemspec +24 -0
- metadata +464 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
class VersionTest < Test::Unit::TestCase
|
4
|
+
module VersionTestMod
|
5
|
+
extend VirtualBox::Version
|
6
|
+
end
|
7
|
+
|
8
|
+
setup do
|
9
|
+
@lib = mock("lib")
|
10
|
+
@vbox = mock("vbox")
|
11
|
+
|
12
|
+
VirtualBox::Lib.stubs(:lib).returns(@lib)
|
13
|
+
@lib.stubs(:virtualbox).returns(@vbox)
|
14
|
+
|
15
|
+
@module = VersionTestMod
|
16
|
+
end
|
17
|
+
|
18
|
+
context "checking if supported version of VirtualBox" do
|
19
|
+
should "return true if version is not nil" do
|
20
|
+
@module.stubs(:version).returns(:foo)
|
21
|
+
assert @module.supported?
|
22
|
+
end
|
23
|
+
|
24
|
+
should "return false if version is nil" do
|
25
|
+
@module.stubs(:version).returns(nil)
|
26
|
+
assert !@module.supported?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
should "return the version" do
|
31
|
+
version = mock("version")
|
32
|
+
@vbox.expects(:version).returns(version)
|
33
|
+
assert_equal version, @module.version(true)
|
34
|
+
end
|
35
|
+
|
36
|
+
should "cache the version" do
|
37
|
+
@vbox.expects(:version).once.returns("v")
|
38
|
+
assert_equal "v", @module.version(true)
|
39
|
+
assert_equal "v", @module.version
|
40
|
+
assert_equal "v", @module.version
|
41
|
+
end
|
42
|
+
|
43
|
+
should "return nil if an error occurs" do
|
44
|
+
@vbox.expects(:version).raises(LoadError)
|
45
|
+
assert @module.version(true).nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
should "return the revision" do
|
49
|
+
@vbox.expects(:revision).returns(7)
|
50
|
+
assert_equal "7", @module.revision(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
should "cache the revision" do
|
54
|
+
@vbox.expects(:revision).once.returns(7)
|
55
|
+
assert_equal "7", @module.revision(true)
|
56
|
+
assert_equal "7", @module.revision
|
57
|
+
assert_equal "7", @module.revision
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
class VirtualSystemDescriptionTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = VirtualBox::VirtualSystemDescription
|
6
|
+
@interface = mock("interface")
|
7
|
+
end
|
8
|
+
|
9
|
+
context "class methods" do
|
10
|
+
context "populating relationship" do
|
11
|
+
setup do
|
12
|
+
@instance = mock("instance")
|
13
|
+
|
14
|
+
@klass.stubs(:new).returns(@instance)
|
15
|
+
end
|
16
|
+
|
17
|
+
should "return a proxied collection" do
|
18
|
+
result = @klass.populate_relationship(nil, [])
|
19
|
+
assert result.is_a?(VirtualBox::Proxies::Collection)
|
20
|
+
end
|
21
|
+
|
22
|
+
should "call new for every description" do
|
23
|
+
interfaces = []
|
24
|
+
5.times { |i| interfaces << mock("i#{i}") }
|
25
|
+
|
26
|
+
expected_result = []
|
27
|
+
new_seq = sequence("new_seq")
|
28
|
+
interfaces.each do |interface|
|
29
|
+
expected_value = "instance-#{interface.inspect}"
|
30
|
+
@klass.expects(:new).with(interface).in_sequence(new_seq).returns(expected_value)
|
31
|
+
expected_result << expected_value
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_equal expected_result, @klass.populate_relationship(nil, interfaces)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "initializing" do
|
40
|
+
should "load attributes from the machine" do
|
41
|
+
@klass.any_instance.expects(:initialize_attributes).with(@interface).once
|
42
|
+
@klass.new(@interface)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "initializing attributes" do
|
47
|
+
setup do
|
48
|
+
@interface.stubs(:get_values_by_type).returns(nil)
|
49
|
+
end
|
50
|
+
|
51
|
+
should "not be dirty" do
|
52
|
+
@instance = @klass.new(@interface)
|
53
|
+
assert !@instance.changed?
|
54
|
+
end
|
55
|
+
|
56
|
+
should "be existing record" do
|
57
|
+
@instance = @klass.new(@interface)
|
58
|
+
assert !@instance.new_record?
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,633 @@
|
|
1
|
+
require File.expand_path("../../test_helper", __FILE__)
|
2
|
+
|
3
|
+
class VMTest < Test::Unit::TestCase
|
4
|
+
setup do
|
5
|
+
@klass = VirtualBox::VM
|
6
|
+
@interface = mock("interface")
|
7
|
+
@parent = mock("parent")
|
8
|
+
end
|
9
|
+
|
10
|
+
context "class methods" do
|
11
|
+
context "retrieving all machines" do
|
12
|
+
should "return an array of VM objects" do
|
13
|
+
vms = mock("vms")
|
14
|
+
global = mock("global")
|
15
|
+
global.expects(:vms).returns(vms)
|
16
|
+
VirtualBox::Global.expects(:global).returns(global)
|
17
|
+
assert_equal vms, VirtualBox::VM.all
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "finding a VM" do
|
22
|
+
setup do
|
23
|
+
@all = []
|
24
|
+
@klass.stubs(:all).returns(@all)
|
25
|
+
end
|
26
|
+
|
27
|
+
def mock_vm(uuid, name=nil)
|
28
|
+
vm = mock("vm-#{uuid}")
|
29
|
+
vm.stubs(:uuid).returns(uuid)
|
30
|
+
vm.stubs(:name).returns(name)
|
31
|
+
vm
|
32
|
+
end
|
33
|
+
|
34
|
+
should "return nil if it doesn't exist" do
|
35
|
+
@all << mock_vm("foo")
|
36
|
+
assert_nil @klass.find("bar")
|
37
|
+
end
|
38
|
+
|
39
|
+
should "return the matching vm if it is found" do
|
40
|
+
vm = mock_vm("foo")
|
41
|
+
@all << mock_vm("bar")
|
42
|
+
@all << vm
|
43
|
+
assert_equal vm, @klass.find("foo")
|
44
|
+
end
|
45
|
+
|
46
|
+
should "return if matching name is found" do
|
47
|
+
vm = mock_vm(nil, "foo")
|
48
|
+
@all << vm
|
49
|
+
assert_equal vm, @klass.find("foo")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "importing" do
|
54
|
+
setup do
|
55
|
+
@path = "foo.rb"
|
56
|
+
@appliance = mock("appliance")
|
57
|
+
@virtual_system = mock("virtual_system")
|
58
|
+
@appliance.stubs(:virtual_systems).returns([@virtual_system])
|
59
|
+
|
60
|
+
@name = :foo
|
61
|
+
@virtual_system.stubs(:descriptions).returns({
|
62
|
+
:name => { :auto => @name }
|
63
|
+
})
|
64
|
+
end
|
65
|
+
|
66
|
+
should "create a new appliance with path, import, and return VM" do
|
67
|
+
result = mock("result")
|
68
|
+
proc = mock("proc")
|
69
|
+
VirtualBox::Appliance.expects(:new).with(@path).returns(@appliance)
|
70
|
+
@appliance.expects(:import).yields(proc)
|
71
|
+
@klass.expects(:find).with(@name).returns(result)
|
72
|
+
proc.expects(:call)
|
73
|
+
|
74
|
+
value = @klass.import(@path) do |proc|
|
75
|
+
proc.call
|
76
|
+
end
|
77
|
+
|
78
|
+
assert_equal result, value
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "populating relationships" do
|
83
|
+
setup do
|
84
|
+
@caller = mock("caller")
|
85
|
+
end
|
86
|
+
|
87
|
+
should "call populate_array_relationship for arrays" do
|
88
|
+
@klass.expects(:populate_array_relationship).with(@caller, []).once
|
89
|
+
@klass.populate_relationship(@caller, [])
|
90
|
+
end
|
91
|
+
|
92
|
+
should "call populate_single_relationship for non-arrays" do
|
93
|
+
@klass.expects(:populate_single_relationship).with(@caller, nil).once
|
94
|
+
@klass.populate_relationship(@caller, nil)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "populating single relationships" do
|
99
|
+
setup do
|
100
|
+
@machine = mock("interface")
|
101
|
+
end
|
102
|
+
|
103
|
+
should "return a new machine" do
|
104
|
+
result = mock("result")
|
105
|
+
@klass.expects(:new).with(@machine).returns(result)
|
106
|
+
assert_equal result, @klass.populate_single_relationship(nil, @machine)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "populating array relationship" do
|
111
|
+
setup do
|
112
|
+
@instance = mock("instance")
|
113
|
+
|
114
|
+
@klass.stubs(:new).returns(@instance)
|
115
|
+
end
|
116
|
+
|
117
|
+
should "return a proxied collection" do
|
118
|
+
result = @klass.populate_array_relationship(nil, [])
|
119
|
+
assert result.is_a?(VirtualBox::Proxies::Collection)
|
120
|
+
end
|
121
|
+
|
122
|
+
should "call new for every machine" do
|
123
|
+
machines = []
|
124
|
+
5.times { |i| machines << mock("m#{i}") }
|
125
|
+
|
126
|
+
expected_result = []
|
127
|
+
new_seq = sequence("new_seq")
|
128
|
+
machines.each do |machine|
|
129
|
+
expected_value = "instance-#{machine.inspect}"
|
130
|
+
@klass.expects(:new).with(machine).in_sequence(new_seq).returns(expected_value)
|
131
|
+
expected_result << expected_value
|
132
|
+
end
|
133
|
+
|
134
|
+
assert_equal expected_result, @klass.populate_array_relationship(nil, machines)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "initializing" do
|
140
|
+
should "load attributes from the machine" do
|
141
|
+
@klass.any_instance.expects(:initialize_attributes).with(@interface).once
|
142
|
+
@klass.new(@interface)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "initializing attributes" do
|
147
|
+
setup do
|
148
|
+
@klass.any_instance.stubs(:load_interface_attributes)
|
149
|
+
@klass.any_instance.stubs(:populate_relationships)
|
150
|
+
end
|
151
|
+
|
152
|
+
should "load interface attribtues" do
|
153
|
+
@klass.any_instance.expects(:load_interface_attributes).with(@interface).once
|
154
|
+
@klass.new(@interface)
|
155
|
+
end
|
156
|
+
|
157
|
+
should "populate relationships" do
|
158
|
+
@klass.any_instance.expects(:populate_relationships).with(@interface).once
|
159
|
+
@klass.new(@interface)
|
160
|
+
end
|
161
|
+
|
162
|
+
should "not be dirty" do
|
163
|
+
@instance = @klass.new(@interface)
|
164
|
+
assert !@instance.changed?
|
165
|
+
end
|
166
|
+
|
167
|
+
should "be existing record" do
|
168
|
+
@instance = @klass.new(@interface)
|
169
|
+
assert !@instance.new_record?
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context "instance methods" do
|
174
|
+
setup do
|
175
|
+
@klass.any_instance.stubs(:initialize_attributes)
|
176
|
+
@instance = @klass.new(@interface)
|
177
|
+
end
|
178
|
+
|
179
|
+
def setup_session_mocks
|
180
|
+
@parent = mock("parent")
|
181
|
+
@session = mock("session")
|
182
|
+
@lib = mock("lib")
|
183
|
+
@progress = mock("progress")
|
184
|
+
|
185
|
+
@session.stubs(:close)
|
186
|
+
@progress.stubs(:wait_for_completion)
|
187
|
+
@lib.stubs(:session).returns(@session)
|
188
|
+
@uuid = :foo
|
189
|
+
|
190
|
+
VirtualBox::Lib.stubs(:lib).returns(@lib)
|
191
|
+
@interface.stubs(:parent).returns(@parent)
|
192
|
+
@instance.stubs(:imachine).returns(@interface)
|
193
|
+
@instance.stubs(:uuid).returns(@uuid)
|
194
|
+
@instance.stubs(:running).returns(false)
|
195
|
+
end
|
196
|
+
|
197
|
+
context "reloading" do
|
198
|
+
setup do
|
199
|
+
@instance.stubs(:initialize_attributes)
|
200
|
+
end
|
201
|
+
|
202
|
+
should "just reload the attributes" do
|
203
|
+
@instance.expects(:initialize_attributes).with(@interface).once
|
204
|
+
@instance.reload
|
205
|
+
end
|
206
|
+
|
207
|
+
should "return itself" do
|
208
|
+
assert @instance.equal?(@instance.reload)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
context "destroying" do
|
213
|
+
setup do
|
214
|
+
@instance.stubs(:uuid).returns(:foo)
|
215
|
+
|
216
|
+
@interface_parent = mock("interface_parent")
|
217
|
+
@interface.stubs(:parent).returns(@interface_parent)
|
218
|
+
end
|
219
|
+
|
220
|
+
should "do a full destroy and destroy the media" do
|
221
|
+
destroy_seq = sequence("destroy_seq")
|
222
|
+
media = [1,2,3]
|
223
|
+
progress = mock("progress")
|
224
|
+
@interface.expects(:unregister).with(:full).once.returns(media).in_sequence(destroy_seq)
|
225
|
+
@interface.expects(:delete).with(media).once.returns(progress).in_sequence(destroy_seq)
|
226
|
+
|
227
|
+
@instance.destroy
|
228
|
+
end
|
229
|
+
|
230
|
+
should "not destroy media if there aren't any" do
|
231
|
+
@interface.expects(:unregister).with(:full).once.returns([])
|
232
|
+
@interface.expects(:delete).never
|
233
|
+
|
234
|
+
@instance.destroy
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context "state" do
|
239
|
+
setup do
|
240
|
+
@state = mock("state")
|
241
|
+
@interface = mock("interface")
|
242
|
+
@instance.stubs(:read_attribute).with(:state).returns(@state)
|
243
|
+
@instance.stubs(:interface).returns(@interface)
|
244
|
+
end
|
245
|
+
|
246
|
+
should "reload and return the state" do
|
247
|
+
@instance.expects(:load_interface_attribute).with(:state, @instance.interface).once
|
248
|
+
assert_equal @state, @instance.state
|
249
|
+
end
|
250
|
+
|
251
|
+
should "not reload the state if suppress is given" do
|
252
|
+
@instance.expects(:load_interface_attribute).never
|
253
|
+
assert_equal @state, @instance.state(true)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context "starting" do
|
258
|
+
setup do
|
259
|
+
setup_session_mocks
|
260
|
+
|
261
|
+
@instance.stubs(:running?).returns(false)
|
262
|
+
@session.stubs(:state).returns(:open)
|
263
|
+
end
|
264
|
+
|
265
|
+
should "launch the VM with the given mode" do
|
266
|
+
start_seq = sequence('start_seq')
|
267
|
+
mode = "foo"
|
268
|
+
@interface.expects(:launch_vm_process).with(@session, mode, "").once.returns(@progress).in_sequence(start_seq)
|
269
|
+
@progress.expects(:wait).in_sequence(start_seq)
|
270
|
+
@session.expects(:unlock_machine).in_sequence(start_seq)
|
271
|
+
assert @instance.start(mode)
|
272
|
+
end
|
273
|
+
|
274
|
+
should "return false if state is running" do
|
275
|
+
@instance.expects(:running?).returns(true)
|
276
|
+
assert !@instance.start(nil)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
context "controlling" do
|
281
|
+
setup do
|
282
|
+
setup_session_mocks
|
283
|
+
|
284
|
+
@console = mock("console")
|
285
|
+
@console.stubs(:send)
|
286
|
+
@session.stubs(:console).returns(@console)
|
287
|
+
@session.stubs(:state).returns(:open)
|
288
|
+
|
289
|
+
@instance.stubs(:with_open_session).yields(@session)
|
290
|
+
|
291
|
+
@method = :foo
|
292
|
+
end
|
293
|
+
|
294
|
+
should "get an existing, session, send the command, and close" do
|
295
|
+
method = :foo
|
296
|
+
control_seq = sequence("control_seq")
|
297
|
+
@instance.expects(:with_open_session).with(:shared).yields(@session).in_sequence(control_seq)
|
298
|
+
@console.expects(:send).with(@method).once.in_sequence(control_seq)
|
299
|
+
|
300
|
+
@instance.control(@method)
|
301
|
+
end
|
302
|
+
|
303
|
+
should "wait for completion if an IProgress is returned" do
|
304
|
+
progress = mock("IProgress")
|
305
|
+
progress.stubs(:is_a?).with(VirtualBox::COM::Util.versioned_interface(:Progress)).returns(true)
|
306
|
+
progress.expects(:wait).once
|
307
|
+
@console.expects(:send).with(@method).returns(progress)
|
308
|
+
@instance.control(@method)
|
309
|
+
end
|
310
|
+
|
311
|
+
should "forward other args" do
|
312
|
+
@console.expects(:send).with(@method, 1, 2, 3).once
|
313
|
+
@instance.control(@method, 1, 2, 3)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
context "control helpers" do
|
318
|
+
should "call the proper control method" do
|
319
|
+
methods = {
|
320
|
+
:shutdown => :power_button,
|
321
|
+
:stop => :power_down,
|
322
|
+
:pause => :pause,
|
323
|
+
:resume => :resume,
|
324
|
+
:save_state => :save_state,
|
325
|
+
:discard_state => [:discard_saved_state, true]
|
326
|
+
}
|
327
|
+
|
328
|
+
methods.each do |method, control|
|
329
|
+
control = [control] unless control.is_a?(Array)
|
330
|
+
@instance.expects(:control).with(*control).once
|
331
|
+
@instance.send(method)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
context "saving" do
|
337
|
+
setup do
|
338
|
+
@session = mock("session")
|
339
|
+
@session.stubs(:machine).returns(@parent)
|
340
|
+
|
341
|
+
@locked_interface = mock("locked_interface")
|
342
|
+
|
343
|
+
@instance.stubs(:saved?).returns(false)
|
344
|
+
@instance.stubs(:valid?).returns(true)
|
345
|
+
@instance.stubs(:with_open_session)
|
346
|
+
end
|
347
|
+
|
348
|
+
should "open the session, save, and close" do
|
349
|
+
save_seq = sequence("save_seq")
|
350
|
+
@instance.expects(:with_open_session).once.yields(@session).in_sequence(save_seq)
|
351
|
+
@session.expects(:machine).returns(@locked_interface).in_sequence(save_seq)
|
352
|
+
@instance.expects(:save_interface_attribute).with(:boot_order, @locked_interface).in_sequence(save_seq)
|
353
|
+
@instance.expects(:save_changed_interface_attributes).with(@locked_interface).in_sequence(save_seq)
|
354
|
+
@instance.expects(:save_relationships).in_sequence(save_seq)
|
355
|
+
|
356
|
+
@instance.save
|
357
|
+
end
|
358
|
+
|
359
|
+
should "raise an exception if saved" do
|
360
|
+
@instance.stubs(:saved?).returns(true)
|
361
|
+
|
362
|
+
assert_raises(VirtualBox::Exceptions::ReadonlyVMStateException) {
|
363
|
+
@instance.save
|
364
|
+
}
|
365
|
+
end
|
366
|
+
|
367
|
+
should "return false if not valid" do
|
368
|
+
@instance.stubs(:valid?).returns(false)
|
369
|
+
assert !@instance.save
|
370
|
+
end
|
371
|
+
|
372
|
+
should "return true if save succeeds" do
|
373
|
+
assert @instance.save
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
context "opening a session [direct]" do
|
378
|
+
setup do
|
379
|
+
setup_session_mocks
|
380
|
+
|
381
|
+
@locked_interface = mock("locked_interface")
|
382
|
+
@locked_interface.stubs(:state).returns(:powered_off)
|
383
|
+
@session.stubs(:machine).returns(@locked_interface)
|
384
|
+
@session.stubs(:state).returns(:closed)
|
385
|
+
@interface.stubs(:lock_machine)
|
386
|
+
end
|
387
|
+
|
388
|
+
should "close the session if an exception is raised" do
|
389
|
+
@locked_interface.expects(:save_settings).raises(Exception)
|
390
|
+
@session.expects(:unlock_machine).once
|
391
|
+
|
392
|
+
assert_raises(Exception) do
|
393
|
+
@instance.with_open_session do
|
394
|
+
# After this point, state should be open
|
395
|
+
@session.stubs(:state).returns(:open)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
should "open the session, save, and close" do
|
401
|
+
save_seq = sequence("save_seq")
|
402
|
+
@proc = Proc.new {}
|
403
|
+
|
404
|
+
@interface.expects(:lock_machine).with(@session, :write).in_sequence(save_seq)
|
405
|
+
@proc.expects(:call).with(@session).once.in_sequence(save_seq)
|
406
|
+
@locked_interface.expects(:save_settings).once.in_sequence(save_seq)
|
407
|
+
@session.expects(:unlock_machine).in_sequence(save_seq)
|
408
|
+
|
409
|
+
@instance.with_open_session do |session|
|
410
|
+
@proc.call(session)
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
should "open the session with the shared type and NOT save settings" do
|
415
|
+
@interface.expects(:lock_machine).with(@session, :shared)
|
416
|
+
@session.expects(:unlock_machine)
|
417
|
+
@locked_interface.expects(:save_settings).never
|
418
|
+
|
419
|
+
@instance.with_open_session(:shared)
|
420
|
+
end
|
421
|
+
|
422
|
+
should "not save settings when the state is saved" do
|
423
|
+
@locked_interface.stubs(:state).returns(:saved)
|
424
|
+
|
425
|
+
save_seq = sequence("save_seq")
|
426
|
+
@interface.expects(:lock_machine).with(@session, :write).in_sequence(save_seq)
|
427
|
+
@locked_interface.expects(:save_settings).never
|
428
|
+
@session.expects(:unlock_machine).in_sequence(save_seq)
|
429
|
+
|
430
|
+
@instance.with_open_session { |session| }
|
431
|
+
end
|
432
|
+
|
433
|
+
should "only open the session and close once" do
|
434
|
+
open_seq = sequence("open_seq")
|
435
|
+
|
436
|
+
@interface.expects(:lock_machine).with(@session, :write).in_sequence(open_seq)
|
437
|
+
@locked_interface.expects(:save_settings).once.in_sequence(open_seq)
|
438
|
+
@session.expects(:unlock_machine).once.in_sequence(open_seq)
|
439
|
+
|
440
|
+
@instance.with_open_session do |session|
|
441
|
+
session.stubs(:state).returns(:open)
|
442
|
+
|
443
|
+
@instance.with_open_session do |subsession|
|
444
|
+
assert_equal session, subsession
|
445
|
+
end
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
context "state methods" do
|
451
|
+
should "check the proper results" do
|
452
|
+
methods = {
|
453
|
+
:starting? => :starting,
|
454
|
+
:running? => :running,
|
455
|
+
:powered_off? => :powered_off,
|
456
|
+
:paused? => :paused,
|
457
|
+
:saved? => :saved,
|
458
|
+
:aborted? => :aborted
|
459
|
+
}
|
460
|
+
|
461
|
+
methods.each do |method, value|
|
462
|
+
@instance.stubs(:state).returns(value)
|
463
|
+
assert @instance.send(method)
|
464
|
+
|
465
|
+
@instance.stubs(:state).returns(:nope)
|
466
|
+
assert !@instance.send(method)
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
context "exporting" do
|
472
|
+
setup do
|
473
|
+
@path = "foo.rb"
|
474
|
+
@appliance = mock("appliance")
|
475
|
+
@appliance.stubs(:path=)
|
476
|
+
@appliance.stubs(:add_machine)
|
477
|
+
|
478
|
+
VirtualBox::Appliance.stubs(:new).returns(@appliance)
|
479
|
+
end
|
480
|
+
|
481
|
+
should "create a new appliance with path and export" do
|
482
|
+
result = mock("result")
|
483
|
+
options = mock("options")
|
484
|
+
VirtualBox::Appliance.expects(:new).returns(@appliance)
|
485
|
+
@appliance.expects(:path=).with(@path)
|
486
|
+
@appliance.expects(:add_machine).with(@instance, options)
|
487
|
+
@appliance.expects(:export)
|
488
|
+
|
489
|
+
@instance.export(@path, options)
|
490
|
+
end
|
491
|
+
|
492
|
+
should "forward any block to the appliance export method" do
|
493
|
+
proc = mock("proc")
|
494
|
+
@appliance.expects(:export).yields(proc)
|
495
|
+
proc.expects(:call)
|
496
|
+
|
497
|
+
@instance.export(@path) do |yielded_proc|
|
498
|
+
yielded_proc.call
|
499
|
+
end
|
500
|
+
end
|
501
|
+
end
|
502
|
+
|
503
|
+
context "taking a snapshot" do
|
504
|
+
setup do
|
505
|
+
setup_session_mocks
|
506
|
+
|
507
|
+
@progress = mock("progress")
|
508
|
+
@progress.stubs(:wait)
|
509
|
+
|
510
|
+
@console = mock("console")
|
511
|
+
@console.stubs(:take_snapshot).returns(@progress)
|
512
|
+
@session.stubs(:console).returns(@console)
|
513
|
+
|
514
|
+
@instance.stubs(:with_open_session).yields(@session)
|
515
|
+
end
|
516
|
+
|
517
|
+
should "take a snapshot on the console and wait" do
|
518
|
+
name = "foo"
|
519
|
+
description = "baz"
|
520
|
+
@console.expects(:take_snapshot).with(name, description).returns(@progress)
|
521
|
+
@instance.take_snapshot(name, description)
|
522
|
+
end
|
523
|
+
|
524
|
+
should "wait and pass in the given block, if given" do
|
525
|
+
foo = mock("foo")
|
526
|
+
@progress.expects(:wait).yields(foo)
|
527
|
+
foo.expects(:called).once
|
528
|
+
|
529
|
+
@instance.take_snapshot(nil, nil) do |obj|
|
530
|
+
obj.called
|
531
|
+
end
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
context "root snapshot" do
|
536
|
+
should "return nil if the current snapshot is nil" do
|
537
|
+
@instance.stubs(:current_snapshot).returns(nil)
|
538
|
+
assert_nil @instance.root_snapshot
|
539
|
+
end
|
540
|
+
|
541
|
+
should "return the proper root snapshot" do
|
542
|
+
root = mock("root_snapshot")
|
543
|
+
root.stubs(:parent).returns(nil)
|
544
|
+
|
545
|
+
parent = mock("parent")
|
546
|
+
parent.stubs(:parent).returns(root)
|
547
|
+
|
548
|
+
snapshot = mock("snapshot")
|
549
|
+
snapshot.stubs(:parent).returns(parent)
|
550
|
+
|
551
|
+
@instance.stubs(:current_snapshot).returns(snapshot)
|
552
|
+
assert_equal root, @instance.root_snapshot
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
context "finding a snapshot" do
|
557
|
+
should "return nil if there is no root snapshot" do
|
558
|
+
@instance.stubs(:current_snapshot).returns(nil)
|
559
|
+
assert_nil @instance.find_snapshot("foo")
|
560
|
+
end
|
561
|
+
|
562
|
+
should "return nil if the snapshot is not found" do
|
563
|
+
snapshot = mock("snapshot")
|
564
|
+
snapshot.stubs(:name).returns("wrong")
|
565
|
+
snapshot.stubs(:uuid).returns(nil)
|
566
|
+
snapshot.stubs(:children).returns([])
|
567
|
+
@instance.stubs(:root_snapshot).returns(snapshot)
|
568
|
+
|
569
|
+
assert_nil @instance.find_snapshot("bar")
|
570
|
+
end
|
571
|
+
|
572
|
+
# TODO: Testing traversing the snapshot tree. Too many mocks :S
|
573
|
+
end
|
574
|
+
|
575
|
+
context "getting the boot order" do
|
576
|
+
setup do
|
577
|
+
@max = 4
|
578
|
+
@global = mock("global")
|
579
|
+
@sys_props = mock("system_properties")
|
580
|
+
|
581
|
+
@sys_props.stubs(:max_boot_position).returns(@max)
|
582
|
+
@global.stubs(:system_properties).returns(@sys_props)
|
583
|
+
VirtualBox::Global.stubs(:global).returns(@global)
|
584
|
+
end
|
585
|
+
|
586
|
+
should "get the boot order for each up to max" do
|
587
|
+
expected = (1..@max).inject([]) do |acc, pos|
|
588
|
+
result = mock("p#{pos}")
|
589
|
+
@interface.expects(:get_boot_order).with(pos).returns(result)
|
590
|
+
acc << result
|
591
|
+
acc
|
592
|
+
end
|
593
|
+
|
594
|
+
assert_equal expected, @instance.get_boot_order(@interface, nil)
|
595
|
+
end
|
596
|
+
end
|
597
|
+
|
598
|
+
context "setting the boot order" do
|
599
|
+
setup do
|
600
|
+
@max = 4
|
601
|
+
@global = mock("global")
|
602
|
+
@sys_props = mock("system_properties")
|
603
|
+
|
604
|
+
@sys_props.stubs(:max_boot_position).returns(@max)
|
605
|
+
@global.stubs(:system_properties).returns(@sys_props)
|
606
|
+
VirtualBox::Global.stubs(:global).returns(@global)
|
607
|
+
end
|
608
|
+
|
609
|
+
should "set the boot order for each up to max" do
|
610
|
+
expected = (1..@max).inject([]) do |acc, pos|
|
611
|
+
result = mock("p#{pos}")
|
612
|
+
@interface.expects(:set_boot_order).with(pos, result)
|
613
|
+
acc << result
|
614
|
+
acc
|
615
|
+
end
|
616
|
+
|
617
|
+
@instance.set_boot_order(@interface, nil, expected)
|
618
|
+
end
|
619
|
+
|
620
|
+
should "set the boot order for max items even if value has less than the proper amount" do
|
621
|
+
items = [1, 2]
|
622
|
+
items.concat(Array.new(@max - items.size))
|
623
|
+
items.each_with_index do |item, i|
|
624
|
+
@interface.expects(:set_boot_order).with(i + 1, item).once
|
625
|
+
end
|
626
|
+
|
627
|
+
assert_equal @max, items.size # sanity
|
628
|
+
|
629
|
+
@instance.set_boot_order(@interface, nil, items)
|
630
|
+
end
|
631
|
+
end
|
632
|
+
end
|
633
|
+
end
|