MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / test_DialogLoadMask_1

Function test_DialogLoadMask_1

pyxrf/gui_module/tests/test_wd_load_data.py:13–57  ·  view source on GitHub ↗

Set/Read values from ROI widget group of DialogLoadMask object

(qtbot)

Source from the content-addressed store, hash-verified

11
12
13def test_DialogLoadMask_1(qtbot):
14 """Set/Read values from ROI widget group of DialogLoadMask object"""
15 dlg = DialogLoadMask()
16 qtbot.addWidget(dlg)
17 dlg.show()
18
19 # Set image size
20 n_rows, n_columns = 15, 17
21 dlg.set_image_size(n_rows=n_rows, n_columns=n_columns)
22 assert f"{n_rows} rows, {n_columns} columns" in dlg.label_map_size.text(), "Map size was not set correctly"
23
24 def _check_roi_widgets(expected_values):
25 l_edit_widgets = (dlg.le_roi_start_row, dlg.le_roi_start_col, dlg.le_roi_end_row, dlg.le_roi_end_col)
26 for n, v in enumerate(expected_values):
27 if n < 2: # First 2 entries (are incremented when displayed)
28 v += 1
29 s = f"{v}" if v > 0 else ""
30 assert l_edit_widgets[n].text() == s, "Line Edit text does not match the expected text"
31
32 # Check if the default values were set correctly when image size was set
33 # (try to activate/deactivate the ROI selection group box)
34 _check_roi_widgets([0, 0, n_rows, n_columns]) # Default values
35 dlg.set_roi_active(True) # Activate ROI group
36 _check_roi_widgets([0, 0, n_rows, n_columns]) # Default values
37 dlg.set_roi_active(False)
38 _check_roi_widgets([0, 0, n_rows, n_columns]) # Default values
39
40 # Set ROI. Initially the ROI group is inactive, so no text is displayed
41 roi = (2, 3, 14, 15)
42 dlg.set_roi(row_start=roi[0], column_start=roi[1], row_end=roi[2], column_end=roi[3])
43 assert not dlg.gb_roi.isChecked(), "ROI group is checked, while it must be unchecked"
44 assert dlg.get_roi_active() is False, "ROI 'enable' status was not read correctly"
45 _check_roi_widgets(roi)
46 # Activate ROI group
47 dlg.set_roi_active(True)
48 assert dlg.gb_roi.isChecked(), "ROI group is unchecked, while it must be checked"
49 assert dlg.get_roi_active() is True, "ROI 'enable' status was not read correctly"
50 _check_roi_widgets(roi)
51
52 # Set the values outside the range. The values must be clipped
53 roi = (0, 0, 50, 50)
54 dlg.set_roi(row_start=roi[0], column_start=roi[1], row_end=roi[2], column_end=roi[3])
55 assert dlg.get_roi() == (roi[0], roi[1], n_rows, n_columns), "Indexes were not clipped correctly"
56
57 dlg.close()
58
59
60def test_DialogLoadMask_2(qtbot):

Callers

nothing calls this directly

Calls 8

set_image_sizeMethod · 0.95
set_roi_activeMethod · 0.95
set_roiMethod · 0.95
get_roi_activeMethod · 0.95
get_roiMethod · 0.95
DialogLoadMaskClass · 0.85
_check_roi_widgetsFunction · 0.85
showMethod · 0.80

Tested by

no test coverage detected