def _test_slots_sorted_by_name(browser):
    #projects_page, project_info_page, project_dict, workspace_page = startup(browser)
    project_dict, workspace_page = startup(browser)

    #drop 'metamodel' onto the grid
    meta_name = put_element_on_grid(workspace_page, "MetaModel")
    #find it on the page
    metamodel = workspace_page.get_dataflow_figure(meta_name)

    #open the 'edit' dialog on metamodel
    editor = metamodel.editor_page(False)

    # see if the slot names are sorted
    slot_name_elements = editor.root.find_elements_by_css_selector('text#name')
    slot_names = [s.text for s in slot_name_elements]
    eq(slot_names, sorted(slot_names))

    #closeout(projects_page, project_info_page, project_dict, workspace_page)
    closeout(project_dict, workspace_page)
def _test_slots_sorted_by_name(browser):
    #projects_page, project_info_page, project_dict, workspace_page = startup(browser)
    project_dict, workspace_page = startup(browser)

    #drop 'metamodel' onto the grid
    meta_name = put_element_on_grid(workspace_page, "MetaModel")
    #find it on the page
    metamodel = workspace_page.get_dataflow_figure(meta_name)

    #open the 'edit' dialog on metamodel
    editor = metamodel.editor_page(False)

    # see if the slot names are sorted
    slot_name_elements = editor.root.find_elements_by_css_selector('text#name')
    slot_names = [s.text for s in slot_name_elements]
    eq(slot_names, sorted(slot_names))

    #closeout(projects_page, project_info_page, project_dict, workspace_page)
    closeout(project_dict, workspace_page)
def _test_drop_onto_layered_div(browser):
    project_dict, workspace_page = startup(browser)

    # Add paraboloid and vehicle_threesim files
    file1_path = pkg_resources.resource_filename('openmdao.examples.simple',
                                                 'paraboloid.py')
    file2_path = pkg_resources.resource_filename(
        'openmdao.examples.enginedesign', 'vehicle_threesim.py')
    workspace_page.add_file(file1_path)
    workspace_page.add_file(file2_path)

    # add VehicleSim2 to the globals
    sim_name = put_element_on_grid(workspace_page, 'VehicleSim2')

    # add Paraboloid to VehicleSim dataflow assembly
    sim = workspace_page.get_dataflow_figure(sim_name)
    paraboloid = workspace_page.find_library_button('Paraboloid')
    chain = drag_element_to(browser, paraboloid,
                            sim('content_area').element, False)
    release(chain)
    paraboloid_name = NameInstanceDialog(workspace_page).create_and_dismiss()
    paraboloid_pathname = sim_name + "." + paraboloid_name

    # Open up the component editor for the sim_EPA_city inside the vehicle sim
    sim_EPA_city_driver = workspace_page.get_dataflow_figure(
        'sim_EPA_city', sim_name)
    driver_editor = sim_EPA_city_driver.editor_page(base_type='Driver')
    driver_editor.move(-200, 0)
    driver_editor.show_workflow()

    # Confirm expected number of workflow component figures before adding one
    eq(len(driver_editor.get_workflow_component_figures()), 5)
    eq(len(workspace_page.get_workflow_component_figures()), 22)

    # Drop onto the object editor's workflow figure is no longer supported.
    # -- KTM

    # Drag paraboloid component into sim_EPA_city workflow
    #workspace_page('dataflow_tab').click()
    #workspace_page.expand_object(sim_name)
    #simsim_name = sim_name + '.' + 'sim_EPA_city'
    #workspace_page.add_object_to_workflow(paraboloid_pathname, simsim_name)

    ## Confirm there is one more workflow component figure in the editor
    #workspace_page('workflow_tab').click()
    #eq(len(driver_editor.get_workflow_component_figures()), 6)

    ## Confirm two more workflow component figures in the workspace as a whole
    #eq(len(workspace_page.get_workflow_component_figures()), 24)

    ## Confirm that the paraboloid has been added to the sim_EPA_city workflow
    ## by trying to access it.
    #obj = workspace_page.find_object_button(simsim_name + "." + paraboloid_name)

    # Don't see the reason to verfiy again that you can't add something to an
    # out-of-scope workflow. -- KTM

    ## Try dragging paraboloid component into vehicle workflow under sim_EPA_city
    ## should NOT add to the list of workflow component figures
    #workspace_page.expand_object(sim_name)
    #paraboloid_component = workspace_page.find_object_button(paraboloid_pathname)
    #vehicle_workflow_figure = workspace_page.get_workflow_figure("vehicle.driver")
    #chain = drag_element_to(browser, paraboloid_component,
    #vehicle_workflow_figure.components[0], True)
    #assert not vehicle_workflow_figure.highlighted
    #release(chain)

    ## Confirm that there is NOT a new workflow component figure in either place
    #eq(len(driver_editor.get_workflow_component_figures()), 6)
    #eq(len(workspace_page.get_workflow_component_figures()), 24)

    ## Confirm that the paraboloid has NOT been added to the vehicle workflow
    #assert paraboloid_name not in vehicle_workflow_figure.component_names

    # Clean up.
    closeout(project_dict, workspace_page)
