void Doc_Test::loadWrongRoot() { Doc doc(this, m_fixtureDefCache); QDomDocument document; QDomElement root = document.createElement("Enjine"); root.appendChild(createFixtureNode(document, 0)); root.appendChild(createFixtureNode(document, 72)); root.appendChild(createFixtureNode(document, 15)); root.appendChild(createCollectionNode(document, 5)); root.appendChild(createCollectionNode(document, 9)); root.appendChild(createCollectionNode(document, 1)); root.appendChild(createCollectionNode(document, 7)); root.appendChild(createBusNode(document, 0, 1)); root.appendChild(createBusNode(document, 7, 2)); root.appendChild(createBusNode(document, 12, 3)); root.appendChild(createBusNode(document, 29, 4)); root.appendChild(createBusNode(document, 31, 500)); root.appendChild(document.createElement("ExtraTag")); QVERIFY(doc.loadXML(&root) == false); }
void Doc_Test::load() { Doc doc(this, m_fixtureDefCache); QDomDocument document; QDomElement root = document.createElement("Engine"); root.appendChild(createFixtureNode(document, 0)); root.appendChild(createFixtureNode(document, 72)); root.appendChild(createFixtureNode(document, 15)); root.appendChild(createCollectionNode(document, 5)); root.appendChild(createCollectionNode(document, 9)); root.appendChild(createCollectionNode(document, 1)); root.appendChild(createCollectionNode(document, 7)); root.appendChild(createBusNode(document, 0, 1)); root.appendChild(createBusNode(document, 7, 2)); root.appendChild(createBusNode(document, 12, 3)); root.appendChild(createBusNode(document, 29, 4)); root.appendChild(createBusNode(document, 31, 500)); root.appendChild(document.createElement("ExtraTag")); QVERIFY(doc.fixtures() == 0); QVERIFY(doc.functions() == 0); QVERIFY(doc.loadXML(&root) == true); QVERIFY(doc.fixtures() == 3); QVERIFY(doc.functions() == 4); QVERIFY(Bus::instance()->value(0) == 1); QVERIFY(Bus::instance()->value(7) == 2); QVERIFY(Bus::instance()->value(12) == 3); QVERIFY(Bus::instance()->value(29) == 4); QVERIFY(Bus::instance()->value(31) == 500); }
void Doc_Test::loadWrongRoot() { QDomDocument document; QDomElement root = document.createElement("Enjine"); root.appendChild(createFixtureNode(document, 0)); root.appendChild(createFixtureNode(document, 72)); root.appendChild(createFixtureNode(document, 15)); root.appendChild(createFixtureGroupNode(document, 0)); root.appendChild(createFixtureGroupNode(document, 42)); root.appendChild(createFixtureGroupNode(document, 72)); root.appendChild(createCollectionNode(document, 5)); root.appendChild(createCollectionNode(document, 9)); root.appendChild(createCollectionNode(document, 1)); root.appendChild(createCollectionNode(document, 7)); root.appendChild(createBusNode(document, 0, 1)); root.appendChild(createBusNode(document, 7, 2)); root.appendChild(createBusNode(document, 12, 3)); root.appendChild(createBusNode(document, 29, 4)); root.appendChild(createBusNode(document, 31, 500)); root.appendChild(document.createElement("ExtraTag")); QVERIFY(m_doc->loadXML(root) == false); }
void Doc_Test::load() { QBuffer buffer; buffer.open(QIODevice::WriteOnly | QIODevice::Text); QXmlStreamWriter xmlWriter(&buffer); xmlWriter.writeStartElement("Engine"); createFixtureNode(xmlWriter, 0, m_currentAddr, 18); m_currentAddr += 18; createFixtureNode(xmlWriter, 72, m_currentAddr, 18); m_currentAddr += 18; createFixtureNode(xmlWriter, 15, m_currentAddr, 18); m_currentAddr += 18; createFixtureGroupNode(xmlWriter, 0); createFixtureGroupNode(xmlWriter, 42); createFixtureGroupNode(xmlWriter, 72); createCollectionNode(xmlWriter, 5); createCollectionNode(xmlWriter, 9); createCollectionNode(xmlWriter, 1); createCollectionNode(xmlWriter, 7); createBusNode(xmlWriter, 0, 1); createBusNode(xmlWriter, 7, 2); createBusNode(xmlWriter, 12, 3); createBusNode(xmlWriter, 29, 4); createBusNode(xmlWriter, 31, 500); xmlWriter.writeStartElement("ExtraTag"); xmlWriter.writeEndElement(); xmlWriter.writeEndDocument(); xmlWriter.setDevice(NULL); buffer.close(); buffer.open(QIODevice::ReadOnly | QIODevice::Text); QXmlStreamReader xmlReader(&buffer); xmlReader.readNextStartElement(); QVERIFY(m_doc->fixtures().size() == 0); QVERIFY(m_doc->functions().size() == 0); QVERIFY(m_doc->loadXML(xmlReader) == true); QVERIFY(m_doc->fixtures().size() == 3); QVERIFY(m_doc->functions().size() == 4); QVERIFY(m_doc->fixtureGroups().size() == 3); QVERIFY(Bus::instance()->value(0) == 1); QVERIFY(Bus::instance()->value(7) == 2); QVERIFY(Bus::instance()->value(12) == 3); QVERIFY(Bus::instance()->value(29) == 4); QVERIFY(Bus::instance()->value(31) == 500); }
void Doc_Test::loadWrongRoot() { QBuffer buffer; buffer.open(QIODevice::WriteOnly | QIODevice::Text); QXmlStreamWriter xmlWriter(&buffer); xmlWriter.writeStartElement("Enjine"); createFixtureNode(xmlWriter, 0, m_currentAddr, 18); m_currentAddr += 18; createFixtureNode(xmlWriter, 72, m_currentAddr, 18); m_currentAddr += 18; createFixtureNode(xmlWriter, 15, m_currentAddr, 18); m_currentAddr += 18; createFixtureGroupNode(xmlWriter, 0); createFixtureGroupNode(xmlWriter, 42); createFixtureGroupNode(xmlWriter, 72); createCollectionNode(xmlWriter, 5); createCollectionNode(xmlWriter, 9); createCollectionNode(xmlWriter, 1); createCollectionNode(xmlWriter, 7); createBusNode(xmlWriter, 0, 1); createBusNode(xmlWriter, 7, 2); createBusNode(xmlWriter, 12, 3); createBusNode(xmlWriter, 29, 4); createBusNode(xmlWriter, 31, 500); xmlWriter.writeStartElement("ExtraTag"); xmlWriter.writeEndElement(); xmlWriter.writeEndDocument(); xmlWriter.setDevice(NULL); buffer.close(); buffer.open(QIODevice::ReadOnly | QIODevice::Text); QXmlStreamReader xmlReader(&buffer); xmlReader.readNextStartElement(); QVERIFY(m_doc->loadXML(xmlReader) == false); }
void Doc_Test::load() { QDomDocument document; QDomElement root = document.createElement("Engine"); root.appendChild(createFixtureNode(document, 0)); root.appendChild(createFixtureNode(document, 72)); root.appendChild(createFixtureNode(document, 15)); root.appendChild(createFixtureGroupNode(document, 0)); root.appendChild(createFixtureGroupNode(document, 42)); root.appendChild(createFixtureGroupNode(document, 72)); root.appendChild(createCollectionNode(document, 5)); root.appendChild(createCollectionNode(document, 9)); root.appendChild(createCollectionNode(document, 1)); root.appendChild(createCollectionNode(document, 7)); root.appendChild(createBusNode(document, 0, 1)); root.appendChild(createBusNode(document, 7, 2)); root.appendChild(createBusNode(document, 12, 3)); root.appendChild(createBusNode(document, 29, 4)); root.appendChild(createBusNode(document, 31, 500)); root.appendChild(document.createElement("ExtraTag")); QVERIFY(m_doc->fixtures().size() == 0); QVERIFY(m_doc->functions().size() == 0); QVERIFY(m_doc->loadXML(root) == true); QVERIFY(m_doc->fixtures().size() == 3); QVERIFY(m_doc->functions().size() == 4); QVERIFY(m_doc->fixtureGroups().size() == 3); QVERIFY(Bus::instance()->value(0) == 1); QVERIFY(Bus::instance()->value(7) == 2); QVERIFY(Bus::instance()->value(12) == 3); QVERIFY(Bus::instance()->value(29) == 4); QVERIFY(Bus::instance()->value(31) == 500); }