Merge "Merge remote-tracking branch 'origin/qds-1.59'"

This commit is contained in:
The Qt Project
2020-06-11 13:31:26 +00:00
33 changed files with 456 additions and 273 deletions

View File

@@ -768,7 +768,8 @@ QObject *ObjectNodeInstance::createComponent(const QString &componentPath, QQmlC
qWarning() << error;
}
object->setProperty("__designer_url__", QUrl::fromLocalFile(componentPath));
if (object)
object->setProperty("__designer_url__", QUrl::fromLocalFile(componentPath));
return object;
}

View File

@@ -192,6 +192,8 @@ public:
columnDefinitionString.append(defaultValue.value.toStringView());
columnDefinitionString.append("'");
break;
default:
break;
}
}

View File

@@ -33,6 +33,7 @@
namespace Sqlite {
template<unsigned int TableCount = 0>
class LastChangedRowId
{
public:
@@ -40,86 +41,82 @@ public:
: database(database)
{
callback = [=](ChangeType, char const *, char const *, long long rowId) {
this->lastRowId = rowId;
};
database.setUpdateHook(callback);
database.setUpdateHook(this, callbackOnlyRowId);
}
LastChangedRowId(DatabaseInterface &database, Utils::SmallStringView databaseName)
: database(database)
, databaseName(databaseName)
{
callback = [=](ChangeType, char const *database, char const *, long long rowId) {
if (databaseName == database)
this->lastRowId = rowId;
};
database.setUpdateHook(callback);
database.setUpdateHook(this, callbackWithDatabase);
}
template<typename... Tables>
LastChangedRowId(DatabaseInterface &database,
Utils::SmallStringView databaseName,
Utils::SmallStringView tableName)
Tables... tableNames)
: database(database)
, databaseName(databaseName)
, tableNames({tableNames...})
{
callback = [=](ChangeType, char const *database, char const *table, long long rowId) {
if (databaseName == database && tableName == table)
this->lastRowId = rowId;
};
database.setUpdateHook(callback);
}
LastChangedRowId(DatabaseInterface &database,
Utils::SmallStringView databaseName,
Utils::SmallStringView tableName,
Utils::SmallStringView tableName2)
: database(database)
{
callback = [=](ChangeType, char const *database, char const *table, long long rowId) {
if (databaseName == database && (tableName == table || tableName2 == table))
this->lastRowId = rowId;
};
database.setUpdateHook(callback);
}
LastChangedRowId(DatabaseInterface &database,
Utils::SmallStringView databaseName,
Utils::SmallStringView tableName,
Utils::SmallStringView tableName2,
Utils::SmallStringView tableName3)
: database(database)
{
callback = [=](ChangeType, char const *database, char const *table, long long rowId) {
if (databaseName == database
&& (tableName == table || tableName2 == table || tableName3 == table))
this->lastRowId = rowId;
};
database.setUpdateHook(callback);
database.setUpdateHook(this, callbackWithTables);
}
~LastChangedRowId() { database.resetUpdateHook(); }
long long takeLastRowId()
void operator()(long long rowId) { lastRowId = rowId; }
static void callbackOnlyRowId(void *object, int, char const *, char const *, long long rowId)
{
long long rowId = lastRowId;
lastRowId = -1;
return rowId;
(*static_cast<LastChangedRowId *>(object))(rowId);
}
bool lastRowIdIsValid() { return lastRowId >= 0; }
bool containsTable(Utils::SmallStringView table)
{
return std::find(tableNames.begin(), tableNames.end(), table) != tableNames.end();
}
void operator()(Utils::SmallStringView database, long long rowId)
{
if (databaseName == database)
lastRowId = rowId;
}
static void callbackWithDatabase(
void *object, int, char const *database, char const *, long long rowId)
{
(*static_cast<LastChangedRowId *>(object))(Utils::SmallStringView{database}, rowId);
}
void operator()(Utils::SmallStringView database, Utils::SmallStringView table, long long rowId)
{
if (databaseName == database && containsTable(table))
lastRowId = rowId;
}
static void callbackWithTables(
void *object, int, char const *database, char const *table, long long rowId)
{
(*static_cast<LastChangedRowId *>(
object))(Utils::SmallStringView{database}, Utils::SmallStringView{table}, rowId);
}
long long takeLastRowId()
{
long long lastId = lastRowId;
lastRowId = -1;
return lastId;
}
bool lastRowIdIsValid() const { return lastRowId >= 0; }
public:
DatabaseInterface &database;
DatabaseInterface::UpdateCallback callback;
long long lastRowId = -1;
Utils::SmallStringView databaseName;
std::array<Utils::SmallStringView, TableCount> tableNames;
};
} // namespace Sqlite

View File

@@ -214,6 +214,9 @@ void BaseStatement::bind(int index, const Value &value)
case ValueType::String:
bind(index, value.toStringView());
break;
case ValueType::Null:
bind(index, NullValue{});
break;
}
}

View File

@@ -89,7 +89,7 @@ public:
void setOpenMode(OpenMode openMode);
OpenMode openMode() const;
void execute(Utils::SmallStringView sqlStatement);
void execute(Utils::SmallStringView sqlStatement) override;
DatabaseBackend &backend();
@@ -116,15 +116,20 @@ public:
m_databaseBackend.walCheckpointFull();
}
void setUpdateHook(DatabaseBackend::UpdateCallback &callback)
void setUpdateHook(void *object,
void (*callback)(void *object,
int,
char const *database,
char const *,
long long rowId)) override
{
m_databaseBackend.setUpdateHook(callback);
m_databaseBackend.setUpdateHook(object, callback);
}
void resetUpdateHook() { m_databaseBackend.resetUpdateHook(); }
void resetUpdateHook() override { m_databaseBackend.resetUpdateHook(); }
void setAttachedTables(const Utils::SmallStringVector &tables);
void applyAndUpdateSessions();
void setAttachedTables(const Utils::SmallStringVector &tables) override;
void applyAndUpdateSessions() override;
private:
void deferredBegin() override;

View File

