llpermissions_tut.cpp

Go to the documentation of this file.
00001 
00034 #include <tut/tut.h>
00035 #include "linden_common.h"
00036 #include "lltut.h"
00037 #include "message.h"
00038 #include "llpermissions.h"
00039 
00040 
00041 namespace tut
00042 {
00043         struct permission
00044         {
00045         };
00046         typedef test_group<permission> permission_t;
00047         typedef permission_t::object permission_object_t;
00048         tut::permission_t tut_permission("permission");
00049 
00050         template<> template<>
00051         void permission_object_t::test<1>()
00052         {
00053                 LLPermissions permissions;
00054                 LLUUID  uuid = permissions.getCreator();
00055                 LLUUID  uuid1 = permissions.getOwner(); 
00056                 LLUUID  uuid2 = permissions.getGroup();
00057                 LLUUID  uuid3 = permissions.getLastOwner(); 
00058 
00059                 ensure("LLPermission Get Functions failed", (uuid == LLUUID::null && uuid1 == LLUUID::null && 
00060                         uuid2 == LLUUID::null && uuid3 == LLUUID::null));
00061                 ensure("LLPermission Get Functions failed", (permissions.getMaskBase() == PERM_ALL && permissions.getMaskOwner() == PERM_ALL && 
00062                         permissions.getMaskGroup() == PERM_ALL && permissions.getMaskEveryone() == PERM_ALL && permissions.getMaskNextOwner() == PERM_ALL));
00063                 ensure("Ownership functions failed", (permissions.isGroupOwned() == FALSE && permissions.isOwned() == FALSE));
00064         }
00065 
00066         template<> template<>
00067         void permission_object_t::test<2>()
00068         {
00069                 LLPermissions permissions;
00070                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00071                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00072                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00073                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00074                 permissions.init(creator, owner, lastOwner, group);
00075 
00076                 ensure_equals("init/getCreator():failed to return the creator ", creator, permissions.getCreator());    
00077                 ensure_equals("init/getOwner():failed to return the owner ", owner, permissions.getOwner());
00078                 ensure_equals("init/getLastOwner():failed to return the group ", lastOwner, permissions.getLastOwner());        
00079                 ensure_equals("init/getGroup():failed to return the group ", group, permissions.getGroup());    
00080         }
00081 
00082         template<> template<>
00083         void permission_object_t::test<3>()
00084         {
00085                 LLPermissions permissions;
00086                 U32 base = PERM_ALL;
00087                 U32 owner = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
00088                 U32 group = PERM_TRANSFER | PERM_MOVE | PERM_COPY|PERM_MODIFY;
00089                 U32 everyone = PERM_TRANSFER | PERM_MOVE | PERM_MODIFY;
00090                 U32 next = PERM_NONE;
00091 
00092                 U32 fixedbase = base;
00093                 U32 fixedowner = PERM_ITEM_UNRESTRICTED; //owner & fixedbase
00094                 U32 fixedgroup = PERM_ITEM_UNRESTRICTED; // no PERM_MOVE as owner does not have that perm either
00095                 U32 fixedeveryone = PERM_TRANSFER; // no PERM_MOVE. Everyone can never modify.
00096                 U32 fixednext = PERM_NONE;
00097 
00098                 permissions.initMasks(base, owner, everyone, group, next); // will fix perms if not allowed.
00099                 ensure_equals("initMasks/getMaskBase():failed to return the MaskBase ", fixedbase, permissions.getMaskBase());  
00100                 ensure_equals("initMasks/getMaskOwner():failed to return the MaskOwner ", fixedowner, permissions.getMaskOwner());      
00101                 ensure_equals("initMasks/getMaskEveryone():failed to return the MaskGroup ", fixedgroup, permissions.getMaskGroup());   
00102                 ensure_equals("initMasks/getMaskEveryone():failed to return the MaskEveryone ", fixedeveryone, permissions.getMaskEveryone());  
00103                 ensure_equals("initMasks/getMaskNextOwner():failed to return the MaskNext ", fixednext, permissions.getMaskNextOwner());        
00104 
00105                 // explictly set should maintain the values
00106                 permissions.setMaskBase(base); //no fixing
00107                 ensure_equals("setMaskBase/getMaskBase():failed to return the MaskBase ", base, permissions.getMaskBase());     
00108 
00109                 permissions.setMaskOwner(owner);
00110                 ensure_equals("setMaskOwner/getMaskOwner():failed to return the MaskOwner ", owner, permissions.getMaskOwner());        
00111                 
00112                 permissions.setMaskEveryone(everyone);
00113                 ensure_equals("setMaskEveryone/getMaskEveryone():failed to return the MaskEveryone ", everyone, permissions.getMaskEveryone()); 
00114 
00115                 permissions.setMaskGroup(group);
00116                 ensure_equals("setMaskGroup/getMaskEveryone():failed to return the MaskGroup ", group, permissions.getMaskGroup());     
00117 
00118                 permissions.setMaskNext(next);
00119                 ensure_equals("setMaskNext/getMaskNextOwner():failed to return the MaskNext ", next, permissions.getMaskNextOwner());   
00120 
00121                 // further tests can be added to ensure perms for owner/group/everyone etc. get properly fixed. 
00122                 // code however suggests that there is no explict check if the perms are correct and the user of this 
00123                 // class is expected to know how to use them correctly. skipping further test cases for now for various
00124                 // perm combinations.
00125         }
00126 
00127         template<> template<>
00128         void permission_object_t::test<4>()
00129         {
00130                 LLPermissions perm,perm1;
00131                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00132                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00133                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00134                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00135                 perm1.init(creator,owner,lastOwner,group);
00136                 perm.set(perm1);
00137                 ensure("set():failed to set ", (creator == perm.getCreator()) && (owner == perm.getOwner())&&
00138                                                                         (lastOwner == perm.getLastOwner())&& (group == perm.getGroup()));       
00139                 }
00140 
00141         template<> template<>
00142         void permission_object_t::test<5>()
00143         {
00144                 LLPermissions perm,perm1;
00145                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00146                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00147                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00148                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00149                 perm1.init(creator,owner,lastOwner,group);
00150 
00151                 U32 base = PERM_TRANSFER;
00152                 U32 ownerp = PERM_TRANSFER;
00153                 U32 groupp = PERM_TRANSFER;
00154                 U32 everyone = PERM_TRANSFER;
00155                 U32 next = PERM_NONE;
00156 
00157                 perm1.initMasks(base, ownerp, everyone, groupp, next);
00158 
00159                 base = PERM_ALL;
00160                 ownerp = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
00161                 groupp = PERM_TRANSFER | PERM_COPY|PERM_MODIFY;
00162                 everyone = PERM_TRANSFER;
00163                 next = PERM_NONE;
00164                 
00165                 perm.init(creator,owner,lastOwner,group);
00166                 perm.initMasks(base, ownerp, everyone, groupp, next); 
00167 
00168                 // restrict permissions by accumulation
00169                 perm.accumulate(perm1);
00170 
00171                 U32 fixedbase = PERM_TRANSFER | PERM_MOVE;
00172                 U32 fixedowner = PERM_TRANSFER;
00173                 U32 fixedgroup = PERM_TRANSFER;
00174                 U32 fixedeveryone = PERM_TRANSFER;
00175                 U32 fixednext = PERM_NONE;
00176 
00177                 ensure_equals("accumulate failed ", fixedbase, perm.getMaskBase());     
00178                 ensure_equals("accumulate failed ", fixedowner, perm.getMaskOwner());   
00179                 ensure_equals("accumulate failed ", fixedgroup, perm.getMaskGroup());   
00180                 ensure_equals("accumulate failed ", fixedeveryone, perm.getMaskEveryone());     
00181                 ensure_equals("accumulate failed ", fixednext, perm.getMaskNextOwner());        
00182         }
00183 
00184         template<> template<>
00185         void permission_object_t::test<6>()
00186         {
00187                 LLPermissions perm;
00188                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00189                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00190                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00191                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00192                 perm.init(creator,owner,lastOwner,group);
00193                 ensure_equals("getSafeOwner:failed ", owner,perm.getSafeOwner());
00194                 
00196                 perm.init(creator,LLUUID::null,lastOwner,group);
00197                 ensure_equals("getSafeOwner:failed ", group, perm.getSafeOwner());
00198         }
00199         
00200                 template<> template<>
00201         void permission_object_t::test<7>()
00202         {
00203                 LLPermissions perm1;
00204                 LLUUID uuid;
00205                 BOOL is_group_owned = FALSE;
00206                 ensure("1:getOwnership:failed ", (FALSE == perm1.getOwnership(uuid,is_group_owned)));
00207                 
00208                 LLPermissions perm;
00209                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00210                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00211                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00212                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00213                 perm.init(creator,owner,lastOwner,group);
00214                 perm.getOwnership(uuid,is_group_owned);
00215                 ensure("2:getOwnership:failed ", ((uuid == owner) && (FALSE == is_group_owned))); 
00216 
00217                 perm.init(creator,LLUUID::null,lastOwner,group);
00218                 perm.getOwnership(uuid,is_group_owned);
00219                 ensure("3:getOwnership:failed ", ((uuid == group) && (TRUE == is_group_owned))); 
00220         }
00221 
00222         template<> template<>
00223         void permission_object_t::test<8>()
00224         {
00225                 LLPermissions perm,perm1;
00226                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00227                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00228                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00229                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00230                 perm.init(creator,owner,lastOwner,group);
00231                 perm1.init(creator,owner,lastOwner,group);
00232                 ensure_equals("getCRC32:failed ", perm.getCRC32(),perm1.getCRC32());
00233         }
00234 
00235         template<> template<>
00236         void permission_object_t::test<9>()
00237         {
00238                 LLPermissions perm;
00239                 LLUUID agent("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");   
00240                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00241                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
00242                 bool is_atomic = TRUE;
00243                 ensure("setOwnerAndGroup():failed ", (TRUE == perm.setOwnerAndGroup(agent,owner,group,is_atomic)));
00244                 
00245                 LLUUID owner2("68edcf47-ccd7-45b8-9f90-1649d7f12807"); 
00246                 LLUUID group2("9c8eca51-53d5-42a7-bb58-cef070395db9");
00247                 
00248                 // cant change - agent need to be current owner
00249                 ensure("setOwnerAndGroup():failed ", (FALSE == perm.setOwnerAndGroup(agent,owner2,group2,is_atomic)));
00250                 
00251                 // should be able to change - agent and owner same as current owner
00252                 ensure("setOwnerAndGroup():failed ", (TRUE == perm.setOwnerAndGroup(owner,owner,group2,is_atomic)));
00253         }
00254 
00255         template<> template<>
00256         void permission_object_t::test<10>()
00257         {
00258                 LLPermissions perm;
00259                 LLUUID agent;
00260                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
00261                 ensure("deedToGroup():failed ", (TRUE == perm.deedToGroup(agent,group)));
00262         }
00263         template<> template<>
00264         void permission_object_t::test<11>()
00265         {
00266                 LLPermissions perm;
00267                 LLUUID agent;
00268                 BOOL set = 1;
00269                 U32 bits = PERM_TRANSFER | PERM_MODIFY;
00270                 ensure("setBaseBits():failed ", (TRUE == perm.setBaseBits(agent, set, bits)));
00271                 ensure("setOwnerBits():failed ", (TRUE == perm.setOwnerBits(agent, set, bits)));
00272 
00273                 LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
00274                 ensure("setBaseBits():failed ", (FALSE == perm.setBaseBits(agent1, set, bits)));
00275                 ensure("setOwnerBits():failed ", (FALSE == perm.setOwnerBits(agent1, set, bits)));
00276         }
00277 
00278         template<> template<>
00279         void permission_object_t::test<12>()
00280         {
00281                 LLPermissions perm;
00282                 LLUUID agent;
00283                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00284                 BOOL set = 1;
00285                 U32 bits = 10;
00286                 ensure("setGroupBits():failed ", (TRUE == perm.setGroupBits(agent,group, set, bits)));
00287                 ensure("setEveryoneBits():failed ", (TRUE == perm.setEveryoneBits(agent,group, set, bits)));
00288                 ensure("setNextOwnerBits():failed ", (TRUE == perm.setNextOwnerBits(agent,group, set, bits)));
00289 
00290                 LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");  
00291                 ensure("setGroupBits():failed ", (FALSE == perm.setGroupBits(agent1,group, set, bits)));
00292                 ensure("setEveryoneBits():failed ", (FALSE == perm.setEveryoneBits(agent1,group, set, bits)));
00293                 ensure("setNextOwnerBits():failed ", (FALSE == perm.setNextOwnerBits(agent1,group, set, bits)));
00294         }
00295 
00296         template<> template<>
00297         void permission_object_t::test<13>()
00298         {
00299                 LLPermissions perm;
00300                 LLUUID agent;
00301                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00302                 U32 bits = 10;
00303                 ensure("allowOperationBy():failed ", (TRUE == perm.allowOperationBy(bits,agent,group)));
00304 
00305                 LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
00306                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00307                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00308                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00309                 perm.init(creator,owner,lastOwner,group);
00310                 ensure("allowOperationBy():failed ", (TRUE == perm.allowOperationBy(bits,agent1,group)));
00311         }
00312 
00313         template<> template<>
00314         void permission_object_t::test<14>()
00315         {
00316                 LLPermissions perm;
00317                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00318                 LLUUID owner;
00319                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00320                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00321                 perm.init(creator,owner,lastOwner,group);
00322                 LLUUID agent;
00323                 ensure("1:allowModifyBy():failed ", (TRUE == perm.allowModifyBy(agent)));
00324                 ensure("2:allowModifyBy():failed ", (TRUE == perm.allowModifyBy(agent,group)));
00325                                 
00326                 U32 val1 = 0x7FFFFFFF;
00327                 S32 sVal = 1 << 14;
00328                 sVal = val1 & sVal;
00329                 LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8"); 
00330                 ensure("3:allowModifyBy():failed ", (sVal == perm.allowModifyBy(agent1)));
00331                 ensure("4:allowModifyBy():failed ", (sVal == perm.allowModifyBy(agent1,group)));
00332         }
00333         
00334         template<> template<>
00335         void permission_object_t::test<15>()
00336         {
00337                 LLPermissions perm;
00338                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00339                 LLUUID owner;
00340                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00341                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00342                 perm.init(creator,owner,lastOwner,group);
00343                 LLUUID agent;
00344                 ensure("1:allowCopyBy():failed ", (TRUE == perm.allowModifyBy(agent)));
00345                 ensure("2:allowCopyBy():failed ", (TRUE == perm.allowModifyBy(agent,group)));
00346                                 
00347                 U32 val1 = 0x7FFFFFFF;
00348                 S32 sVal = 1 << 15;
00349                 sVal = val1 & sVal;
00350                 LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8"); 
00351                 ensure("3:allowCopyBy():failed ", (sVal == perm.allowCopyBy(agent1)));
00352                 ensure("4:allowCopyBy():failed ", (sVal == perm.allowCopyBy(agent1,group)));
00353         }
00354 
00355         template<> template<>
00356         void permission_object_t::test<16>()
00357         {
00358                 LLPermissions perm;
00359                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00360                 LLUUID owner;
00361                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00362                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00363                 perm.init(creator,owner,lastOwner,group);
00364                 LLUUID agent;
00365                 ensure("1:allowMoveBy():failed ", (TRUE == perm.allowMoveBy(agent)));
00366                 ensure("2:allowMoveBy():failed ", (TRUE == perm.allowMoveBy(agent,group)));
00367 
00368                 U32 val1 = 0x7FFFFFFF;
00369                 S32 sVal = 1 << 19;
00370                 sVal = val1 & sVal;
00371                 LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8"); 
00372                 ensure("3:allowMoveBy():failed ", (sVal == perm.allowMoveBy(agent1)));
00373                 ensure("4:allowMoveBy():failed ", (sVal == perm.allowMoveBy(agent1,group)));
00374         }
00375 
00376         template<> template<>
00377         void permission_object_t::test<17>()
00378         {
00379                 LLPermissions perm;
00380                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00381                 LLUUID owner;
00382                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00383                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00384                 LLUUID agent;
00385                 ensure("1:allowMoveBy():failed ", (TRUE == perm.allowTransferTo(agent)));
00386                 
00387                 perm.init(creator,owner,lastOwner,group);
00388                 U32 val1 = 0x7FFFFFFF;
00389                 S32 sVal = 1 << 13;
00390                 sVal = val1 & sVal;
00391                 ensure("2:allowMoveBy():failed ", (sVal == perm.allowTransferTo(agent)));
00392         }
00393 
00394         template<> template<>
00395         void permission_object_t::test<18>()
00396         {
00397                 LLPermissions perm,perm1;
00398                 ensure("1:Operator==:failed ", perm == perm1);
00399                 
00400                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00401                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00402                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00403                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00404                 perm.init(creator,owner,lastOwner,group);
00405                 perm = perm1;
00406                 ensure("2:Operator==:failed ", perm == perm1);
00407         }
00408 
00409         template<> template<>
00410         void permission_object_t::test<19>()
00411         {
00412                 LLPermissions perm,perm1;
00413                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00414                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00415                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00416                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00417                 perm.init(creator,owner,lastOwner,group);
00418                 ensure("2:Operator==:failed ", perm != perm1);
00419         }
00420 
00421         template<> template<>
00422         void permission_object_t::test<20>()
00423         {
00424                 FILE* fp = fopen("linden_file.dat","w+");
00425                 if(!fp)
00426                 {
00427                         llerrs << "file coudnt be opened\n" << llendl;
00428                         return;
00429                 }
00430                 LLPermissions perm,perm1;
00431                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00432                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00433                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00434                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00435                 perm.init(creator,owner,lastOwner,group);
00436                 
00437                 U32 base = PERM_TRANSFER | PERM_COPY;
00438                 U32 ownerp = PERM_TRANSFER;
00439                 U32 groupp = PERM_TRANSFER;
00440                 U32 everyone = PERM_TRANSFER;
00441                 U32 next = PERM_NONE;
00442 
00443                 perm.initMasks(base, ownerp, everyone, groupp, next);
00444 
00445                 perm.exportFile(fp);
00446                 fclose(fp);     
00447                 fp = fopen("linden_file.dat","r+");
00448                 if(!fp)
00449                 {
00450                         llerrs << "file coudnt be opened\n" << llendl;
00451                         return;
00452                 }
00453                 perm1.importFile(fp);
00454                 fclose(fp);
00455                 ensure("exportFile()/importFile():failed to export and import the data ", perm1 == perm);       
00456 }
00457 
00458         template<> template<>
00459         void permission_object_t::test<21>()
00460         {
00461                 LLPermissions perm,perm1;
00462                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00463                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00464                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00465                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00466                 perm.init(creator,owner,lastOwner,group);
00467 
00468                 U32 base = PERM_TRANSFER | PERM_COPY;
00469                 U32 ownerp = PERM_TRANSFER;
00470                 U32 groupp = PERM_TRANSFER;
00471                 U32 everyone = PERM_TRANSFER;
00472                 U32 next = PERM_NONE;
00473 
00474                 perm.initMasks(base, ownerp, everyone, groupp, next);
00475 
00476                 std::ostringstream ostream;
00477                 perm.exportLegacyStream(ostream);
00478                 std::istringstream istream(ostream.str());
00479                 perm1.importLegacyStream(istream);
00480 
00481                 ensure("exportLegacyStream()/importLegacyStream():failed to export and import the data ", perm1 == perm);       
00482         }
00483 
00484         template<> template<>
00485         void permission_object_t::test<22>()
00486         {
00487                 LLPermissions perm,perm1;
00488                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00489                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00490                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00491                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00492                 perm.init(creator,owner,lastOwner,group);
00493                 LLXMLNode* xml_node = perm.exportFileXML();
00494                 perm1.importXML(xml_node);
00495                 ensure("exportFileXML()/importXML():failed to export and import the data ", perm1 == perm);     
00496         }
00497 
00498         template<> template<>
00499         void permission_object_t::test<23>()
00500         {
00501                 LLPermissions perm,perm1;
00502                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00503                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00504                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00505                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00506                 perm.init(creator,owner,lastOwner,group);
00507                 std::ostringstream stream1, stream2;
00508                 stream1 << perm;
00509                 perm1.init(creator,owner,lastOwner,group);
00510                 stream2 << perm1;
00511                 ensure("1:operator << failed",(stream1.str() == stream2.str()));        
00512         }
00513 
00514         template<> template<>
00515         void permission_object_t::test<24>()
00516         {
00517                 LLPermissions perm,perm1;
00518                 LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e"); 
00519                 LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806"); 
00520                 LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d"); 
00521                 LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");           
00522                 perm.init(creator,owner,lastOwner,group);
00523                 
00524                 U32 base = PERM_TRANSFER | PERM_COPY;
00525                 U32 ownerp = PERM_TRANSFER;
00526                 U32 groupp = PERM_TRANSFER;
00527                 U32 everyone = PERM_TRANSFER;
00528                 U32 next = PERM_NONE;
00529 
00530                 perm.initMasks(base, ownerp, everyone, groupp, next);
00531 
00532                 LLSD sd = ll_create_sd_from_permissions(perm);
00533                 perm1 = ll_permissions_from_sd(sd);
00534                 ensure_equals("ll_permissions_from_sd() and ll_create_sd_from_permissions()functions failed", perm, perm1);
00535         }
00536 
00537         template<> template<>
00538         void permission_object_t::test<25>()
00539         {
00540                 LLAggregatePermissions AggrPermission;  
00541                 LLAggregatePermissions AggrPermission1; 
00542                 ensure("getU8() function failed", (AggrPermission.getU8() == 0));
00543                 ensure("isEmpty() function failed", (AggrPermission.isEmpty() == TRUE));
00544                 AggrPermission.getValue(PERM_TRANSFER);
00545                 ensure_equals("getValue() function failed", AggrPermission.getValue(PERM_TRANSFER), 0x00);
00546 
00547                 AggrPermission.aggregate(PERM_ITEM_UNRESTRICTED);
00548                 ensure("aggregate() function failed", (AggrPermission.isEmpty() == FALSE));
00549 
00550                 AggrPermission1.aggregate(AggrPermission);
00551                 ensure("aggregate() function failed", (AggrPermission1.isEmpty() == FALSE));
00552 
00553                 std::ostringstream stream1;
00554                 stream1 << AggrPermission;
00555                 ensure("operator<< failed", (stream1.str() == "{PI_COPY=All, PI_MODIFY=All, PI_TRANSFER=All}"));
00556         }
00557 }

Generated on Thu Jul 1 06:09:00 2010 for Second Life Viewer by  doxygen 1.4.7