VirtualBox

Changeset 3834 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 25, 2007 1:34:36 PM (17 years ago)
Author:
vboxsync
Message:

Main/testcase: More IUnknown Identity tests.

File:
1 edited

Legend:

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

    r3668 r3834  
    252252    }
    253253
    254 #if 0
     254#if 1
    255255    // IUnknown identity test
    256256    ////////////////////////////////////////////////////////////////////////////
    257257    {
    258         ComPtr <IVirtualBox> virtualBox2;
    259 
    260         printf ("Creating one more VirtualBox object...\n");
    261         CHECK_RC (virtualBox2.createLocalObject (CLSID_VirtualBox));
    262         if (FAILED (rc))
    263         {
    264             CHECK_ERROR_NOCALL();
    265             break;
    266         }
    267 
    268         printf ("IVirtualBox(virualBox)=%p IVirtualBox(virualBox2)=%p\n",
    269                 (IVirtualBox *) virtualBox, (IVirtualBox *) virtualBox2);
    270 
    271         ComPtr <IUnknown> unk (virtualBox);
    272         ComPtr <IUnknown> unk2;
    273         unk2 = virtualBox2;
    274 
    275         printf ("IUnknown(virualBox)=%p IUnknown(virualBox2)=%p\n",
    276                 (IUnknown *) unk, (IUnknown *) unk2);
    277 
    278         ComPtr <IVirtualBox> vb = unk;
    279         ComPtr <IVirtualBox> vb2 = unk;
    280 
    281         printf ("IVirtualBox(IUnknown(virualBox))=%p IVirtualBox(IUnknown(virualBox2))=%p\n",
    282                 (IVirtualBox *) vb, (IVirtualBox *) vb2);
    283 
    284         printf ("Will be now released (press Enter)...");
    285         getchar();
     258        {
     259            ComPtr <IVirtualBox> virtualBox2;
     260
     261            printf ("Creating one more VirtualBox object...\n");
     262            CHECK_RC (virtualBox2.createLocalObject (CLSID_VirtualBox));
     263            if (FAILED (rc))
     264            {
     265                CHECK_ERROR_NOCALL();
     266                break;
     267            }
     268
     269            printf ("IVirtualBox(virualBox)=%p IVirtualBox(virualBox2)=%p\n",
     270                    (IVirtualBox *) virtualBox, (IVirtualBox *) virtualBox2);
     271            Assert ((IVirtualBox *) virtualBox == (IVirtualBox *) virtualBox2);
     272
     273            ComPtr <IUnknown> unk (virtualBox);
     274            ComPtr <IUnknown> unk2;
     275            unk2 = virtualBox2;
     276
     277            printf ("IUnknown(virualBox)=%p IUnknown(virualBox2)=%p\n",
     278                    (IUnknown *) unk, (IUnknown *) unk2);
     279            Assert ((IUnknown *) unk == (IUnknown *) unk2);
     280
     281            ComPtr <IVirtualBox> vb = unk;
     282            ComPtr <IVirtualBox> vb2 = unk;
     283
     284            printf ("IVirtualBox(IUnknown(virualBox))=%p IVirtualBox(IUnknown(virualBox2))=%p\n",
     285                    (IVirtualBox *) vb, (IVirtualBox *) vb2);
     286            Assert ((IVirtualBox *) vb == (IVirtualBox *) vb2);
     287        }
     288
     289        {
     290            ComPtr <IHost> host;
     291            CHECK_ERROR_BREAK (virtualBox, COMGETTER(Host)(host.asOutParam()));
     292            printf (" IHost(host)=%p\n", (IHost *) host);
     293            ComPtr <IUnknown> unk = host;
     294            printf (" IUnknown(host)=%p\n", (IUnknown *) unk);
     295            ComPtr <IHost> host_copy = unk;
     296            printf (" IHost(host_copy)=%p\n", (IHost *) host_copy);
     297            ComPtr <IUnknown> unk_copy = host_copy;
     298            printf (" IUnknown(host_copy)=%p\n", (IUnknown *) unk_copy);
     299            Assert ((IUnknown *) unk == (IUnknown *) unk_copy);
     300
     301            /* query IUnknown on IUnknown */
     302            ComPtr <IUnknown> unk_copy_copy;
     303            unk_copy.queryInterfaceTo (unk_copy_copy.asOutParam());
     304            printf (" IUnknown(unk_copy)=%p\n", (IUnknown *) unk_copy_copy);
     305            Assert ((IUnknown *) unk_copy == (IUnknown *) unk_copy_copy);
     306            /* query IUnknown on IUnknown in the opposite direction */
     307            unk_copy_copy.queryInterfaceTo (unk_copy.asOutParam());
     308            printf (" IUnknown(unk_copy_copy)=%p\n", (IUnknown *) unk_copy);
     309            Assert ((IUnknown *) unk_copy == (IUnknown *) unk_copy_copy);
     310
     311            /* query IUnknown again after releasing all previous IUnknown instances
     312             * but keeping IHost -- it should remain the same (Identity Rule) */
     313            IUnknown *oldUnk = unk;
     314            unk.setNull();
     315            unk_copy.setNull();
     316            unk_copy_copy.setNull();
     317            unk = host;
     318            printf (" IUnknown(host)=%p\n", (IUnknown *) unk);
     319            Assert (oldUnk == (IUnknown *) unk);
     320        }
     321
     322//        printf ("Will be now released (press Enter)...");
     323//        getchar();
    286324    }
    287325#endif
     
    705743#endif
    706744
    707 #if 1
     745#if 0
    708746    // open a (direct) session
    709747    ///////////////////////////////////////////////////////////////////////////
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