static void debugDownloadStr(
    WRT::Download * download,
    WRT::DownloadAttribute which,
    const char * name)
{
    QString value = stringAttribute(download, which);

    debugDownloadAttribute(download, name, value);
}
QString DownloadProxyData::fileName()
{
#ifdef USE_DOWNLOAD_MANAGER
    if (m_download == 0) {
        return QString();
    }

    return stringAttribute(m_download, WRT::FileName);
#else
    return QString();
#endif
}
Ejemplo n.º 3
0
void GenericAttributeTest::testString() {
	const std::string value = "abc";
	{ // Direct construction
		Util::StringAttribute stringAttribute(value);
		testStringGetters(stringAttribute, value, false, 0);

		const std::string secondValue = "28";
		stringAttribute.set(secondValue);
		testStringGetters(stringAttribute, secondValue, false, 28);

		const std::string thirdValue = "true";
		stringAttribute = Util::StringAttribute(thirdValue);
		testStringGetters(stringAttribute, thirdValue, true, 0);
	}
	{ // Specific factory
		std::unique_ptr<Util::StringAttribute> stringAttribute(Util::GenericAttribute::createString(value));
		testStringGetters(*stringAttribute, value, false, 0);

		const std::string valueDouble = value + value;
		stringAttribute->set(valueDouble);
		testStringGetters(*stringAttribute, valueDouble, false, 0);

		std::unique_ptr<Util::StringAttribute> clonedStringAttribute(stringAttribute->clone());
		CPPUNIT_ASSERT(*stringAttribute == *clonedStringAttribute);
		stringAttribute.reset();

		testStringGetters(*clonedStringAttribute, valueDouble, false, 0);
	}
	{ // Generic factory
		std::unique_ptr<Util::GenericAttribute> genericStringAttribute(Util::GenericAttribute::create(value));
		CPPUNIT_ASSERT(genericStringAttribute->isA<Util::StringAttribute>());
		CPPUNIT_ASSERT_EQUAL(value, genericStringAttribute->toType<Util::StringAttribute>()->get());
		CPPUNIT_ASSERT_EQUAL(false, genericStringAttribute->toBool());
		CPPUNIT_ASSERT_EQUAL(static_cast<int>(0), genericStringAttribute->toInt());
		CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(0), genericStringAttribute->toUnsignedInt());
		CPPUNIT_ASSERT_EQUAL(static_cast<float>(0), genericStringAttribute->toFloat());
		CPPUNIT_ASSERT_EQUAL(static_cast<double>(0), genericStringAttribute->toDouble());
		CPPUNIT_ASSERT_EQUAL(value, genericStringAttribute->toString());
	}
}