Add root to images search path, readImageFile svg; unit tests

This commit is contained in:
gitlost
2019-08-21 15:04:52 +01:00
parent 2444cacb74
commit 010879fa71
16 changed files with 1034 additions and 63 deletions
+53 -6
View File
@@ -22,8 +22,6 @@
#include "model/ColorNode.h"
#include "merge/Record.h"
#include <QtDebug>
@@ -48,6 +46,7 @@ void TestColorNode::colorNode()
QColor silver80 = QColor( 192, 192, 192, 128 );
Record record;
Variables vars;
ColorNode colorNode;
QVERIFY( !colorNode.isField() );
@@ -56,6 +55,8 @@ void TestColorNode::colorNode()
QCOMPARE( colorNode.rgba(), rgbaBlackTransparent );
QCOMPARE( colorNode.color( nullptr, nullptr ), blackTransparent );
QCOMPARE( colorNode.color( &record, nullptr ), blackTransparent );
QCOMPARE( colorNode.color( nullptr, &vars ), blackTransparent );
QCOMPARE( colorNode.color( &record, &vars ), blackTransparent );
colorNode.setField( true );
QVERIFY( colorNode.isField() );
@@ -67,6 +68,8 @@ void TestColorNode::colorNode()
QCOMPARE( colorNode.rgba(), rgbaWhite );
QCOMPARE( colorNode.color( nullptr, nullptr ), white );
QCOMPARE( colorNode.color( &record, nullptr ), white );
QCOMPARE( colorNode.color( nullptr, &vars ), white );
QCOMPARE( colorNode.color( &record, &vars ), white );
colorNode.setKey( "key1" );
QCOMPARE( colorNode.key(), QString( "key1" ) );
@@ -99,15 +102,15 @@ void TestColorNode::colorNode()
colorNode.setColor( red );
QVERIFY( colorNode3 == colorNode );
///
/// Record
///
colorNode = ColorNode( QString( "key1" ) );
QVERIFY( colorNode.isField() ); // Defaults to true if given key only
QCOMPARE( colorNode.key(), QString( "key1" ) );
QCOMPARE( colorNode.color(), blackTransparent );
QCOMPARE( colorNode.color( &record, nullptr ), silver80 ); // Defaults to silver if given non-matching record/variables
QCOMPARE( colorNode.color( &record, &vars ), silver80 ); // Defaults to silver if given non-matching record/variables
///
/// Record
///
record["key1"] = "white";
QCOMPARE( colorNode.color( &record, nullptr ), white );
@@ -127,4 +130,48 @@ void TestColorNode::colorNode()
QCOMPARE( colorNode.color( &record, nullptr ), silver80 );
record["key2"] = "#8000FF00";
QCOMPARE( colorNode.color( &record, nullptr ), green80 );
///
/// Variable
///
colorNode = ColorNode( QString( "c1" ) );
QVERIFY( colorNode.isField() ); // Defaults to true if given key only
QCOMPARE( colorNode.key(), QString( "c1" ) );
QCOMPARE( colorNode.color(), blackTransparent );
QCOMPARE( colorNode.color( &record, &vars ), silver80 ); // Defaults to silver if given non-matching record/variables
{
Variable c1( Variable::Type::COLOR, "c1", "white", Variable::Increment::PER_ITEM );
vars.addVariable( c1 );
}
QCOMPARE( colorNode.color( nullptr, &vars ), white );
vars.incrementVariablesOnItem();
QCOMPARE( colorNode.color( nullptr, &vars ), white );
{
Variable c1( Variable::Type::COLOR, "c1", "red", Variable::Increment::PER_ITEM );
vars.addVariable( c1 );
}
QCOMPARE( colorNode.color( nullptr, &vars ), red );
{
Variable c1( Variable::Type::COLOR, "c1", "#8000FF00", Variable::Increment::PER_ITEM );
vars.addVariable( c1 );
}
QCOMPARE( colorNode.color( nullptr, &vars ), green80 );
colorNode.setKey( "c2" );
QCOMPARE( colorNode.color( &record, nullptr ), silver80 );
{
Variable c2( Variable::Type::COLOR, "c2", "#8000FF00", Variable::Increment::PER_ITEM );
vars.addVariable( c2 );
}
QCOMPARE( colorNode.color( nullptr, &vars ), green80 );
///
/// Record beats variable
///
record["c2"] = "red";
QCOMPARE( colorNode.color( &record, &vars ), red );
}