Skip to content
Permalink
Browse files

Tests and doxygen for QgsDataDefined

  • Loading branch information
nyalldawson committed Aug 6, 2015
1 parent 1e6483c commit 013e1da783af469b3a1755720c1c3765efdac6b7
@@ -65,11 +65,34 @@ class QgsDataDefined
bool isActive() const;
void setActive( bool active );

/**
* Returns if the field or the expression part is active.
*
* @return True if it is in expression mode.
*/
bool useExpression() const;
void setUseExpression( bool use );

/**
* Returns the expression string of this QgsDataDefined.
*
* @return An expression
*
* @see field()
* @see expressionOrField()
*/
QString expressionString() const;

void setExpressionString( const QString& expr );

/**
* Returns an expression which represents a single field if useExpression returns false, otherwise
* returns the current expression string.
* @return An expression
*
* @note added in 2.12
*/
QString expressionOrField() const;

// @note not available in python bindings
//QMap<QString, QVariant> expressionParams() const;
@@ -108,7 +131,16 @@ class QgsDataDefined
*/
QStringList referencedColumns( const QgsFields& fields = QgsFields() );

/**
* Get the field which this QgsDataDefined represents. Be aware that this may return
* a field name which may not be active if useExpression is true.
*
* @return A fieldname
*
* @see expressionOrField()
*/
QString field() const;

void setField( const QString& field );

/** Encodes the QgsDataDefined into a string map.
@@ -113,8 +113,8 @@ class CORE_EXPORT QgsDataDefined
void setExpressionString( const QString& expr );

/**
* Returns an expression which represents a single field if useExpression returns false
*
* Returns an expression which represents a single field if useExpression returns false, otherwise
* returns the current expression string.
* @return An expression
*
* @note added in 2.12
@@ -42,6 +42,7 @@ class TestQgsDataDefined: public QObject
void xmlMethods(); //test saving and reading from xml
void mapMethods(); //test saving and reading from a string map
void referencedColumns(); //test referenced columns method
void expressionOrString();

private:
};
@@ -307,5 +308,18 @@ void TestQgsDataDefined::referencedColumns()
QVERIFY( cols.contains( QString( "col3" ) ) );
}

void TestQgsDataDefined::expressionOrString()
{
QgsDataDefined dd;
dd.setActive( true );
dd.setField( "field" );
dd.setExpressionString( "1+col1+col2" );
dd.setUseExpression( true );
QCOMPARE( dd.expressionOrField(), QString( "1+col1+col2" ) );

dd.setUseExpression( false );
QCOMPARE( dd.expressionOrField(), QString( "\"field\"" ) );
}

QTEST_MAIN( TestQgsDataDefined )
#include "testqgsdatadefined.moc"
@@ -32,7 +32,7 @@
# DON'T RAISE THIS THRESHOLD!!!
# (changes which lower this threshold are welcomed though!)

ACCEPTABLE_MISSING_DOCS = 4427
ACCEPTABLE_MISSING_DOCS = 4412


def elemIsDocumentableClass(elem):
@@ -128,7 +128,7 @@ def testCoverage(self):

documentable, documented = parseDocs(docPath)
coverage = 100.0 * documented / documentable
missing = documentable - documented
missing = documentable - documented

print "---------------------------------"
print "{} total documentable members".format(documentable)

0 comments on commit 013e1da

Please sign in to comment.
You can’t perform that action at this time.