void GTUtilsMSAEditorSequenceArea::scrollToPosition(HI::GUITestOpStatus &os, const QPoint &position) {
    MSAEditorSequenceArea *msaSeqArea = qobject_cast<MSAEditorSequenceArea*>(GTWidget::findWidget(os, "msa_editor_sequence_area", GTUtilsMdi::activeWindow(os)));
    GT_CHECK(NULL != msaSeqArea, "MSA Editor sequence area is not found");
    GT_CHECK(msaSeqArea->isInRange(position), "Position is out of range");

    // scroll down
    GScrollBar* vBar = msaSeqArea->getVBar();
    GT_CHECK(NULL != vBar, "Vertical scroll bar is not found");

    QStyleOptionSlider vScrollBarOptions;
    vScrollBarOptions.initFrom(vBar);

    while (!msaSeqArea->isSeqVisible(position.y(), false)) {
        const QRect sliderSpaceRect = vBar->style()->subControlRect(QStyle::CC_ScrollBar, &vScrollBarOptions, QStyle::SC_ScrollBarGroove, vBar);
        const QPoint bottomEdge(sliderSpaceRect.width() / 2, sliderSpaceRect.y() + sliderSpaceRect.height());

        GTMouseDriver::moveTo(vBar->mapToGlobal(bottomEdge) - QPoint(0, 1));
        GTMouseDriver::click();
    }

    // scroll right
    GScrollBar* hBar = msaSeqArea->getHBar();
    GT_CHECK(NULL != hBar, "Horisontal scroll bar is not found");

    QStyleOptionSlider hScrollBarOptions;
    hScrollBarOptions.initFrom(hBar);

    while (!msaSeqArea->isPosVisible(position.x(), false)) {
        const QRect sliderSpaceRect = hBar->style()->subControlRect(QStyle::CC_ScrollBar, &hScrollBarOptions, QStyle::SC_ScrollBarGroove, hBar);
        const QPoint rightEdge(sliderSpaceRect.x() + sliderSpaceRect.width(), sliderSpaceRect.height() / 2);

        GTMouseDriver::moveTo(hBar->mapToGlobal(rightEdge) - QPoint(1, 0));
        GTMouseDriver::click();
    }

    SAFE_POINT(msaSeqArea->isVisible(position, false), "The position is still invisible after scrolling", );
}
void GTUtilsWorkflowDesigner::addAlgorithm(HI::GUITestOpStatus &os, QString algName, bool exactMatch, bool useDragAndDrop){
    expandTabs(os);
    QTabWidget* tabs = qobject_cast<QTabWidget*>(GTWidget::findWidget(os,"tabs"));
    GT_CHECK(tabs!=NULL, "tabs widget not found");

    GTTabWidget::setCurrentIndex(os,tabs,0);
    GTGlobals::sleep(500);

    QTreeWidgetItem *alg = findTreeItem(os, algName, algoriths, exactMatch);
    GTGlobals::sleep(100);
    GT_CHECK(alg!=NULL,"algorithm is NULL");

    selectAlgorithm(os,alg);
    QWidget* w = GTWidget::findWidget(os,"sceneView");

    int workerNum = getWorkers(os).size();
    QPoint p(w->rect().topLeft() + QPoint(100+300*(workerNum-(workerNum/2)*2),100 + 200*(workerNum/2)));//shifting workers position
    if(useDragAndDrop){
        GTMouseDriver::dragAndDrop(os, GTMouseDriver::getMousePosition(), w->mapToGlobal(p));
    }else{
        GTWidget::click(os, w,Qt::LeftButton, p);
    }
    GTGlobals::sleep(1000);
}
示例#3
0
void DotPlotFiller::commonScenario() {

    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    QSpinBox *minLenBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "minLenBox", dialog));
    if(but1kpressed){
        GTWidget::click(os, GTWidget::findWidget(os, "minLenHeuristicsButton", dialog));
        GTGlobals::sleep();
        GT_CHECK(minLenBox->value()==2,"minLem not 2, 1k button works wrong");
    }
    else
        GTSpinBox::setValue(os, minLenBox, minLen,GTGlobals::UseKeyBoard);

    if (identity) {
        QSpinBox *identityBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "identityBox", dialog));
        GTSpinBox::setValue(os, identityBox, identity,GTGlobals::UseKeyBoard);
    }

    QCheckBox* invertedCheckBox = qobject_cast<QCheckBox*>(GTWidget::findWidget(os, "invertedCheckBox", dialog));
    GTCheckBox::setChecked(os, invertedCheckBox, invertedRepeats);

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
void GTUtilsMSAEditorSequenceArea::selectArea(HI::GUITestOpStatus &os, QPoint p1, QPoint p2)
{
    MSAEditorSequenceArea *msaEditArea = qobject_cast<MSAEditorSequenceArea*>(GTWidget::findWidget(os, "msa_editor_sequence_area", GTUtilsMdi::activeWindow(os)));
    GT_CHECK(msaEditArea != NULL, "MsaEditorSequenceArea not found");

    p1.rx() = p1.x()==-1 ? msaEditArea->getNumVisibleBases(true)-1 : p1.x();
    p2.rx() = p2.x()==-1 ? msaEditArea->getNumVisibleBases(true)-1 : p2.x();
    p1.ry() = p1.y()==-1 ? msaEditArea->getNumVisibleSequences(true)-1 : p1.y();
    p2.ry() = p2.y()==-1 ? msaEditArea->getNumVisibleSequences(true)-1 : p2.y();

    moveTo(os, p1);
    GTMouseDriver::press();
    GTMouseDriver::moveTo(convertCoordinates(os,p2));
    GTMouseDriver::release();
    GTGlobals::sleep(1000);
}
void ExportMSA2MSADialogFiller::commonScenario()
{
    QWidget *dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog != NULL, "dialog not found");

    if(!path.isEmpty()){
        QLineEdit* fileNameEdit = dialog->findChild<QLineEdit*>("fileNameEdit");
        GTLineEdit::setText(os, fileNameEdit,path);
    }
    if(formatVal>=0){
        QComboBox* formatCombo = dialog->findChild<QComboBox*>("formatCombo");
        GTComboBox::setCurrentIndex(os, formatCombo, formatVal);
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
void GTMouseDriver::press(GUITestOpStatus &os, Qt::MouseButton button)
{
    unsigned int btn = button == Qt::LeftButton ? MOUSEEVENTF_LEFTDOWN :
                       button == Qt::RightButton ? MOUSEEVENTF_RIGHTDOWN :
                       button == Qt::MidButton ? MOUSEEVENTF_MIDDLEDOWN : 0;
    GT_CHECK(btn != 0, "button is 0");

    INPUT event;
    event.type = INPUT_MOUSE;
    event.mi.dx = 0;
    event.mi.dy = 0;
    event.mi.mouseData = 0;
    event.mi.dwFlags = btn;
    event.mi.time = 0;
    event.mi.dwExtraInfo = 0;

    SendInput(1, &event, sizeof(event));
}
示例#7
0
void GTLineEdit::pasteClipboard(GUITestOpStatus& os, QLineEdit* lineEdit, PasteMethod pasteMethod) {

    GT_CHECK(lineEdit != NULL, "lineEdit is NULL");

    clear(os, lineEdit);
    switch(pasteMethod) {
    case Mouse:
        os.setError("GTLineEdit::pasteClipboard: Not implemented: Paste by mouse");
        break;

    default:
    case Shortcut:
        GTKeyboardUtils::paste(os);
        break;
    }

    GTGlobals::sleep(500);
}
void GTUtilsWorkflowDesigner::expandTabs(HI::GUITestOpStatus &os){
    QSplitter* splitter = qobject_cast<QSplitter*>(GTWidget::findWidget(os,"splitter"));
    GT_CHECK(splitter, "splitter not found");
    QList<int> s;
    s  = splitter->sizes();

    if(s.first()==0){//expands tabs if collapsed
        QPoint p;
        p.setX(splitter->geometry().left()+2);
        p.setY(splitter->geometry().center().y());
        GTMouseDriver::moveTo(os, p);
        GTGlobals::sleep(300);
        GTMouseDriver::press(os);
        p.setX(p.x()+200);
        GTMouseDriver::moveTo(os,p);
        GTMouseDriver::release(os);
    }
}
void RemoveGapColsDialogFiller::commonScenario() {
    GTGlobals::sleep(1000);
    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    QRadioButton* radio = dialog->findChild<QRadioButton*>(radioMap[button]);
    GTRadioButton::click(os, radio);

    if (button==Number){
        QSpinBox* box = dialog->findChild<QSpinBox*>("absoluteSpinBox");
        GTSpinBox::setValue(os, box, spinValue);
    }else if (button==Percent){
        QSpinBox* box = dialog->findChild<QSpinBox*>("relativeSpinBox");
        GTSpinBox::setValue(os, box, spinValue);
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
void KalignDialogFiller::commonScenario()
{
    QWidget *dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog != NULL, "dialog not found");

    if(gapOpenVal) {
        QCheckBox* gapOpenCheckBox = dialog->findChild<QCheckBox*>("gapOpenCheckBox");
        GTCheckBox::setChecked(os,gapOpenCheckBox, true);

        QDoubleSpinBox* gapOpenSpinBox = dialog->findChild<QDoubleSpinBox*>("gapOpenSpinBox");
        GTDoubleSpinbox::setValue(os,gapOpenSpinBox,gapOpenVal,GTGlobals::UseKeyBoard);
    }

    QCheckBox* translateCheckBox = GTWidget::findExactWidget<QCheckBox*>(os, "translateCheckBox", dialog);
    GTCheckBox::setChecked(os, translateCheckBox, toAmino);

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
示例#11
0
void GTScrollBar::lineUp(GUITestOpStatus &os, QScrollBar *scrollbar, GTGlobals::UseMethod useMethod) {
    GT_CHECK(scrollbar != NULL, "scrollbar is NULL");
    switch (useMethod) {
        case GTGlobals::UseMouse:
            GTMouseDriver::moveTo(os, GTScrollBar::getUpArrowPosition(os, scrollbar));
            GTMouseDriver::click(os);
            break;

        case GTGlobals::UseKey:
            GTMouseDriver::moveTo(os, GTScrollBar::getSliderPosition(os, scrollbar));
            GTMouseDriver::click(os);
            GTKeyboardDriver::keyClick(os, GTKeyboardDriver::key["up"]);
            break;

        default:
            break;
    }
}
void DistanceMatrixDialogFiller::commonScenario(){

    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog!=NULL, "dialog not found");


    QComboBox* algoCombo = dialog->findChild<QComboBox*>("algoCombo");
    if(hamming){
        GTComboBox::setCurrentIndex(os,algoCombo,0);
    }
    else{
        GTComboBox::setCurrentIndex(os,algoCombo,1);
    }

    if(counts){
        QRadioButton* countsRB = dialog->findChild<QRadioButton*>("countsRB");
        GTRadioButton::click(os,countsRB);
    }
    else{
        QRadioButton* percentsRB = dialog->findChild<QRadioButton*>("percentsRB");
        GTRadioButton::click(os,percentsRB);
    }

    if(saveToFile){
        GTGroupBox::setChecked(os, "saveBox", dialog);

        QLineEdit* fileEdit = dialog->findChild<QLineEdit*>("fileEdit");
        GTLineEdit::setText(os, fileEdit,path);

        if(format == HTML){
            QRadioButton* htmlRB = dialog->findChild<QRadioButton*>("htmlRB");
            GTRadioButton::click(os,htmlRB);
        }
        else{
            QRadioButton* csvRB = dialog->findChild<QRadioButton*>("csvRB");
            GTRadioButton::click(os,csvRB);
        }
    }
    QCheckBox* checkBox = dialog->findChild<QCheckBox*>("checkBox");
    GTCheckBox::setChecked(os,checkBox,excludeGaps);

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
示例#13
0
void BuildTreeDialogFillerPhyML::commonScenario() {
    QWidget *dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    GTUtilsDialog::waitForDialogWhichMayRunOrNot(os, new LicenseAgreemntDialogFiller(os));

    GTComboBox::setIndexWithText(os, GTWidget::findExactWidget<QComboBox*>(os, "algorithmBox", dialog), "PhyML Maximum Likelihood");

    if (freqOptimRadioPressed) {
        GTRadioButton::click(os, GTWidget::findExactWidget<QRadioButton*>(os, "freqOptimRadio", dialog));
    }

    if (bootstrap >= 0) {
        GTTabWidget::setCurrentIndex(os, GTWidget::findExactWidget<QTabWidget *>(os, "twSettings", dialog), 1);
        GTCheckBox::setChecked(os, GTWidget::findExactWidget<QCheckBox *>(os, "bootstrapCheckBox"), true);
        GTSpinBox::setValue(os, GTWidget::findExactWidget<QSpinBox *>(os, "bootstrapSpinBox"), bootstrap);
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
示例#14
0
void GTMouseDriver::release(GUITestOpStatus &os, Qt::MouseButton button)
{
    // TODO: check if this key has been already pressed
    //unsigned int buttons[3] = {MOUSEEVENTF_LEFTUP, MOUSEEVENTF_RIGHTUP, MOUSEEVENTF_MIDDLEUP};
    unsigned int btn = button == Qt::LeftButton ? MOUSEEVENTF_LEFTUP :
                       button == Qt::RightButton ? MOUSEEVENTF_RIGHTUP :
                       button == Qt::MidButton ? MOUSEEVENTF_MIDDLEUP : 0;
    GT_CHECK(btn != 0, "button is 0");

    INPUT event;
    event.type = INPUT_MOUSE;
    event.mi.dx = 0;
    event.mi.dy = 0;
    event.mi.mouseData = 0;
    event.mi.dwFlags = btn;
    event.mi.time = 0;
    event.mi.dwExtraInfo = 0;

    SendInput(1, &event, sizeof(event));
}
void SequenceReadingModeSelectorDialogFiller::commonScenario()
{   GTGlobals::sleep(1000);
    QWidget *dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog != NULL, "dialog not found");
    QDialogButtonBox *buttonBox = dialog->findChild<QDialogButtonBox*>(QString::fromUtf8("buttonBox"));
    GT_CHECK(buttonBox != NULL, "buttonBox not found");
    if (cancel) {
        QPushButton *button = buttonBox->button(QDialogButtonBox::Cancel);
        GT_CHECK(button != NULL, "standard button not found");
        GTWidget::click(os, button);
        return;
    }
    if (readingMode == Separate) {
        QRadioButton *separateRB = dialog->findChild<QRadioButton*>(QString::fromUtf8("separateRB"));
        GT_CHECK(separateRB != NULL, "radio button not found");
        GTRadioButton::click(os, separateRB);
    }
    if (readingMode == Merge) {
        QRadioButton *mergeRB = dialog->findChild<QRadioButton*>(QString::fromUtf8("mergeRB"));
        GT_CHECK(mergeRB != NULL, "radio button not found");
        GTRadioButton::click(os, mergeRB);

        QSpinBox *mergeSpinBox = dialog->findChild<QSpinBox*>(QString::fromUtf8("mergeSpinBox"));
        GT_CHECK(mergeSpinBox != NULL, "merge spin box not found");
        GTSpinBox::setValue(os, mergeSpinBox, bases, GTGlobals::UseKeyBoard);
    }
    if (readingMode == Join) {
        QRadioButton *malignmentRB = dialog->findChild<QRadioButton*>(QString::fromUtf8("malignmentRB"));
        GT_CHECK(malignmentRB != NULL, "radio button not found");
        GTRadioButton::click(os, malignmentRB);
    }
    if (readingMode == Align) {
        QRadioButton *refalignmentRB = dialog->findChild<QRadioButton*>(QString::fromUtf8("refalignmentRB"));
        GT_CHECK(refalignmentRB != NULL, "radio button not found");
        GTRadioButton::click(os, refalignmentRB);
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
示例#16
0
void BuildTreeDialogFiller::commonScenario() {

    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    GTUtilsDialog::waitForDialogWhichMayRunOrNot(os, new LicenseAgreemntDialogFiller(os));
    if(saveTree!="default"){
        QLineEdit* saveLineEdit = qobject_cast<QLineEdit*>(GTWidget::findWidget(os,"fileNameEdit"));
        GTLineEdit::setText(os,saveLineEdit, saveTree);
    }

    if (0 != model) {
        GTComboBox::setCurrentIndex(os, GTWidget::findExactWidget<QComboBox *>(os, "cbModel", dialog), model);
    }

    if (0 != alpha) {
        GTCheckBox::setChecked(os, GTWidget::findExactWidget<QCheckBox *>(os, "chbGamma", dialog), true);
        GTDoubleSpinbox::setValue(os, GTWidget::findExactWidget<QDoubleSpinBox *>(os, "sbAlpha", dialog), alpha, GTGlobals::UseKeyBoard);
    } else {
        GTCheckBox::setChecked(os, GTWidget::findExactWidget<QCheckBox *>(os, "chbGamma", dialog), false);
    }

    if (0 != replicates) {
        GTTabWidget::setCurrentIndex(os, GTWidget::findExactWidget<QTabWidget *>(os, "tabWidget", dialog), 1);
        GTCheckBox::setChecked(os, GTWidget::findExactWidget<QCheckBox *>(os, "chbEnableBootstrapping"), true);
        GTSpinBox::setValue(os, GTWidget::findExactWidget<QSpinBox *>(os, "sbReplicatesNumber"), replicates, GTGlobals::UseKeyBoard);
        GTSpinBox::setValue(os, GTWidget::findExactWidget<QSpinBox *>(os, "sbSeed"), seed, GTGlobals::UseKeyBoard);
        GTComboBox::setCurrentIndex(os, GTWidget::findExactWidget<QComboBox *>(os, "cbConsensusType"), type);
        if (type == M1) {
            GTDoubleSpinbox::setValue(os, GTWidget::findExactWidget<QDoubleSpinBox *>(os, "sbFraction"), fraction, GTGlobals::UseKeyBoard);
        }
    }

    if (!displayWithMsa) {
        GTTabWidget::setCurrentIndex(os, GTWidget::findExactWidget<QTabWidget *>(os, "tabWidget", dialog), 2);
        GTRadioButton::click(os, GTWidget::findExactWidget<QRadioButton *>(os, "createNewView"));
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
void FindRepeatsDialogFiller::commonScenario() {
    GTGlobals::sleep(1000);
    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    if (button == Cancel) {
        QAbstractButton *cancelButton = qobject_cast<QAbstractButton*>(GTWidget::findWidget(os, "cancelButton", dialog));
        GTWidget::click(os, cancelButton);
        return;
    }

    QTabWidget *tabWidget = qobject_cast<QTabWidget*>(GTWidget::findWidget(os, "tabWidget", dialog));
    GTTabWidget::setCurrentIndex(os, tabWidget, 0);

    if (-1 != minRepeatLength) {
        QSpinBox *minLenBox = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "minLenBox", dialog));
        GTSpinBox::setValue(os, minLenBox, minRepeatLength, GTGlobals::UseKeyBoard);
    }

    if (-1 != repeatsIdentity) {
        QSpinBox *identityBox = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "identityBox", dialog));
        GTSpinBox::setValue(os, identityBox, repeatsIdentity);
    }

    if (-1 != minDistance) {
        QSpinBox *minDistBox = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "minDistBox", dialog));
        GTSpinBox::setValue(os, minDistBox, minDistance);
    }

    QLineEdit *resultLocationEdit = qobject_cast<QLineEdit *>(GTWidget::findWidget(os, "leNewTablePath", dialog));
    resultLocationEdit->setText(resultAnnotationFilesPath);

    GTTabWidget::setCurrentIndex(os, tabWidget, 1);

    QCheckBox *invertedRepeatsIndicator = qobject_cast<QCheckBox *>(GTWidget::findWidget(os, "invertCheck", dialog));
    invertedRepeatsIndicator->setChecked(searchInverted);

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
void GenerateAlignmentProfileDialogFiller::commonScenario() {

    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    GTGlobals::sleep(500);
    if(counts){
        QRadioButton* countsRB = dialog->findChild<QRadioButton*>("countsRB");
        GTRadioButton::click(os,countsRB);
    }
    else{
        QRadioButton* percentsRB = dialog->findChild<QRadioButton*>("percentsRB");
        GTRadioButton::click(os,percentsRB);
    }

    if (format != NONE) {
        GTGroupBox::setChecked(os, "saveBox", dialog);
        GTGlobals::sleep(500);

        QLineEdit* fileEdit = dialog->findChild<QLineEdit*>("fileEdit");
        GTLineEdit::setText(os,fileEdit, filePath);

        QRadioButton* formatRB = dialog->findChild<QRadioButton*>(checkBoxItems[format]);
        GTRadioButton::click(os,formatRB);
    }

    QCheckBox* gapCB = dialog->findChild<QCheckBox*>("gapCB");
    GTCheckBox::setChecked(os,gapCB,gapScore);

    QCheckBox* unusedCB = dialog->findChild<QCheckBox*>("unusedCB");
    GTCheckBox::setChecked(os,unusedCB,symdolScore);

    QCheckBox* skipGapPositionsCB = dialog->findChild<QCheckBox*>("skipGapPositionsCB");
    GTCheckBox::setChecked(os,skipGapPositionsCB,skipGaps);

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
示例#19
0
void BuildIndexDialogFiller::commonScenario() {

    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    QComboBox* methodNamesBox = dialog->findChild<QComboBox*>("methodNamesBox");
    for(int i=0; i < methodNamesBox->count();i++){
        if(methodNamesBox->itemText(i) == method){
            GTComboBox::setCurrentIndex(os, methodNamesBox, i);
        }
    }

    GTFileDialogUtils *ob = new GTFileDialogUtils(os, refPath, refFileName);
    GTUtilsDialog::waitForDialog(os, ob);
    GTWidget::click(os, GTWidget::findWidget(os, "addRefButton",dialog));

    if (!useDefaultIndexName) {
        QLineEdit* indexFileNameEdit = dialog->findChild<QLineEdit*>("indexFileNameEdit");
        indexFileNameEdit->clear();
        indexFileNameEdit->setText(indPath + indFileName);
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
void ExportAnnotationsFiller::commonScenario()
{
    QWidget *dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog != NULL, "dialog not found");

    QLineEdit *lineEdit = dialog->findChild<QLineEdit*>("fileNameEdit");
    GT_CHECK(lineEdit != NULL, "line edit not found");
    GTLineEdit::setText(os, lineEdit, exportToFile);

    QComboBox *comboBox = dialog->findChild<QComboBox*>();
    GT_CHECK(comboBox != NULL, "ComboBox not found");

    int index = comboBox->findText(comboBoxItems[format]);
    GT_CHECK(index != -1, QString("item \"%1\" in combobox not found").arg(comboBoxItems[format]));
    if (comboBox->currentIndex() != index){
        GTComboBox::setCurrentIndex(os, comboBox, index, true, useMethod);
    }
    if (!addToProject){
        QCheckBox *addToProjectButton = dialog->findChild<QCheckBox*>(QString::fromUtf8("addToProjectCheck"));
        GT_CHECK(addToProjectButton != NULL, "Check box not found");
        if (addToProjectButton->isEnabled()) {
            GTCheckBox::setChecked(os, addToProjectButton, false);
        }
    }

    if (!softMode) {
        QCheckBox *checkButton = dialog->findChild<QCheckBox*>(QString::fromUtf8("exportSequenceCheck"));
        GT_CHECK(checkButton != NULL, "Check box not found");
        GTCheckBox::setChecked(os, checkButton, saveSequencesUnderAnnotations);

        checkButton = dialog->findChild<QCheckBox*>(QString::fromUtf8("exportSequenceNameCheck"));
        GT_CHECK(checkButton != NULL, "Check box not found");
        GTCheckBox::setChecked(os, checkButton, saveSequenceNames);
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}
示例#21
0
void GTUtilsWorkflowDesigner::setCurrentTab(HI::GUITestOpStatus &os, tab t) {
    QTabWidget *tabs = qobject_cast<QTabWidget*>(GTWidget::findWidget(os, "tabs"));
    GT_CHECK(NULL != tabs, "tabs widget is not found");
    GTTabWidget::setCurrentIndex(os, tabs, int(t));
}
示例#22
0
void GTMouseDriver::moveToP(GUITestOpStatus &os, const int x, const int y)
{
    QByteArray display_name = qgetenv("DISPLAY");
    GT_CHECK(!display_name.isEmpty(), "Environment variable \"DISPLAY\" not found");

    Display *display = XOpenDisplay(display_name.constData());
    GT_CHECK(display != 0, "display is NULL");

    int horres = XDisplayWidth(display, 0);
    int vertres = XDisplayHeight(display, 0);

    QRect screen(0, 0, horres-1, vertres-1);
    GT_CHECK(screen.contains(QPoint(x, y)), "Invalid coordinates");

    Window root, child;
    int root_x, root_y, pos_x, pos_y;
    unsigned mask;
    XQueryPointer(display, RootWindow(display, DefaultScreen(display)),
                  &root, &child, &root_x, &root_y,
                  &pos_x, &pos_y, &mask);

    const int delay = 0;// msec
    int x0 = pos_x;
    int y0 = pos_y;
    int x1 = x;
    int y1 = y;

    if (x0 == x1) {
        while(y0 != y1) {
            if (y0 < y1) {
                ++y0;
            } else {
                --y0;
            }

            XTestFakeMotionEvent(display, -1, x1, y0, delay);
            XFlush(display);
        }
    } else if (y0 == y1) {
        while(x0 != x1) {
            if (x0 < x1) {
                ++x0;
            } else {
                --x0;
            }
            XTestFakeMotionEvent(display, -1, x0, y1, delay);
            XFlush(display);
        }
    } else {
        // moved by the shortest way
        // equation of the line by two points y = (-(x0 * y1 - x1 * y0) - x*(y0 - y1)) / (x1 - x0)
        int diff_x = x1 - x0;
        int diff_y = y0 - y1;
        int diff_xy = -(x0 * y1 - x1 * y0);
        int current_x = x0, current_y;

        while (current_x != x1) {
            if (x1 > x0) {
                ++current_x;
            } else {
                -- current_x;
            }

            current_y = (diff_xy - current_x * diff_y) / diff_x;
            XTestFakeMotionEvent(display, -1, current_x, current_y, delay);
            XFlush(display);
        }
    }

    XCloseDisplay(display);
#ifdef _DEBUG
    GTGlobals::sleep(500);
#else
    GTGlobals::sleep(100); //May be not needed
#endif
}
示例#23
0
void GTDoubleSpinbox::setValue(GUITestOpStatus& os, QDoubleSpinBox *spinBox, double v, GTGlobals::UseMethod useMethod) {
    GT_CHECK(spinBox != NULL, "spinBox is NULL");
    if(spinBox->value() == v){
        return;
    }

    QPoint arrowPos;
    QRect spinBoxRect;

    GT_CHECK(spinBox->isEnabled(), "SpinBox is not enabled");

    if (spinBox->value() != v) {
        switch(useMethod) {
        case GTGlobals::UseMouse:
            spinBoxRect = spinBox->rect();
            if (v > spinBox->value()) {
                arrowPos = QPoint(spinBoxRect.right() - 5, spinBoxRect.height() / 4); // -5 it's needed that area under cursor was clickable
            } else {
                arrowPos = QPoint(spinBoxRect.right() - 5, spinBoxRect.height() * 3 / 4);
            }

            GTMouseDriver::moveTo(os, spinBox->mapToGlobal(arrowPos));
            while (QString().setNum(spinBox->value()) != QString().setNum(v)) {
                GTMouseDriver::click(os);
                GTGlobals::sleep(100);
            }
            break;

        case GTGlobals::UseKey: {
            int key = 0;
            if (v > spinBox->value()) {
                key = GTKeyboardDriver::key["up"];
            } else {
                key = GTKeyboardDriver::key["down"];
            }

            GTWidget::setFocus(os, spinBox);
            while (QString().setNum(spinBox->value()) != QString().setNum(v)) {
                GTKeyboardDriver::keyClick(os, key);
                GTGlobals::sleep(100);
            }
            break;
        }
        case GTGlobals::UseKeyBoard:
            QString s = QString::number(v);
            GTWidget::setFocus(os, spinBox);

            GTGlobals::sleep(100);
            GTKeyboardDriver::keyClick(os, GTKeyboardDriver::key["up"]);
            GTGlobals::sleep(100);
            GTKeyboardDriver::keyClick(os, GTKeyboardDriver::key["down"]);
            GTKeyboardDriver::keySequence(os,s);
            GTGlobals::sleep(100);

        }
    }

    GTThread::waitForMainThread(os);
    double currIndex = spinBox->value();
    GT_CHECK(QString().setNum(currIndex) == QString().setNum(v), "Expected: " + QString().setNum(v) + " Found: " + QString().setNum(currIndex));
}
void GTUtilsSharedDatabaseDocument::disconnectDatabase(HI::GUITestOpStatus &os, Document *databaseDoc) {
    Q_UNUSED(os);
    GT_CHECK(NULL != databaseDoc, "databaseDoc is NULL");
    disconnectDatabase(os, databaseDoc->getName());
}
示例#25
0
void GTSpinBox::setValue(GUITestOpStatus& os, QSpinBox *spinBox, int v, GTGlobals::UseMethod useMethod) {
    GT_CHECK(spinBox != NULL, "spinBox is NULL");
    if(spinBox->value() == v){
        return;
    }

    GT_CHECK(v <= spinBox->maximum(), QString("value for this spinbox cannot be more then %1").arg(spinBox->maximum()));
    GT_CHECK(v >= spinBox->minimum(), QString("value for this spinbox cannot be less then %1").arg(spinBox->minimum()));

    QPoint arrowPos;
    QRect spinBoxRect;

    GT_CHECK(spinBox->isEnabled(), "SpinBox is not enabled");

    if (spinBox->value() != v) {
        switch(useMethod) {
        case GTGlobals::UseMouse:
            spinBoxRect = spinBox->rect();
            if (v > spinBox->value()) {
                arrowPos = QPoint(spinBoxRect.right() - 5, spinBoxRect.height() / 4); // -5 it's needed that area under cursor was clickable
            } else {
                arrowPos = QPoint(spinBoxRect.right() - 5, spinBoxRect.height() * 3 / 4);
            }

            GTMouseDriver::moveTo(spinBox->mapToGlobal(arrowPos));
            while (spinBox->value() != v) {
                GTMouseDriver::click();
                GTGlobals::sleep(100);
            }
            break;

        case GTGlobals::UseKey: {
            Qt::Key key;
            if (v > spinBox->value()) {
                key = Qt::Key_Up;
            } else {
                key = Qt::Key_Down;
            }

            GTWidget::setFocus(os, spinBox);
            while (spinBox->value() != v) {
                GTKeyboardDriver::keyClick( key);
                GTGlobals::sleep(100);
            }
            break;
        }
        case GTGlobals::UseKeyBoard:
            QString s = QString::number(v);
            GTWidget::setFocus(os, spinBox);
            GTGlobals::sleep(100);
            GTKeyboardDriver::keyClick( 'a', Qt::ControlModifier);
            GTGlobals::sleep(100);
            GTKeyboardDriver::keyClick( Qt::Key_Delete);
            GTGlobals::sleep(100);
            GTKeyboardDriver::keySequence(s);
            GTGlobals::sleep(100);
        }
    }
    GTThread::waitForMainThread();
    int currIndex = spinBox->value();
    GT_CHECK(currIndex == v, QString("Can't set index. Expected: %1 actual: %2").arg(v).arg(currIndex));
    GTGlobals::sleep(100);
}
示例#26
0
void GTLineEdit::checkText(GUITestOpStatus &os, QLineEdit *lineEdit, const QString &expectedText) {
    Q_UNUSED(os);
    GT_CHECK(NULL != lineEdit, "Line edit is NULL");
    GT_CHECK(expectedText == lineEdit->text(), QString("The text differs: expect '%1', got '%2'").arg(expectedText).arg(lineEdit->text()));
}
void AlignShortReadsFiller::setBowtie2AdditionalParameters(Bowtie2Parameters* bowtie2Parameters, QWidget* dialog) {
    // Parameters
    QComboBox* modeComboBox = qobject_cast<QComboBox*>(GTWidget::findWidget(os, "modeComboBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(modeComboBox, "modeComboBox is NULL");
    GTComboBox::setIndexWithText(os, modeComboBox, bowtie2Parameters->getMode());
    CHECK_OP(os, );

    QSpinBox* mismatchesSpinBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "mismatchesSpinBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(mismatchesSpinBox, "mismatchesSpinBox is NULL");
    GTSpinBox::setValue(os, mismatchesSpinBox, bowtie2Parameters->numberOfMismatches);
    CHECK_OP(os, );

    QCheckBox* seedlenCheckBox = qobject_cast<QCheckBox*>(GTWidget::findWidget(os, "seedlenCheckBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(seedlenCheckBox, "seedlenCheckBox is NULL");
    GTCheckBox::setChecked(os, seedlenCheckBox, bowtie2Parameters->seedLengthCheckBox);
    CHECK_OP(os, );

    QSpinBox* seedlenSpinBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "seedlenSpinBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(seedlenSpinBox, "seedlenSpinBox is NULL");
    if(seedlenCheckBox->isChecked()){
        GTSpinBox::setValue(os, seedlenSpinBox, bowtie2Parameters->seedLength);
    }
    CHECK_OP(os, );

    QCheckBox* dpadCheckBox = qobject_cast<QCheckBox*>(GTWidget::findWidget(os, "dpadCheckBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(dpadCheckBox, "dpadCheckBox is NULL");
    GTCheckBox::setChecked(os, dpadCheckBox, bowtie2Parameters->addColumnsToAllowGapsCheckBox);
    CHECK_OP(os, );

    QSpinBox* dpadSpinBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "dpadSpinBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(dpadSpinBox, "dpadSpinBox is NULL");
    if(dpadCheckBox->isChecked()){
        GTSpinBox::setValue(os, dpadSpinBox, bowtie2Parameters->addColumnsToAllowGaps);
    }
    CHECK_OP(os, );

    QCheckBox* gbarCheckBox = qobject_cast<QCheckBox*>(GTWidget::findWidget(os, "gbarCheckBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(gbarCheckBox, "gbarCheckBox is NULL");
        GTCheckBox::setChecked(os, gbarCheckBox, bowtie2Parameters->disallowGapsCheckBox);
    CHECK_OP(os, );

    QSpinBox* gbarSpinBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "gbarSpinBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(gbarSpinBox, "gbarSpinBox is NULL");
    if(gbarCheckBox->isChecked()){
        GTSpinBox::setValue(os, gbarSpinBox, bowtie2Parameters->disallowGaps);
    }
    CHECK_OP(os, );

    QCheckBox* seedCheckBox = qobject_cast<QCheckBox*>(GTWidget::findWidget(os, "seedCheckBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(seedCheckBox, "seedCheckBox is NULL");
    GTCheckBox::setChecked(os, seedCheckBox, bowtie2Parameters->seedCheckBox);
    CHECK_OP(os, );

    QSpinBox* seedSpinBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "seedSpinBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(seedSpinBox, "seedSpinBox is NULL");
    if(seedCheckBox->isChecked()){
        GTSpinBox::setValue(os, seedSpinBox, bowtie2Parameters->seed);
    }
    CHECK_OP(os, );

#ifndef Q_OS_WIN
    QSpinBox* threadsSpinBox = qobject_cast<QSpinBox*>(GTWidget::findWidget(os, "threadsSpinBox", dialog));
    CHECK_OP(os, );
    GT_CHECK(threadsSpinBox, "threadsSpinBox is NULL");
    if ( threadsSpinBox->minimum( ) <= bowtie2Parameters->threads
         && threadsSpinBox->maximum( ) >= bowtie2Parameters->threads )
    {
        GTSpinBox::setValue(os, threadsSpinBox, bowtie2Parameters->threads);
        CHECK_OP(os, );
    }
示例#28
0
void GTMouseDriver::moveToP(GUITestOpStatus &os, const int x, const int y)
{
    // get screen resolution
    HDC hDCScreen = GetDC(NULL);
    int horres = GetDeviceCaps(hDCScreen, HORZRES);
    int vertres = GetDeviceCaps(hDCScreen, VERTRES);
    ReleaseDC(NULL, hDCScreen);

    QRect screen(0, 0, horres-1, vertres-1);
    GT_CHECK(screen.contains(QPoint(x, y)), "Invalid coordinates");

    const int points_in_line = 65535;
    const double points_in_x_pixel = points_in_line / static_cast<double>(horres);
    const double points_in_y_pixel = points_in_line / static_cast<double>(vertres);

    POINT pos;
    GetCursorPos(&pos);

    int x0 = pos.x;
    int y0 = pos.y;
    int x1 = x;
    int y1 = y;

    INPUT event;
    event.type = INPUT_MOUSE;
    event.mi.dx = 0;
    event.mi.dy = 0;
    event.mi.mouseData = 0;
    event.mi.dwFlags =  MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
    event.mi.time = 0;
    event.mi.dwExtraInfo = 0;

    if (x0 == x1) {
        event.mi.dx = x0 * points_in_x_pixel + 0.5;
        while(y0 != y1) {
            if (y0 < y1) {
                ++y0;
            } else {
                --y0;
            }
            event.mi.dy = y0 * points_in_y_pixel + 0.5;
            SendInput(1, &event, sizeof(event));
        }
    } else if (y0 == y1) {
        event.mi.dy = y0 * points_in_y_pixel + 0.5;
        while(x0 != x1) {
            if (x0 < x1) {
                ++x0;
            } else {
                --x0;
            }
            event.mi.dx = x0 * points_in_x_pixel + 0.5;
            SendInput(1, &event, sizeof(event));
        }
    } else {
        // moved by the shortest way
        // equation of the line by two points y = (-(x0 * y1 - x1 * y0) - x*(y0 - y1)) / (x1 - x0)
        int diff_x = x1 - x0;
        int diff_y = y0 - y1;
        int diff_xy = -(x0 * y1 - x1 * y0);
        int current_x = x0, current_y;

        while (current_x != x1) {
            if (x1 > x0) {
                ++current_x;
            } else {
                -- current_x;
            }

            current_y = (diff_xy - current_x * diff_y) / diff_x;
            event.mi.dy = current_y * points_in_y_pixel + 0.5;
            event.mi.dx = current_x * points_in_x_pixel + 0.5;
            SendInput(1, &event, sizeof(event));
        }
    }

#ifdef _DEBUG
    GTGlobals::sleep(500);
#else
    GTGlobals::sleep(100); //May be not needed
#endif
}
void SmithWatermanDialogFiller::commonScenario() {
    QWidget* dialog = QApplication::activeModalWidget();
    GT_CHECK(dialog, "activeModalWidget is NULL");

    if (button == Cancel) {
        QDialogButtonBox* box = qobject_cast<QDialogButtonBox*>(GTWidget::findWidget(os, "buttonBox", dialog));
        GT_CHECK(box != NULL, "buttonBox is NULL");
        QPushButton* button = box->button(QDialogButtonBox::Cancel);
        GT_CHECK(button !=NULL, "cancel button is NULL");
        GTWidget::click(os, button);
        return;
    }

    QTabWidget *tabWidget = qobject_cast<QTabWidget*>(GTWidget::findWidget(os, "tabWidget", dialog));

    GTTabWidget::setCurrentIndex(os, tabWidget, 1);
    QComboBox * resultViewVariants = qobject_cast<QComboBox *>(GTWidget::findWidget(os, "resultViewVariants", dialog));
    int resultViewIndex = 0;
    if(SmithWatermanSettings::MULTIPLE_ALIGNMENT == resultView) {
        resultViewIndex = 0;
    } else if(SmithWatermanSettings::ANNOTATIONS == resultView) {
        resultViewIndex = 1;
    } else {
        assert(0);
    }
    GTComboBox::setCurrentIndex(os, resultViewVariants, resultViewIndex);

    if(!resultFilesPath.isEmpty()) {
        QLineEdit * resultFilePathContainer = NULL;
        if(SmithWatermanSettings::MULTIPLE_ALIGNMENT == resultView) {
            resultFilePathContainer = qobject_cast<QLineEdit *>(GTWidget::findWidget(os, "alignmentFilesPath", dialog));
        } else if(SmithWatermanSettings::ANNOTATIONS == resultView) {
            QRadioButton * newFileRB = qobject_cast<QRadioButton *>(GTWidget::findWidget(os, "rbCreateNewTable", dialog));
            newFileRB->setChecked(true);
            resultFilePathContainer = qobject_cast<QLineEdit *>(GTWidget::findWidget(os, "leNewTablePath", dialog));
            resultFilesPath += ANNOTATION_RESULT_FILE_NAME;
        }
        assert(NULL != resultFilePathContainer);
        GTLineEdit::setText(os, resultFilePathContainer, resultFilesPath);
    }

    if(autoSetupAlgorithmParams) {
        if(SmithWatermanSettings::MULTIPLE_ALIGNMENT == resultView) {
            QGroupBox * advOptions = qobject_cast<QGroupBox *>(GTWidget::findWidget(os, "advOptions", dialog));
            GTGroupBox::setChecked(os, advOptions, true);

            QLineEdit * mObjectNameTmpl = qobject_cast<QLineEdit *>(GTWidget::findWidget(os, "mObjectNameTmpl", dialog));
            GTLineEdit::setText(os, mObjectNameTmpl, mObjectNameTmpl->text() + TEST_NAME_FOR_MA_RESULTS);

            QLineEdit * refSubseqNameTmpl = qobject_cast<QLineEdit *>(GTWidget::findWidget(os, "refSubseqNameTmpl", dialog));
            GTLineEdit::setText(os, refSubseqNameTmpl, refSubseqNameTmpl->text() + TEST_NAME_FOR_MA_RESULTS);
        } else if(SmithWatermanSettings::ANNOTATIONS == resultView) {
            QLineEdit * annotationNameEdit = qobject_cast<QLineEdit *>(GTWidget::findWidget(os, "leAnnotationName", dialog));
            GTLineEdit::setText(os, annotationNameEdit, TEST_NAME_FOR_ANNOT_RESULTS);
        } else {
            assert(0);
        }
    }

    GTTabWidget::setCurrentIndex(os, tabWidget, 0);

    RegionSelector *regionSelector = qobject_cast<RegionSelector*>(GTWidget::findWidget(os, "range_selector", dialog));
    GTRegionSelector::setRegion(os, regionSelector, s);

    QTextEdit* textEdit = qobject_cast<QTextEdit*>(GTWidget::findWidget(os, "teditPattern", dialog));
    GTTextEdit::setText(os, textEdit, pattern);

    if(autoSetupAlgorithmParams) {
        QComboBox * comboRealization = qobject_cast<QComboBox *>(GTWidget::findWidget(os, "comboRealization", dialog));
        QString realizationName;
        switch(realization) {
        case CLASSIC:
            realizationName = CLASSIC_SW_REALIZATION_NAME;
            break;
        case SSE2:
            realizationName = SSE2_SW_REALIZATION_NAME;
            break;
        default:
            Q_ASSERT(false);
        }

        const int swRealizationIndex = comboRealization->findText(realizationName);
        GTComboBox::setCurrentIndex(os, comboRealization, swRealizationIndex);

        QComboBox * comboResultFilter = qobject_cast<QComboBox *>(GTWidget::findWidget(os, "comboResultFilter", dialog));
        GTComboBox::setCurrentIndex(os, comboResultFilter, RESULT_INTERSECTION_FILTER_INDEX);

        QSpinBox * spinScorePercent = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "spinScorePercent", dialog));
        GTSpinBox::setValue(os, spinScorePercent, RESULT_SCORE_PERCENTAGE, GTGlobals::UseKeyBoard);

        QSpinBox * dblSpinGapOpen = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "spinGapOpen", dialog));
        GTSpinBox::setValue(os, dblSpinGapOpen, GAP_OPEN_PENALTY);

        QSpinBox * dblSpinGapExtd = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "spinGapExtd", dialog));
        GTSpinBox::setValue(os, dblSpinGapExtd, GAP_EXTENDING_PENALTY);
    }

    GTUtilsDialog::clickButtonBox(os, dialog, QDialogButtonBox::Ok);
}