1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #include <drivers/GTKeyboardDriver.h>
23 #include <primitives/GTCheckBox.h>
24 #include <primitives/GTComboBox.h>
25 #include <primitives/GTLineEdit.h>
26 #include <primitives/GTSpinBox.h>
27 #include <primitives/GTTableView.h>
28 #include <primitives/GTTextEdit.h>
29 #include <primitives/GTWidget.h>
30 #include <system/GTClipboard.h>
31 #include <utils/GTThread.h>
32 
33 #include <QDir>
34 #include <QGroupBox>
35 #include <QLabel>
36 #include <QRadioButton>
37 #include <QTableWidget>
38 #include <QTextEdit>
39 #include <QTreeWidget>
40 
41 #include <U2Core/U2SafePoints.h>
42 
43 #include "GTUtilsMdi.h"
44 #include "GTUtilsMsaEditorSequenceArea.h"
45 #include "GTUtilsOptionPanelSequenceView.h"
46 #include "GTUtilsSequenceView.h"
47 #include "GTUtilsTaskTreeView.h"
48 
49 namespace U2 {
50 using namespace HI;
51 
initNames()52 QMap<GTUtilsOptionPanelSequenceView::Tabs, QString> GTUtilsOptionPanelSequenceView::initNames() {
53     QMap<Tabs, QString> result;
54     result.insert(Search, "OP_FIND_PATTERN");
55     result.insert(AnnotationsHighlighting, "OP_ANNOT_HIGHLIGHT");
56     result.insert(Statistics, "OP_SEQ_INFO");
57     result.insert(InSilicoPcr, "OP_IN_SILICO_PCR");
58     result.insert(CircularView, "OP_CV_SETTINGS");
59     return result;
60 }
61 
initInnerWidgetNames()62 QMap<GTUtilsOptionPanelSequenceView::Tabs, QString> GTUtilsOptionPanelSequenceView::initInnerWidgetNames() {
63     QMap<Tabs, QString> result;
64     result.insert(Search, "FindPatternWidget");
65     result.insert(AnnotationsHighlighting, "AnnotHighlightWidget");
66     result.insert(Statistics, "SequenceInfo");
67     result.insert(InSilicoPcr, "InSilicoPcrOptionPanelWidget");
68     result.insert(CircularView, "CircularViewSettingsWidget");
69     return result;
70 }
71 
72 const QMap<GTUtilsOptionPanelSequenceView::Tabs, QString> GTUtilsOptionPanelSequenceView::tabsNames = initNames();
73 const QMap<GTUtilsOptionPanelSequenceView::Tabs, QString> GTUtilsOptionPanelSequenceView::innerWidgetNames = initInnerWidgetNames();
74 
75 #define GT_CLASS_NAME "GTUtilsOptionPanelSequenceView"
76 
77 #define GT_METHOD_NAME "enterPattern"
78 
enterPattern(HI::GUITestOpStatus & os,QString pattern,bool useCopyPaste)79 void GTUtilsOptionPanelSequenceView::enterPattern(HI::GUITestOpStatus &os, QString pattern, bool useCopyPaste) {
80     QTextEdit *patternEdit = qobject_cast<QTextEdit *>(GTWidget::findWidget(os, "textPattern"));
81     GTWidget::click(os, patternEdit);
82 
83     if (!patternEdit->toPlainText().isEmpty()) {
84         GTTextEdit::clear(os, patternEdit);
85     }
86     if (useCopyPaste) {
87         GTClipboard::setText(os, pattern);
88         GTKeyboardDriver::keyClick('v', Qt::ControlModifier);
89     } else {
90         GTTextEdit::setText(os, patternEdit, pattern);
91     }
92 }
93 
94 #undef GT_METHOD_NAME
95 
96 #define GT_METHOD_NAME "toggleTab"
toggleTab(HI::GUITestOpStatus & os,GTUtilsOptionPanelSequenceView::Tabs tab)97 void GTUtilsOptionPanelSequenceView::toggleTab(HI::GUITestOpStatus &os, GTUtilsOptionPanelSequenceView::Tabs tab) {
98     GTWidget::click(os, GTWidget::findWidget(os, tabsNames[tab], GTUtilsSequenceView::getActiveSequenceViewWindow(os)));
99     GTGlobals::sleep(200);
100 }
101 #undef GT_METHOD_NAME
102 
103 #define GT_METHOD_NAME "openTab"
openTab(HI::GUITestOpStatus & os,Tabs tab)104 void GTUtilsOptionPanelSequenceView::openTab(HI::GUITestOpStatus &os, Tabs tab) {
105     if (!isTabOpened(os, tab)) {
106         toggleTab(os, tab);
107         GTThread::waitForMainThread();
108     }
109 }
110 #undef GT_METHOD_NAME
111 
112 #define GT_METHOD_NAME "closeTab"
closeTab(HI::GUITestOpStatus & os,GTUtilsOptionPanelSequenceView::Tabs tab)113 void GTUtilsOptionPanelSequenceView::closeTab(HI::GUITestOpStatus &os, GTUtilsOptionPanelSequenceView::Tabs tab) {
114     if (isTabOpened(os, tab)) {
115         toggleTab(os, tab);
116     }
117 }
118 #undef GT_METHOD_NAME
119 
120 #define GT_METHOD_NAME "isTabOpened"
isTabOpened(HI::GUITestOpStatus & os,GTUtilsOptionPanelSequenceView::Tabs tab)121 bool GTUtilsOptionPanelSequenceView::isTabOpened(HI::GUITestOpStatus &os, GTUtilsOptionPanelSequenceView::Tabs tab) {
122     QWidget *innerTabWidget = GTWidget::findWidget(os, innerWidgetNames[tab], GTUtilsSequenceView::getActiveSequenceViewWindow(os), GTGlobals::FindOptions(false));
123     return innerTabWidget != nullptr && innerTabWidget->isVisible();
124 }
125 #undef GT_METHOD_NAME
126 
127 #define GT_METHOD_NAME "checkTabIsOpened"
checkTabIsOpened(HI::GUITestOpStatus & os,GTUtilsOptionPanelSequenceView::Tabs tab)128 void GTUtilsOptionPanelSequenceView::checkTabIsOpened(HI::GUITestOpStatus &os, GTUtilsOptionPanelSequenceView::Tabs tab) {
129     QString name = innerWidgetNames[tab];
130     GTWidget::findWidget(os, name, GTUtilsSequenceView::getActiveSequenceViewWindow(os));
131 }
132 #undef GT_METHOD_NAME
133 
134 #define GT_METHOD_NAME "checkResultsText"
135 
checkResultsText(HI::GUITestOpStatus & os,QString expectedText)136 bool GTUtilsOptionPanelSequenceView::checkResultsText(HI::GUITestOpStatus &os, QString expectedText) {
137     GTUtilsTaskTreeView::waitTaskFinished(os);
138 
139     QLabel *label = qobject_cast<QLabel *>(GTWidget::findWidget(os, "resultLabel"));
140     return label->text() == expectedText;
141 }
142 
143 #undef GT_METHOD_NAME
144 
145 #define GT_METHOD_NAME "setSearchWithAmbiguousBases"
setSearchWithAmbiguousBases(HI::GUITestOpStatus & os,bool searchWithAmbiguousBases)146 void GTUtilsOptionPanelSequenceView::setSearchWithAmbiguousBases(HI::GUITestOpStatus &os, bool searchWithAmbiguousBases) {
147     GTCheckBox::setChecked(os, GTWidget::findExactWidget<QCheckBox *>(os, "useAmbiguousBasesBox"), searchWithAmbiguousBases);
148 }
149 #undef GT_METHOD_NAME
150 
151 #define GT_METHOD_NAME "clickNext"
152 
clickNext(HI::GUITestOpStatus & os)153 void GTUtilsOptionPanelSequenceView::clickNext(HI::GUITestOpStatus &os) {
154     QPushButton *next = qobject_cast<QPushButton *>(GTWidget::findWidget(os, "nextPushButton"));
155     GTWidget::click(os, next);
156 }
157 
158 #undef GT_METHOD_NAME
159 
160 #define GT_METHOD_NAME "clickPrev"
161 
clickPrev(HI::GUITestOpStatus & os)162 void GTUtilsOptionPanelSequenceView::clickPrev(HI::GUITestOpStatus &os) {
163     QPushButton *prev = qobject_cast<QPushButton *>(GTWidget::findWidget(os, "prevPushButton"));
164     GTWidget::click(os, prev);
165 }
166 
167 #undef GT_METHOD_NAME
168 
169 #define GT_METHOD_NAME "clickGetAnnotation"
170 
clickGetAnnotation(HI::GUITestOpStatus & os)171 void GTUtilsOptionPanelSequenceView::clickGetAnnotation(HI::GUITestOpStatus &os) {
172     QPushButton *getAnnotations = qobject_cast<QPushButton *>(GTWidget::findWidget(os, "getAnnotationsPushButton"));
173     GTWidget::click(os, getAnnotations);
174     GTThread::waitForMainThread();
175 }
176 
177 #undef GT_METHOD_NAME
178 
179 #define GT_METHOD_NAME "isPrevNextEnabled"
180 
isPrevNextEnabled(HI::GUITestOpStatus & os)181 bool GTUtilsOptionPanelSequenceView::isPrevNextEnabled(HI::GUITestOpStatus &os) {
182     QPushButton *next = qobject_cast<QPushButton *>(GTWidget::findWidget(os, "nextPushButton"));
183     QPushButton *prev = qobject_cast<QPushButton *>(GTWidget::findWidget(os, "prevPushButton"));
184     return prev->isEnabled() && next->isEnabled();
185 }
186 
187 #undef GT_METHOD_NAME
188 
189 #define GT_METHOD_NAME "isGetAnnotationsEnabled"
isGetAnnotationsEnabled(HI::GUITestOpStatus & os)190 bool GTUtilsOptionPanelSequenceView::isGetAnnotationsEnabled(HI::GUITestOpStatus &os) {
191     QPushButton *getAnnotations = qobject_cast<QPushButton *>(GTWidget::findWidget(os, "getAnnotationsPushButton"));
192     return getAnnotations->isEnabled();
193 }
194 #undef GT_METHOD_NAME
195 
196 #define GT_METHOD_NAME "toggleCircularView"
toggleCircularView(HI::GUITestOpStatus & os)197 void GTUtilsOptionPanelSequenceView::toggleCircularView(HI::GUITestOpStatus &os) {
198     GTWidget::click(os, GTWidget::findButtonByText(os, "Open Circular View(s)", GTUtilsSequenceView::getActiveSequenceViewWindow(os)));
199     GTThread::waitForMainThread();
200 }
201 #undef GT_METHOD_NAME
202 
203 #define GT_METHOD_NAME "setTitleFontSize"
setTitleFontSize(HI::GUITestOpStatus & os,int fontSize)204 void GTUtilsOptionPanelSequenceView::setTitleFontSize(HI::GUITestOpStatus &os, int fontSize) {
205     GTSpinBox::setValue(os, GTWidget::findExactWidget<QSpinBox *>(os, "fontSizeSpinBox"), fontSize);
206 }
207 #undef GT_METHOD_NAME
208 
209 #define GT_METHOD_NAME "getTitleFontSize"
getTitleFontSize(HI::GUITestOpStatus & os)210 int GTUtilsOptionPanelSequenceView::getTitleFontSize(HI::GUITestOpStatus &os) {
211     return GTSpinBox::getValue(os, GTWidget::findExactWidget<QSpinBox *>(os, "fontSizeSpinBox", GTUtilsSequenceView::getActiveSequenceViewWindow(os)));
212 }
213 #undef GT_METHOD_NAME
214 
215 #define GT_METHOD_NAME "setForwardPrimer"
setForwardPrimer(HI::GUITestOpStatus & os,const QString & primer)216 void GTUtilsOptionPanelSequenceView::setForwardPrimer(HI::GUITestOpStatus &os, const QString &primer) {
217     openTab(os, InSilicoPcr);
218     QWidget *primerContainer = GTWidget::findWidget(os, "forwardPrimerBox");
219     GT_CHECK(nullptr != primerContainer, "Forward primer container widget is NULL");
220     GTLineEdit::setText(os, GTWidget::findExactWidget<QLineEdit *>(os, "primerEdit", primerContainer), primer);
221 }
222 #undef GT_METHOD_NAME
223 
224 #define GT_METHOD_NAME "setForwardPrimerMismatches"
setForwardPrimerMismatches(HI::GUITestOpStatus & os,const int mismatches)225 void GTUtilsOptionPanelSequenceView::setForwardPrimerMismatches(HI::GUITestOpStatus &os, const int mismatches) {
226     openTab(os, InSilicoPcr);
227     QWidget *primerContainer = GTWidget::findWidget(os, "forwardPrimerBox");
228     GT_CHECK(nullptr != primerContainer, "Forward primer container widget is NULL");
229 
230     QSpinBox *mismatchesSpinBox = GTWidget::findExactWidget<QSpinBox *>(os, "mismatchesSpinBox", primerContainer);
231     GT_CHECK(nullptr != primerContainer, "Forward primer mismatches SpinBox is NULL");
232 
233     GTSpinBox::setValue(os, mismatchesSpinBox, mismatches, GTGlobals::UseKey);
234 }
235 #undef GT_METHOD_NAME
236 
237 #define GT_METHOD_NAME "setReversePrimer"
setReversePrimer(HI::GUITestOpStatus & os,const QString & primer)238 void GTUtilsOptionPanelSequenceView::setReversePrimer(HI::GUITestOpStatus &os, const QString &primer) {
239     openTab(os, InSilicoPcr);
240     QWidget *primerContainer = GTWidget::findWidget(os, "reversePrimerBox");
241     GT_CHECK(nullptr != primerContainer, "Reverse primer container widget is NULL");
242     GTLineEdit::setText(os, GTWidget::findExactWidget<QLineEdit *>(os, "primerEdit", primerContainer), primer);
243 }
244 #undef GT_METHOD_NAME
245 
246 #define GT_METHOD_NAME "setReversePrimerMismatches"
setReversePrimerMismatches(HI::GUITestOpStatus & os,const int mismatches)247 void GTUtilsOptionPanelSequenceView::setReversePrimerMismatches(HI::GUITestOpStatus &os, const int mismatches) {
248     openTab(os, InSilicoPcr);
249     QWidget *primerContainer = GTWidget::findWidget(os, "reversePrimerBox");
250     GT_CHECK(nullptr != primerContainer, "Reverse primer container widget is NULL");
251 
252     QSpinBox *mismatchesSpinBox = GTWidget::findExactWidget<QSpinBox *>(os, "mismatchesSpinBox", primerContainer);
253     GT_CHECK(nullptr != primerContainer, "Reverse primer mismatches SpinBox is NULL");
254 
255     GTSpinBox::setValue(os, mismatchesSpinBox, mismatches, GTGlobals::UseKey);
256 }
257 #undef GT_METHOD_NAME
258 
259 #define GT_METHOD_NAME "productsCount"
productsCount(HI::GUITestOpStatus & os)260 int GTUtilsOptionPanelSequenceView::productsCount(HI::GUITestOpStatus &os) {
261     openTab(os, InSilicoPcr);
262     QTableWidget *tableWidget = qobject_cast<QTableWidget *>(GTWidget::findWidget(os, "productsTable"));
263     GT_CHECK_RESULT(nullptr != tableWidget, "In Silico PCR Products Table is not found", -1);
264 
265     return tableWidget->rowCount();
266 }
267 #undef GT_METHOD_NAME
268 
269 #define GT_METHOD_NAME "showPrimersDetails"
showPrimersDetails(HI::GUITestOpStatus & os)270 void GTUtilsOptionPanelSequenceView::showPrimersDetails(HI::GUITestOpStatus &os) {
271     openTab(os, InSilicoPcr);
272     QWidget *label = GTWidget::findWidget(os, "detailsLinkLabel");
273     GTWidget::click(os, GTWidget::findWidget(os, "detailsLinkLabel"), Qt::LeftButton, QPoint(20, label->geometry().height() / 2));
274 }
275 #undef GT_METHOD_NAME
276 
277 #define GT_METHOD_NAME "pressFindProducts"
pressFindProducts(HI::GUITestOpStatus & os)278 void GTUtilsOptionPanelSequenceView::pressFindProducts(HI::GUITestOpStatus &os) {
279     openTab(os, InSilicoPcr);
280     QPushButton *findProducts = qobject_cast<QPushButton *>(GTWidget::findWidget(os, "findProductButton"));
281     GT_CHECK(nullptr != findProducts, "Find Product(s) buttons is not found");
282 
283     GTWidget::click(os, findProducts);
284 }
285 #undef GT_METHOD_NAME
286 
287 #define GT_METHOD_NAME "pressExtractProduct"
pressExtractProduct(HI::GUITestOpStatus & os)288 void GTUtilsOptionPanelSequenceView::pressExtractProduct(HI::GUITestOpStatus &os) {
289     openTab(os, InSilicoPcr);
290     QPushButton *extractProduct = qobject_cast<QPushButton *>(GTWidget::findWidget(os, "extractProductButton"));
291     GT_CHECK(nullptr != extractProduct, "Extract Product buttons is not found");
292     GT_CHECK(extractProduct->isEnabled(), "Extract Product buttons is unexpectably disabled");
293 
294     GTWidget::click(os, extractProduct);
295 }
296 #undef GT_METHOD_NAME
297 
298 #define GT_METHOD_NAME "isSearchAlgorithmShowHideWidgetOpened"
isSearchAlgorithmShowHideWidgetOpened(HI::GUITestOpStatus & os)299 bool GTUtilsOptionPanelSequenceView::isSearchAlgorithmShowHideWidgetOpened(HI::GUITestOpStatus &os) {
300     QWidget *algorithmInnerWidget = GTWidget::findWidget(os, "widgetAlgorithm");
301     GT_CHECK_RESULT(nullptr != algorithmInnerWidget, "algorithmInnerWidget is NULL", false);
302     return algorithmInnerWidget->isVisible();
303 }
304 #undef GT_METHOD_NAME
305 
306 #define GT_METHOD_NAME "isSearchInShowHideWidgetOpened"
isSearchInShowHideWidgetOpened(HI::GUITestOpStatus & os)307 bool GTUtilsOptionPanelSequenceView::isSearchInShowHideWidgetOpened(HI::GUITestOpStatus &os) {
308     QWidget *searchInInnerWidget = GTWidget::findWidget(os, "widgetSearchIn");
309     GT_CHECK_RESULT(nullptr != searchInInnerWidget, "searchInInnerWidget is NULL", false);
310     return searchInInnerWidget->isVisible();
311 }
312 #undef GT_METHOD_NAME
313 
314 #define GT_METHOD_NAME "isOtherSettingsShowHideWidgetOpened"
isOtherSettingsShowHideWidgetOpened(HI::GUITestOpStatus & os)315 bool GTUtilsOptionPanelSequenceView::isOtherSettingsShowHideWidgetOpened(HI::GUITestOpStatus &os) {
316     QWidget *otherSettingsInnerWidget = GTWidget::findWidget(os, "widgetOther");
317     GT_CHECK_RESULT(nullptr != otherSettingsInnerWidget, "otherSettingsInnerWidget is NULL", false);
318     return otherSettingsInnerWidget->isVisible();
319 }
320 #undef GT_METHOD_NAME
321 
322 #define GT_METHOD_NAME "isSaveAnnotationToShowHideWidgetOpened"
isSaveAnnotationToShowHideWidgetOpened(HI::GUITestOpStatus & os)323 bool GTUtilsOptionPanelSequenceView::isSaveAnnotationToShowHideWidgetOpened(HI::GUITestOpStatus &os) {
324     QWidget *annotationsWidget = GTWidget::findWidget(os, "annotationsWidget");
325     GT_CHECK_RESULT(nullptr != annotationsWidget, "annotationsWidget is NULL", false);
326     QWidget *saveAnnotationsToInnerWidget = GTWidget::findWidget(os, "saveAnnotationsInnerWidget", annotationsWidget);
327     GT_CHECK_RESULT(nullptr != saveAnnotationsToInnerWidget, "saveAnnotationsInnerWidget is NULL", false);
328     return saveAnnotationsToInnerWidget->isVisible();
329 }
330 #undef GT_METHOD_NAME
331 
332 #define GT_METHOD_NAME "isAnnotationParametersShowHideWidgetOpened"
isAnnotationParametersShowHideWidgetOpened(HI::GUITestOpStatus & os)333 bool GTUtilsOptionPanelSequenceView::isAnnotationParametersShowHideWidgetOpened(HI::GUITestOpStatus &os) {
334     QWidget *annotationsWidget = GTWidget::findWidget(os, "annotationsWidget");
335     GT_CHECK_RESULT(nullptr != annotationsWidget, "annotationsWidget is NULL", false);
336     QWidget *annotationsParametersInnerWidget = GTWidget::findWidget(os, "annotationParametersInnerWidget", annotationsWidget);
337     GT_CHECK_RESULT(nullptr != annotationsParametersInnerWidget, "annotationsParametersInnerWidget is NULL", false);
338     return annotationsParametersInnerWidget->isVisible();
339 }
340 #undef GT_METHOD_NAME
341 
342 #define GT_METHOD_NAME "openSearchAlgorithmShowHideWidget"
openSearchAlgorithmShowHideWidget(HI::GUITestOpStatus & os,bool open)343 void GTUtilsOptionPanelSequenceView::openSearchAlgorithmShowHideWidget(HI::GUITestOpStatus &os, bool open) {
344     CHECK(open != isSearchAlgorithmShowHideWidgetOpened(os), );
345     GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Search algorithm"));
346 }
347 #undef GT_METHOD_NAME
348 
349 #define GT_METHOD_NAME "openSearchInShowHideWidget"
openSearchInShowHideWidget(HI::GUITestOpStatus & os,bool open)350 void GTUtilsOptionPanelSequenceView::openSearchInShowHideWidget(HI::GUITestOpStatus &os, bool open) {
351     CHECK(open != isSearchInShowHideWidgetOpened(os), );
352     GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Search in"));
353 }
354 #undef GT_METHOD_NAME
355 
356 #define GT_METHOD_NAME "openOtherSettingsShowHideWidget"
openOtherSettingsShowHideWidget(HI::GUITestOpStatus & os,bool open)357 void GTUtilsOptionPanelSequenceView::openOtherSettingsShowHideWidget(HI::GUITestOpStatus &os, bool open) {
358     CHECK(open != isOtherSettingsShowHideWidgetOpened(os), );
359     GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Other settings"));
360 }
361 #undef GT_METHOD_NAME
362 
363 #define GT_METHOD_NAME "openSaveAnnotationToShowHideWidget"
openSaveAnnotationToShowHideWidget(HI::GUITestOpStatus & os,bool open)364 void GTUtilsOptionPanelSequenceView::openSaveAnnotationToShowHideWidget(HI::GUITestOpStatus &os, bool open) {
365     CHECK(open != isSaveAnnotationToShowHideWidgetOpened(os), );
366     GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Save annotation(s) to"));
367 }
368 #undef GT_METHOD_NAME
369 
370 #define GT_METHOD_NAME "openAnnotationParametersShowHideWidget"
openAnnotationParametersShowHideWidget(HI::GUITestOpStatus & os,bool open)371 void GTUtilsOptionPanelSequenceView::openAnnotationParametersShowHideWidget(HI::GUITestOpStatus &os, bool open) {
372     CHECK(open != isAnnotationParametersShowHideWidgetOpened(os), );
373     GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Annotation parameters"));
374 }
375 #undef GT_METHOD_NAME
376 
377 #define GT_METHOD_NAME "toggleInputFromFilePattern"
378 
toggleInputFromFilePattern(HI::GUITestOpStatus & os)379 void GTUtilsOptionPanelSequenceView::toggleInputFromFilePattern(HI::GUITestOpStatus &os) {
380     QRadioButton *loadFromFile = qobject_cast<QRadioButton *>(GTWidget::findWidget(os, "usePatternFromFileRadioButton"));
381     GTWidget::click(os, loadFromFile);
382     // kinda hack for QGroupBox should be rewriten
383     GTKeyboardDriver::keyClick(Qt::Key_Space);
384 }
385 
386 #undef GT_METHOD_NAME
387 
388 #define GT_METHOD_NAME "toggleSaveAnnotationsTo"
389 
toggleSaveAnnotationsTo(HI::GUITestOpStatus & os)390 void GTUtilsOptionPanelSequenceView::toggleSaveAnnotationsTo(HI::GUITestOpStatus &os) {
391     QLabel *obj = qobject_cast<QLabel *>(GTWidget::findWidget(os, "ArrowHeader_Save annotation(s) to"));
392     GTWidget::click(os, obj);
393 }
394 
395 #undef GT_METHOD_NAME
396 
397 #define GT_METHOD_NAME "enterPatternFromFile"
398 
enterPatternFromFile(HI::GUITestOpStatus & os,QString filePathStr,QString fileName)399 void GTUtilsOptionPanelSequenceView::enterPatternFromFile(HI::GUITestOpStatus &os, QString filePathStr, QString fileName) {
400     GTFileDialogUtils *ob = new GTFileDialogUtils(os, filePathStr, fileName, GTFileDialogUtils::Open);
401     GTUtilsDialog::waitForDialog(os, ob);
402 
403     QToolButton *browse = qobject_cast<QToolButton *>(GTWidget::findWidget(os, "loadFromFileToolButton"));
404     GTWidget::click(os, browse);
405     GTGlobals::sleep(2500);
406     GTUtilsTaskTreeView::waitTaskFinished(os);
407 }
408 
409 #undef GT_METHOD_NAME
410 
411 #define GT_METHOD_NAME "setStrand"
412 
setStrand(HI::GUITestOpStatus & os,QString strandStr)413 void GTUtilsOptionPanelSequenceView::setStrand(HI::GUITestOpStatus &os, QString strandStr) {
414     QComboBox *strand = qobject_cast<QComboBox *>(GTWidget::findWidget(os, "boxStrand", nullptr, GTGlobals::FindOptions(false)));
415     GT_CHECK(strand != nullptr, "combobox is NULL");
416 
417     if (!strand->isVisible()) {
418         GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Search in"));
419     }
420     GTComboBox::selectItemByText(os, strand, strandStr);
421     GTGlobals::sleep(2500);
422 }
423 #undef GT_METHOD_NAME
424 
425 #define GT_METHOD_NAME "setRegionType"
setRegionType(HI::GUITestOpStatus & os,const QString & regionType)426 void GTUtilsOptionPanelSequenceView::setRegionType(HI::GUITestOpStatus &os, const QString &regionType) {
427     openSearchInShowHideWidget(os);
428     GTComboBox::selectItemByText(os, GTWidget::findExactWidget<QComboBox *>(os, "boxRegion"), regionType);
429 }
430 #undef GT_METHOD_NAME
431 
432 #define GT_METHOD_NAME "setRegion"
setRegion(HI::GUITestOpStatus & os,int from,int to)433 void GTUtilsOptionPanelSequenceView::setRegion(HI::GUITestOpStatus &os, int from, int to) {
434     openSearchInShowHideWidget(os);
435     GTLineEdit::setText(os, GTWidget::findExactWidget<QLineEdit *>(os, "editStart"), QString::number(from));
436     GTLineEdit::setText(os, GTWidget::findExactWidget<QLineEdit *>(os, "editEnd"), QString::number(to));
437 }
438 #undef GT_METHOD_NAME
439 
440 #define GT_METHOD_NAME "enterFilepathForSavingAnnotations"
enterFilepathForSavingAnnotations(HI::GUITestOpStatus & os,QString filepath)441 void GTUtilsOptionPanelSequenceView::enterFilepathForSavingAnnotations(HI::GUITestOpStatus &os, QString filepath) {
442     QLineEdit *leFilePath = qobject_cast<QLineEdit *>(GTWidget::findWidget(os, "leNewTablePath"));
443     GT_CHECK(leFilePath != nullptr, "File path line edit is NULL");
444     QDir().mkpath(QFileInfo(filepath).dir().absolutePath());
445     GTLineEdit::setText(os, leFilePath, filepath);
446 }
447 
448 #undef GT_METHOD_NAME
449 
450 #define GT_METHOD_NAME "setAlgorithm"
setAlgorithm(HI::GUITestOpStatus & os,QString algorithm)451 void GTUtilsOptionPanelSequenceView::setAlgorithm(HI::GUITestOpStatus &os, QString algorithm) {
452     QComboBox *algoBox = qobject_cast<QComboBox *>(GTWidget::findWidget(os, "boxAlgorithm"));
453     GT_CHECK(algoBox != nullptr, "algoBox is NULL");
454 
455     if (!algoBox->isVisible()) {
456         GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Search algorithm"));
457     }
458     GTComboBox::selectItemByText(os, algoBox, algorithm);
459     GTGlobals::sleep(2500);
460 }
461 #undef GT_METHOD_NAME
462 
463 #define GT_METHOD_NAME "getMatchPercentage"
getMatchPercentage(HI::GUITestOpStatus & os)464 int GTUtilsOptionPanelSequenceView::getMatchPercentage(HI::GUITestOpStatus &os) {
465     QSpinBox *spinMatchBox = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "spinBoxMatch"));
466     GT_CHECK_RESULT(nullptr != spinMatchBox, "Match percentage spinbox is NULL", -1);
467     return spinMatchBox->value();
468 }
469 #undef GT_METHOD_NAME
470 
471 #define GT_METHOD_NAME "getRegionType"
getRegionType(HI::GUITestOpStatus & os)472 QString GTUtilsOptionPanelSequenceView::getRegionType(HI::GUITestOpStatus &os) {
473     openSearchInShowHideWidget(os);
474     QComboBox *cbRegionType = GTWidget::findExactWidget<QComboBox *>(os, "boxRegion");
475     GT_CHECK_RESULT(nullptr != cbRegionType, "Region type combobox is NULL", "");
476     return cbRegionType->currentText();
477 }
478 #undef GT_METHOD_NAME
479 
480 #define GT_METHOD_NAME "setMatchPercentage"
getRegion(HI::GUITestOpStatus & os)481 QPair<int, int> GTUtilsOptionPanelSequenceView::getRegion(HI::GUITestOpStatus &os) {
482     openSearchInShowHideWidget(os);
483 
484     QPair<int, int> result;
485     QLineEdit *leRegionStart = GTWidget::findExactWidget<QLineEdit *>(os, "editStart");
486     QLineEdit *leRegionEnd = GTWidget::findExactWidget<QLineEdit *>(os, "editEnd");
487 
488     bool ok = false;
489     const int regionStart = leRegionStart->text().toInt(&ok);
490     GT_CHECK_RESULT(ok, QString("Can't convert the string to int: %1").arg(leRegionStart->text()), result);
491     const int regionEnd = leRegionEnd->text().toInt(&ok);
492     GT_CHECK_RESULT(ok, QString("Can't convert the string to int: %1").arg(leRegionEnd->text()), result);
493 
494     return qMakePair(regionStart, regionEnd);
495 }
496 #undef GT_METHOD_NAME
497 
498 #define GT_METHOD_NAME "getHintText"
getHintText(HI::GUITestOpStatus & os)499 const QString GTUtilsOptionPanelSequenceView::getHintText(HI::GUITestOpStatus &os) {
500     QLabel *lblHint = GTWidget::findExactWidget<QLabel *>(os, "lblErrorMessage");
501     GT_CHECK_RESULT(nullptr != lblHint, "Hintlabel is NULL", "");
502     CHECK(lblHint->isVisible(), "");
503     return lblHint->text();
504 }
505 #undef GT_METHOD_NAME
506 
507 #define GT_METHOD_NAME "setMatchPercentage"
setMatchPercentage(HI::GUITestOpStatus & os,int percentage)508 void GTUtilsOptionPanelSequenceView::setMatchPercentage(HI::GUITestOpStatus &os, int percentage) {
509     QSpinBox *spinMatchBox = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "spinBoxMatch"));
510 
511     GTSpinBox::setValue(os, spinMatchBox, percentage, GTGlobals::UseKeyBoard);
512     GTGlobals::sleep(2500);
513 }
514 #undef GT_METHOD_NAME
515 
516 #define GT_METHOD_NAME "setUsePatternName"
setUsePatternName(HI::GUITestOpStatus & os,bool setChecked)517 void GTUtilsOptionPanelSequenceView::setUsePatternName(HI::GUITestOpStatus &os, bool setChecked) {
518     openAnnotationParametersShowHideWidget(os);
519     GTCheckBox::setChecked(os, GTWidget::findExactWidget<QCheckBox *>(os, "chbUsePatternNames"), setChecked);
520 }
521 #undef GT_METHOD_NAME
522 
523 #define GT_METHOD_NAME "setSearchInTranslation"
setSearchInTranslation(HI::GUITestOpStatus & os,bool inTranslation)524 void GTUtilsOptionPanelSequenceView::setSearchInTranslation(HI::GUITestOpStatus &os, bool inTranslation /* = true*/) {
525     QComboBox *searchIn = qobject_cast<QComboBox *>(GTWidget::findWidget(os, "boxSeqTransl", nullptr, GTGlobals::FindOptions(false)));
526     GT_CHECK(searchIn != nullptr, "combobox is NULL");
527 
528     if (!searchIn->isVisible()) {
529         GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Search in"));
530     }
531     if (inTranslation) {
532         GTComboBox::selectItemByText(os, searchIn, "Translation");
533     } else {
534         GTComboBox::selectItemByText(os, searchIn, "Sequence");
535     }
536     GTGlobals::sleep(2500);
537 }
538 #undef GT_METHOD_NAME
539 
540 #define GT_METHOD_NAME "setSearchInLocation"
setSearchInLocation(HI::GUITestOpStatus & os,QString locationStr)541 void GTUtilsOptionPanelSequenceView::setSearchInLocation(HI::GUITestOpStatus &os, QString locationStr) {
542     QComboBox *region = qobject_cast<QComboBox *>(GTWidget::findWidget(os, "boxRegion", nullptr, GTGlobals::FindOptions(false)));
543     GT_CHECK(region != nullptr, "combobox is NULL");
544 
545     if (!region->isVisible()) {
546         GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Search in"));
547     }
548     GTComboBox::selectItemByText(os, region, locationStr);
549     GTGlobals::sleep(2500);
550 }
551 #undef GT_METHOD_NAME
552 
553 #define GT_METHOD_NAME "setSetMaxResults"
setSetMaxResults(HI::GUITestOpStatus & os,int maxResults)554 void GTUtilsOptionPanelSequenceView::setSetMaxResults(HI::GUITestOpStatus &os, int maxResults) {
555     QSpinBox *limit = qobject_cast<QSpinBox *>(GTWidget::findWidget(os, "boxMaxResult", nullptr, GTGlobals::FindOptions(false)));
556     GT_CHECK(limit != nullptr, "spinbox is NULL");
557 
558     if (!limit->isVisible()) {
559         GTWidget::click(os, GTWidget::findWidget(os, "ArrowHeader_Other settings"));
560     }
561     GTSpinBox::setValue(os, limit, maxResults);
562     GTGlobals::sleep(2500);
563 }
564 
565 #undef GT_METHOD_NAME
566 
567 #undef GT_CLASS_NAME
568 
569 }  // namespace U2
570