DialogLoadMask - ROI selection group. Check if validation of dialog controls works as expected. In this test the values are set using dialog box functions, not using mouse/keyboard input.
(qtbot, use_keys_and_mouse)
| 116 | |
| 117 | @pytest.mark.parametrize("use_keys_and_mouse", [False, True]) |
| 118 | def test_DialogLoadMask_3(qtbot, use_keys_and_mouse): |
| 119 | """ |
| 120 | DialogLoadMask - ROI selection group. |
| 121 | Check if validation of dialog controls works as expected. |
| 122 | In this test the values are set using dialog box functions, not using mouse/keyboard input. |
| 123 | """ |
| 124 | |
| 125 | dlg = DialogLoadMask() |
| 126 | qtbot.addWidget(dlg) |
| 127 | dlg.show() |
| 128 | |
| 129 | # Set image size |
| 130 | n_rows, n_columns = 25, 37 |
| 131 | dlg.set_image_size(n_rows=n_rows, n_columns=n_columns) |
| 132 | |
| 133 | def _set_roi_group_active(status): |
| 134 | if use_keys_and_mouse: |
| 135 | dlg.set_roi_active(status) |
| 136 | else: |
| 137 | dlg.set_roi_active(status) |
| 138 | |
| 139 | def _enter_value(edit_box, value): |
| 140 | """Use keyboard to enter values line edit box""" |
| 141 | qtbot.mouseDClick(edit_box, Qt.LeftButton) |
| 142 | qtbot.keyClicks(edit_box, f"{value}") |
| 143 | qtbot.keyClick(edit_box, Qt.Key_Enter) |
| 144 | |
| 145 | def _set_roi(roi): |
| 146 | if use_keys_and_mouse: |
| 147 | dlg.set_roi(row_start=roi[0], column_start=roi[1], row_end=roi[2], column_end=roi[3]) |
| 148 | else: |
| 149 | _enter_value(dlg.le_roi_start_row, roi[0]) |
| 150 | _enter_value(dlg.le_roi_start_col, roi[1]) |
| 151 | _enter_value(dlg.le_roi_end_row, roi[2]) |
| 152 | _enter_value(dlg.le_roi_end_col, roi[3]) |
| 153 | |
| 154 | def _check_controls(status): |
| 155 | assert dlg.le_roi_start_row.isValid() is status[0], "Invalid status: ROI control - row start" |
| 156 | assert dlg.le_roi_start_col.isValid() is status[1], "Invalid status: ROI control - column start" |
| 157 | assert dlg.le_roi_end_row.isValid() is status[2], "Invalid status: ROI control - row end" |
| 158 | assert dlg.le_roi_end_col.isValid() is status[3], "Invalid status: ROI control - column end" |
| 159 | assert dlg.button_ok.isEnabled() is status[4], "Invalid status: Button Ok" |
| 160 | |
| 161 | # Activate ROI selection group |
| 162 | _set_roi_group_active(True) |
| 163 | |
| 164 | # Set valid selection |
| 165 | sel = (11, 8, 23, 19) |
| 166 | _set_roi(sel) |
| 167 | _check_controls([True, True, True, True, True]) |
| 168 | |
| 169 | # Set invalid selection for rows |
| 170 | sel = (23, 8, 4, 19) |
| 171 | _set_roi(sel) |
| 172 | _check_controls([False, True, False, True, False]) |
| 173 | |
| 174 | # Set invalid selection for columns |
| 175 | sel = (11, 19, 23, 5) |
nothing calls this directly
no test coverage detected