@skip_if_null
def test_visible_when_layout():
    # Bug: The size of a dialog that contains elements that are activated
    # by "visible_when" can end up being the *sum* of the sizes of the
    # elements, even though the elements are mutually exclusive (e.g.,
    # a typical case is a dropbox that lets you select different cases).
    # The expected behavior is that the size of the dialog should be at most
    # the size of the largest combination of elements.

    with store_exceptions_on_all_threads():
        dialog = VisibleWhenProblem()
        ui = dialog.edit_traits()

        # have the dialog switch from group one to two and back to one
        dialog.which = 'two'
        dialog.which = 'one'

        # the size of the window should not be larger than the largest
        # combination (in this case, the `text_group` plus the `which` item
        size = get_dialog_size(ui.control)
        # leave some margin for labels, dropbox, etc
        nose.tools.assert_less(size[0], _TEXT_WIDTH+100)
        nose.tools.assert_less(size[1], _TEXT_HEIGHT+150)
dataset/ETHPy150Open enthought/traitsui/traitsui/tests/test_visible_when_layout.py/test_visible_when_layout/original