def _test_component_to_complex_workflow(browser):
    project_dict, workspace_page = startup(browser)

    # Add paraboloid and vehicle_threesim files
    file1_path = pkg_resources.resource_filename('openmdao.examples.simple',
                                                 'paraboloid.py')
    file2_path = pkg_resources.resource_filename(
        'openmdao.examples.enginedesign', 'vehicle_threesim.py')
    workspace_page.add_file(file1_path)
    workspace_page.add_file(file2_path)

    # create an instance of VehicleSim2
    sim_name = put_element_on_grid(workspace_page, "VehicleSim2")

    # Drag paraboloid element into sim dataflow figure
    sim = workspace_page.get_dataflow_figure(sim_name)
    paraboloid = workspace_page.find_library_button('Paraboloid')
    chain = drag_element_to(browser, paraboloid,
                            sim('content_area').element, False)
    release(chain)
    paraboloid_name = NameInstanceDialog(workspace_page).create_and_dismiss()
    paraboloid_pathname = sim_name + "." + paraboloid_name

    # Switch to Workflow pane and show the sim workflow
    workspace_page('workflow_tab').click()
    workspace_page.show_workflow(sim_name)

    # See how many workflow component figures there are before we add to it
    eq(len(workspace_page.get_workflow_component_figures()), 16)

    ############################################################################
    # Drop paraboloid component onto the top level workflow for sim
    ############################################################################
    workspace_page('dataflow_tab').click()
    workspace_page.expand_object(sim_name)
    workspace_page.add_object_to_workflow(paraboloid_pathname, sim_name)

    # Confirm that there is one more workflow component figure
    workspace_page('workflow_tab').click()
    eq(len(workspace_page.get_workflow_component_figures()), 17)

    # Confirm that the paraboloid has been added to the sim workflow by trying
    # to access it.
    obj = workspace_page.find_object_button(sim_name + "." + paraboloid_name)

    ############################################################################
    # Drop paraboloid component onto the sim_acc workflow under sim
    ############################################################################
    workspace_page('dataflow_tab').click()
    simsim_name = sim_name + '.sim_acc'
    workspace_page.add_object_to_workflow(paraboloid_pathname, simsim_name)

    # Confirm that there is one more workflow component figure
    workspace_page('workflow_tab').click()
    eq(len(workspace_page.get_workflow_component_figures()), 18)

    # Confirm that the paraboloid has been added to the sim workflow by trying
    # to access it.
    obj = workspace_page.find_object_button(sim_name + "." + paraboloid_name)

    ############################################################################
    # Drop paraboloid component onto the vehicle workflow under sim_acc
    # This should NOT work since the paraboloid is not in the vehicle assembly
    ############################################################################

    # These error messages are tested in SequentialFlow, though we may want
    # to have one test that makes sure that the error dialog makes it through.

    #workspace_page('dataflow_tab').click()
    #workspace_page.expand_object(simsim_name)
    #simsimsim_name = simsim_name + '.vehicle'
    #workspace_page.add_object_to_workflow(paraboloid_pathname, simsimsim_name)
    #message = NotifierPage.wait(workspace_page)
    #eq(message, "x")

    # Confirm that there is NOT a new workflow component figure
    #workspace_page('workflow_tab').click()
    #eq(len(workspace_page.get_workflow_component_figures()), 18)

    # Clean up.
    closeout(project_dict, workspace_page)
