Example #1
0
File: test.py Project: AdaCore/gps
def driver():
    # type 'foo' in the omnisearch
    yield wait_tasks()
    w = pygps.get_widget_by_name('global_search')
    w.get_toplevel().grab_focus()
    yield wait_idle()
    w.grab_focus()
    yield wait_idle()
    w.set_text("foo")
    yield timeout(1000)
    popup = pygps.get_widget_by_name('global_search-results-list')
    results_tree = pygps.get_widgets_by_type(Gtk.TreeView, popup)[0]

    # select "foo.adb" file
    click_in_tree(results_tree, path="0", column=1)
    yield timeout(1000)
    if not GPS.EditorBuffer.get().file().name().endswith("foo.adb"):
        simple_error("foo.adb is not opened")

    #  retype 'foo' in the omnisearch
    w.get_toplevel().grab_focus()
    yield wait_idle()
    w.grab_focus()
    yield wait_idle()
    w.set_text("foo")
    yield timeout(1000)

    # check whether we have result from the History provider
    popup = pygps.get_widget_by_name('global_search-results-list')
    results_tree = pygps.get_widgets_by_type(Gtk.TreeView, popup)[0]
    result = dump_tree_model(results_tree.get_model(), 3)

    gps_assert("History (1)" in result,
               True,
               "wrong omnisearch result")
Example #2
0
def driver():
    yield timeout(1000)
    als = GPS.LanguageServer.get_by_language_name("Ada")

    b = GPS.EditorBuffer.get(GPS.File("main.adb"))
    b.current_view().goto(b.at(4, 5))
    yield hook('language_server_response_processed')

    GPS.execute_action("Entity called by")
    yield hook('language_server_response_processed')
    yield timeout(1000)

    call_tree = get_widget_by_name("Call Graph Tree")
    selection = call_tree.get_selection()
    selection.unselect_all()
    model = call_tree.get_model()
    selection.select_iter(model.iter_nth_child(model.get_iter_first(), 0))

    GPS.execute_action("calltree expand selected")
    yield hook('language_server_response_processed')

    expected = [
        'Foo is called by ',
        [
            'Foo', ['Foo', ['computing...'], 'Main', ['computing...']], 'Main',
            ['computing...']
        ]
    ]

    yield timeout(1000)
    gps_assert(expected, dump_tree_model(model, 0),
               "The model didn't contain the expected text")

    # Now verify that double-clicking on the row that lists 'Main'
    # correctly open its editor and selects it.

    GPS.execute_action("close all editors")
    yield wait_tasks(other_than=known_tasks)

    click_in_tree(call_tree,
                  path=Gtk.TreePath("0:0:1"),
                  button=1,
                  events=double_click_events)
    yield wait_idle()

    buffer = GPS.EditorBuffer.get()
    gps_assert(
        buffer.file(), GPS.File("main.adb"),
        "double-clicking on a Call Trees row should open an " +
        "editor for the clicked entity")
    gps_assert((buffer.selection_start(), buffer.selection_end()),
               (buffer.at(2, 11), buffer.at(2, 15)),
               "Main should be selected in main.adb after double-clicking " +
               "on its row in the Call Trees")
Example #3
0
File: test.py Project: AdaCore/gps
def driver():
    prj_view = Project_View()
    yield prj_view.open_and_yield()

    explorer = prj_view.dialog
    explorer.expand_all()

    filt = get_widget_by_name("Project Explorer Filter")
    filt.set_text("be")
    yield hook("filter_view_changed")
    dump = dump_tree_model(explorer.get_model(), 1)
    gps_assert(dump, ['p', ['src1', ['beau.adb']]],
               "Project view content wrong after filtering")

    filt.set_text("")
    yield wait_tasks()
    dump = dump_tree_model(explorer.get_model(), 1)
    GPS.Console().write(str(dump))
    gps_assert(dump, ['p', ['src1', ['beau.adb'], 'src2', ['nico.adb'], '.']],
               "Project view content wrong after removing the filter text")
Example #4
0
def run_test():
    GPS.execute_action("open Files")
    buf = GPS.EditorBuffer.get(GPS.File('main.adb'))
    yield wait_idle()
    entry = get_widget_by_name("Files_View_Directory")
    entry.set_text(os.path.join(GPS.Project.root().file().directory(), "b"))
    yield wait_tasks()

    explorer = get_widget_by_name("File Explorer Tree")
    d = dump_tree_model(explorer.get_model(), 1)
    gps_assert(d, ['b', ['b.adb', 'b.ads']],
               "Wrong contents of the files view")
Example #5
0
def driver():
    prj_view = Project_View()
    yield prj_view.open_and_yield()

    explorer = prj_view.dialog
    dump = dump_tree_model(explorer.get_model(), 1)
    gps_assert(dump, ['p', ['.', ['beau.adb', 'nico.adb'], '.']],
               "Initial project view contents wrong")

    filt = get_widget_by_name("Project Explorer Filter")
    filt.set_text("be")
    yield hook("filter_view_changed")
    dump = dump_tree_model(explorer.get_model(), 1)
    gps_assert(dump, ['p', ['.', ['beau.adb'], '.']],
               "Project view content wrong after filtering")

    GPS.execute_action("reload project")
    yield wait_tasks()
    dump = dump_tree_model(explorer.get_model(), 1)
    gps_assert(dump, ['p', ['.', ['beau.adb'], '.']],
               "Project view not filtered properly after reload")
Example #6
0
def driver():
    GPS.Preference("explorer-hierarchical-directories").set("True")
    yield wait_tasks()

    prj_view = Project_View()
    yield prj_view.open_and_yield()

    tree = prj_view.dialog
    path = find_in_tree(tree, column=1, key='A')
    tree.expand_row(path, open_all=False)
    path = find_in_tree(tree, column=1, key='B')
    tree.expand_row(path, open_all=False)
    yield wait_idle()

    d1 = dump_tree_model(tree.get_model(), 1)
    gps_assert(d1, expected, "Wrong hierarchi")

    filt = get_widget_by_name("Project Explorer Filter")
    filt.set_text("lib")
    yield wait_tasks()

    d2 = dump_tree_model(tree.get_model(), 1)
    gps_assert(d2,filtered,"Wrong filtered")
Example #7
0
def driver():
    # Open bla.adb, goto declaration of "Create"
    b = GPS.EditorBuffer.get(GPS.File("bla.adb"))
    b.current_view().goto(b.at(6, 16))
    GPS.execute_action("goto declaration")
    yield wait_tasks(other_than=known_tasks)

    # Sanity check that we're on the runtime file
    b2 = GPS.EditorBuffer.get()
    gps_assert(os.path.basename(b2.file().name()), "a-textio.ads",
               "goto declaration didn't work")

    # Run "is called by"
    GPS.execute_action("Entity called by")
    yield hook('language_server_response_processed')
    yield timeout(1000)

    # Verify that the call tree does show the call location in "Bla"
    call_tree = get_widget_by_name("Call Graph Tree")
    model = call_tree.get_model()
    gps_assert(dump_tree_model(model, 0),
               ['Create is called by ', ['Bla', ['computing...']]],
               "The model didn't contain the expected result")