@@ -400,22 +400,11 @@ void DatabaseBackend::walCheckpointFull()
}
}
namespace {
void updateCallback(
void *callback, int type, char const *database, char const *table, sqlite3_int64 row)
void DatabaseBackend::setUpdateHook(
void *object,
void (*callback)(void *object, int, char const *database, char const *, long long rowId))
{
auto &function = *reinterpret_cast<DatabaseBackend::UpdateCallback *>(callback);
function(static_cast<ChangeType>(type), database, table, row);
}
} // namespace
void DatabaseBackend::setUpdateHook(UpdateCallback &callback)
{
if (callback)
sqlite3_update_hook(m_databaseHandle, updateCallback, &callback);
else
sqlite3_update_hook(m_databaseHandle, nullptr, nullptr);
sqlite3_update_hook(m_databaseHandle, callback, object);
}
void DatabaseBackend::resetUpdateHook()

View File

@@ -41,9 +41,6 @@ class Database;
class SQLITE_EXPORT DatabaseBackend
{
public:
using UpdateCallback
= std::function<void(ChangeType type, char const *, char const *, long long)>;
DatabaseBackend(Database &database);
~DatabaseBackend();
@@ -88,7 +85,9 @@ public:
void walCheckpointFull();
void setUpdateHook(UpdateCallback &callback);
void setUpdateHook(
void *object,
void (*callback)(void *object, int, char const *database, char const *, long long rowId));
void resetUpdateHook();
protected:

View File

@@ -29,18 +29,16 @@
#include "sqliteglobal.h"
#include <functional>
namespace Sqlite {
class DatabaseInterface
{
public:
using UpdateCallback
= std::function<void(ChangeType type, char const *, char const *, long long)>;
virtual void walCheckpointFull() = 0;
virtual void execute(Utils::SmallStringView sqlStatement) = 0;
virtual void setUpdateHook(UpdateCallback &callback) = 0;
virtual void setUpdateHook(
void *object,
void (*)(void *object, int, char const *database, char const *, long long rowId))
= 0;
virtual void resetUpdateHook() = 0;
virtual void applyAndUpdateSessions() = 0;
virtual void setAttachedTables(const Utils::SmallStringVector &tables) = 0;

View File

@@ -102,6 +102,8 @@ public:
return QVariant(toFloat());
case ValueType::String:
return QVariant(QString(toStringView()));
case ValueType::Null:
break;
}
return {};
@@ -281,6 +283,8 @@ public:
return first.toFloat() == second.toFloat();
case ValueType::String:
return first.toStringView() == second.toStringView();
case ValueType::Null:
return false;
}
return false;

View File

@@ -36,6 +36,6 @@ add_qtc_plugin(ClangRefactoring
symbol.h
symbolquery.h
symbolqueryinterface.h
symbolsfindfilter.cpp symbolsfindfilter.h
clangsymbolsfindfilter.cpp clangsymbolsfindfilter.h
symbolsfindfilterconfigwidget.cpp symbolsfindfilterconfigwidget.h
)

View File

@@ -6,6 +6,7 @@ HEADERS += \
$$PWD/clangqueryhighlighter.h \
$$PWD/clangqueryhighlightmarker.h \
$$PWD/clangqueryprojectsfindfilter.h \
$$PWD/clangsymbolsfindfilter.h \
$$PWD/projectpartutilities.h \
$$PWD/refactoringclient.h \
$$PWD/refactoringconnectionclient.h \
@@ -13,7 +14,6 @@ HEADERS += \
$$PWD/refactoringprojectupdater.h \
$$PWD/searchinterface.h \
$$PWD/searchhandle.h \
$$PWD/symbolsfindfilter.h \
$$PWD/symbolqueryinterface.h \
$$PWD/symbol.h \
$$PWD/projectpartproviderinterface.h \
@@ -24,11 +24,11 @@ SOURCES += \
$$PWD/clangqueryexamplehighlighter.cpp \
$$PWD/clangqueryhighlighter.cpp \
$$PWD/clangqueryprojectsfindfilter.cpp \
$$PWD/clangsymbolsfindfilter.cpp \
$$PWD/projectpartutilities.cpp \
$$PWD/refactoringclient.cpp \
$$PWD/refactoringconnectionclient.cpp \
$$PWD/refactoringengine.cpp \
$$PWD/refactoringprojectupdater.cpp \
$$PWD/searchhandle.cpp \
$$PWD/symbolsfindfilter.cpp \
$$PWD/locatorfilter.cpp

View File

@@ -73,8 +73,8 @@ QtcPlugin {
"symbol.h",
"symbolquery.h",
"symbolqueryinterface.h",
"symbolsfindfilter.cpp",
"symbolsfindfilter.h",
"clangsymbolsfindfilter.cpp",
"clangsymbolsfindfilter.h",
"symbolsfindfilterconfigwidget.cpp",
"symbolsfindfilterconfigwidget.h",
]

View File

@@ -23,7 +23,7 @@
**
****************************************************************************/
#include "symbolsfindfilter.h"
#include "clangsymbolsfindfilter.h"
#include <cpptools/cpptoolsconstants.h>

View File

@@ -25,7 +25,7 @@
#pragma once
#include "symbolsfindfilter.h"
#include "clangsymbolsfindfilter.h"
namespace ClangRefactoring {

View File

@@ -26,7 +26,7 @@
#include "symbolsfindfilterconfigwidget.h"
#include "symbolsfindfilter.h"
#include "clangsymbolsfindfilter.h"
namespace ClangRefactoring {

View File

@@ -56,6 +56,7 @@ const int flowBlockSize = 200;
const int blockRadius = 18;
const int blockAdjust = 40;
const int startItemOffset = 96;
const int labelFontSize = 16;
void drawIcon(QPainter *painter,
int x,
@@ -670,6 +671,7 @@ void FormEditorFlowActionItem::paint(QPainter *painter, const QStyleOptionGraphi
if (qmlItemNode().modelNode().hasAuxiliaryData("color"))
flowColor = qmlItemNode().modelNode().auxiliaryData("color").value<QColor>();
const qreal scaleFactor = viewportTransform().m11();
qreal width = 2;
if (qmlItemNode().modelNode().hasAuxiliaryData("width"))
@@ -787,26 +789,28 @@ public:
}
}
}
// Only assign area node if there is exactly one from (QmlFlowItemNode)
if (from.size() == 1) {
const QmlItemNode tmp = from.back();
const QmlFlowItemNode f(tmp.modelNode());
if (f.isValid()) {
for (const QmlFlowActionAreaNode &area : f.flowActionAreas()) {
ModelNode target = area.targetTransition();
if (target == node.modelNode()) {
areaNode = area;
} else {
const ModelNode decisionNode = area.decisionNodeForTransition(node.modelNode());
if (decisionNode.isValid()) {
from.clear();
from.append(decisionNode);
areaNode = ModelNode();
// Only assign area node if there is exactly one from (QmlFlowItemNode)
if (from.size() == 1) {
const QmlItemNode tmp = from.back();
const QmlFlowItemNode f(tmp.modelNode());
if (f.isValid()) {
for (const QmlFlowActionAreaNode &area : f.flowActionAreas()) {
ModelNode target = area.targetTransition();
if (target == node.modelNode()) {
areaNode = area;
} else {
const ModelNode decisionNode = area.decisionNodeForTransition(node.modelNode());
if (decisionNode.isValid()) {
from.clear();
from.append(decisionNode);
areaNode = ModelNode();
}
}
}
}
if (f.modelNode().hasAuxiliaryData("joinConnection"))
joinConnection = f.modelNode().auxiliaryData("joinConnection").toBool();
if (f.modelNode().hasAuxiliaryData("joinConnection"))
joinConnection = f.modelNode().auxiliaryData("joinConnection").toBool();
} else {
if (f == node.rootModelNode())
isStartLine = true;
@@ -852,7 +856,7 @@ public:
, bezier(50)
, type(ConnectionType::Default)
, label()
, fontSize(16 / scaleFactor)
, fontSize(labelFontSize / scaleFactor)
, labelOffset(14 / scaleFactor)
, labelPosition(50.0)
, labelFlags(Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextDontClip)
@@ -1159,10 +1163,29 @@ public:
const ConnectionConfiguration &connectionConfig)
: config(connectionConfig)
{
if (from.isFlowDecision() || from.isFlowWildcard() || from.isFlowView())
if (from.isFlowDecision()) {
int size = flowBlockSize;
if (from.modelNode().hasAuxiliaryData("blockSize"))
size = from.modelNode().auxiliaryData("blockSize").toInt();
fromRect = QRectF(0, 0, size, size);
QTransform transform;
transform.translate(fromRect.center().x(), fromRect.center().y());
transform.rotate(45);
transform.translate(-fromRect.center().x(), -fromRect.center().y());
fromRect = transform.mapRect(fromRect);
} else if (from.isFlowWildcard()) {
int size = flowBlockSize;
if (from.modelNode().hasAuxiliaryData("blockSize"))
size = from.modelNode().auxiliaryData("blockSize").toInt();
fromRect = QRectF(0, 0, size, size);
} else if (from.isFlowView()) {
fromRect = QRectF(0, 0, flowBlockSize, flowBlockSize);
else
} else {
fromRect = from.instanceBoundingRect();
}
fromRect.translate(from.flowPosition());
@@ -1172,15 +1195,27 @@ public:
fromRect.translate(resolveConnection.areaNode.instancePosition());
}
if (to.isFlowDecision())
toRect = QRectF(0, 0, flowBlockSize,flowBlockSize);
else
if (to.isFlowDecision()) {
int size = flowBlockSize;
if (to.modelNode().hasAuxiliaryData("blockSize"))
size = to.modelNode().auxiliaryData("blockSize").toInt();
toRect = QRectF(0, 0, size, size);
QTransform transform;
transform.translate(toRect.center().x(), toRect.center().y());
transform.rotate(45);
transform.translate(-toRect.center().x(), -toRect.center().y());
toRect = transform.mapRect(toRect);
} else {
toRect = to.instanceBoundingRect();
}
toRect.translate(to.flowPosition());
if (resolveConnection.isStartLine) {
fromRect = QRectF(0, 0, 96, 96);
fromRect = QRectF(0, 0, 96, 96); // TODO Use const startItemOffset
fromRect.translate(to.flowPosition() + QPoint(-180, toRect.height() / 2 - 96 / 2));
fromRect.translate(0, config.outOffset);
}
@@ -1623,7 +1658,76 @@ QTransform FormEditorItem::viewportTransform() const
void FormEditorFlowDecisionItem::updateGeometry()
{
prepareGeometryChange();
m_selectionBoundingRect = QRectF(0, 0, flowBlockSize, flowBlockSize);
int size = flowBlockSize;
if (qmlItemNode().modelNode().hasAuxiliaryData("blockSize"))
size = qmlItemNode().modelNode().auxiliaryData("blockSize").toInt();
QRectF boundingRect(0, 0, size, size);
QTransform transform;
if (qmlItemNode().isFlowDecision()) {
transform.translate(boundingRect.center().x(), boundingRect.center().y());
transform.rotate(45);
transform.translate(-boundingRect.center().x(), -boundingRect.center().y());
// If drawing the dialog title is requested we need to add it to the bounding rect.
QRectF labelBoundingRect;
int showDialogLabel = false;
if (qmlItemNode().modelNode().hasAuxiliaryData("showDialogLabel"))
showDialogLabel = qmlItemNode().modelNode().auxiliaryData("showDialogLabel").toBool();
if (showDialogLabel) {
QString dialogTitle;
if (qmlItemNode().modelNode().hasVariantProperty("dialogTitle"))
dialogTitle = qmlItemNode().modelNode().variantProperty("dialogTitle").value().toString();
if (!dialogTitle.isEmpty()) {
// Local painter is used to get the labels bounding rect by using drawText()
QPixmap pixmap(640, 480);
QPainter localPainter(&pixmap);
QFont font = localPainter.font();
font.setPixelSize(labelFontSize / viewportTransform().m11());
localPainter.setFont(font);
int margin = blockAdjust * 0.5;
const QRectF adjustedRect = boundingRect.adjusted(margin, margin, -margin, -margin);
QRectF textRect(0, 0, 100, 20);
Qt::Corner corner = Qt::TopRightCorner;
if (qmlItemNode().modelNode().hasAuxiliaryData("dialogLabelPosition"))
corner = qmlItemNode().modelNode().auxiliaryData("dialogLabelPosition").value<Qt::Corner>();
int flag = 0;
switch (corner) {
case Qt::TopLeftCorner:
flag = Qt::AlignRight;
textRect.moveBottomRight(adjustedRect.topLeft());
break;
case Qt::TopRightCorner:
flag = Qt::AlignLeft;
textRect.moveBottomLeft(adjustedRect.topRight());
break;
case Qt::BottomLeftCorner:
flag = Qt::AlignRight;
textRect.moveTopRight(adjustedRect.bottomLeft());
break;
case Qt::BottomRightCorner:
flag = Qt::AlignLeft;
textRect.moveTopLeft(adjustedRect.bottomRight());
break;
}
localPainter.drawText(textRect, flag | Qt::TextDontClip, dialogTitle, &labelBoundingRect);
}
}
// Unite the rotate item bounding rect with the label bounding rect.
boundingRect = transform.mapRect(boundingRect);
boundingRect = boundingRect.united(labelBoundingRect);
}
m_selectionBoundingRect = boundingRect;
m_paintedBoundingRect = m_selectionBoundingRect;
m_boundingRect = m_paintedBoundingRect;
setTransform(qmlItemNode().instanceTransformWithContentTransform());
@@ -1665,6 +1769,7 @@ void FormEditorFlowDecisionItem::paint(QPainter *painter, const QStyleOptionGrap
if (qmlItemNode().modelNode().hasAuxiliaryData("color"))
flowColor = qmlItemNode().modelNode().auxiliaryData("color").value<QColor>();
const qreal scaleFactor = viewportTransform().m11();
qreal width = 2;
if (qmlItemNode().modelNode().hasAuxiliaryData("width"))
@@ -1692,30 +1797,84 @@ void FormEditorFlowDecisionItem::paint(QPainter *painter, const QStyleOptionGrap
painter->save();
if (m_iconType == DecisionIcon) {
painter->translate(boundingRect().center());
painter->rotate(45);
painter->translate(-boundingRect().center());
}
if (fillColor.alpha() > 0)
painter->setBrush(fillColor);
int radius = blockRadius;
if (qmlItemNode().modelNode().hasAuxiliaryData("blockRadius"))
radius = qmlItemNode().modelNode().auxiliaryData("blockRadius").toInt();
const QRectF adjustedRect = boundingRect().adjusted(blockAdjust,
blockAdjust,
-blockAdjust,
-blockAdjust);
int size = flowBlockSize;
if (qmlItemNode().modelNode().hasAuxiliaryData("blockSize"))
size = qmlItemNode().modelNode().auxiliaryData("blockSize").toInt();
QRectF boundingRect(0, 0, size, size);
QTransform transform;
int margin = blockAdjust;
if (m_iconType == DecisionIcon) {
transform.translate(boundingRect.center().x(), boundingRect.center().y());
transform.rotate(45);
transform.translate(-boundingRect.center().x(), -boundingRect.center().y());
margin *= 0.5;
}
const QRectF adjustedRect = boundingRect.adjusted(margin, margin, -margin, -margin);
painter->setTransform(transform, true);
painter->drawRoundedRect(adjustedRect, radius, radius);
const int iconDecrement = 32;
const int iconSize = adjustedRect.width() - iconDecrement;
const int offset = iconDecrement / 2 + blockAdjust;
const int offset = iconDecrement / 2 + margin;
painter->restore();
// Draw the dialog title inside the form view if requested. Decision item only.
int showDialogLabel = false;
if (qmlItemNode().modelNode().hasAuxiliaryData("showDialogLabel"))
showDialogLabel = qmlItemNode().modelNode().auxiliaryData("showDialogLabel").toBool();
if (showDialogLabel) {
QString dialogTitle;
if (qmlItemNode().modelNode().hasVariantProperty("dialogTitle"))
dialogTitle = qmlItemNode().modelNode().variantProperty("dialogTitle").value().toString();
if (!dialogTitle.isEmpty()) {
QFont font = painter->font();
font.setPixelSize(labelFontSize / scaleFactor);
painter->setFont(font);
QRectF textRect(0, 0, 100, 20);
Qt::Corner corner = Qt::TopRightCorner;
if (qmlItemNode().modelNode().hasAuxiliaryData("dialogLabelPosition"))
corner = qmlItemNode().modelNode().auxiliaryData("dialogLabelPosition").value<Qt::Corner>();
int flag = 0;
switch (corner) {
case Qt::TopLeftCorner:
flag = Qt::AlignRight;
textRect.moveBottomRight(adjustedRect.topLeft());
break;
case Qt::TopRightCorner:
flag = Qt::AlignLeft;
textRect.moveBottomLeft(adjustedRect.topRight());
break;
case Qt::BottomLeftCorner:
flag = Qt::AlignRight;
textRect.moveTopRight(adjustedRect.bottomLeft());
break;
case Qt::BottomRightCorner:
flag = Qt::AlignLeft;
textRect.moveTopLeft(adjustedRect.bottomRight());
break;
}
painter->drawText(textRect, flag | Qt::TextDontClip, dialogTitle);
}
}
const QString icon = (m_iconType ==
WildcardIcon) ? Theme::getIconUnicode(Theme::wildcard)
: Theme::getIconUnicode(Theme::decisionNode);

View File

@@ -392,9 +392,9 @@ void FormEditorView::variantPropertiesChanged(const QList<VariantProperty> &prop
Q_UNUSED(propertyChange)
for (const VariantProperty &property : propertyList) {
QmlVisualNode node(property.parentModelNode());
if (node.isFlowTransition()) {
if (node.isFlowTransition() || node.isFlowDecision()) {
if (FormEditorItem *item = m_scene->itemForQmlItemNode(node.toQmlItemNode())) {
if (property.name() == "question")
if (property.name() == "question" || property.name() == "dialogTitle")
item->updateGeometry();
}
}
@@ -572,7 +572,8 @@ void FormEditorView::auxiliaryDataChanged(const ModelNode &node, const PropertyN
// Update the geomtry if one of the following auxiliary properties has changed
static const QStringList updateGeometryPropertyNames = {
"breakPoint", "bezier", "transitionBezier", "type", "tranitionType", "radius",
"transitionRadius", "labelPosition", "labelFlipSide", "inOffset", "outOffset"
"transitionRadius", "labelPosition", "labelFlipSide", "inOffset", "outOffset",
"blockSize", "blockRadius", "showDialogLabel", "dialogLabelPosition"
};
if (updateGeometryPropertyNames.contains(QString::fromUtf8(name)))
editorItem->updateGeometry();

View File

@@ -188,6 +188,14 @@ QVariant properDefaultAuxiliaryProperties(const QmlObjectNode &qmlObjectNode,
return QString();
else if (propertyName == "joinConnection")
return false;
else if (propertyName == "blockSize")
return 200;
else if (propertyName == "blockRadius")
return 18;
else if (propertyName == "showDialogLabel")
return false;
else if (propertyName == "dialogLabelPosition")
return Qt::TopRightCorner;
return {};
}
@@ -259,9 +267,9 @@ void PropertyEditorQmlBackend::setupAuxiliaryProperties(const QmlObjectNode &qml
} else if (itemNode.isFlowActionArea()) {
propertyNames.append({"color", "width", "fillColor", "outOffset", "dash"});
} else if (itemNode.isFlowDecision()) {
propertyNames.append({"color", "width", "fillColor", "dash"});
propertyNames.append({"color", "width", "fillColor", "dash", "blockSize", "blockRadius", "showDialogLabel", "dialogLabelPosition"});
} else if (itemNode.isFlowWildcard()) {
propertyNames.append({"color", "width", "fillColor", "dash"});
propertyNames.append({"color", "width", "fillColor", "dash", "blockSize", "blockRadius"});
} else if (itemNode.isFlowView()) {
propertyNames.append({"transitionColor", "areaColor", "areaFillColor", "blockColor", "transitionType", "transitionRadius", "transitionBezier"});
}

View File

@@ -62,6 +62,7 @@ add_qtc_test(unittest GTEST
gtest-creator-printing.cpp gtest-creator-printing.h
gtest-llvm-printing.h
gtest-qt-printing.cpp gtest-qt-printing.h
gtest-std-printing.h
headerpathfilter-test.cpp
highlightingresultreporter-test.cpp
lineprefixer-test.cpp
@@ -390,7 +391,7 @@ extend_qtc_test(unittest
refactoringprojectupdater.cpp refactoringprojectupdater.h
searchinterface.h
searchhandle.cpp searchhandle.h
symbolsfindfilter.cpp symbolsfindfilter.h
clangsymbolsfindfilter.cpp clangsymbolsfindfilter.h
symbolqueryinterface.h
symbol.h
projectpartproviderinterface.h

View File

@@ -16,7 +16,7 @@ include($$PWD/../../../src/plugins/clangpchmanager/clangpchmanager-source.pri)
include($$PWD/../../../src/plugins/cpptools/cpptoolsunittestfiles.pri)
include($$PWD/../../../src/plugins/debugger/debuggerunittestfiles.pri)
include($$PWD/../../../src/plugins/compilationdatabaseprojectmanager/compilationdatabaseunittestfiles.pri)
include(cplusplus.pri)
!isEmpty(QTC_UNITTEST_BUILD_CPP_PARSER):include(cplusplus.pri)
!isEmpty(LLVM_VERSION) {
include($$PWD/../../../src/plugins/clangtools/clangtoolsunittestfiles.pri)
include($$PWD/../../../src/shared/clang/clang_defines.pri)

View File

@@ -38,9 +38,10 @@
#include "compare-operators.h"
#include "conditionally-disabled-tests.h"
#include "gtest-qt-printing.h"
#include "gtest-creator-printing.h"
#include "gtest-llvm-printing.h"
#include "gtest-qt-printing.h"
#include "gtest-std-printing.h"
#ifdef CLANG_UNIT_TESTS
# include "gtest-clang-printing.h"
#endif

View File

@@ -24,6 +24,7 @@
****************************************************************************/
#include "gtest-creator-printing.h"
#include "gtest-std-printing.h"
#ifdef CLANG_UNIT_TESTS
#include <clang/Basic/SourceLocation.h>

View File

@@ -24,6 +24,7 @@
****************************************************************************/
#include "gtest-creator-printing.h"
#include "gtest-std-printing.h"
#include "gtest-qt-printing.h"
@@ -320,6 +321,9 @@ std::ostream &operator<<(std::ostream &out, const Value &value)
case Sqlite::ValueType::String:
out << "\"" << value.toStringView() << "\"";
break;
case Sqlite::ValueType::Null:
out << "null";
break;
}
return out << ")";

View File

@@ -350,24 +350,4 @@ std::ostream &operator<<(std::ostream &out, const Diagnostic &diag);
} // namespace Internal
} // namespace CppTools
namespace std {
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &vector)
{
out << "[";
for (auto current = vector.begin(); current != vector.end(); ++current) {
out << *current;
if (std::next(current) != vector.end())
out << ", ";
}
out << "]";
return out;
}
} // namespace std
void setFilePathCache(ClangBackEnd::FilePathCaching *filePathCache);

View File

@@ -23,7 +23,8 @@
**
****************************************************************************/
#include "gtest-creator-printing.h"
#include "gtest-llvm-printing.h"
#include "gtest-std-printing.h"
#include <gtest/gtest-printers.h>

View File

@@ -0,0 +1,41 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
****************************************************************************/
#pragma once
#include <ostream>
#include <vector>
namespace std {
template<typename T>
ostream &operator<<(ostream &out, const vector<T> &vector)
{
out << "[";
for (auto current = vector.begin(); current != vector.end(); ++current) {
out << *current;
if (std::next(current) != vector.end())
out << ", ";
}
out << "]";
return out;
}
} // namespace std

View File

@@ -35,14 +35,14 @@ class LastChangedRowId : public testing::Test
{
protected:
NiceMock<MockSqliteDatabase> mockSqliteDatabase;
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main", "foo"};
Sqlite::LastChangedRowId<1> lastRowId{mockSqliteDatabase, "main", "foo"};
};
TEST_F(LastChangedRowId, SetUpdateHookInContructor)
{
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_));
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_, _));
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main", "foo"};
Sqlite::LastChangedRowId<1> lastRowId{mockSqliteDatabase, "main", "foo"};
}
TEST_F(LastChangedRowId, ResetUpdateHookInDestructor)
@@ -57,42 +57,42 @@ TEST_F(LastChangedRowId, GetMinusOneAsRowIdIfNoCallbackWasCalled)
TEST_F(LastChangedRowId, CallbackSetsLastRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowId, CallbackChecksDatabaseName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId("main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "temp", "foo", 42);
lastRowId("temp", "foo", 42);
ASSERT_THAT(lastRowId.lastRowId, 33);
}
TEST_F(LastChangedRowId, CallbackChecksTableName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId("main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "main", "bar", 42);
lastRowId("main", "bar", 42);
ASSERT_THAT(lastRowId.lastRowId, 33);
}
TEST_F(LastChangedRowId, LastCallSetsRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId.callback(Sqlite::ChangeType::Insert, "main", "foo", 33);
lastRowId("main", "foo", 42);
lastRowId("main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Delete, "main", "foo", 66);
lastRowId("main", "foo", 66);
ASSERT_THAT(lastRowId.lastRowId, 66);
}
TEST_F(LastChangedRowId, TakeLastRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
auto id = lastRowId.takeLastRowId();
@@ -101,7 +101,7 @@ TEST_F(LastChangedRowId, TakeLastRowId)
TEST_F(LastChangedRowId, TakeLastRowIdResetsRowIdToMinusOne)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
lastRowId.takeLastRowId();
auto id = lastRowId.takeLastRowId();
@@ -114,14 +114,14 @@ class LastChangedRowIdWithTwoTables : public testing::Test
protected:
NiceMock<MockSqliteDatabase> mockSqliteDatabase;
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main", "foo", "bar"};
Sqlite::LastChangedRowId<2> lastRowId{mockSqliteDatabase, "main", "foo", "bar"};
};
TEST_F(LastChangedRowIdWithTwoTables, SetUpdateHookInContructor)
{
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_));
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_, _));
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main", "foo"};
Sqlite::LastChangedRowId<2> lastRowId{mockSqliteDatabase, "main", "foo", "bar"};
}
TEST_F(LastChangedRowIdWithTwoTables, ResetUpdateHookInDestructor)
@@ -136,48 +136,48 @@ TEST_F(LastChangedRowIdWithTwoTables, GetMinusOneAsRowIdIfNoCallbackWasCalled)
TEST_F(LastChangedRowIdWithTwoTables, CallbackSetsLastRowIdFirstTable)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithTwoTables, CallbackSetsLastRowIdSecondTable)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "bar", 66);
lastRowId("main", "bar", 66);
ASSERT_THAT(lastRowId.lastRowId, 66);
}
TEST_F(LastChangedRowIdWithTwoTables, CallbackChecksDatabaseName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId("main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "temp", "foo", 42);
lastRowId("temp", "foo", 42);
ASSERT_THAT(lastRowId.lastRowId, 33);
}
TEST_F(LastChangedRowIdWithTwoTables, CallbackChecksTableName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId("main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "main", "zoo", 42);
lastRowId("main", "zoo", 42);
ASSERT_THAT(lastRowId.lastRowId, 33);
}
TEST_F(LastChangedRowIdWithTwoTables, LastCallSetsRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
lastRowId.callback(Sqlite::ChangeType::Delete, "main", "bar", 66);
lastRowId("main", "bar", 66);
ASSERT_THAT(lastRowId.lastRowId, 66);
}
TEST_F(LastChangedRowIdWithTwoTables, TakeLastRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
auto id = lastRowId.takeLastRowId();
@@ -186,7 +186,7 @@ TEST_F(LastChangedRowIdWithTwoTables, TakeLastRowId)
TEST_F(LastChangedRowIdWithTwoTables, TakeLastRowIdResetsRowIdToMinusOne)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
lastRowId.takeLastRowId();
auto id = lastRowId.takeLastRowId();
@@ -199,14 +199,14 @@ class LastChangedRowIdWithThreeTables : public testing::Test
protected:
NiceMock<MockSqliteDatabase> mockSqliteDatabase;
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main", "foo", "bar", "too"};
Sqlite::LastChangedRowId<3> lastRowId{mockSqliteDatabase, "main", "foo", "bar", "too"};
};
TEST_F(LastChangedRowIdWithThreeTables, SetUpdateHookInContructor)
{
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_));
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_, _));
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main", "foo"};
Sqlite::LastChangedRowId<3> lastRowId{mockSqliteDatabase, "main", "foo", "bar", "too"};
}
TEST_F(LastChangedRowIdWithThreeTables, ResetUpdateHookInDestructor)
@@ -221,56 +221,56 @@ TEST_F(LastChangedRowIdWithThreeTables, GetMinusOneAsRowIdIfNoCallbackWasCalled)
TEST_F(LastChangedRowIdWithThreeTables, CallbackSetsLastRowIdFirstTable)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithThreeTables, CallbackSetsLastRowIdSecondTable)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "bar", 42);
lastRowId("main", "bar", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithThreeTables, CallbackSetsLastRowIdThirdTable)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "too", 42);
lastRowId("main", "too", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithThreeTables, CallbackChecksDatabaseName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId("main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "temp", "foo", 42);
lastRowId("temp", "foo", 42);
ASSERT_THAT(lastRowId.lastRowId, 33);
}
TEST_F(LastChangedRowIdWithThreeTables, CallbackChecksTableName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId("main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "main", "zoo", 42);
lastRowId("main", "zoo", 42);
ASSERT_THAT(lastRowId.lastRowId, 33);
}
TEST_F(LastChangedRowIdWithThreeTables, LastCallSetsRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "bar", 42);
lastRowId.callback(Sqlite::ChangeType::Insert, "main", "too", 33);
lastRowId("main", "bar", 42);
lastRowId("main", "too", 33);
lastRowId.callback(Sqlite::ChangeType::Delete, "main", "too", 66);
lastRowId("main", "too", 66);
ASSERT_THAT(lastRowId.lastRowId, 66);
}
TEST_F(LastChangedRowIdWithThreeTables, TakeLastRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
auto id = lastRowId.takeLastRowId();
@@ -279,7 +279,7 @@ TEST_F(LastChangedRowIdWithThreeTables, TakeLastRowId)
TEST_F(LastChangedRowIdWithThreeTables, TakeLastRowIdResetsRowIdToMinusOne)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", "foo", 42);
lastRowId.takeLastRowId();
auto id = lastRowId.takeLastRowId();
@@ -291,14 +291,14 @@ class LastChangedRowIdWithNoDatabaseAndTable : public testing::Test
{
protected:
NiceMock<MockSqliteDatabase> mockSqliteDatabase;
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase};
Sqlite::LastChangedRowId<> lastRowId{mockSqliteDatabase};
};
TEST_F(LastChangedRowIdWithNoDatabaseAndTable, SetUpdateHookInContructor)
{
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_));
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_, _));
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main", "foo"};
Sqlite::LastChangedRowId<> lastRowId{mockSqliteDatabase};
}
TEST_F(LastChangedRowIdWithNoDatabaseAndTable, ResetUpdateHookInDestructor)
@@ -313,42 +313,24 @@ TEST_F(LastChangedRowIdWithNoDatabaseAndTable, GetMinusOneAsRowIdIfNoCallbackWas
TEST_F(LastChangedRowIdWithNoDatabaseAndTable, CallbackSetsLastRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithNoDatabaseAndTable, CallbackDoNotChecksDatabaseName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "temp", "foo", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithNoDatabaseAndTable, CallbackDoNotChecksTableName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "main", "bar", 42);
lastRowId(42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithNoDatabaseAndTable, LastCallSetsRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId.callback(Sqlite::ChangeType::Insert, "main", "foo", 33);
lastRowId(42);
lastRowId(33);
lastRowId.callback(Sqlite::ChangeType::Delete, "main", "foo", 66);
lastRowId(66);
ASSERT_THAT(lastRowId.lastRowId, 66);
}
TEST_F(LastChangedRowIdWithNoDatabaseAndTable, TakeLastRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId(42);
auto id = lastRowId.takeLastRowId();
@@ -357,7 +339,7 @@ TEST_F(LastChangedRowIdWithNoDatabaseAndTable, TakeLastRowId)
TEST_F(LastChangedRowIdWithNoDatabaseAndTable, TakeLastRowIdResetsRowIdToMinusOne)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId(42);
lastRowId.takeLastRowId();
auto id = lastRowId.takeLastRowId();
@@ -369,14 +351,14 @@ class LastChangedRowIdWithNoTable : public testing::Test
{
protected:
NiceMock<MockSqliteDatabase> mockSqliteDatabase;
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main"};
Sqlite::LastChangedRowId<> lastRowId{mockSqliteDatabase, "main"};
};
TEST_F(LastChangedRowIdWithNoTable, SetUpdateHookInContructor)
{
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_));
EXPECT_CALL(mockSqliteDatabase, setUpdateHook(_, _));
Sqlite::LastChangedRowId lastRowId{mockSqliteDatabase, "main", "foo"};
Sqlite::LastChangedRowId<> lastRowId{mockSqliteDatabase, "main"};
}
TEST_F(LastChangedRowIdWithNoTable, ResetUpdateHookInDestructor)
@@ -391,42 +373,33 @@ TEST_F(LastChangedRowIdWithNoTable, GetMinusOneAsRowIdIfNoCallbackWasCalled)
TEST_F(LastChangedRowIdWithNoTable, CallbackSetsLastRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithNoTable, CallbackChecksDatabaseName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId("main", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "temp", "foo", 42);
lastRowId("temp", 42);
ASSERT_THAT(lastRowId.lastRowId, 33);
}
TEST_F(LastChangedRowIdWithNoTable, CallbackDoNotChecksTableName)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 33);
lastRowId.callback(Sqlite::ChangeType::Update, "main", "bar", 42);
ASSERT_THAT(lastRowId.lastRowId, 42);
}
TEST_F(LastChangedRowIdWithNoTable, LastCallSetsRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId.callback(Sqlite::ChangeType::Insert, "main", "foo", 33);
lastRowId("main", 42);
lastRowId("main", 33);
lastRowId.callback(Sqlite::ChangeType::Delete, "main", "foo", 66);
lastRowId("main", 66);
ASSERT_THAT(lastRowId.lastRowId, 66);
}
TEST_F(LastChangedRowIdWithNoTable, TakeLastRowId)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", 42);
auto id = lastRowId.takeLastRowId();
@@ -435,7 +408,7 @@ TEST_F(LastChangedRowIdWithNoTable, TakeLastRowId)
TEST_F(LastChangedRowIdWithNoTable, TakeLastRowIdResetsRowIdToMinusOne)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 42);
lastRowId("main", 42);
lastRowId.takeLastRowId();
auto id = lastRowId.takeLastRowId();
@@ -452,7 +425,7 @@ TEST_F(LastChangedRowIdWithNoTable, LastRowIdIsNotValidForNegativeValues)
TEST_F(LastChangedRowIdWithNoTable, LastRowIdIsValidForNull)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 0);
lastRowId("main", 0);
auto isValid = lastRowId.lastRowIdIsValid();
@@ -461,7 +434,7 @@ TEST_F(LastChangedRowIdWithNoTable, LastRowIdIsValidForNull)
TEST_F(LastChangedRowIdWithNoTable, LastRowIdIsValidForPositiveValues)
{
lastRowId.callback(Sqlite::ChangeType::Update, "main", "foo", 777);
lastRowId("main", 777);
auto isValid = lastRowId.lastRowIdIsValid();

View File

@@ -60,7 +60,9 @@ public:
MOCK_METHOD0(walCheckpointFull, void());
MOCK_METHOD1(setUpdateHook, void(Sqlite::DatabaseInterface::UpdateCallback &));
MOCK_METHOD2(setUpdateHook,
void(void *object,
void (*)(void *object, int, char const *database, char const *, long long rowId)));
MOCK_METHOD0(resetUpdateHook, void());

View File

@@ -39,6 +39,8 @@
#include <QTemporaryFile>
#include <QVariant>
#include <functional>
namespace {
using testing::Contains;
@@ -74,13 +76,23 @@ protected:
return Sqlite::ReadStatement("SELECT name FROM test", database).values<Utils::SmallString>(8);
}
static void updateHookCallback(
void *object, int type, char const *database, char const *table, long long rowId)
{
static_cast<SqliteDatabase *>(object)->callback(static_cast<Sqlite::ChangeType>(type),
database,
table,
rowId);
}
protected:
SpyDummy spyDummy;
QString databaseFilePath{":memory:"};
mutable Sqlite::Database database;
Sqlite::TransactionInterface &transactionInterface = database;
MockFunction<void(Sqlite::ChangeType tupe, char const *, char const *, long long)> callbackMock;
Sqlite::Database::UpdateCallback callback = callbackMock.AsStdFunction();
std::function<void(Sqlite::ChangeType tupe, char const *, char const *, long long)>
callback = callbackMock.AsStdFunction();
};
TEST_F(SqliteDatabase, SetDatabaseFilePath)
@@ -232,7 +244,7 @@ TEST_F(SqliteDatabase, Rollback)
TEST_F(SqliteDatabase, SetUpdateHookSet)
{
database.setUpdateHook(callback);
database.setUpdateHook(this, updateHookCallback);
EXPECT_CALL(callbackMock, Call(_, _, _, _));
Sqlite::WriteStatement("INSERT INTO test(name) VALUES (?)", database).write(42);
@@ -240,10 +252,9 @@ TEST_F(SqliteDatabase, SetUpdateHookSet)
TEST_F(SqliteDatabase, SetNullUpdateHook)
{
database.setUpdateHook(callback);
Sqlite::Database::UpdateCallback newCallback;
database.setUpdateHook(this, updateHookCallback);
database.setUpdateHook(newCallback);
database.setUpdateHook(nullptr, nullptr);
EXPECT_CALL(callbackMock, Call(_, _, _, _)).Times(0);
Sqlite::WriteStatement("INSERT INTO test(name) VALUES (?)", database).write(42);
@@ -251,8 +262,7 @@ TEST_F(SqliteDatabase, SetNullUpdateHook)
TEST_F(SqliteDatabase, ResetUpdateHook)
{
database.setUpdateHook(callback);
Sqlite::Database::UpdateCallback newCallback;
database.setUpdateHook(this, updateHookCallback);
database.resetUpdateHook();
@@ -263,7 +273,7 @@ TEST_F(SqliteDatabase, ResetUpdateHook)
TEST_F(SqliteDatabase, DeleteUpdateHookCall)
{
Sqlite::WriteStatement("INSERT INTO test(name) VALUES (?)", database).write(42);
database.setUpdateHook(callback);
database.setUpdateHook(this, updateHookCallback);
EXPECT_CALL(callbackMock, Call(Eq(Sqlite::ChangeType::Delete), _, _, _));
@@ -272,7 +282,7 @@ TEST_F(SqliteDatabase, DeleteUpdateHookCall)
TEST_F(SqliteDatabase, InsertUpdateHookCall)
{
database.setUpdateHook(callback);
database.setUpdateHook(this, updateHookCallback);
EXPECT_CALL(callbackMock, Call(Eq(Sqlite::ChangeType::Insert), _, _, _));
@@ -281,7 +291,7 @@ TEST_F(SqliteDatabase, InsertUpdateHookCall)
TEST_F(SqliteDatabase, UpdateUpdateHookCall)
{
database.setUpdateHook(callback);
database.setUpdateHook(this, updateHookCallback);
EXPECT_CALL(callbackMock, Call(Eq(Sqlite::ChangeType::Insert), _, _, _));
@@ -290,7 +300,7 @@ TEST_F(SqliteDatabase, UpdateUpdateHookCall)
TEST_F(SqliteDatabase, RowIdUpdateHookCall)
{
database.setUpdateHook(callback);
database.setUpdateHook(this, updateHookCallback);
EXPECT_CALL(callbackMock, Call(_, _, _, Eq(42)));
@@ -299,7 +309,7 @@ TEST_F(SqliteDatabase, RowIdUpdateHookCall)
TEST_F(SqliteDatabase, DatabaseUpdateHookCall)
{
database.setUpdateHook(callback);
database.setUpdateHook(this, updateHookCallback);
EXPECT_CALL(callbackMock, Call(_, StrEq("main"), _, _));
@@ -308,7 +318,7 @@ TEST_F(SqliteDatabase, DatabaseUpdateHookCall)
TEST_F(SqliteDatabase, TableUpdateHookCall)
{
database.setUpdateHook(callback);
database.setUpdateHook(this, updateHookCallback);
EXPECT_CALL(callbackMock, Call(_, _, StrEq("test"), _));

View File

@@ -388,6 +388,7 @@ TEST_F(SqliteStatement, WritePointerValues)
TEST_F(SqliteStatement, WriteNullValues)
{
WriteStatement statement("UPDATE test SET name=?, number=? WHERE rowid=?", database);
statement.write(1, 1, 1);
statement.write(Sqlite::NullValue{}, Sqlite::Value{}, 1);

View File

@@ -25,7 +25,7 @@
#include "googletest.h"
#include <clangrefactoring/symbolsfindfilter.h>
#include <clangrefactoring/clangsymbolsfindfilter.h>
namespace {

View File

@@ -1,9 +1,11 @@
INCLUDEPATH += ../mockup
QT += core network testlib widgets
CONFIG += console c++14 testcase object_parallel_to_source
CONFIG += console c++14 testcase
CONFIG -= app_bundle shared
QTC_UNITTEST_BUILD_CPP_PARSER = $$(QTC_UNITTEST_BUILD_CPP_PARSER)
include(gmock_dependency.pri)
include(clang_dependency.pri)
include(creator_dependency.pri)
@@ -11,8 +13,6 @@ include(benchmark_dependency.pri)
requires(isEmpty(QTC_CLANG_BUILDMODE_MISMATCH))
OBJECTS_DIR = $$OUT_PWD/obj # workaround for qmake bug in object_parallel_to_source
!msvc:force_debug_info:QMAKE_CXXFLAGS += -fno-omit-frame-pointer
DEFINES += \
@@ -66,7 +66,6 @@ SOURCES += \
lastchangedrowid-test.cpp \
lineprefixer-test.cpp \
locatorfilter-test.cpp \
matchingtext-test.cpp \
mimedatabase-utilities.cpp \
pchmanagerclientserverinprocess-test.cpp \
pchmanagerclient-test.cpp \
@@ -133,6 +132,8 @@ SOURCES += \
sqlstatementbuilder-test.cpp \
createtablesqlstatementbuilder-test.cpp
!isEmpty(QTC_UNITTEST_BUILD_CPP_PARSER):matchingtext-test.cpp
!isEmpty(LIBCLANG_LIBS) {
SOURCES += \
activationsequencecontextprocessor-test.cpp \
@@ -229,6 +230,7 @@ HEADERS += \
gtest-creator-printing.h \
gtest-llvm-printing.h \
gtest-qt-printing.h \
gtest-std-printing.h \
mimedatabase-utilities.h \
mockclangcodemodelclient.h \
mockclangcodemodelserver.h \