def _test_drop_onto_layered_div(browser):
    project_dict, workspace_page = startup(browser)

    # Add paraboloid and vehicle_threesim files
    file1_path = pkg_resources.resource_filename('openmdao.examples.simple',
                                                'paraboloid.py')
    file2_path = pkg_resources.resource_filename('openmdao.examples.enginedesign',
                                                            'vehicle_threesim.py')
    workspace_page.add_file(file1_path)
    workspace_page.add_file(file2_path)

    # add VehicleSim2 to the globals
    sim_name = put_element_on_grid(workspace_page, 'VehicleSim2')

    # add Paraboloid to VehicleSim dataflow assembly
    sim = workspace_page.get_dataflow_figure(sim_name)
    paraboloid = workspace_page.find_library_button('Paraboloid')
    chain = drag_element_to(browser, paraboloid,
                            sim('content_area').element, False)
    release(chain)
    paraboloid_name = NameInstanceDialog(workspace_page).create_and_dismiss()
    paraboloid_pathname = sim_name + "." + paraboloid_name

    # Open up the component editor for the sim_EPA_city inside the vehicle sim
    sim_EPA_city_driver = workspace_page.get_dataflow_figure('sim_EPA_city',
                                                             sim_name)
    driver_editor = sim_EPA_city_driver.editor_page(base_type='Driver')
    driver_editor.move(-200, 0)
    driver_editor.show_workflow()

    # Confirm expected number of workflow component figures before adding one
    eq(len(driver_editor.get_workflow_component_figures()), 5)
    eq(len(workspace_page.get_workflow_component_figures()), 22)

    # Drop onto the object editor's workflow figure is no longer supported.
    # -- KTM

    # Drag paraboloid component into sim_EPA_city workflow
    #workspace_page('dataflow_tab').click()
    #workspace_page.expand_object(sim_name)
    #simsim_name = sim_name + '.' + 'sim_EPA_city'
    #workspace_page.add_object_to_workflow(paraboloid_pathname, simsim_name)
    
    ## Confirm there is one more workflow component figure in the editor
    #workspace_page('workflow_tab').click()
    #eq(len(driver_editor.get_workflow_component_figures()), 6)

    ## Confirm two more workflow component figures in the workspace as a whole
    #eq(len(workspace_page.get_workflow_component_figures()), 24)

    ## Confirm that the paraboloid has been added to the sim_EPA_city workflow
    ## by trying to access it.
    #obj = workspace_page.find_object_button(simsim_name + "." + paraboloid_name)    

    # Don't see the reason to verfiy again that you can't add something to an 
    # out-of-scope workflow. -- KTM
    
    ## Try dragging paraboloid component into vehicle workflow under sim_EPA_city
    ## should NOT add to the list of workflow component figures
    #workspace_page.expand_object(sim_name)
    #paraboloid_component = workspace_page.find_object_button(paraboloid_pathname)
    #vehicle_workflow_figure = workspace_page.get_workflow_figure("vehicle.driver")
    #chain = drag_element_to(browser, paraboloid_component,
                            #vehicle_workflow_figure.components[0], True)
    #assert not vehicle_workflow_figure.highlighted
    #release(chain)

    ## Confirm that there is NOT a new workflow component figure in either place
    #eq(len(driver_editor.get_workflow_component_figures()), 6)
    #eq(len(workspace_page.get_workflow_component_figures()), 24)

    ## Confirm that the paraboloid has NOT been added to the vehicle workflow
    #assert paraboloid_name not in vehicle_workflow_figure.component_names

    # Clean up.
    closeout(project_dict, workspace_page)
