@@ -262,7 +262,8 @@ def test_no_duplicate_creation_tabs():
262262
263263 This test verifies the fix for the bug where clicking "Apply" in the
264264 Creation tab would create a new Creation tab instead of reusing the
265- existing one.
265+ existing one. It also verifies that the Creation tab remains current
266+ after applying changes.
266267 """
267268 with qt_app_context ():
268269 with datalab_test_app_context () as win :
@@ -316,6 +317,12 @@ def test_no_duplicate_creation_tabs():
316317 f"applying amplitude={ amplitude } "
317318 )
318319
320+ # Verify that the Creation tab is the current tab
321+ assert objprop .currentWidget () is objprop .creation_scroll , (
322+ f"Creation tab should remain current after "
323+ f"applying amplitude={ amplitude } "
324+ )
325+
319326
320327def test_no_creation_parameters_for_base_classes ():
321328 """Test that creation parameters are NOT stored for base classes
@@ -480,6 +487,87 @@ def test_apply_processing_parameters_image():
480487 assert stored_param .value == v1
481488
482489
490+ def test_no_duplicate_processing_tabs ():
491+ """Test that applying processing parameters multiple times doesn't create
492+ duplicate tabs.
493+
494+ This test verifies the fix for the bug where clicking "Apply" in the
495+ Processing tab would create a new Processing tab instead of reusing the
496+ existing one. It also verifies that the Processing tab remains current
497+ after applying changes.
498+ """
499+ with qt_app_context ():
500+ with datalab_test_app_context () as win :
501+ panel = win .imagepanel
502+ processor = panel .processor
503+ objprop = panel .objprop
504+
505+ # Create a default test image
506+ panel .new_object (edit = False )
507+ image = panel .objview .get_current_object ()
508+ assert image is not None
509+
510+ # Apply addition_constant with initial value
511+ v0 = 7.0
512+ processor .run_feature ("addition_constant" , ConstantParam .create (value = v0 ))
513+
514+ # Get the processed image
515+ processed_ima = panel .objview .get_current_object ()
516+ assert processed_ima is not None
517+
518+ # Select the processed image to trigger setup_processing_tab
519+ panel .objview .set_current_object (processed_ima )
520+
521+ # Verify Processing tab was set up
522+ assert objprop .processing_param_editor is not None
523+ assert objprop .processing_scroll is not None
524+
525+ # Count how many Processing tabs exist initially
526+ initial_index = objprop .indexOf (objprop .processing_scroll )
527+ assert initial_index >= 0 , "Processing tab should be present"
528+
529+ # Count tabs by checking if they reference the same scroll widget
530+ initial_count = sum (
531+ 1
532+ for i in range (objprop .count ())
533+ if objprop .widget (i ) is objprop .processing_scroll
534+ )
535+ assert initial_count == 1 , (
536+ "Should have exactly one Processing tab initially"
537+ )
538+
539+ # Apply processing parameters multiple times
540+ editor = objprop .processing_param_editor
541+ for value in [10.0 , 15.0 , 20.0 ]:
542+ editor .dataset .value = value
543+ report = objprop .apply_processing_parameters ()
544+ assert report .success
545+
546+ # Wait for the deferred setup_processing_tab to complete
547+ from qtpy .QtTest import QTest
548+
549+ QTest .qWait (100 )
550+
551+ # Verify that processing_scroll reference still exists
552+ assert objprop .processing_scroll is not None
553+
554+ # Count Processing tabs again - should still be just one
555+ processing_count = sum (
556+ 1
557+ for i in range (objprop .count ())
558+ if objprop .widget (i ) is objprop .processing_scroll
559+ )
560+ assert processing_count == 1 , (
561+ f"Should still have exactly one Processing tab after "
562+ f"applying value={ value } "
563+ )
564+
565+ # Verify that the Processing tab is the current tab
566+ assert objprop .currentWidget () is objprop .processing_scroll , (
567+ f"Processing tab should remain current after applying value={ value } "
568+ )
569+
570+
483571def test_apply_processing_parameters_missing_source ():
484572 """Test apply_processing_parameters when source object is missing"""
485573 with qt_app_context ():
@@ -874,6 +962,7 @@ def test_select_source_objects_deleted_source():
874962 test_no_creation_parameters_for_base_classes ()
875963 test_apply_processing_parameters_signal ()
876964 test_apply_processing_parameters_image ()
965+ test_no_duplicate_processing_tabs ()
877966 test_apply_processing_parameters_missing_source ()
878967 test_cross_panel_image_to_signal ()
879968 test_cross_panel_image_to_signal_group ()
0 commit comments