bool AddToolChainOperation::test() const { QVariantMap map = initializeToolChains(); // Add toolchain: map = addToolChain(map, QLatin1String("testId"), QLatin1String("name"), QLatin1String("/tmp/test"), QLatin1String("test-abi"), QLatin1String("test-abi,test-abi2"), KeyValuePairList() << KeyValuePair(QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue")))); if (map.value(QLatin1String(COUNT)).toInt() != 1 || !map.contains(QString::fromLatin1(PREFIX) + QLatin1Char('0'))) return false; QVariantMap tcData = map.value(QString::fromLatin1(PREFIX) + QLatin1Char('0')).toMap(); if (tcData.count() != 7 || tcData.value(QLatin1String(ID)).toString() != QLatin1String("testId") || tcData.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("name") || tcData.value(QLatin1String(AUTODETECTED)).toBool() != true || tcData.value(QLatin1String(PATH)).toString() != QLatin1String("/tmp/test") || tcData.value(QLatin1String(TARGET_ABI)).toString() != QLatin1String("test-abi") || tcData.value(QLatin1String(SUPPORTED_ABIS)).toList().count() != 2 || tcData.value(QLatin1String("ExtraKey")).toString() != QLatin1String("ExtraValue")) return false; // Ignore same Id: QVariantMap unchanged = addToolChain(map, QLatin1String("testId"), QLatin1String("name2"), QLatin1String("/tmp/test2"), QLatin1String("test-abi2"), QLatin1String("test-abi2,test-abi3"), KeyValuePairList() << KeyValuePair(QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue2")))); if (!unchanged.isEmpty()) return false; // Make sure name stays unique: map = addToolChain(map, QLatin1String("testId2"), QLatin1String("name"), QLatin1String("/tmp/test"), QLatin1String("test-abi"), QLatin1String("test-abi,test-abi2"), KeyValuePairList() << KeyValuePair(QLatin1String("ExtraKey"), QVariant(QLatin1String("ExtraValue")))); if (map.value(QLatin1String(COUNT)).toInt() != 2 || !map.contains(QString::fromLatin1(PREFIX) + QLatin1Char('0')) || !map.contains(QString::fromLatin1(PREFIX) + QLatin1Char('1'))) return false; tcData = map.value(QString::fromLatin1(PREFIX) + QLatin1Char('0')).toMap(); if (tcData.count() != 7 || tcData.value(QLatin1String(ID)).toString() != QLatin1String("testId") || tcData.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("name") || tcData.value(QLatin1String(AUTODETECTED)).toBool() != true || tcData.value(QLatin1String(PATH)).toString() != QLatin1String("/tmp/test") || tcData.value(QLatin1String(TARGET_ABI)).toString() != QLatin1String("test-abi") || tcData.value(QLatin1String(SUPPORTED_ABIS)).toList().count() != 2 || tcData.value(QLatin1String("ExtraKey")).toString() != QLatin1String("ExtraValue")) return false; tcData = map.value(QString::fromLatin1(PREFIX) + QLatin1Char('1')).toMap(); if (tcData.count() != 7 || tcData.value(QLatin1String(ID)).toString() != QLatin1String("testId2") || tcData.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("name2") || tcData.value(QLatin1String(AUTODETECTED)).toBool() != true || tcData.value(QLatin1String(PATH)).toString() != QLatin1String("/tmp/test") || tcData.value(QLatin1String(TARGET_ABI)).toString() != QLatin1String("test-abi") || tcData.value(QLatin1String(SUPPORTED_ABIS)).toList().count() != 2 || tcData.value(QLatin1String("ExtraKey")).toString() != QLatin1String("ExtraValue")) return false; return true; }
bool RmKitOperation::test() const { QVariantMap map = AddKitOperation::addKit(AddKitOperation::initializeKits(), QLatin1String("testId"), QLatin1String("Test Qt Version"), QLatin1String("/tmp/icon.png"), 1, QLatin1String("/usr/bin/gdb-test"), QByteArray("Desktop"), QString(), QLatin1String("{some-tc-id}"), QLatin1String("{some-qt-id}"), QLatin1String("unsupported/mkspec"), KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue")))); map = AddKitOperation::addKit(map, QLatin1String("testId2"), QLatin1String("Test Qt Version"), QLatin1String("/tmp/icon2.png"), 1, QLatin1String("/usr/bin/gdb-test2"), QByteArray("Desktop"), QString(), QLatin1String("{some-tc-id2}"), QLatin1String("{some-qt-id2}"), QLatin1String("unsupported/mkspec2"), KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue2")))); QVariantMap result = rmKit(map, QLatin1String("testId")); if (result.count() != 4 || !result.contains(QLatin1String("Profile.0")) || !result.contains(QLatin1String(COUNT)) || result.value(QLatin1String(COUNT)).toInt() != 1 || !result.contains(QLatin1String(DEFAULT)) || result.value(QLatin1String(DEFAULT)).toInt() != 0 || !result.contains(QLatin1String(VERSION)) || result.value(QLatin1String(VERSION)).toInt() != 1) return false; result = rmKit(map, QLatin1String("unknown")); if (result != map) return false; result = rmKit(map, QLatin1String("testId2")); if (result.count() != 4 || !result.contains(QLatin1String("Profile.0")) || !result.contains(QLatin1String(COUNT)) || result.value(QLatin1String(COUNT)).toInt() != 1 || !result.contains(QLatin1String(DEFAULT)) || result.value(QLatin1String(DEFAULT)).toInt() != 0 || !result.contains(QLatin1String(VERSION)) || result.value(QLatin1String(VERSION)).toInt() != 1) return false; result = rmKit(result, QLatin1String("testId")); if (result.count() != 3 || !result.contains(QLatin1String(COUNT)) || result.value(QLatin1String(COUNT)).toInt() != 0 || !result.contains(QLatin1String(DEFAULT)) || result.value(QLatin1String(DEFAULT)).toInt() != -1 || !result.contains(QLatin1String(VERSION)) || result.value(QLatin1String(VERSION)).toInt() != 1) return false; return true; }
/** * @brief Update journal from the central service. Only done by the current server. * @return True if successful */ bool CentralServiceUpdater::updateJournal() { QObject parent; if (!m_proxyConnection->session(&parent)->isServer()) return true; SyncServer server(m_proxyConnection); QVariantMap clientRecordNumbers = server.clientRecordNumbers(); if (clientRecordNumbers.count() == 0) return false; QVariantMap body; body.insert("workspace_id", workspaceId()); body.insert("sync_all_groups", true); body.insert("client_record_numbers", clientRecordNumbers); IRequest *request = m_proxyConnection->createRequest(IRequest::POST, "central_service", "Sync/GetUpdates", this); request->setPostBody(body); IResponse *response = m_proxyConnection->callModule(request); if (response->status() != IResponse::OK) { m_proxyConnection->debugMessage("Central Service Update: Failed to retrieve journal updates from the service"); return false; } server.saveAndApplyUpdates(response->body().toList()); return true; }
void TestCntActions::phonenumberCallSupport() { QContact contact; //Add phonenumber to contact QContactPhoneNumber number; number.setSubTypes(QContactPhoneNumber::SubTypeMobile); number.setNumber("555111222"); contact.saveDetail(&number); m_manager->saveContact(&contact); //verify that the contact has a phonenumber QList<QContactPhoneNumber> numberList = contact.details<QContactPhoneNumber>(); QVERIFY(numberList.count() > 0); //get the actions QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); QStringList actions; for (int i = 0;i < actionDescriptors.count();i++) { QString action = actionDescriptors.at(i).actionName(); actions << action; } //verify that it includes the actiosn QVERIFY(actions.contains("call", Qt::CaseInsensitive)); //verify that the action works QList<QContactActionDescriptor> callActionDescriptors = QContactAction::actionDescriptors("call", "symbian"); QVERIFY(callActionDescriptors.count() == 1); QContactAction *callAction = QContactAction::action(callActionDescriptors.at(0)); QVERIFY(callAction != 0); QContactAction::State state = callAction->state(); QVERIFY(state != QContactAction::InactiveState); QVERIFY(callAction->isDetailSupported(numberList.at(0)) == true); QList<QContactDetail> supportedDetails = callAction->supportedDetails(contact); QVERIFY(supportedDetails.count() != 0); QVariantMap variantMap = callAction->metaData(); QVERIFY(variantMap.count() == 0); variantMap = callAction->results(); QVERIFY(variantMap.count() == 0); QSignalSpy spyCallAction(callAction, SIGNAL(stateChanged(QContactAction::State))); callAction->invokeAction(contact, numberList.at(0)); callAction->invokeAction(contact); QTRY_COMPARE(spyCallAction.count(), 2); // make sure the signal was emitted exactly one time delete callAction; }
bool RmDebuggerOperation::test() const { QVariantMap map = AddDebuggerOperation::addDebugger(AddDebuggerOperation::initializeDebuggers(), QLatin1String("id1"), QLatin1String("Name1"), 2, QLatin1String("/tmp/debugger1"), QStringList() << QLatin1String("test11") << QLatin1String("test12"), KeyValuePairList()); map = AddDebuggerOperation::addDebugger(map, QLatin1String("id2"), QLatin1String("Name2"), 2, QLatin1String("/tmp/debugger2"), QStringList() << QLatin1String("test21") << QLatin1String("test22"), KeyValuePairList()); QVariantMap result = rmDebugger(map, QLatin1String("id2")); if (result.count() != 3 || !result.contains(QLatin1String("DebuggerItem.0")) || !result.contains(QLatin1String(COUNT)) || result.value(QLatin1String(COUNT)).toInt() != 1 || !result.contains(QLatin1String(VERSION)) || result.value(QLatin1String(VERSION)).toInt() != 1) return false; result = rmDebugger(map, QLatin1String("unknown")); if (result != map) return false; result = rmDebugger(map, QLatin1String("id2")); if (result.count() != 3 || !result.contains(QLatin1String("DebuggerItem.0")) || !result.contains(QLatin1String(COUNT)) || result.value(QLatin1String(COUNT)).toInt() != 1 || !result.contains(QLatin1String(VERSION)) || result.value(QLatin1String(VERSION)).toInt() != 1) return false; result = rmDebugger(result, QLatin1String("id1")); if (result.count() != 2 || !result.contains(QLatin1String(COUNT)) || result.value(QLatin1String(COUNT)).toInt() != 0 || !result.contains(QLatin1String(VERSION)) || result.value(QLatin1String(VERSION)).toInt() != 1) return false; return true; }
void TestCntActions::urlSupport() { QContact contact; QContactUrl url; url.setUrl("www.test.com"); contact.saveDetail(&url); m_manager->saveContact(&contact); //one number exist in contact QList<QContactUrl> urlList = contact.details<QContactUrl>(); QVERIFY(urlList.count() == 1); //no actions expected QList<QContactActionDescriptor> actionDescriptors = contact.availableActions(); QStringList actions; for (int i = 0;i < actionDescriptors.count();i++) { QString action = actionDescriptors.at(i).actionName(); actions << action; } QVERIFY(actions.count() == 1); QVERIFY(actions.contains("url", Qt::CaseInsensitive)); //pick first number for the actions QContactUrl urlAddress = contact.detail<QContactUrl>(); //Test Email action QList<QContactActionDescriptor> urlActionDescriptors = QContactAction::actionDescriptors("url", "symbian"); QVERIFY(urlActionDescriptors.count() == 1); QContactAction *urlAction = QContactAction::action(urlActionDescriptors.at(0)); QVERIFY(urlAction != 0); QVERIFY(urlAction->isDetailSupported(urlList.at(0)) == true); QList<QContactDetail> supportedDetails = urlAction->supportedDetails(contact); QVERIFY(supportedDetails.count() != 0); QVariantMap variantMap = urlAction->metaData(); QVERIFY(variantMap.count() == 0); variantMap = urlAction->results(); QVERIFY(variantMap.count() == 0); QSignalSpy spyUrlAction(urlAction, SIGNAL(stateChanged(QContactAction::State))); urlAction->invokeAction(contact, urlAddress); urlAction->invokeAction(contact); QTRY_COMPARE(spyUrlAction.count(), 2); // make sure the signal was emitted exactly once each time delete urlAction; }
QVariantMap RmKitOperation::rmKit(const QVariantMap &map, const QString &id) { QVariantMap result = AddKitOperation::initializeKits(); QVariantList profileList; bool ok; int count = GetOperation::get(map, QLatin1String(COUNT)).toInt(&ok); if (!ok) { std::cerr << "Error: The count found in map is not an integer." << std::endl; return map; } int kitPos = -1; for (int i = 0; i < count; ++i) { const QString key = QString::fromLatin1(PREFIX) + QString::number(i); QVariantMap profile = map.value(key).toMap(); if (profile.value(QLatin1String(ID)).toString() == id) { kitPos = i; continue; } profileList << profile; } if (profileList.count() == map.count() - 3) { std::cerr << "Error: Id was not found." << std::endl; return map; } int defaultKit = GetOperation::get(map, QLatin1String(DEFAULT)).toInt(&ok); if (!ok) { std::cerr << "Error: Could not find the default kit." << std::endl; defaultKit = -1; } if (defaultKit == kitPos || defaultKit < 0) defaultKit = (count > 1) ? 0 : -1; // remove data: QStringList toRemove; toRemove << QLatin1String(COUNT) << QLatin1String(DEFAULT); result = RmKeysOperation::rmKeys(result, toRemove); // insert data: KeyValuePairList data; data << KeyValuePair(QStringList() << QLatin1String(DEFAULT), QVariant(defaultKit)); data << KeyValuePair(QStringList() << QLatin1String(COUNT), QVariant(count - 1)); for (int i = 0; i < profileList.count(); ++i) data << KeyValuePair(QStringList() << QString::fromLatin1(PREFIX) + QString::number(i), profileList.at(i)); return AddKeysOperation::addKeys(result, data); }
bool AddDebuggerOperation::test() const { QVariantMap map = initializeDebuggers(); if (map.count() != 2 || !map.contains(QLatin1String(VERSION)) || map.value(QLatin1String(VERSION)).toInt() != 1 || !map.contains(QLatin1String(COUNT)) || map.value(QLatin1String(COUNT)).toInt() != 0) return false; return true; }
bool AddDeviceOperation::test() const { QVariantMap map = initializeDevices(); QVariantMap result = addDevice(map, QLatin1String("test id"), QLatin1String("test name"), 1, 2, QLatin1String("HW"), QLatin1String("SW"), QLatin1String("debugServer"), QLatin1String("ports"), QLatin1String("host"), QLatin1String("keyfile"), 3, QLatin1String("ostype"), QLatin1String("passwd"), 4, 5, QLatin1String("uname"), 6, KeyValuePairList()); QVariantMap data = result.value(QLatin1String(DEVICEMANAGER_ID)).toMap(); QVariantList devList = data.value(QLatin1String(DEVICE_LIST_ID)).toList(); if (devList.count() != 1) return false; QVariantMap dev = devList.at(0).toMap(); if (dev.count() != 17) return false; if (dev.value(QLatin1String("Authentication")).toInt() != 2) return false; if (dev.value(QLatin1String("DebugServerKey")).toString() != QLatin1String("debugServer")) return false; if (dev.value(QLatin1String("FreePortsSpec")).toString() != QLatin1String("ports")) return false; if (dev.value(QLatin1String("Host")).toString() != QLatin1String("host")) return false; if (dev.value(QLatin1String("InternalId")).toString() != QLatin1String("test id")) return false; if (dev.value(QLatin1String("KeyFile")).toString() != QLatin1String("keyfile")) return false; if (dev.value(QLatin1String("Name")).toString() != QLatin1String("test name")) return false; if (dev.value(QLatin1String("Origin")).toInt() != 3) return false; if (dev.value(QLatin1String("OsType")).toString() != QLatin1String("ostype")) return false; if (dev.value(QLatin1String("Password")).toString() != QLatin1String("passwd")) return false; if (dev.value(QLatin1String("SshPort")).toInt() != 4) return false; if (dev.value(QLatin1String("Timeout")).toInt() != 5) return false; if (dev.value(QLatin1String("Type")).toInt() != 1) return false; if (dev.value(QLatin1String("Uname")).toString() != QLatin1String("uname")) return false; if (dev.value(QLatin1String("Version")).toInt() != 6) return false; return true; }
void shouldGetItemWithCorrectValues() { history->add(QUrl("http://example1.org/"), "Example 1 Domain", QUrl()); QVariantMap item = model->get(0); QHash<int, QByteArray> roles = model->roleNames(); QCOMPARE(roles.count(), item.count()); Q_FOREACH(int role, roles.keys()) { QString roleName = QString::fromUtf8(roles.value(role)); QCOMPARE(model->data(model->index(0, 0), role), item.value(roleName)); } }
void TestTools::testBuildConfigMerging() { Settings settings((QString())); TemporaryProfile tp(QLatin1String("tst_tools_profile"), &settings); Profile profile = tp.p; profile.setValue(QLatin1String("topLevelKey"), QLatin1String("topLevelValue")); profile.setValue(QLatin1String("qbs.toolchain"), QLatin1String("gcc")); profile.setValue(QLatin1String("qbs.architecture"), QLatin1String("Jean-Claude Pillemann")); profile.setValue(QLatin1String("cpp.treatWarningsAsErrors"), true); QVariantMap overrideMap; overrideMap.insert(QLatin1String("qbs.toolchain"), QLatin1String("clang")); overrideMap.insert(QLatin1String("qbs.installRoot"), QLatin1String("/blubb")); SetupProjectParameters params; params.setTopLevelProfile(profile.name()); params.setConfigurationName(QLatin1String("debug")); params.setOverriddenValues(overrideMap); const ErrorInfo error = params.expandBuildConfiguration(); QVERIFY2(!error.hasError(), qPrintable(error.toString())); const QVariantMap finalMap = params.finalBuildConfigurationTree(); QCOMPARE(finalMap.count(), 3); QCOMPARE(finalMap.value(QLatin1String("topLevelKey")).toString(), QString::fromLatin1("topLevelValue")); const QVariantMap finalQbsMap = finalMap.value(QLatin1String("qbs")).toMap(); QCOMPARE(finalQbsMap.count(), 4); QCOMPARE(finalQbsMap.value(QLatin1String("toolchain")).toString(), QString::fromLatin1("clang")); QCOMPARE(finalQbsMap.value(QLatin1String("configurationName")).toString(), QString::fromLatin1("debug")); QCOMPARE(finalQbsMap.value(QLatin1String("architecture")).toString(), QString::fromLatin1("Jean-Claude Pillemann")); QCOMPARE(finalQbsMap.value(QLatin1String("installRoot")).toString(), QLatin1String("/blubb")); const QVariantMap finalCppMap = finalMap.value(QLatin1String("cpp")).toMap(); QCOMPARE(finalCppMap.count(), 1); QCOMPARE(finalCppMap.value(QLatin1String("treatWarningsAsErrors")).toBool(), true); }
void CClientApp::commandAdded(const QJsonArray& commands) { QList<QString> kCmdName; QList<QString> kCmdDisplayName; DeviceHandle* kDevicesInfo = new DeviceHandle; for (auto i : commands) { QVariantMap cmdMap = i.toObject().toVariantMap(); if (cmdMap.count()>0) { kCmdName.append(cmdMap["deviceCmd"].toString()); kCmdDisplayName.append(cmdMap["command_displayName"].toString()); kDevicesInfo->setCmdKeys(kCmdName); kDevicesInfo->setCmdDisplayName(kCmdDisplayName); } } m_DeviceCmdListModel->addDevice(*kDevicesInfo); }
void DeviceProperties::UpdateHardwareInfo() { // Hardware information QString id = index_.data(DeviceManager::Role_UniqueId).toString(); if (DeviceLister* lister = manager_->GetLister(index_.row())) { QVariantMap info = lister->DeviceHardwareInfo(id); // Remove empty items for (const QString& key : info.keys()) { if (info[key].isNull() || info[key].toString().isEmpty()) info.remove(key); } ui_->hardware_info_stack->setCurrentWidget(ui_->hardware_info_page); ui_->hardware_info->clear(); ui_->hardware_info->setRowCount(2 + info.count()); int row = 0; AddHardwareInfo(row++, tr("Model"), lister->DeviceModel(id)); AddHardwareInfo(row++, tr("Manufacturer"), lister->DeviceManufacturer(id)); for (const QString& key : info.keys()) { AddHardwareInfo(row++, tr(key.toAscii()), info[key].toString()); } ui_->hardware_info->sortItems(0); } else { ui_->hardware_info_stack->setCurrentWidget( ui_->hardware_info_not_connected_page); } // Size quint64 total = index_.data(DeviceManager::Role_Capacity).toLongLong(); QVariant free_var = index_.data(DeviceManager::Role_FreeSpace); if (free_var.isValid()) { quint64 free = free_var.toLongLong(); ui_->free_space_bar->set_total_bytes(total); ui_->free_space_bar->set_free_bytes(free); ui_->free_space_bar->show(); } else { ui_->free_space_bar->hide(); } }
/* * Test the creation & initialising of the indicator data */ void testPluginInterfaceProfile2() { IndicatorsManager manager; manager.setProfile("test2"); manager.load(); Indicator::Ptr indicator = manager.indicator("indicator-fake1"); QVERIFY(indicator ? true : false); QCOMPARE(indicator->identifier(), QString("indicator-fake1")); QCOMPARE(indicator->position(), 1); // Check that the initial properties have been set. QVariantMap props = indicator->indicatorProperties().toMap(); QCOMPARE(props.count(), 4); QCOMPARE(props["busName"].toString(), QString("com.canonical.indicator.fake1")); QCOMPARE(props["actionsObjectPath"].toString(), QString("/com/canonical/indicator/fake1")); QCOMPARE(props["menuObjectPath"].toString(), QString("/com/canonical/indicator/fake1/test2")); }
static bool hasMethodRequiredArguments (const Method &method, const QVariantMap &arguments) { if (arguments.count () != method.names.length ()) { return false; } // Check that all arguments are expected for (int i = 0; i < method.names.length (); i++) { int type = method.types.at (i); const QString ¤t = method.names.at (i); // Check that we have a value for the argument. if (!arguments.contains (current) && arguments.value (current).userType () != type) { return false; } } // Ok return true; }
QVariantMap RmMerSdkOperation::removeSdk(const QVariantMap &map, const QString &sdkName) { QVariantMap result = AddMerSdkOperation::initializeSdks(); QVariantList sdkList; bool ok; int count = GetOperation::get(map, QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt(&ok); if (!ok) { std::cerr << "Error: The count found in map is not an integer." << std::endl; return map; } for (int i = 0; i < count; ++i) { const QString sdk = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(i); QVariantMap sdkMap = map.value(sdk).toMap(); if (sdkMap.value(QLatin1String(Mer::Constants::VM_NAME)).toString() == sdkName) { continue; } sdkList << sdkMap; } if (sdkList.count() == map.count() - 2) { std::cerr << "Error: Sdk was not found." << std::endl; return map; } // remove data: QStringList toRemove; toRemove << QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY); result = RmKeysOperation::rmKeys(result, toRemove); // insert data: KeyValuePairList data; data << KeyValuePair(QStringList() << QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY), QVariant(count - 1)); for (int i = 0; i < sdkList.count(); ++i) data << KeyValuePair(QStringList() << QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(i), sdkList.at(i)); return AddKeysOperation::addKeys(result, data); }
QVariantMap RmDebuggerOperation::rmDebugger(const QVariantMap &map, const QString &id) { QVariantMap result = AddDebuggerOperation::initializeDebuggers(); QVariantList debuggerList; bool ok; int count = GetOperation::get(map, QLatin1String(COUNT)).toInt(&ok); if (!ok) { std::cerr << "Error: The count found in map is not an integer." << std::endl; return map; } for (int i = 0; i < count; ++i) { const QString key = QString::fromLatin1(PREFIX) + QString::number(i); QVariantMap debugger = map.value(key).toMap(); if (debugger.value(QLatin1String(ID)).toString() == id) continue; debuggerList << debugger; } if (debuggerList.count() == map.count() - 2) { std::cerr << "Error: Id was not found." << std::endl; return map; } // remove data: QStringList toRemove; toRemove << QLatin1String(COUNT); result = RmKeysOperation::rmKeys(result, toRemove); // insert data: KeyValuePairList data; data << KeyValuePair(QLatin1String(COUNT), count - 1); for (int i = 0; i < debuggerList.count(); ++i) { data << KeyValuePair(QStringList() << QString::fromLatin1(PREFIX) + QString::number(i), debuggerList.at(i)); } return AddKeysOperation::addKeys(result, data); }
/*! \brief Launches a small dialog-box showing info about the currently selected symbol. This method demonstrates the usage of the \a getSymbolInfo method of the Search API. These API returns these values as a \a QVariantMap with Key-Value pairs that refer to each of the \a SymbolInfos flags passed in. The method grabs this information from the API and then displays it to the user in a dialog box. */ void Dialog::on_search_itemClicked(QListWidgetItem* item) { QString symbolName = item->text(); QVariantMap vMap = symbolNameOrId2VariantMap(symbolName); if (vMap.count() == 0) return; QImage image = dictionary.symbolImage(symbolName, 150, 150); lblImage->setPixmap(QPixmap::fromImage(image)); lblSymbolId->setText("Symbol Id : " % vMap.value("SymbolID").toString() % "\n"); lblSymbolName->setText("Symbol Name : " % symbolName % "\n"); lblStyleFile->setText("Stylefile : " % vMap.value("StyleFile").toString() % "\n"); lblCategory->setText("Category : " % vMap.value("Category").toString() % "\n"); lblTags->setText("Keywords : " % vMap.value("Tags").toStringList().join("\n") % "\n"); dlg->setModal(true); dlg->setWindowTitle("Symbol Info"); dlg->show(); }
void ProjectLangstatsModel::populate(const QVariantMap &data) { int length = data.count(); beginInsertRows(QModelIndex(), 0, length-1); QMapIterator<QString, QVariant> i(data); while (i.hasNext()) { i.next(); QVariantMap map = i.value().toMap(); LangstatObject *sobj = new LangstatObject(i.key(), map.value("translated").toDouble(), map.value("untranslated").toDouble(), map.value("reviewed").toDouble()); m_stats.append(sobj); } endInsertRows(); emit gotData(); }
Tileset *VariantToMapConverter::toTileset(const QVariant &variant) { const QVariantMap variantMap = variant.toMap(); const int firstGid = variantMap["firstgid"].toInt(); const QString name = variantMap["name"].toString(); const int tileWidth = variantMap["tilewidth"].toInt(); const int tileHeight = variantMap["tileheight"].toInt(); const int spacing = variantMap["spacing"].toInt(); const int margin = variantMap["margin"].toInt(); const QVariantMap tileOffset = variantMap["tileoffset"].toMap(); const int tileOffsetX = tileOffset["x"].toInt(); const int tileOffsetY = tileOffset["y"].toInt(); if (tileWidth <= 0 || tileHeight <= 0 || firstGid == 0) { mError = tr("Invalid tileset parameters for tileset '%1'").arg(name); return 0; } typedef QScopedPointer<Tileset> TilesetPtr; TilesetPtr tileset(new Tileset(name, tileWidth, tileHeight, spacing, margin)); tileset->setTileOffset(QPoint(tileOffsetX, tileOffsetY)); const QString trans = variantMap["transparentcolor"].toString(); if (!trans.isEmpty() && QColor::isValidColor(trans)) tileset->setTransparentColor(QColor(trans)); QVariant imageVariant = variantMap["image"]; if (!imageVariant.isNull()) { QString imagePath = resolvePath(mMapDir, imageVariant); if (!tileset->loadFromImage(imagePath)) { mError = tr("Error loading tileset image:\n'%1'").arg(imagePath); return 0; } } tileset->setProperties(toProperties(variantMap["properties"])); // Read tile terrain and external image information const QVariantMap tilesVariantMap = variantMap["tiles"].toMap(); QVariantMap::const_iterator it = tilesVariantMap.constBegin(); for (; it != tilesVariantMap.end(); ++it) { bool ok; const int tileIndex = it.key().toInt(); if (tileIndex < 0) { mError = tr("Tileset tile index negative:\n'%1'").arg(tileIndex); } if (tileIndex >= tileset->tileCount()) { // Extend the tileset to fit the tile if (tileIndex >= tilesVariantMap.count()) { // If tiles are defined this way, there should be an entry // for each tile. // Limit the index to number of entries to prevent running out // of memory on malicious input. mError = tr("Tileset tile index too high:\n'%1'").arg(tileIndex); return 0; } int i; for (i=tileset->tileCount(); i <= tileIndex; i++) tileset->addTile(QPixmap()); } Tile *tile = tileset->tileAt(tileIndex); if (tile) { const QVariantMap tileVar = it.value().toMap(); QList<QVariant> terrains = tileVar["terrain"].toList(); if (terrains.count() == 4) { for (int i = 0; i < 4; ++i) { int terrainID = terrains.at(i).toInt(&ok); if (ok && terrainID >= 0 && terrainID < tileset->terrainCount()) tile->setCornerTerrain(i, terrainID); } } float terrainProbability = tileVar["probability"].toFloat(&ok); if (ok) tile->setTerrainProbability(terrainProbability); imageVariant = tileVar["image"]; if (!imageVariant.isNull()) { QString imagePath = resolvePath(mMapDir, imageVariant); tileset->setTileImage(tileIndex, QPixmap(imagePath), imagePath); } QVariantMap objectGroupVariant = tileVar["objectgroup"].toMap(); if (!objectGroupVariant.isEmpty()) tile->setObjectGroup(toObjectGroup(objectGroupVariant)); QVariantList frameList = tileVar["animation"].toList(); if (!frameList.isEmpty()) { QVector<Frame> frames(frameList.size()); for (int i = frameList.size() - 1; i >= 0; --i) { const QVariantMap frameVariantMap = frameList[i].toMap(); Frame &frame = frames[i]; frame.tileId = frameVariantMap["tileid"].toInt(); frame.duration = frameVariantMap["duration"].toInt(); } tile->setFrames(frames); } } } // Read tile properties QVariantMap propertiesVariantMap = variantMap["tileproperties"].toMap(); for (it = propertiesVariantMap.constBegin(); it != propertiesVariantMap.constEnd(); ++it) { const int tileIndex = it.key().toInt(); const QVariant propertiesVar = it.value(); if (tileIndex >= 0 && tileIndex < tileset->tileCount()) { const Properties properties = toProperties(propertiesVar); tileset->tileAt(tileIndex)->setProperties(properties); } } // Read terrains QVariantList terrainsVariantList = variantMap["terrains"].toList(); for (int i = 0; i < terrainsVariantList.count(); ++i) { QVariantMap terrainMap = terrainsVariantList[i].toMap(); tileset->addTerrain(terrainMap["name"].toString(), terrainMap["tile"].toInt()); } mGidMapper.insert(firstGid, tileset.data()); return tileset.take(); }
bool AddKitOperation::test() const { QVariantMap map = initializeKits(); QVariantMap tcMap = AddToolChainOperation::initializeToolChains(); tcMap = AddToolChainOperation::addToolChain(tcMap, "{tc-id}", "langId", "TC", "/usr/bin/gcc", "x86-linux-generic-elf-32bit", "x86-linux-generic-elf-32bit", KeyValuePairList()); QVariantMap qtMap = AddQtOperation::initializeQtVersions(); qtMap = AddQtOperation::addQt(qtMap, "{qt-id}", "Qt", "desktop-qt", "/usr/bin/qmake", KeyValuePairList()); QVariantMap devMap = AddDeviceOperation::initializeDevices(); devMap = AddDeviceOperation::addDevice(devMap, "{dev-id}", "Dev", 0, 0, "HWplatform", "SWplatform", "localhost", "10000-11000", "localhost", "", 42, "desktop", "", 22, 10000, "uname", 1, KeyValuePairList()); const QStringList env = { "TEST=1", "PATH" }; if (map.count() != 3 || !map.contains(VERSION) || map.value(VERSION).toInt() != 1 || !map.contains(COUNT) || map.value(COUNT).toInt() != 0 || !map.contains(DEFAULT) || !map.value(DEFAULT).toString().isEmpty()) return false; QHash<QString, QString> tcs; tcs.insert("Cxx", "{tcXX-id}"); // Fail if TC is not there: QVariantMap empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), tcs, "{qt-id}", "unsupported/mkspec", QStringList(), KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (!empty.isEmpty()) return false; // Do not fail if TC is an ABI: tcs.clear(); tcs.insert("C", "x86-linux-generic-elf-64bit"); empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), tcs, "{qt-id}", "unsupported/mkspec", env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (empty.isEmpty()) return false; // QTCREATORBUG-11983, mach_o was not covered by the first attempt to fix this. tcs.insert("D", "x86-macos-generic-mach_o-64bit"); empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), tcs, "{qt-id}", "unsupported/mkspec", env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (empty.isEmpty()) return false; tcs.clear(); tcs.insert("Cxx", "{tc-id}"); // Fail if Qt is not there: empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{dev-id}", QString(), tcs, "{qtXX-id}", "unsupported/mkspec", env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (!empty.isEmpty()) return false; // Fail if dev is not there: empty = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", "{devXX-id}", QString(), tcs, "{qt-id}", "unsupported/mkspec", env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (!empty.isEmpty()) return false; // Profile 0: map = addKit(map, tcMap, qtMap, devMap, "testId", "Test Kit", "/tmp/icon.png", QString(), 1, "/usr/bin/gdb-test", "Desktop", QString(), QString(), tcs, "{qt-id}", "unsupported/mkspec", env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (map.count() != 4 || !map.contains(VERSION) || map.value(VERSION).toInt() != 1 || !map.contains(COUNT) || map.value(COUNT).toInt() != 1 || !map.contains(DEFAULT) || map.value(DEFAULT).toString() != "testId" || !map.contains("Profile.0")) return false; QVariantMap profile0 = map.value("Profile.0").toMap(); if (profile0.count() != 6 || !profile0.contains(ID) || profile0.value(ID).toString() != "testId" || !profile0.contains(DISPLAYNAME) || profile0.value(DISPLAYNAME).toString() != "Test Kit" || !profile0.contains(ICON) || profile0.value(ICON).toString() != "/tmp/icon.png" || !profile0.contains(DATA) || profile0.value(DATA).type() != QVariant::Map || !profile0.contains(AUTODETECTED) || profile0.value(AUTODETECTED).toBool() != true || !profile0.contains(SDK) || profile0.value(SDK).toBool() != true) return false; QVariantMap data = profile0.value(DATA).toMap(); if (data.count() != 7 || !data.contains(DEBUGGER) || data.value(DEBUGGER).type() != QVariant::Map || !data.contains(DEVICE_TYPE) || data.value(DEVICE_TYPE).toString() != "Desktop" || !data.contains(TOOLCHAIN) || !data.contains(QT) || data.value(QT).toString() != "SDK.{qt-id}" || !data.contains(MKSPEC) || data.value(MKSPEC).toString() != "unsupported/mkspec" || !data.contains("extraData") || data.value("extraData").toString() != "extraValue") return false; QVariantMap tcOutput = data.value(TOOLCHAIN).toMap(); if (tcOutput.count() != 1 || !tcOutput.contains("Cxx") || tcOutput.value("Cxx") != "{tc-id}") return false; // Ignore existing ids: QVariantMap result = addKit(map, tcMap, qtMap, devMap, "testId", "Test Qt Version X", "/tmp/icon3.png", QString(), 1, "/usr/bin/gdb-test3", "Desktop", QString(), QString(), tcs, "{qt-id}", "unsupported/mkspec", env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (!result.isEmpty()) return false; // Profile 1: Make sure name is unique: map = addKit(map, tcMap, qtMap, devMap, "testId2", "Test Kit2", "/tmp/icon2.png", QString(), 1, "/usr/bin/gdb-test2", "Desktop", "{dev-id}", "/sys/root\\\\", tcs, "{qt-id}", "unsupported/mkspec", env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (map.count() != 5 || !map.contains(VERSION) || map.value(VERSION).toInt() != 1 || !map.contains(COUNT) || map.value(COUNT).toInt() != 2 || !map.contains(DEFAULT) || map.value(DEFAULT).toInt() != 0 || !map.contains("Profile.0") || !map.contains("Profile.1")) if (map.value("Profile.0") != profile0) return false; QVariantMap profile1 = map.value("Profile.1").toMap(); if (profile1.count() != 6 || !profile1.contains(ID) || profile1.value(ID).toString() != "testId2" || !profile1.contains(DISPLAYNAME) || profile1.value(DISPLAYNAME).toString() != "Test Kit2" || !profile1.contains(ICON) || profile1.value(ICON).toString() != "/tmp/icon2.png" || !profile1.contains(DATA) || profile1.value(DATA).type() != QVariant::Map || !profile1.contains(AUTODETECTED) || profile1.value(AUTODETECTED).toBool() != true || !profile1.contains(SDK) || profile1.value(SDK).toBool() != true) return false; data = profile1.value(DATA).toMap(); if (data.count() != 9 || !data.contains(DEBUGGER) || data.value(DEBUGGER).type() != QVariant::Map || !data.contains(DEVICE_TYPE) || data.value(DEVICE_TYPE).toString() != "Desktop" || !data.contains(DEVICE_ID) || data.value(DEVICE_ID).toString() != "{dev-id}" || !data.contains(SYSROOT) || data.value(SYSROOT).toString() != "/sys/root\\\\" || !data.contains(TOOLCHAIN) || !data.contains(QT) || data.value(QT).toString() != "SDK.{qt-id}" || !data.contains(MKSPEC) || data.value(MKSPEC).toString() != "unsupported/mkspec" || !data.contains(ENV) || data.value(ENV).toStringList() != env || !data.contains("extraData") || data.value("extraData").toString() != "extraValue") return false; tcOutput = data.value(TOOLCHAIN).toMap(); if (tcOutput.count() != 1 || !tcOutput.contains("Cxx") || tcOutput.value("Cxx") != "{tc-id}") return false; // Profile 2: Test debugger id: map = addKit(map, tcMap, qtMap, devMap, "test with debugger Id", "Test debugger Id", "/tmp/icon2.png", "debugger Id", 0, QString(), "Desktop", QString(), QString(), tcs, "{qt-id}", "unsupported/mkspec", env, KeyValuePairList({ KeyValuePair("PE.Profile.Data/extraData", QVariant("extraValue")) })); if (map.count() != 6 || !map.contains(VERSION) || map.value(VERSION).toInt() != 1 || !map.contains(COUNT) || map.value(COUNT).toInt() != 3 || !map.contains(DEFAULT) || map.value(DEFAULT).toInt() != 0 || !map.contains("Profile.0") || !map.contains("Profile.1") || !map.contains("Profile.2")) if (map.value("Profile.0") != profile0) return false; if (map.value("Profile.1") != profile1) return false; QVariantMap profile2 = map.value("Profile.2").toMap(); if (profile2.count() != 6 || !profile2.contains(ID) || profile2.value(ID).toString() != "test with debugger Id" || !profile2.contains(DISPLAYNAME) || profile2.value(DISPLAYNAME).toString() != "Test debugger Id" || !profile2.contains(ICON) || profile2.value(ICON).toString() != "/tmp/icon2.png" || !profile2.contains(DATA) || profile2.value(DATA).type() != QVariant::Map || !profile2.contains(AUTODETECTED) || profile2.value(AUTODETECTED).toBool() != true || !profile2.contains(SDK) || profile2.value(SDK).toBool() != true) return false; data = profile2.value(DATA).toMap(); if (data.count() != 7 || !data.contains(DEBUGGER) || data.value(DEBUGGER).toString() != "debugger Id") return false; return true; }
bool AddQtOperation::test() const { QVariantMap map = initializeQtVersions(); if (map.count() != 1 || !map.contains(QLatin1String(VERSION)) || map.value(QLatin1String(VERSION)).toInt() != 1) return false; #if defined Q_OS_WIN map = addQt(map, QLatin1String("testId"), QLatin1String("Test Qt Version"), QLatin1String("testType"), QLatin1String("/tmp//../tmp/test\\qmake"), KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue")))); #else map = addQt(map, QLatin1String("testId"), QLatin1String("Test Qt Version"), QLatin1String("testType"), QLatin1String("/tmp//../tmp/test/qmake"), KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue")))); #endif if (map.count() != 2 || !map.contains(QLatin1String(VERSION)) || map.value(QLatin1String(VERSION)).toInt() != 1 || !map.contains(QLatin1String("QtVersion.0"))) return false; QVariantMap version0 = map.value(QLatin1String("QtVersion.0")).toMap(); if (version0.count() != 7 || !version0.contains(QLatin1String(ID)) || version0.value(QLatin1String(ID)).toInt() != -1 || !version0.contains(QLatin1String(DISPLAYNAME)) || version0.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Qt Version") || !version0.contains(QLatin1String(AUTODETECTED)) || version0.value(QLatin1String(AUTODETECTED)).toBool() != true || !version0.contains(QLatin1String(AUTODETECTION_SOURCE)) || version0.value(QLatin1String(AUTODETECTION_SOURCE)).toString() != QLatin1String("SDK.testId") || !version0.contains(QLatin1String(TYPE)) || version0.value(QLatin1String(TYPE)).toString() != QLatin1String("testType") || !version0.contains(QLatin1String(QMAKE)) || version0.value(QLatin1String(QMAKE)).toString() != QLatin1String("/tmp/test/qmake") || !version0.contains(QLatin1String("extraData")) || version0.value(QLatin1String("extraData")).toString() != QLatin1String("extraValue")) return false; // Ignore existing ids: QVariantMap result = addQt(map, QLatin1String("testId"), QLatin1String("Test Qt Version2"), QLatin1String("testType2"), QLatin1String("/tmp/test/qmake2"), KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue")))); if (!result.isEmpty()) return false; // Make sure name is unique: map = addQt(map, QLatin1String("testId2"), QLatin1String("Test Qt Version"), QLatin1String("testType3"), QLatin1String("/tmp/test/qmake2"), KeyValuePairList() << KeyValuePair(QLatin1String("extraData"), QVariant(QLatin1String("extraValue")))); if (map.count() != 3 || !map.contains(QLatin1String(VERSION)) || map.value(QLatin1String(VERSION)).toInt() != 1 || !map.contains(QLatin1String("QtVersion.0")) || !map.contains(QLatin1String("QtVersion.1"))) return false; if (map.value(QLatin1String("QtVersion.0")) != version0) return false; QVariantMap version1 = map.value(QLatin1String("QtVersion.1")).toMap(); if (version1.count() != 7 || !version1.contains(QLatin1String(ID)) || version1.value(QLatin1String(ID)).toInt() != -1 || !version1.contains(QLatin1String(DISPLAYNAME)) || version1.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Qt Version2") || !version1.contains(QLatin1String(AUTODETECTED)) || version1.value(QLatin1String(AUTODETECTED)).toBool() != true || !version1.contains(QLatin1String(AUTODETECTION_SOURCE)) || version1.value(QLatin1String(AUTODETECTION_SOURCE)).toString() != QLatin1String("SDK.testId2") || !version1.contains(QLatin1String(TYPE)) || version1.value(QLatin1String(TYPE)).toString() != QLatin1String("testType3") || !version1.contains(QLatin1String(QMAKE)) || version1.value(QLatin1String(QMAKE)).toString() != QLatin1String("/tmp/test/qmake2") || !version1.contains(QLatin1String("extraData")) || version1.value(QLatin1String("extraData")).toString() != QLatin1String("extraValue")) return false; return true; }
bool RmMerSdkOperation::test() const { QVariantMap map = AddMerSdkOperation::addSdk(AddMerSdkOperation::initializeSdks(), QLatin1String("testSdk"), true, QLatin1String("/test/sharedHomePath"), QLatin1String("/test/sharedTargetPath"), QLatin1String("/test/sharedSshPath"), QLatin1String("/test/sharedSrcPath"), QLatin1String("/test/sharedConfigPath"), QLatin1String("host"),QLatin1String("user"), QLatin1String("/test/privateKey"),22,80,false); map = AddMerSdkOperation::addSdk(map, QLatin1String("testSdk2"), true, QLatin1String("/test/sharedHomePath"), QLatin1String("/test/sharedTargetPath"), QLatin1String("/test/sharedSshPath"), QLatin1String("/test/sharedSrcPath"), QLatin1String("/test/sharedConfigPath"), QLatin1String("host"),QLatin1String("user"), QLatin1String("/test/privateKey"),22,80,false); const QString sdk1 = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(0); const QString sdk2 = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(1); if (map.count() != 4 || !map.contains(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)) || map.value(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)).toInt() != 2 || !map.contains(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)) || map.value(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt() != 2 || !map.contains(sdk1) || !map.contains(sdk2)) return false; QVariantMap result = removeSdk(map, QLatin1String("testSdk2")); if (result.count() != 3 || result.contains(sdk2) || !result.contains(sdk1) || !result.contains(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)) || result.value(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt() != 1 || !result.contains(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)) || result.value(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)).toInt() != 2) return false; QString sdk = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(0); QVariantMap sdkMap = result.value(sdk).toMap(); if (sdkMap.value(QLatin1String(Mer::Constants::VM_NAME)).toString() == QLatin1String("testSdk2")) return false; result = removeSdk(map, QLatin1String("unknown")); if (result != map) return false; result = removeSdk(map, QLatin1String("testSdk")); if (result.count() != 3 || result.contains(sdk2) || !result.contains(sdk1) || !result.contains(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)) || result.value(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt() != 1 || !result.contains(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)) || result.value(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)).toInt() != 2) return false; sdk = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(0); sdkMap = result.value(sdk).toMap(); if (sdkMap.value(QLatin1String(Mer::Constants::VM_NAME)).toString() == QLatin1String("testSdk")) return false; return true; }
bool RmKeysOperation::test() const { QVariantMap testMap; QVariantMap subKeys; QVariantMap cur; cur.insert(QLatin1String("testint2"), 53); subKeys.insert(QLatin1String("subsubkeys"), cur); subKeys.insert(QLatin1String("testbool"), true); testMap.insert(QLatin1String("subkeys"), subKeys); subKeys.clear(); testMap.insert(QLatin1String("subkeys2"), subKeys); testMap.insert(QLatin1String("testint"), 23); QStringList data; QVariantMap result = rmKeys(testMap, data); if (result != testMap) return false; data.append(QLatin1String("testint")); result = rmKeys(testMap, data); if (result.count() != 2 || !result.contains(QLatin1String("subkeys")) || !result.contains(QLatin1String("subkeys2"))) return false; cur = result.value(QLatin1String("subkeys")).toMap(); if (cur.count() != 2 || !cur.contains(QLatin1String("subsubkeys")) || !cur.contains(QLatin1String("testbool"))) return false; cur = cur.value(QLatin1String("subsubkeys")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("testint2"))) return false; cur = result.value(QLatin1String("subkeys2")).toMap(); if (cur.count() != 0) return false; data.clear(); data.append(QLatin1String("subkeys/subsubkeys")); result = rmKeys(testMap, data); if (result.count() != 3 || !result.contains(QLatin1String("subkeys")) || !result.contains(QLatin1String("subkeys2")) || !result.contains(QLatin1String("testint"))) return false; cur = result.value(QLatin1String("subkeys")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("testbool"))) return false; cur = result.value(QLatin1String("subkeys2")).toMap(); if (cur.count() != 0) return false; data.clear(); data.append(QLatin1String("subkeys/testbool")); result = rmKeys(testMap, data); if (result.count() != 3 || !result.contains(QLatin1String("subkeys")) || !result.contains(QLatin1String("subkeys2")) || !result.contains(QLatin1String("testint"))) return false; cur = result.value(QLatin1String("subkeys")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("subsubkeys"))) return false; cur = cur.value(QLatin1String("subsubkeys")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("testint2"))) return false; cur = result.value(QLatin1String("subkeys2")).toMap(); if (cur.count() != 0) return false; cur = result.value(QLatin1String("subkeys2")).toMap(); if (cur.count() != 0) return false; return true; }
bool AddMerSdkOperation::test() const { QVariantMap map = initializeSdks(); if (map.count() != 2 || !map.contains(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)) || map.value(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)).toInt() != 2 || !map.contains(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)) || map.value(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt() != 0) return false; map = addSdk(map, QLatin1String("testSdk"), true, QLatin1String("/test/sharedHomePath"), QLatin1String("/test/sharedTargetPath"), QLatin1String("/test/sharedSshPath"), QLatin1String("/test/sharedSrcPath"), QLatin1String("/test/sharedConfigPath"), QLatin1String("host"), QLatin1String("user"), QLatin1String("/test/privateKey"),22,80,false); const QString sdk = QString::fromLatin1(Mer::Constants::MER_SDK_DATA_KEY) + QString::number(0); if (map.count() != 3 || !map.contains(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)) || map.value(QLatin1String(Mer::Constants::MER_SDK_FILE_VERSION_KEY)).toInt() != 2 || !map.contains(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)) || map.value(QLatin1String(Mer::Constants::MER_SDK_COUNT_KEY)).toInt() != 1 || !map.contains(sdk)) return false; QVariantMap sdkMap= map.value(sdk).toMap(); if (sdkMap.count() != 13 || !sdkMap.contains(QLatin1String(Mer::Constants::VM_NAME)) || sdkMap.value(QLatin1String(Mer::Constants::VM_NAME)).toString() != QLatin1String("testSdk") || !sdkMap.contains(QLatin1String(Mer::Constants::AUTO_DETECTED)) || sdkMap.value(QLatin1String(Mer::Constants::AUTO_DETECTED)).toBool() != true || !sdkMap.contains(QLatin1String(Mer::Constants::SHARED_HOME)) || sdkMap.value(QLatin1String(Mer::Constants::SHARED_HOME)).toString() != QLatin1String("/test/sharedHomePath") || !sdkMap.contains(QLatin1String(Mer::Constants::SHARED_TARGET)) || sdkMap.value(QLatin1String(Mer::Constants::SHARED_TARGET)).toString() != QLatin1String("/test/sharedTargetPath") || !sdkMap.contains(QLatin1String(Mer::Constants::SHARED_SSH)) || sdkMap.value(QLatin1String(Mer::Constants::SHARED_SSH)).toString() != QLatin1String("/test/sharedSshPath") || !sdkMap.contains(QLatin1String(Mer::Constants::SHARED_SRC)) || sdkMap.value(QLatin1String(Mer::Constants::SHARED_SRC)).toString() != QLatin1String("/test/sharedSrcPath") || !sdkMap.contains(QLatin1String(Mer::Constants::SHARED_CONFIG)) || sdkMap.value(QLatin1String(Mer::Constants::SHARED_CONFIG)).toString() != QLatin1String("/test/sharedConfigPath") || !sdkMap.contains(QLatin1String(Mer::Constants::HOST)) || sdkMap.value(QLatin1String(Mer::Constants::HOST)).toString() != QLatin1String("host") || !sdkMap.contains(QLatin1String(Mer::Constants::USERNAME)) || sdkMap.value(QLatin1String(Mer::Constants::USERNAME)).toString() != QLatin1String("user") || !sdkMap.contains(QLatin1String(Mer::Constants::PRIVATE_KEY_FILE)) || sdkMap.value(QLatin1String(Mer::Constants::PRIVATE_KEY_FILE)).toString() != QLatin1String("/test/privateKey") || !sdkMap.contains(QLatin1String(Mer::Constants::SSH_PORT)) || sdkMap.value(QLatin1String(Mer::Constants::SSH_PORT)).toInt() != 22 || !sdkMap.contains(QLatin1String(Mer::Constants::WWW_PORT)) || sdkMap.value(QLatin1String(Mer::Constants::WWW_PORT)).toInt() != 80 || !sdkMap.contains(QLatin1String(Mer::Constants::HEADLESS)) || sdkMap.value(QLatin1String(Mer::Constants::HEADLESS)).toBool() != false) return false; return true; }
int main(int argc, char **argv) { QCoreApplication app(argc, argv); QStringList args = app.arguments(); QFile vcf, xml; if (args.count() > 1) { vcf.setFileName(args[1]); if (not vcf.open(QFile::ReadOnly)) { qWarning("Cannot open %s for reading: %s", qPrintable(vcf.fileName()), qPrintable(vcf.errorString())); return 1; } } else { if (not vcf.open(stdin, QFile::ReadOnly)) { qWarning("Cannot open STDIN for reading: %s", qPrintable(vcf.errorString())); return 1; } } QVersitReader reader(&vcf); if (not reader.startReading() || not reader.waitForFinished() || QVersitReader::NoError != reader.error()) { qWarning("Cannot read vcard: rc=%d", reader.error()); return 1; } QVersitContactImporter importer; if (not importer.importDocuments(reader.results())) { typedef QMap<int, QVersitContactImporter::Error> ErrorMap; const ErrorMap errors = importer.errors(); for(ErrorMap::ConstIterator it = errors.constBegin(); it != errors.constEnd(); ++it) { qWarning("Cannot convert contact #%d: %d", it.key(), it.value()); } return 1; } if (args.count() > 2) { xml.setFileName(args[2]); if (not xml.open(QFile::WriteOnly)) { qWarning("Cannot open %s for writing: %s", qPrintable(xml.fileName()), qPrintable(xml.errorString())); return 1; } } else { if (not xml.open(stdout, QFile::WriteOnly)) { qWarning("Cannot open STDIN for writing: %s", qPrintable(xml.errorString())); return 1; } } QTextStream out(&xml); out << "<Contacts>\n"; foreach(const QContact &contact, importer.contacts()) { out << " <Contact id=\"" << makeIri(contact) << "\">\n"; foreach(const QContactDetail &detail, contact.details()) { QVariantMap fields = detail.variantValues(); out << " <" << detail.definitionName(); if (not detail.detailUri().isEmpty()) { out << " id=\"" << detail.detailUri() << "\""; } out << ">"; if (fields.count() > 1 || fields.keys().first() != detail.definitionName()) { QVariantMap::ConstIterator it; for(it = fields.constBegin(); it != fields.constEnd(); ++it) { out << "\n "; out << "<" << it.key() << ">"; out << toString(it.value()); out << "</" << it.key() << ">"; } out << "\n "; } else { out << toString(fields.values().first()); } out << "</" << detail.definitionName() << ">\n"; } out << " </Contact>\n"; } out << "</Contacts>\n"; return 0; }
bool AddKitOperation::test() const { QVariantMap map = initializeKits(); if (map.count() != 3 || !map.contains(QLatin1String(VERSION)) || map.value(QLatin1String(VERSION)).toInt() != 1 || !map.contains(QLatin1String(COUNT)) || map.value(QLatin1String(COUNT)).toInt() != 0 || !map.contains(QLatin1String(DEFAULT)) || map.value(QLatin1String(DEFAULT)).toInt() != -1) return false; map = addKit(map, QLatin1String("testId"), QLatin1String("Test Kit"), QLatin1String("/tmp/icon.png"), 1, QLatin1String("/usr/bin/gdb-test"), QByteArray("Desktop"), QString(), QLatin1String("{some-tc-id}"), QLatin1String("{some-qt-id}"), QLatin1String("unsupported/mkspec"), KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue")))); if (map.count() != 4 || !map.contains(QLatin1String(VERSION)) || map.value(QLatin1String(VERSION)).toInt() != 1 || !map.contains(QLatin1String(COUNT)) || map.value(QLatin1String(COUNT)).toInt() != 1 || !map.contains(QLatin1String(DEFAULT)) || map.value(QLatin1String(DEFAULT)).toInt() != 0 || !map.contains(QLatin1String("Profile.0"))) return false; QVariantMap profile0 = map.value(QLatin1String("Profile.0")).toMap(); if (profile0.count() != 5 || !profile0.contains(QLatin1String(ID)) || profile0.value(QLatin1String(ID)).toString() != QLatin1String("testId") || !profile0.contains(QLatin1String(DISPLAYNAME)) || profile0.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Kit") || !profile0.contains(QLatin1String(AUTODETECTED)) || profile0.value(QLatin1String(AUTODETECTED)).toBool() != true) return false; // Ignore existing ids: QVariantMap result = addKit(map, QLatin1String("testId"), QLatin1String("Test Qt Version X"), QLatin1String("/tmp/icon3.png"), 1, QLatin1String("/usr/bin/gdb-test3"), QByteArray("Desktop"), QString(), QLatin1String("{some-tc-id3}"), QLatin1String("{some-qt-id3}"), QLatin1String("unsupported/mkspec3"), KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue3")))); if (!result.isEmpty()) return false; // Make sure name is unique: map = addKit(map, QLatin1String("testId2"), QLatin1String("Test Kit2"), QLatin1String("/tmp/icon2.png"), 1, QLatin1String("/usr/bin/gdb-test2"), QByteArray("Desktop"), QString(), QLatin1String("{some-tc-id2}"), QLatin1String("{some-qt-id2}"), QLatin1String("unsupported/mkspec2"), KeyValuePairList() << KeyValuePair(QLatin1String("PE.Profile.Data/extraData"), QVariant(QLatin1String("extraValue2")))); if (map.count() != 5 || !map.contains(QLatin1String(VERSION)) || map.value(QLatin1String(VERSION)).toInt() != 1 || !map.contains(QLatin1String(COUNT)) || map.value(QLatin1String(COUNT)).toInt() != 2 || !map.contains(QLatin1String(DEFAULT)) || map.value(QLatin1String(DEFAULT)).toInt() != 0 || !map.contains(QLatin1String("Profile.0")) || !map.contains(QLatin1String("Profile.1"))) if (map.value(QLatin1String("Profile.0")) != profile0) return false; QVariantMap profile1 = map.value(QLatin1String("Profile.1")).toMap(); if (profile1.count() != 5 || !profile1.contains(QLatin1String(ID)) || profile1.value(QLatin1String(ID)).toString() != QLatin1String("testId2") || !profile1.contains(QLatin1String(DISPLAYNAME)) || profile1.value(QLatin1String(DISPLAYNAME)).toString() != QLatin1String("Test Kit2") || !profile1.contains(QLatin1String(AUTODETECTED)) || profile1.value(QLatin1String(AUTODETECTED)).toBool() != true) return false; return true; }
bool AddKeysOperation::test() const { QVariantMap testMap; QVariantMap subKeys; subKeys.insert(QLatin1String("subsubkeys"), QVariantMap()); subKeys.insert(QLatin1String("testbool"), true); testMap.insert(QLatin1String("subkeys"), subKeys); subKeys.clear(); testMap.insert(QLatin1String("subkeys2"), subKeys); testMap.insert(QLatin1String("testint"), 23); KeyValuePairList data; data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe"))); data.append(KeyValuePair(QLatin1String("bool-false"), QString::fromLatin1("bool:false"))); data.append(KeyValuePair(QLatin1String("int"), QString::fromLatin1("int:42"))); data.append(KeyValuePair(QLatin1String("qstring"), QString::fromLatin1("QString:test string."))); data.append(KeyValuePair(QLatin1String("qbytearray"), QString::fromLatin1("QByteArray:test array."))); data.append(KeyValuePair(QLatin1String("subkeys/qbytearray"), QString::fromLatin1("QByteArray:test array."))); data.append(KeyValuePair(QLatin1String("subkeys/newsubkeys/qbytearray"), QString::fromLatin1("QByteArray:test array."))); data.append(KeyValuePair(QLatin1String("newsub/1/2/3/qbytearray"), QString::fromLatin1("QByteArray:test array."))); data.append(KeyValuePair(QLatin1String("newsub/1/2.1/3/qbytearray"), QString::fromLatin1("QByteArray:test array."))); QVariantMap result = addKeys(testMap, data); if (result.count() != 9) return false; // subkeys: QVariantMap cur = result.value(QLatin1String("subkeys")).toMap(); if (cur.count() != 4 || !cur.contains(QLatin1String("qbytearray")) || !cur.contains(QLatin1String("testbool")) || !cur.contains(QLatin1String("subsubkeys")) || !cur.contains(QLatin1String("newsubkeys"))) return false; // subkeys/newsubkeys: QVariantMap tmp = cur; cur = cur.value(QLatin1String("newsubkeys")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("qbytearray"))) return false; // subkeys/subsubkeys: cur = tmp.value(QLatin1String("subsubkeys")).toMap(); if (cur.count() != 0) return false; // newsub: cur = result.value(QLatin1String("newsub")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("1"))) return false; // newsub/1: cur = cur.value(QLatin1String("1")).toMap(); if (cur.count() != 2 || !cur.contains(QLatin1String("2")) || !cur.contains(QLatin1String("2.1"))) return false; // newsub/1/2: tmp = cur; cur = cur.value(QLatin1String("2")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("3"))) return false; // newsub/1/2/3: cur = cur.value(QLatin1String("3")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("qbytearray"))) return false; // newsub/1/2.1: cur = tmp.value(QLatin1String("2.1")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("3"))) return false; // newsub/1/2.1/3: cur = cur.value(QLatin1String("3")).toMap(); if (cur.count() != 1 || !cur.contains(QLatin1String("qbytearray"))) return false; // subkeys2: cur = result.value(QLatin1String("subkeys2")).toMap(); if (cur.count() != 0) return false; // values: if (!result.contains(QLatin1String("bool-true")) || !result.value(QLatin1String("bool-true")).toBool()) return false; if (!result.contains(QLatin1String("bool-false")) || result.value(QLatin1String("bool-false")).toBool()) return false; if (!result.contains(QLatin1String("int")) || result.value(QLatin1String("int")).toInt() != 42) return false; if (!result.contains(QLatin1String("qstring")) || result.value(QLatin1String("qstring")).toString() != QLatin1String("test string.")) return false; if (!result.contains(QLatin1String("qbytearray")) || result.value(QLatin1String("qbytearray")).toByteArray() != "test array.") return false; // Make sure we do not overwrite data: // preexisting: data.clear(); data.append(KeyValuePair(QLatin1String("testint"), QString::fromLatin1("int:4"))); result = addKeys(testMap, data); if (!result.isEmpty()) return false; data.clear(); data.append(KeyValuePair(QLatin1String("subkeys/testbool"), QString::fromLatin1("int:24"))); result = addKeys(testMap, data); if (!result.isEmpty()) return false; // data inserted before: data.clear(); data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe"))); data.append(KeyValuePair(QLatin1String("bool-true"), QString::fromLatin1("bool:trUe"))); result = addKeys(testMap, data); if (!result.isEmpty()) return false; return true; }
ApiTraceState::ApiTraceState(const QVariantMap &parsedJson) { m_parameters = parsedJson[QLatin1String("parameters")].toMap(); QVariantMap attachedShaders = parsedJson[QLatin1String("shaders")].toMap(); QVariantMap::const_iterator itr; for (itr = attachedShaders.constBegin(); itr != attachedShaders.constEnd(); ++itr) { QString type = itr.key(); QString source = itr.value().toString(); m_shaderSources[type] = source; } QVariantList textureUnits = parsedJson[QLatin1String("textures")].toList(); for (int i = 0; i < textureUnits.count(); ++i) { QVariantMap unit = textureUnits[i].toMap(); for (itr = unit.constBegin(); itr != unit.constEnd(); ++itr) { QVariantMap target = itr.value().toMap(); if (target.count()) { QVariantList levels = target[QLatin1String("levels")].toList(); for (int j = 0; j < levels.count(); ++j) { QVariantMap level = levels[j].toMap(); QVariantMap image = level[QLatin1String("image")].toMap(); QSize size(image[QLatin1String("__width__")].toInt(), image[QLatin1String("__height__")].toInt()); QString cls = image[QLatin1String("__class__")].toString(); QString type = image[QLatin1String("__type__")].toString(); bool normalized = image[QLatin1String("__normalized__")].toBool(); int numChannels = image[QLatin1String("__channels__")].toInt(); Q_ASSERT(type == QLatin1String("uint8")); Q_ASSERT(normalized == true); QByteArray dataArray = image[QLatin1String("__data__")].toByteArray(); ApiTexture tex; tex.setSize(size); tex.setNumChannels(numChannels); tex.setLevel(j); tex.setUnit(i); tex.setTarget(itr.key()); tex.contentsFromBase64(dataArray); m_textures.append(tex); } } } } QVariantMap fbos = parsedJson[QLatin1String("framebuffer")].toMap(); for (itr = fbos.constBegin(); itr != fbos.constEnd(); ++itr) { QVariantMap buffer = itr.value().toMap(); QSize size(buffer[QLatin1String("__width__")].toInt(), buffer[QLatin1String("__height__")].toInt()); QString cls = buffer[QLatin1String("__class__")].toString(); QString type = buffer[QLatin1String("__type__")].toString(); bool normalized = buffer[QLatin1String("__normalized__")].toBool(); int numChannels = buffer[QLatin1String("__channels__")].toInt(); Q_ASSERT(type == QLatin1String("uint8")); Q_ASSERT(normalized == true); QByteArray dataArray = buffer[QLatin1String("__data__")].toByteArray(); ApiFramebuffer fbo; fbo.setSize(size); fbo.setNumChannels(numChannels); fbo.setType(itr.key()); fbo.contentsFromBase64(dataArray); m_framebuffers.append(fbo); } }
QVariantMap QgsProcessingModelAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const { QSet< QString > toExecute; QMap< QString, ChildAlgorithm >::const_iterator childIt = mChildAlgorithms.constBegin(); for ( ; childIt != mChildAlgorithms.constEnd(); ++childIt ) { if ( childIt->isActive() && childIt->algorithm() ) toExecute.insert( childIt->childId() ); } QTime totalTime; totalTime.start(); QMap< QString, QVariantMap > childResults; QVariantMap finalResults; QSet< QString > executed; bool executedAlg = true; while ( executedAlg && executed.count() < toExecute.count() ) { executedAlg = false; Q_FOREACH ( const QString &childId, toExecute ) { if ( executed.contains( childId ) ) continue; bool canExecute = true; Q_FOREACH ( const QString &dependency, dependsOnChildAlgorithms( childId ) ) { if ( !executed.contains( dependency ) ) { canExecute = false; break; } } if ( !canExecute ) continue; executedAlg = true; feedback->pushDebugInfo( QObject::tr( "Prepare algorithm: %1" ).arg( childId ) ); const ChildAlgorithm &child = mChildAlgorithms[ childId ]; QVariantMap childParams = parametersForChildAlgorithm( child, parameters, childResults ); feedback->setProgressText( QObject::tr( "Running %1 [%2/%3]" ).arg( child.description() ).arg( executed.count() + 1 ).arg( toExecute.count() ) ); //feedback->pushDebugInfo( "Parameters: " + ', '.join( [str( p ).strip() + // '=' + str( p.value ) for p in alg.algorithm.parameters] ) ) QTime childTime; childTime.start(); bool ok = false; QVariantMap results = child.algorithm()->run( childParams, context, feedback, &ok ); if ( !ok ) { QString error = QObject::tr( "Error encountered while running %1" ).arg( child.description() ); feedback->reportError( error ); throw QgsProcessingException( error ); } childResults.insert( childId, results ); // look through child alg's outputs to determine whether any of these should be copied // to the final model outputs QMap<QString, QgsProcessingModelAlgorithm::ModelOutput> outputs = child.modelOutputs(); QMap<QString, QgsProcessingModelAlgorithm::ModelOutput>::const_iterator outputIt = outputs.constBegin(); for ( ; outputIt != outputs.constEnd(); ++outputIt ) { finalResults.insert( childId + ':' + outputIt->name(), results.value( outputIt->childOutputName() ) ); } executed.insert( childId ); feedback->pushDebugInfo( QObject::tr( "OK. Execution took %1 s (%2 outputs)." ).arg( childTime.elapsed() / 1000.0 ).arg( results.count() ) ); } } feedback->pushDebugInfo( QObject::tr( "Model processed ok. Executed %1 algorithms total in %2 s." ).arg( executed.count() ).arg( totalTime.elapsed() / 1000.0 ) ); return finalResults; }