VirtualBox

Changeset 60063 in vbox for trunk/src/VBox/Main/testcase


Ignore:
Timestamp:
Mar 16, 2016 3:00:06 PM (9 years ago)
Author:
vboxsync
Message:

Frontends etc: convert more code to use VirtualBoxClient instead of direct creation of VirtualBox instances, to improve error handling

Location:
trunk/src/VBox/Main/testcase
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r55969 r60063  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    223223    ////////////////////////////////////////////////////////////////////////////
    224224
     225    ComPtr<IVirtualBoxClient> virtualBoxClient;
    225226    ComPtr<IVirtualBox> virtualBox;
    226227    ComPtr<ISession> session;
     
    242243
    243244    RTPrintf("Creating VirtualBox object...\n");
    244     rc = virtualBox.createLocalObject(CLSID_VirtualBox);
     245    rc = virtualBoxClient.createInprocObject(CLSID_VirtualBoxClient);
     246    if (SUCCEEDED(rc))
     247        rc = virtualBoxClient->COMGETTER(VirtualBox)(virtualBox.asOutParam());
    245248    if (FAILED(rc))
    246249        RTPrintf("ERROR: failed to create the VirtualBox object!\n");
     
    303306
    304307            RTPrintf("Creating one more VirtualBox object...\n");
    305             CHECK_RC(virtualBox2.createLocalObject(CLSID_VirtualBox));
     308            CHECK_RC(virtualBoxClient->COMGETTER(virtualBox2.asOutParam()));
    306309            if (FAILED(rc))
    307310            {
  • trunk/src/VBox/Main/testcase/tstMediumLock.cpp

    r55969 r60063  
    55
    66/*
    7  * Copyright (C) 2013-2015 Oracle Corporation
     7 * Copyright (C) 2013-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7373
    7474    bool fComInit = false;
     75    ComPtr<IVirtualBoxClient> pVirtualBoxClient;
    7576    ComPtr<IVirtualBox> pVirtualBox;
    7677    char szPathTemp[RTPATH_MAX] = "";
     
    99100
    100101        RTTestSub(hTest, "Getting VirtualBox reference");
    101         TEST_COM_SUCCESS(hTest, pVirtualBox.createLocalObject(CLSID_VirtualBox), "vbox reference");
     102        TEST_COM_SUCCESS(hTest, pVirtualBoxClient.createInprocObject(CLSID_VirtualBoxClient), "vboxclient reference");
     103        TEST_COM_SUCCESS(hTest, pVirtualBoxClient->COMGETTER(VirtualBox)(pVirtualBox.asOutParam()), "vbox reference");
    102104    }
    103105
     
    279281
    280282    pVirtualBox.setNull();
     283    pVirtualBoxClient.setNull();
    281284
    282285    /* Make sure that there are no object references alive here, XPCOM does
  • trunk/src/VBox/Main/testcase/tstOVF.cpp

    r50351 r60063  
    66
    77/*
    8  * Copyright (C) 2010-2014 Oracle Corporation
     8 * Copyright (C) 2010-2016 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    296296    std::list<Guid> llMachinesCreated;
    297297
     298    ComPtr<IVirtualBoxClient> pVirtualBoxClient;
    298299    ComPtr<IVirtualBox> pVirtualBox;
    299300
     
    307308
    308309        RTPrintf("Creating VirtualBox object...\n");
    309         rc = pVirtualBox.createLocalObject(CLSID_VirtualBox);
     310        rc = pVirtualBoxClient.createInprocObject(CLSID_VirtualBoxClient);
     311        if (SUCCEEDED(rc))
     312            rc = pVirtualBoxClient->COMGETTER(VirtualBox)(pVirtualBox.asOutParam());
    310313        if (FAILED(rc)) throw MyError(rc, "failed to create the VirtualBox object!\n");
    311314
  • trunk/src/VBox/Main/testcase/tstVBoxAPI.cpp

    r57358 r60063  
    55
    66/*
    7  * Copyright (C) 2006-2014 Oracle Corporation
     7 * Copyright (C) 2006-2015 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    369369    if (SUCCEEDED(hrc))
    370370    {
     371        ComPtr<IVirtualBoxClient> ptrVBoxClient;
    371372        ComPtr<IVirtualBox> ptrVBox;
    372         hrc = TST_COM_EXPR(ptrVBox.createLocalObject(CLSID_VirtualBox));
     373        hrc = TST_COM_EXPR(ptrVBoxClient.createInprocObject(CLSID_VirtualBoxClient));
     374        if (SUCCEEDED(hrc))
     375            hrc = TST_COM_EXPR(ptrVBoxClient->COMGETTER(VirtualBox)(ptrVBox.asOutParam()));
    373376        if (SUCCEEDED(hrc))
    374377        {
  • trunk/src/VBox/Main/testcase/tstVBoxAPIPerf.cpp

    r57358 r60063  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2016 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    211211    if (SUCCEEDED(hrc))
    212212    {
     213        ComPtr<IVirtualBoxClient> ptrVBoxClient;
    213214        ComPtr<IVirtualBox> ptrVBox;
    214         hrc = TST_COM_EXPR(ptrVBox.createLocalObject(CLSID_VirtualBox));
     215        hrc = TST_COM_EXPR(ptrVBoxClient.createInprocObject(CLSID_VirtualBoxClient));
     216        if (SUCCEEDED(hrc))
     217            hrc = TST_COM_EXPR(ptrVBoxClient->COMGETTER(VirtualBox)(ptrVBox.asOutParam()));
    215218        if (SUCCEEDED(hrc))
    216219        {
  • trunk/src/VBox/Main/testcase/tstVBoxAPIWin.cpp

    r50339 r60063  
    1313
    1414/*
    15  * Copyright (C) 2006-2014 Oracle Corporation
     15 * Copyright (C) 2006-2016 Oracle Corporation
    1616 *
    1717 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    199199            rc = CoCreateInstance(CLSID_Session,        /* the VirtualBox base object */
    200200                                  NULL,                 /* no aggregation */
    201                                   CLSCTX_INPROC_SERVER, /* the object lives in a server process on this machine */
     201                                  CLSCTX_INPROC_SERVER, /* the object lives in the current process */
    202202                                  IID_ISession,         /* IID of the interface */
    203203                                  (void**)&session);
     
    259259{
    260260    HRESULT rc;
     261    IVirtualBoxClient *virtualBoxClient;
    261262    IVirtualBox *virtualBox;
    262263
     
    267268
    268269        /* Instantiate the VirtualBox root object. */
    269         rc = CoCreateInstance(CLSID_VirtualBox,       /* the VirtualBox base object */
     270        rc = CoCreateInstance(CLSID_VirtualBoxClient, /* the VirtualBoxClient object */
    270271                              NULL,                   /* no aggregation */
    271                               CLSCTX_LOCAL_SERVER,    /* the object lives in a server process on this machine */
    272                               IID_IVirtualBox,        /* IID of the interface */
    273                               (void**)&virtualBox);
     272                              CLSCTX_INPROC_SERVER,   /* the object lives in the current process */
     273                              IID_IVirtualBoxClient,  /* IID of the interface */
     274                              (void**)&virtualBoxClient);
     275        if (SUCCEEDED(rc))
     276            virtualBoxClient->get_VirtualBox(&virtualBox);
    274277
    275278        if (!SUCCEEDED(rc))
     
    288291        /* Release the VirtualBox object. */
    289292        virtualBox->Release();
     293        virtualBoxClient->Release();
    290294
    291295    } while (0);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette