void ConfigFileUnitTests::testLoadPackagedSetup()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\PackagedSetup\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // configurations properties
    CPPUNIT_ASSERT(! config.schema.generator.empty());
    CPPUNIT_ASSERT(! config.schema.version.empty());
    CPPUNIT_ASSERT(config.lcidtype == DVLib::LcidUserExe);
    CPPUNIT_ASSERT(config.uilevel == InstallUILevelFull);
    CPPUNIT_ASSERT(config.fileversion == L"1.0.0.1");
    CPPUNIT_ASSERT(config.productversion == L"1.0.0.0");
    // file attributes
    CPPUNIT_ASSERT(config.fileattributes.size() == 4);
    CPPUNIT_ASSERT(config.fileattributes[L"FileDescription"]->name == L"FileDescription");
    CPPUNIT_ASSERT(config.fileattributes[L"FileDescription"]->value == L"Standalone setup sample");
    // configurations with components
    CPPUNIT_ASSERT(config.size() == 1);
    const InstallConfiguration * configuration = reinterpret_cast<InstallConfiguration *>(get(config[0]));
    CPPUNIT_ASSERT(configuration->components.size() == 1);
    ComponentPtr component = configuration->components[0];
    CPPUNIT_ASSERT(component->type == component_type_msi);
}
void ConfigFileUnitTests::testLoadMultipleSetup()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\MultipleConfig\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // configurations properties
    CPPUNIT_ASSERT(config.size() == 2);	
    // install sequence
    std::vector<ConfigurationPtr> install_configurations = config.GetSupportedConfigurations(LcidUser, SequenceInstall);
    CPPUNIT_ASSERT(configuration_reference == install_configurations[0]->type);
    CPPUNIT_ASSERT(configuration_install == install_configurations[1]->type);
    InstallConfiguration * p_configuration_install = reinterpret_cast<InstallConfiguration *>(get(install_configurations[1]));
    Components install_components = p_configuration_install->GetSupportedComponents(LcidUser, SequenceInstall);
    CPPUNIT_ASSERT(install_components.size() == 2);
    CPPUNIT_ASSERT(install_components[0]->id == L"setup1");
    CPPUNIT_ASSERT(install_components[1]->id == L"setup2");
    Components uninstall_components = p_configuration_install->GetSupportedComponents(LcidUser, SequenceUninstall);
    CPPUNIT_ASSERT(uninstall_components.size() == 2);
    CPPUNIT_ASSERT(uninstall_components[0]->id == L"setup2");
    CPPUNIT_ASSERT(uninstall_components[1]->id == L"setup1");
    std::vector<ConfigurationPtr> uninstall_configurations = config.GetSupportedConfigurations(LcidUser, SequenceUninstall);
    CPPUNIT_ASSERT(configuration_install == uninstall_configurations[0]->type);
    CPPUNIT_ASSERT(configuration_reference == uninstall_configurations[1]->type);	
}
void ConfigFileUnitTests::testLoadInstallCheckOperators()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\InstallCheckOperators\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // configurations properties
    CPPUNIT_ASSERT(! config.schema.generator.empty());
    CPPUNIT_ASSERT(! config.schema.version.empty());
    CPPUNIT_ASSERT(config.lcidtype == DVLib::LcidUserExe);
    CPPUNIT_ASSERT(config.uilevel == InstallUILevelFull);
    CPPUNIT_ASSERT(config.fileversion == L"1.0.0.0");
    CPPUNIT_ASSERT(config.productversion == L"1.0.0.0");
    // file attributes
    CPPUNIT_ASSERT(config.fileattributes.size() == 1);
    CPPUNIT_ASSERT(config.fileattributes[L"FileDescription"]->name == L"FileDescription");
    CPPUNIT_ASSERT(config.fileattributes[L"FileDescription"]->value == L"InstallCheckOperators setup sample");
    // configurations with components
    CPPUNIT_ASSERT(config.size() == 1);
    const InstallConfiguration * configuration = reinterpret_cast<InstallConfiguration *>(get(config[0]));
    CPPUNIT_ASSERT(configuration->components.size() == 4);
    CPPUNIT_ASSERT(configuration->components[0]->type == component_type_cmd);
    CPPUNIT_ASSERT(configuration->components[1]->type == component_type_cmd);
    CPPUNIT_ASSERT(configuration->components[2]->type == component_type_cmd);
    CPPUNIT_ASSERT(configuration->components[3]->type == component_type_cmd);
    // \todo: verify that operators tree is correct
}
void ConfigFileUnitTests::testLoadDownloadSetup()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\DownloadSetup\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // configurations properties
    CPPUNIT_ASSERT(! config.schema.generator.empty());
    CPPUNIT_ASSERT(! config.schema.version.empty());
    CPPUNIT_ASSERT(config.lcidtype == DVLib::LcidUserExe);
    CPPUNIT_ASSERT(config.uilevel == InstallUILevelFull);
    CPPUNIT_ASSERT(config.fileversion == L"1.0.0.0");
    CPPUNIT_ASSERT(config.productversion == L"1.0.0.0");
    // file attributes
    CPPUNIT_ASSERT(config.fileattributes.size() == 0);
    // configurations with components
    CPPUNIT_ASSERT(config.size() == 1);
    const InstallConfiguration * configuration = reinterpret_cast<InstallConfiguration *>(get(config[0]));
    CPPUNIT_ASSERT(configuration->components.size() == 1);
    ComponentPtr component = configuration->components[0];
    CPPUNIT_ASSERT(component->type == component_type_cmd);
    // the component has a download dialog with one file
    CPPUNIT_ASSERT(get(component->downloaddialog) != NULL);
    CPPUNIT_ASSERT(component->downloaddialog->downloadfiles.size() == 1);
}
void ConfigFileUnitTests::testGetSupportedConfigurations()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\StandaloneSetup\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // there're two configurations in this sample, opposite of each other
    CPPUNIT_ASSERT(config.GetSupportedConfigurations(0, SequenceInstall).size() == 1);
}
void ConfigFileUnitTests::testLoadMultilingualSetup()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\MultilingualSetup\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // there're two configurations in this sample, but only 1 will show because the lcids don't overlap
    CPPUNIT_ASSERT(config.size() == 2);
    CPPUNIT_ASSERT(config.GetSupportedConfigurations(0, SequenceInstall).size() == 1);
    CPPUNIT_ASSERT(config.GetSupportedConfigurations(1040, SequenceInstall).size() == 1);
    CPPUNIT_ASSERT(config.GetSupportedConfigurations(1040, SequenceInstall)[0]->lcid_filter == L"1040");
}
void ConfigFileUnitTests::testLoadOsFiltersSetup()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\OsFilters\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // there're three components in this sample, but only 1 will show because the os filters don't overlap
    CPPUNIT_ASSERT(config.size() == 1);
    CPPUNIT_ASSERT(config.GetSupportedConfigurations(0, SequenceInstall).size() == 1);
    const InstallConfiguration * configuration = reinterpret_cast<InstallConfiguration *>(get(config[0]));
    CPPUNIT_ASSERT(configuration->components.size() == 3);	
}
void ConfigFileUnitTests::testLoadExeSetup()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\ExeSetup\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // configurations with components
    CPPUNIT_ASSERT(config.size() == 1);
    const InstallConfiguration * configuration = reinterpret_cast<InstallConfiguration *>(get(config[0]));
    CPPUNIT_ASSERT(configuration->components.size() == 1);
    ComponentPtr component_exe = configuration->components[0];
    CPPUNIT_ASSERT(component_exe->type == component_type_exe);	
}
Exemplo n.º 9
0
static bool try_load_config_file (const char *fname, ConfigFile &conf)
{
	FSTREAM	fp;

	fp = OPEN_FSTREAM(fname, "r");
	if (fp)
	{
		fprintf(stdout, "Reading config file %s.\n", fname);
		conf.LoadFile(new fStream(fp));
        CLOSE_FSTREAM(fp);
		return (true);
	}

	return (false);
}
void ConfigFileUnitTests::testLoadLicenseAgreement()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\LicenseAgreement\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // there's one configuration in this sample
    CPPUNIT_ASSERT(config.size() == 1);
    const InstallConfiguration * configuration = reinterpret_cast<InstallConfiguration *>(get(config[0]));
    CPPUNIT_ASSERT(configuration->components.size() == 1);
    CPPUNIT_ASSERT(configuration->controls.size() == 2);
    CPPUNIT_ASSERT(configuration->controls[0]->type == control_type_license);
    CPPUNIT_ASSERT(configuration->controls[1]->type == control_type_image);
}
Exemplo n.º 11
0
static bool try_load_config_file (const char *fname, ConfigFile &conf)
{
	LOG_DBG("try_load_config_file(%s)", fname);
	FILE * fp;

	fp = fopen(fname, "r");
	if (fp)
	{
		fprintf(stdout, "Reading config file %s.\n", fname);
		conf.LoadFile(new fReader(fp));
		fclose(fp);
	}

	return (false);
}
void ConfigFileUnitTests::testLoadCustomInputSetup()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\CustomInputSetup\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // there's one configuration in this sample
    CPPUNIT_ASSERT(config.size() == 1);
    const InstallConfiguration * configuration = reinterpret_cast<InstallConfiguration *>(get(config[0]));
    CPPUNIT_ASSERT(configuration->components.size() == 1);
    CPPUNIT_ASSERT(configuration->controls.size() == 6);
    CPPUNIT_ASSERT(configuration->controls[0]->type == control_type_label);
    CPPUNIT_ASSERT(configuration->controls[1]->type == control_type_label);
    CPPUNIT_ASSERT(configuration->controls[2]->type == control_type_checkbox);
    CPPUNIT_ASSERT(configuration->controls[3]->type == control_type_browse);
    CPPUNIT_ASSERT(configuration->controls[4]->type == control_type_browse);
    CPPUNIT_ASSERT(configuration->controls[5]->type == control_type_hyperlink);
}
void ConfigFileUnitTests::testLoadStandaloneSetup()
{
    std::wstring configxml = DVLib::DirectoryCombine(DVLib::GetModuleDirectoryW(), 
        L"..\\..\\..\\Samples\\StandaloneSetup\\Configuration.xml");
    CPPUNIT_ASSERT(DVLib::FileExists(configxml));
    ConfigFile config;
    config.LoadFile(configxml);
    // configurations properties
    CPPUNIT_ASSERT(! config.schema.generator.empty());
    CPPUNIT_ASSERT(! config.schema.version.empty());
    CPPUNIT_ASSERT(config.lcidtype == DVLib::LcidUserExe);
    CPPUNIT_ASSERT(config.uilevel == InstallUILevelFull);
    CPPUNIT_ASSERT(config.fileversion == L"1.0.0.0");
    CPPUNIT_ASSERT(config.productversion == L"1.0.0.0");
    // file attributes
    CPPUNIT_ASSERT(config.fileattributes.size() == 0);
    // configurations with components
    CPPUNIT_ASSERT(config.size() == 2);
    // \todo: verify that lcid's are different
}
Exemplo n.º 14
0
bool CCGShader::LoadShader(const char *path)
{
	ConfigFile conf;
	int shaderCount;
	char keyName[100];

	shaderPasses.clear();
	lookupTextures.clear();

	if(strlen(path)<4 || strcasecmp(&path[strlen(path)-4],".cgp")) {
		shaderPass pass;
		pass.scaleParams.scaleTypeX = CG_SCALE_NONE;
		pass.scaleParams.scaleTypeY = CG_SCALE_NONE;
		pass.linearFilter = false;
		pass.filterSet = false;
		strcpy(pass.cgShaderFile,path);
		shaderPasses.push_back(pass);
		return true;
	} else {
		conf.LoadFile(path);
	}	

	shaderCount = conf.GetInt("::shaders",0);

	if(shaderCount<1)
		return false;

	for(int i=0;i<shaderCount;i++) {
		shaderPass pass;
		sprintf(keyName,"::filter_linear%u",i);
		pass.linearFilter = conf.GetBool(keyName);
		pass.filterSet = conf.Exists(keyName);

		sprintf(keyName,"::scale_type%u",i);
		const char *scaleType = conf.GetString(keyName,"");
		if(!strcasecmp(scaleType,"")) {
			sprintf(keyName,"::scale_type_x%u",i);
			const char *scaleTypeX = conf.GetString(keyName,"");
			if(*scaleTypeX=='\0' && (i!=(shaderCount-1)))
				scaleTypeX = "source";
			pass.scaleParams.scaleTypeX = scaleStringToEnum(scaleTypeX);
			sprintf(keyName,"::scale_type_y%u",i);
			const char *scaleTypeY = conf.GetString(keyName,"");
			if(*scaleTypeY=='\0' && (i!=(shaderCount-1)))
				scaleTypeY = "source";
			pass.scaleParams.scaleTypeY = scaleStringToEnum(scaleTypeY);
		} else {
			cgScaleType sType = scaleStringToEnum(scaleType);
			pass.scaleParams.scaleTypeX = sType;
			pass.scaleParams.scaleTypeY = sType;
		}

		sprintf(keyName,"::scale%u",i);
		const char *scaleFloat = conf.GetString(keyName,"");
		int scaleInt = conf.GetInt(keyName,0);
		if(!strcasecmp(scaleFloat,"")) {
			sprintf(keyName,"::scalex%u",i);
			const char *scaleFloatX = conf.GetString(keyName,"1.0");
			pass.scaleParams.scaleX = atof(scaleFloatX);
			pass.scaleParams.absX = conf.GetInt(keyName,1);
			sprintf(keyName,"::scaley%u",i);
			const char *scaleFloatY = conf.GetString(keyName,"1.0");
			pass.scaleParams.scaleY = atof(scaleFloatY);
			pass.scaleParams.absY = conf.GetInt(keyName,1);

		} else {
			float floatval = atof(scaleFloat);
			pass.scaleParams.scaleX = floatval;
			pass.scaleParams.absX = scaleInt;
			pass.scaleParams.scaleY = floatval;
			pass.scaleParams.absY = scaleInt;
		}

		sprintf(keyName,"::shader%u",i);
		strcpy(pass.cgShaderFile,conf.GetString(keyName,""));
		shaderPasses.push_back(pass);
	}

	char *shaderIds = conf.GetStringDup("::textures","");

	char *id = strtok(shaderIds,";");
	while(id!=NULL) {
		lookupTexture tex;
		sprintf(keyName,"::%s",id);
		strcpy(tex.id,id);
		strcpy(tex.texturePath,conf.GetString(keyName,""));
		sprintf(keyName,"::%s_linear",id);
		tex.linearfilter = conf.GetBool(keyName,true);
		lookupTextures.push_back(tex);
		id = strtok(NULL,";");
	}

	free(shaderIds);

	return true;
}