Exemple #1
0
	void inventory_object::test<12>()
	{
		LLPointer<LLInventoryCategory> src = create_random_inventory_cat();
		LLSD sd = ll_create_sd_from_inventory_category(src);
		LLPointer<LLInventoryCategory> dst = ll_create_category_from_sd(sd);
		
		ensure_equals("1.item id::getUUID() failed", dst->getUUID(), src->getUUID());
		ensure_equals("2.parent::getParentUUID() failed", dst->getParentUUID(), src->getParentUUID());
		ensure_equals("3.name::getName() failed", dst->getName(), src->getName());
		ensure_equals("4.type::getType() failed", dst->getType(), src->getType());
		ensure_equals("5.preferred type::getPreferredType() failed", dst->getPreferredType(), src->getPreferredType());

		src->setPreferredType( LLAssetType::AT_TEXTURE);
		sd = ll_create_sd_from_inventory_category(src);
		dst = ll_create_category_from_sd(sd);
		ensure_equals("6.preferred type::getPreferredType() failed", dst->getPreferredType(), src->getPreferredType());

		
	}
LLSD ll_create_sd_from_inventory_category(LLPointer<LLInventoryCategory> cat)
{
	LLSD rv;
	if(cat.isNull()) return rv;
	if (cat->getType() == LLAssetType::AT_NONE)
	{
		llwarns << "ll_create_sd_from_inventory_category() for cat with AT_NONE"
			<< llendl;
		return rv;
	}
	rv[INV_FOLDER_ID_LABEL] = cat->getUUID();
	rv[INV_PARENT_ID_LABEL] = cat->getParentUUID();
	rv[INV_NAME_LABEL] = cat->getName();
	rv[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(cat->getType());
	if(LLAssetType::AT_NONE != cat->getPreferredType())
	{
		rv[INV_PREFERRED_TYPE_LABEL] =
			LLAssetType::lookup(cat->getPreferredType());
	}
	return rv;
}
LLSD ll_create_sd_from_inventory_category(LLPointer<LLInventoryCategory> cat)
{
	LLSD rv;
	if(cat.isNull()) return rv;
	if (cat->getType() == LLAssetType::AT_NONE)
	{
		LL_WARNS() << "ll_create_sd_from_inventory_category() for cat with AT_NONE"
			<< LL_ENDL;
		return rv;
	}
	rv[INV_FOLDER_ID_LABEL] = cat->getUUID();
	rv[INV_PARENT_ID_LABEL] = cat->getParentUUID();
	rv[INV_NAME_LABEL] = cat->getName();
	rv[INV_ASSET_TYPE_LABEL] = LLAssetType::lookup(cat->getType());
	if(LLFolderType::lookupIsProtectedType(cat->getPreferredType()))
	{
		rv[INV_PREFERRED_TYPE_LABEL] =
			LLFolderType::lookup(cat->getPreferredType()).c_str();
	}
	return rv;
}