mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-27 06:45:49 +03:00
Add ASYNC_ASSERT_ICON_IS_EQUAL command to SocketApi
This commit is contained in:
parent
d1f9b1a4f8
commit
25cd52dd9f
2 changed files with 46 additions and 0 deletions
|
@ -1305,6 +1305,51 @@ void SocketApi::command_ASYNC_TRIGGER_MENU_ACTION(const QSharedPointer<SocketApi
|
|||
|
||||
job->reject("Action not found");
|
||||
}
|
||||
|
||||
void SocketApi::command_ASYNC_ASSERT_ICON_IS_EQUAL(const QSharedPointer<SocketApiJob> &job)
|
||||
{
|
||||
auto widget = findWidget(job->arguments()[QLatin1String("queryString")].toString());
|
||||
if (!widget) {
|
||||
QString message("Widget not found: 37: ");
|
||||
message.append(job->arguments()["objectName"].toString());
|
||||
job->reject(message);
|
||||
return;
|
||||
}
|
||||
|
||||
auto propertyName = job->arguments()[QLatin1String("propertyPath")].toString();
|
||||
|
||||
auto segments = propertyName.split('.');
|
||||
|
||||
QObject* currentObject = widget;
|
||||
QIcon value;
|
||||
for(int i = 0;i<segments.count(); i++) {
|
||||
auto segment = segments.at(i);
|
||||
auto var = currentObject->property(segment.toUtf8().constData());
|
||||
|
||||
if(var.canConvert<QIcon>()) {
|
||||
var.convert(QMetaType::QIcon);
|
||||
value = var.value<QIcon>();
|
||||
|
||||
DEBUG << "VALUE: " << value;
|
||||
break;
|
||||
}
|
||||
|
||||
auto tmpObject = var.value<QObject*>();
|
||||
if(tmpObject) {
|
||||
currentObject = tmpObject;
|
||||
} else {
|
||||
DEBUG << "HUH not found .. what do";
|
||||
}
|
||||
}
|
||||
|
||||
auto iconName = job->arguments()[QLatin1String("iconName")].toString();
|
||||
if (value.name() == iconName) {
|
||||
job->resolve();
|
||||
} else {
|
||||
job->reject("iconName " + iconName + " does not match: " + value.name());
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
QString SocketApi::buildRegisterPathMessage(const QString &path)
|
||||
|
|
|
@ -150,6 +150,7 @@ private:
|
|||
DirectEditor* getDirectEditorForLocalFile(const QString &localFile);
|
||||
|
||||
#if GUI_TESTING
|
||||
Q_INVOKABLE void command_ASYNC_ASSERT_ICON_IS_EQUAL(const QSharedPointer<SocketApiJob> &job);
|
||||
Q_INVOKABLE void command_ASYNC_LIST_WIDGETS(const QSharedPointer<SocketApiJob> &job);
|
||||
Q_INVOKABLE void command_ASYNC_INVOKE_WIDGET_METHOD(const QSharedPointer<SocketApiJob> &job);
|
||||
Q_INVOKABLE void command_ASYNC_GET_WIDGET_PROPERTY(const QSharedPointer<SocketApiJob> &job);
|
||||
|
|
Loading…
Reference in a new issue