Changeset 50397 in vbox
- Timestamp:
- Feb 10, 2014 4:04:15 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/testcase/tstVBoxAPI.cpp
r50390 r50397 25 25 #include <VBox/com/Guid.h> 26 26 #include <VBox/com/ErrorInfo.h> 27 #include <VBox/com/errorprint.h> 27 28 #include <VBox/com/VirtualBox.h> 28 29 #include <VBox/sup.h> … … 54 55 55 56 56 static voidtstApiIVirtualBox(IVirtualBox *pVBox)57 static BOOL tstApiIVirtualBox(IVirtualBox *pVBox) 57 58 { 58 HRESULT hrc;59 HRESULT rc; 59 60 Bstr bstrTmp; 60 61 ULONG ulTmp; 61 62 62 63 RTTestSub(g_hTest, "IVirtualBox::version"); 63 hrc = pVBox->COMGETTER(Version)(bstrTmp.asOutParam());64 if (SUCCEEDED( hrc))64 CHECK_ERROR(pVBox, COMGETTER(Version)(bstrTmp.asOutParam())); 65 if (SUCCEEDED(rc)) 65 66 RTTestPassed(g_hTest, "IVirtualBox::version"); 66 67 else 67 RTTestFailed(g_hTest, "%d: IVirtualBox::version failed with return value %Rhrc.", __LINE__, hrc);68 RTTestFailed(g_hTest, "%d: IVirtualBox::version failed", __LINE__); 68 69 69 70 RTTestSub(g_hTest, "IVirtualBox::versionNormalized"); 70 hrc = pVBox->COMGETTER(VersionNormalized)(bstrTmp.asOutParam());71 if (SUCCEEDED( hrc))71 CHECK_ERROR(pVBox, COMGETTER(VersionNormalized)(bstrTmp.asOutParam())); 72 if (SUCCEEDED(rc)) 72 73 RTTestPassed(g_hTest, "IVirtualBox::versionNormalized"); 73 74 else 74 RTTestFailed(g_hTest, "%d: IVirtualBox::versionNormalized failed with return value %Rhrc.", __LINE__, hrc);75 RTTestFailed(g_hTest, "%d: IVirtualBox::versionNormalized failed", __LINE__); 75 76 76 77 RTTestSub(g_hTest, "IVirtualBox::revision"); 77 hrc = pVBox->COMGETTER(Revision)(&ulTmp);78 if (SUCCEEDED( hrc))78 CHECK_ERROR(pVBox, COMGETTER(Revision)(&ulTmp)); 79 if (SUCCEEDED(rc)) 79 80 RTTestPassed(g_hTest, "IVirtualBox::revision"); 80 81 else 81 RTTestFailed(g_hTest, "%d: IVirtualBox::revision failed with return value %Rhrc.", __LINE__, hrc);82 RTTestFailed(g_hTest, "%d: IVirtualBox::revision failed", __LINE__); 82 83 83 84 RTTestSub(g_hTest, "IVirtualBox::packageType"); 84 hrc = pVBox->COMGETTER(PackageType)(bstrTmp.asOutParam());85 if (SUCCEEDED( hrc))85 CHECK_ERROR(pVBox, COMGETTER(PackageType)(bstrTmp.asOutParam())); 86 if (SUCCEEDED(rc)) 86 87 RTTestPassed(g_hTest, "IVirtualBox::packageType"); 87 88 else 88 RTTestFailed(g_hTest, "%d: IVirtualBox::packageType failed with return value %Rhrc.", __LINE__, hrc);89 RTTestFailed(g_hTest, "%d: IVirtualBox::packageType failed", __LINE__); 89 90 90 91 RTTestSub(g_hTest, "IVirtualBox::APIVersion"); 91 hrc = pVBox->COMGETTER(APIVersion)(bstrTmp.asOutParam());92 if (SUCCEEDED( hrc))92 CHECK_ERROR(pVBox, COMGETTER(APIVersion)(bstrTmp.asOutParam())); 93 if (SUCCEEDED(rc)) 93 94 RTTestPassed(g_hTest, "IVirtualBox::APIVersion"); 94 95 else 95 RTTestFailed(g_hTest, "%d: IVirtualBox::APIVersion failed with return value %Rhrc.", __LINE__, hrc);96 RTTestFailed(g_hTest, "%d: IVirtualBox::APIVersion failed", __LINE__); 96 97 97 98 RTTestSub(g_hTest, "IVirtualBox::homeFolder"); 98 hrc = pVBox->COMGETTER(HomeFolder)(bstrTmp.asOutParam());99 if (SUCCEEDED( hrc))99 CHECK_ERROR(pVBox, COMGETTER(HomeFolder)(bstrTmp.asOutParam())); 100 if (SUCCEEDED(rc)) 100 101 RTTestPassed(g_hTest, "IVirtualBox::homeFolder"); 101 102 else 102 RTTestFailed(g_hTest, "%d: IVirtualBox::homeFolder failed with return value %Rhrc.", __LINE__, hrc);103 RTTestFailed(g_hTest, "%d: IVirtualBox::homeFolder failed", __LINE__); 103 104 104 105 RTTestSub(g_hTest, "IVirtualBox::settingsFilePath"); 105 hrc = pVBox->COMGETTER(SettingsFilePath)(bstrTmp.asOutParam());106 if (SUCCEEDED( hrc))106 CHECK_ERROR(pVBox, COMGETTER(SettingsFilePath)(bstrTmp.asOutParam())); 107 if (SUCCEEDED(rc)) 107 108 RTTestPassed(g_hTest, "IVirtualBox::settingsFilePath"); 108 109 else 109 RTTestFailed(g_hTest, "%d: IVirtualBox::settingsFilePath failed with return value %Rhrc.", __LINE__, hrc);110 RTTestFailed(g_hTest, "%d: IVirtualBox::settingsFilePath failed", __LINE__); 110 111 111 112 com::SafeIfaceArray<IGuestOSType> guestOSTypes; 112 113 RTTestSub(g_hTest, "IVirtualBox::guestOSTypes"); 113 hrc = pVBox->COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(guestOSTypes));114 if (SUCCEEDED( hrc))114 CHECK_ERROR(pVBox, COMGETTER(GuestOSTypes)(ComSafeArrayAsOutParam(guestOSTypes))); 115 if (SUCCEEDED(rc)) 115 116 RTTestPassed(g_hTest, "IVirtualBox::guestOSTypes"); 116 117 else 117 RTTestFailed(g_hTest, "%d: IVirtualBox::guestOSTypes failed with return value %Rhrc.", __LINE__, hrc);118 RTTestFailed(g_hTest, "%d: IVirtualBox::guestOSTypes failed", __LINE__); 118 119 119 120 /** Create VM */ 120 121 RTTestSub(g_hTest, "IVirtualBox::CreateMachine"); 121 122 ComPtr<IMachine> ptrMachine; 122 Bstr tstMachineName = " TestMachine";123 Bstr tstMachineName = "tstVBoxAPI test VM"; 123 124 com::SafeArray<BSTR> groups; 124 125 /** Default VM settings */ 125 hrc = pVBox->CreateMachine(NULL, /** Settings */126 tstMachineName.raw(), /** Name */127 ComSafeArrayAsInParam(groups), /** Groups */128 NULL, /** OS Type */129 NULL, /** Create flags */130 ptrMachine.asOutParam());/** Machine */131 if (SUCCEEDED( hrc))126 CHECK_ERROR(pVBox, CreateMachine(NULL, /** Settings */ 127 tstMachineName.raw(), /** Name */ 128 ComSafeArrayAsInParam(groups), /** Groups */ 129 NULL, /** OS Type */ 130 NULL, /** Create flags */ 131 ptrMachine.asOutParam())); /** Machine */ 132 if (SUCCEEDED(rc)) 132 133 RTTestPassed(g_hTest, "IVirtualBox::CreateMachine"); 133 134 else 134 135 { 135 RTTestFailed(g_hTest, "%d: IVirtualBox::CreateMachine failed with return value %Rhrc.", __LINE__, hrc);136 return ;136 RTTestFailed(g_hTest, "%d: IVirtualBox::CreateMachine failed", __LINE__); 137 return FALSE; 137 138 } 138 139 139 140 RTTestSub(g_hTest, "IVirtualBox::RegisterMachine"); 140 hrc = pVBox->RegisterMachine(ptrMachine);141 if (SUCCEEDED( hrc))141 CHECK_ERROR(pVBox, RegisterMachine(ptrMachine)); 142 if (SUCCEEDED(rc)) 142 143 RTTestPassed(g_hTest, "IVirtualBox::RegisterMachine"); 143 144 else 144 145 { 145 RTTestFailed(g_hTest, "%d: IVirtualBox::RegisterMachine failed with return value %Rhrc.", __LINE__, hrc);146 return ;146 RTTestFailed(g_hTest, "%d: IVirtualBox::RegisterMachine failed", __LINE__); 147 return FALSE; 147 148 } 148 149 149 150 ComPtr<IHost> host; 150 151 RTTestSub(g_hTest, "IVirtualBox::host"); 151 hrc = pVBox->COMGETTER(Host)(host.asOutParam());152 if (SUCCEEDED( hrc))152 CHECK_ERROR(pVBox, COMGETTER(Host)(host.asOutParam())); 153 if (SUCCEEDED(rc)) 153 154 { 154 155 /** @todo Add IHost testing here. */ … … 156 157 } 157 158 else 158 RTTestFailed(g_hTest, "%d: IVirtualBox::host failed with return value %Rhrc.", __LINE__, hrc);159 RTTestFailed(g_hTest, "%d: IVirtualBox::host failed", __LINE__); 159 160 160 161 ComPtr<ISystemProperties> sysprop; 161 162 RTTestSub(g_hTest, "IVirtualBox::systemProperties"); 162 hrc = pVBox->COMGETTER(SystemProperties)(sysprop.asOutParam());163 if (SUCCEEDED( hrc))163 CHECK_ERROR(pVBox, COMGETTER(SystemProperties)(sysprop.asOutParam())); 164 if (SUCCEEDED(rc)) 164 165 { 165 166 /** @todo Add ISystemProperties testing here. */ … … 167 168 } 168 169 else 169 RTTestFailed(g_hTest, "%d: IVirtualBox::systemProperties failed with return value %Rhrc.", __LINE__, hrc);170 RTTestFailed(g_hTest, "%d: IVirtualBox::systemProperties failed", __LINE__); 170 171 171 172 com::SafeIfaceArray<IMachine> machines; 172 173 RTTestSub(g_hTest, "IVirtualBox::machines"); 173 hrc = pVBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));174 if (SUCCEEDED( hrc))174 CHECK_ERROR(pVBox, COMGETTER(Machines)(ComSafeArrayAsOutParam(machines))); 175 if (SUCCEEDED(rc)) 175 176 { 176 177 bool bFound = FALSE; … … 180 181 { 181 182 Bstr tmpName; 182 hrc = machines[i]->COMGETTER(Name)(tmpName.asOutParam());183 if (SUCCEEDED( hrc))183 CHECK_ERROR(machines[i], COMGETTER(Name)(tmpName.asOutParam())); 184 if (SUCCEEDED(rc)) 184 185 { 185 186 if (tmpName == tstMachineName) … … 198 199 } 199 200 else 200 RTTestFailed(g_hTest, "%d: IVirtualBox::machines failed with return value %Rhrc.", __LINE__, hrc);201 RTTestFailed(g_hTest, "%d: IVirtualBox::machines failed", __LINE__); 201 202 202 203 #if 0 /** Not yet implemented */ 203 204 com::SafeIfaceArray<ISharedFolder> sharedFolders; 204 205 RTTestSub(g_hTest, "IVirtualBox::sharedFolders"); 205 hrc = pVBox->COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sharedFolders));206 if (SUCCEEDED( hrc))206 CHECK_ERROR(pVBox, COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(sharedFolders))); 207 if (SUCCEEDED(rc)) 207 208 { 208 209 /** @todo Add ISharedFolders testing here. */ … … 210 211 } 211 212 else 212 RTTestFailed(g_hTest, "%d: IVirtualBox::sharedFolders failed with return value %Rhrc.", __LINE__, hrc);213 RTTestFailed(g_hTest, "%d: IVirtualBox::sharedFolders failed", __LINE__); 213 214 #endif 214 215 215 216 com::SafeIfaceArray<IMedium> hardDisks; 216 217 RTTestSub(g_hTest, "IVirtualBox::hardDisks"); 217 hrc = pVBox->COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hardDisks));218 if (SUCCEEDED( hrc))218 CHECK_ERROR(pVBox, COMGETTER(HardDisks)(ComSafeArrayAsOutParam(hardDisks))); 219 if (SUCCEEDED(rc)) 219 220 { 220 221 /** @todo Add hardDisks testing here. */ … … 222 223 } 223 224 else 224 RTTestFailed(g_hTest, "%d: IVirtualBox::hardDisks failed with return value %Rhrc.", __LINE__, hrc);225 RTTestFailed(g_hTest, "%d: IVirtualBox::hardDisks failed", __LINE__); 225 226 226 227 com::SafeIfaceArray<IMedium> DVDImages; 227 228 RTTestSub(g_hTest, "IVirtualBox::DVDImages"); 228 hrc = pVBox->COMGETTER(DVDImages)(ComSafeArrayAsOutParam(DVDImages));229 if (SUCCEEDED( hrc))229 CHECK_ERROR(pVBox, COMGETTER(DVDImages)(ComSafeArrayAsOutParam(DVDImages))); 230 if (SUCCEEDED(rc)) 230 231 { 231 232 /** @todo Add DVDImages testing here. */ … … 233 234 } 234 235 else 235 RTTestFailed(g_hTest, "%d: IVirtualBox::DVDImages failed with return value %Rhrc.", __LINE__, hrc);236 RTTestFailed(g_hTest, "%d: IVirtualBox::DVDImages failed", __LINE__); 236 237 237 238 com::SafeIfaceArray<IMedium> floppyImages; 238 239 RTTestSub(g_hTest, "IVirtualBox::floppyImages"); 239 hrc = pVBox->COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppyImages));240 if (SUCCEEDED( hrc))240 CHECK_ERROR(pVBox, COMGETTER(FloppyImages)(ComSafeArrayAsOutParam(floppyImages))); 241 if (SUCCEEDED(rc)) 241 242 { 242 243 /** @todo Add floppyImages testing here. */ … … 244 245 } 245 246 else 246 RTTestFailed(g_hTest, "%d: IVirtualBox::floppyImages failed with return value %Rhrc.", __LINE__, hrc);247 RTTestFailed(g_hTest, "%d: IVirtualBox::floppyImages failed", __LINE__); 247 248 248 249 com::SafeIfaceArray<IProgress> progressOperations; 249 250 RTTestSub(g_hTest, "IVirtualBox::progressOperations"); 250 hrc = pVBox->COMGETTER(ProgressOperations)(ComSafeArrayAsOutParam(progressOperations));251 if (SUCCEEDED( hrc))251 CHECK_ERROR(pVBox, COMGETTER(ProgressOperations)(ComSafeArrayAsOutParam(progressOperations))); 252 if (SUCCEEDED(rc)) 252 253 { 253 254 /** @todo Add IProgress testing here. */ … … 255 256 } 256 257 else 257 RTTestFailed(g_hTest, "%d: IVirtualBox::progressOperations failed with return value %Rhrc.", __LINE__, hrc);258 RTTestFailed(g_hTest, "%d: IVirtualBox::progressOperations failed", __LINE__); 258 259 259 260 ComPtr<IPerformanceCollector> performanceCollector; 260 261 RTTestSub(g_hTest, "IVirtualBox::performanceCollector"); 261 hrc = pVBox->COMGETTER(PerformanceCollector)(performanceCollector.asOutParam());262 if (SUCCEEDED( hrc))262 CHECK_ERROR(pVBox, COMGETTER(PerformanceCollector)(performanceCollector.asOutParam())); 263 if (SUCCEEDED(rc)) 263 264 { 264 265 /** @todo Add IPerformanceCollector testing here. */ … … 266 267 } 267 268 else 268 RTTestFailed(g_hTest, "%d: IVirtualBox::performanceCollector failed with return value %Rhrc.", __LINE__, hrc);269 RTTestFailed(g_hTest, "%d: IVirtualBox::performanceCollector failed", __LINE__); 269 270 270 271 com::SafeIfaceArray<IDHCPServer> DHCPServers; 271 272 RTTestSub(g_hTest, "IVirtualBox::DHCPServers"); 272 hrc = pVBox->COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(DHCPServers));273 if (SUCCEEDED( hrc))273 CHECK_ERROR(pVBox, COMGETTER(DHCPServers)(ComSafeArrayAsOutParam(DHCPServers))); 274 if (SUCCEEDED(rc)) 274 275 { 275 276 /** @todo Add IDHCPServers testing here. */ … … 277 278 } 278 279 else 279 RTTestFailed(g_hTest, "%d: IVirtualBox::DHCPServers failed with return value %Rhrc.", __LINE__, hrc);280 RTTestFailed(g_hTest, "%d: IVirtualBox::DHCPServers failed", __LINE__); 280 281 281 282 com::SafeIfaceArray<INATNetwork> NATNetworks; 282 283 RTTestSub(g_hTest, "IVirtualBox::NATNetworks"); 283 hrc = pVBox->COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(NATNetworks));284 if (SUCCEEDED( hrc))284 CHECK_ERROR(pVBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(NATNetworks))); 285 if (SUCCEEDED(rc)) 285 286 { 286 287 /** @todo Add INATNetworks testing here. */ … … 288 289 } 289 290 else 290 RTTestFailed(g_hTest, "%d: IVirtualBox::NATNetworks failed with return value %Rhrc.", __LINE__, hrc);291 RTTestFailed(g_hTest, "%d: IVirtualBox::NATNetworks failed", __LINE__); 291 292 292 293 ComPtr<IEventSource> eventSource; 293 294 RTTestSub(g_hTest, "IVirtualBox::eventSource"); 294 hrc = pVBox->COMGETTER(EventSource)(eventSource.asOutParam());295 if (SUCCEEDED( hrc))295 CHECK_ERROR(pVBox, COMGETTER(EventSource)(eventSource.asOutParam())); 296 if (SUCCEEDED(rc)) 296 297 { 297 298 /** @todo Add IEventSource testing here. */ … … 299 300 } 300 301 else 301 RTTestFailed(g_hTest, "%d: IVirtualBox::eventSource failed with return value %Rhrc.", __LINE__, hrc);302 RTTestFailed(g_hTest, "%d: IVirtualBox::eventSource failed", __LINE__); 302 303 303 304 ComPtr<IExtPackManager> extensionPackManager; 304 305 RTTestSub(g_hTest, "IVirtualBox::extensionPackManager"); 305 hrc = pVBox->COMGETTER(ExtensionPackManager)(extensionPackManager.asOutParam());306 if (SUCCEEDED( hrc))306 CHECK_ERROR(pVBox, COMGETTER(ExtensionPackManager)(extensionPackManager.asOutParam())); 307 if (SUCCEEDED(rc)) 307 308 { 308 309 /** @todo Add IExtPackManager testing here. */ … … 310 311 } 311 312 else 312 RTTestFailed(g_hTest, "%d: IVirtualBox::extensionPackManager failed with return value %Rhrc.", __LINE__, hrc);313 RTTestFailed(g_hTest, "%d: IVirtualBox::extensionPackManager failed", __LINE__); 313 314 314 315 com::SafeArray<BSTR> internalNetworks; 315 316 RTTestSub(g_hTest, "IVirtualBox::internalNetworks"); 316 hrc = pVBox->COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks));317 if (SUCCEEDED( hrc))317 CHECK_ERROR(pVBox, COMGETTER(InternalNetworks)(ComSafeArrayAsOutParam(internalNetworks))); 318 if (SUCCEEDED(rc)) 318 319 { 319 320 RTTestPassed(g_hTest, "IVirtualBox::internalNetworks"); 320 321 } 321 322 else 322 RTTestFailed(g_hTest, "%d: IVirtualBox::internalNetworks failed with return value %Rhrc.", __LINE__, hrc);323 RTTestFailed(g_hTest, "%d: IVirtualBox::internalNetworks failed", __LINE__); 323 324 324 325 com::SafeArray<BSTR> genericNetworkDrivers; 325 326 RTTestSub(g_hTest, "IVirtualBox::genericNetworkDrivers"); 326 hrc = pVBox->COMGETTER(GenericNetworkDrivers)(ComSafeArrayAsOutParam(genericNetworkDrivers));327 if (SUCCEEDED( hrc))327 CHECK_ERROR(pVBox, COMGETTER(GenericNetworkDrivers)(ComSafeArrayAsOutParam(genericNetworkDrivers))); 328 if (SUCCEEDED(rc)) 328 329 { 329 330 RTTestPassed(g_hTest, "IVirtualBox::genericNetworkDrivers"); 330 331 } 331 332 else 332 RTTestFailed(g_hTest, "%d: IVirtualBox::genericNetworkDrivers failed with return value %Rhrc.", __LINE__, hrc); 333 RTTestFailed(g_hTest, "%d: IVirtualBox::genericNetworkDrivers failed", __LINE__); 334 335 /** Delete created VM and its files */ 336 ComPtr<IMachine> machine; 337 CHECK_ERROR_RET(pVBox, FindMachine(Bstr(tstMachineName).raw(), machine.asOutParam()), FALSE); 338 SafeIfaceArray<IMedium> media; 339 CHECK_ERROR_RET(machine, Unregister(CleanupMode_DetachAllReturnHardDisksOnly, 340 ComSafeArrayAsOutParam(media)), FALSE); 341 ComPtr<IProgress> progress; 342 CHECK_ERROR_RET(machine, DeleteConfig(ComSafeArrayAsInParam(media), progress.asOutParam()), FALSE); 343 CHECK_ERROR_RET(progress, WaitForCompletion(-1), FALSE); 344 345 return TRUE; 333 346 } 334 347
Note:
See TracChangeset
for help on using the changeset viewer.