Skip to content

Commit

Permalink
test on the legend method
Browse files Browse the repository at this point in the history
  • Loading branch information
rohit2p authored and ReimarBauer committed Nov 27, 2024
1 parent aa55ad6 commit 56de3bd
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/_test_msui/test_multiple_flightpath_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,41 @@ def test_random_custom_color_selection(main_window):
assert color in multiple_flightpath_widget.custom_colors


def test_update_flightpath_legend(main_window):
"""
Test update_flightpath_legend to ensure only checked flight tracks
are included in the legend with correct name, color, and style.
"""
main_window, multiple_flightpath_widget = main_window

# Activate the first flight track
activate_flight_track_at_index(main_window, 0)

# Set the first flight track as checked and the second as unchecked
first_item = multiple_flightpath_widget.list_flighttrack.item(0)
second_item = multiple_flightpath_widget.list_flighttrack.item(1)
first_item.setCheckState(QtCore.Qt.Checked)
second_item.setCheckState(QtCore.Qt.Unchecked)

# Define color and style for the first flight track
multiple_flightpath_widget.dict_flighttrack[first_item.flighttrack_model] = {
"color": "#FF0000",
"line_style": "--"
}

# Calling the method
multiple_flightpath_widget.update_flightpath_legend()

# Verify that only the checked flight track is included in the legend
assert first_item.flighttrack_model.name in multiple_flightpath_widget.flightpath_dict
assert second_item.flighttrack_model.name not in multiple_flightpath_widget.flightpath_dict

# Verify that the color and style in the legend match the first flight track
legend_color, legend_style = multiple_flightpath_widget.flightpath_dict[first_item.flighttrack_model.name]
assert legend_color == "#FF0000"
assert legend_style == "--"


def activate_flight_track_at_index(main_window, index):
# The main window must be on top
main_window.activateWindow()
Expand Down

0 comments on commit 56de3bd

Please sign in to comment.