def _test_component_to_complex_workflow(browser):
    project_dict, workspace_page = startup(browser)

    # Add paraboloid and vehicle_threesim files
    file1_path = pkg_resources.resource_filename('openmdao.examples.simple',
                                                 'paraboloid.py')
    file2_path = pkg_resources.resource_filename('openmdao.examples.enginedesign',
                                                 'vehicle_threesim.py')
    workspace_page.add_file(file1_path)
    workspace_page.add_file(file2_path)

    # create an instance of VehicleSim2
    sim_name = put_element_on_grid(workspace_page, "VehicleSim2")

    # Drag paraboloid element into sim dataflow figure
    sim = workspace_page.get_dataflow_figure(sim_name)
    paraboloid = workspace_page.find_library_button('Paraboloid')
    chain = drag_element_to(browser, paraboloid, sim('content_area').element, False)
    release(chain)
    paraboloid_name = NameInstanceDialog(workspace_page).create_and_dismiss()
    paraboloid_pathname = sim_name + "." + paraboloid_name

    # Switch to Workflow pane and show the sim workflow
    workspace_page('workflow_tab').click()
    workspace_page.show_workflow(sim_name)

    # See how many workflow component figures there are before we add to it
    eq(len(workspace_page.get_workflow_component_figures()), 16)

    ############################################################################
    # Drop paraboloid component onto the top level workflow for sim
    ############################################################################
    workspace_page('dataflow_tab').click()
    workspace_page.expand_object(sim_name)
    workspace_page.add_object_to_workflow(paraboloid_pathname, sim_name)    

    # Confirm that there is one more workflow component figure
    workspace_page('workflow_tab').click()
    eq(len(workspace_page.get_workflow_component_figures()), 17)

    # Confirm that the paraboloid has been added to the sim workflow by trying
    # to access it.
    obj = workspace_page.find_object_button(sim_name + "." + paraboloid_name)

    ############################################################################
    # Drop paraboloid component onto the sim_acc workflow under sim
    ############################################################################
    workspace_page('dataflow_tab').click()
    simsim_name = sim_name + '.sim_acc'
    workspace_page.add_object_to_workflow(paraboloid_pathname, simsim_name)
    
    # Confirm that there is one more workflow component figure
    workspace_page('workflow_tab').click()
    eq(len(workspace_page.get_workflow_component_figures()), 18)

    # Confirm that the paraboloid has been added to the sim workflow by trying
    # to access it.
    obj = workspace_page.find_object_button(sim_name + "." + paraboloid_name)

    ############################################################################
    # Drop paraboloid component onto the vehicle workflow under sim_acc
    # This should NOT work since the paraboloid is not in the vehicle assembly
    ############################################################################
    
    # These error messages are tested in SequentialFlow, though we may want
    # to have one test that makes sure that the error dialog makes it through.
    
    #workspace_page('dataflow_tab').click()
    #workspace_page.expand_object(simsim_name)
    #simsimsim_name = simsim_name + '.vehicle'
    #workspace_page.add_object_to_workflow(paraboloid_pathname, simsimsim_name)
    #message = NotifierPage.wait(workspace_page)
    #eq(message, "x")
    
    # Confirm that there is NOT a new workflow component figure
    #workspace_page('workflow_tab').click()
    #eq(len(workspace_page.get_workflow_component_figures()), 18)

    # Clean up.
    closeout(project_dict, workspace_page)