Esempio n. 1
0
File: test.py Progetto: 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")
Esempio n. 2
0
File: test.py Progetto: AdaCore/gps
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(), "src"))
    yield wait_tasks()

    fview = get_widget_by_name("File Explorer Tree")
    t = Tree(get_widget_by_name("File Explorer Tree"))
    t.expand_by_name(column=1, value='src')
    t.expand_by_name(column=1, value='d1')
    t.expand_by_name(column=1, value='d3')
    yield timeout(100)
    t.expand_by_name(column=1, value='x1')
    yield timeout(100)

    d = dump_expanded(fview, 1)
    gps_assert(d, expected, "Wrong contents of the files view")

    GPS.execute_action("refresh files view")
    yield wait_idle()
    yield timeout(100)

    d = dump_expanded(fview, 1)
    gps_assert(d, expected, "Wrong contents of the files view")
Esempio n. 3
0
def run_test():
    buf = GPS.EditorBuffer.get(GPS.File('main.adb'))
    yield wait_idle()
    GPS.execute_action("Build Main Number 1")
    yield hook("compilation_finished")
    yield wait_idle()

    gps_assert(
        GPS.dump_elaborations(),
        ['b (body):a (spec):pragma Elaborate_All', 'a (body):b (spec):withed'],
        "The elaboration Ccrcularities view has wrong content")
Esempio n. 4
0
def driver():
    b = GPS.EditorBuffer.get(GPS.File("main.adb"))
    b.current_view().goto(b.at(4, 7))
    yield wait_tasks(other_than=known_tasks)

    # First verify that the navigation does *not* work
    GPS.execute_action('goto declaration')
    # At this point "language_server_response_processed" shouldn't work,
    # timeout instead
    yield timeout(500)
    current_buf = GPS.EditorBuffer.get()
    gps_assert(current_buf.file(), GPS.File('main.adb'),
               "'goto declaration' should not have worked at this point")

    # Now set the project path and reload the project
    GPS.setenv("GPR_PROJECT_PATH", os.path.join(GPS.pwd(), "subdir"))

    # Restart the language server
    GPS.LanguageServer.get_by_language_name("Ada").restart()
    GPS.Project.load("p.gpr")
    yield timeout(1000)

    # Verify that the navigation works now
    b = GPS.EditorBuffer.get(GPS.File("main.adb"))
    b.current_view().goto(b.at(4, 7))
    yield wait_idle()
    GPS.execute_action('goto declaration')
    # using this hook to be sure that declaration is found by ALS
    yield hook("language_server_response_processed")
    gps_assert(GPS.EditorBuffer.get().file(), GPS.File('foo.ads'),
               "'goto declaration' did not open the right file")

    GPS.Project.load("p1.gpr")
    b = GPS.EditorBuffer.get(GPS.File("main1.adb"))
    b.current_view().goto(b.at(6, 26))
    yield wait_tasks()
    GPS.execute_action('goto declaration')
    yield hook("language_server_response_processed")
    yield wait_idle()
    gps_assert(b.current_view().cursor().line(), 4,
               "'goto declaration' did not find a proper line")

    GPS.LanguageServer.get_by_language_name("Ada").restart()
    yield timeout(1000)

    b.current_view().goto(b.at(6, 26))
    yield wait_idle()
    GPS.execute_action('goto declaration')
    yield hook("language_server_response_processed")
    yield wait_idle()
    yield timeout(300)
    gps_assert(b.current_view().cursor().line(), 4,
               "'goto declaration' did not find a proper line")
Esempio n. 5
0
def driver():
    yield wait_tasks()
    b = GS.EditorBuffer.get(GS.File("main.adb"))
    GPS.execute_action("Expand alias under cursor")
    yield wait_idle()

    gps_assert(b.get_chars(), expected, "Autofix failed")
Esempio n. 6
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")
Esempio n. 7
0
File: test.py Progetto: AdaCore/gps
def driver():
    b = GPS.EditorBuffer.get(GPS.File("hello.adb"))
    orig = b.get_chars()
    v = b.current_view()
    v.goto(b.at(2, 14))
    send_key_event(GDK_RETURN)
    yield wait_idle()

    # Check contents after entern
    gps_assert(b.get_chars(), orig.replace(" Foo", "\n   Foo"),
               "enter character was not received")

    # Undo and check for contents
    b.undo()
    gps_assert(b.get_chars(), orig, "contents corrupted after undo")
Esempio n. 8
0
def driver():
    yield wait_tasks()
    b = GS.EditorBuffer.get(GS.File("main.adb"))

    d = dialogs.Custom_Build_Dialog()
    yield d.open_and_yield()
    d.get_command_line_entry().set_text("cat output")
    get_button_from_label("Execute", d.dialog).clicked()
    yield wait_tasks()

    yield wait_for_mdi_child('Locations')
    tree = pygps.get_widgets_by_type(Gtk.TreeView,
                                     GPS.MDI.get("Locations").pywidget())[0]
    windows = Gtk.Window.list_toplevels()
    click_in_tree(tree, path=Gtk.TreePath("0:0:0"), column=1, button=3)
    activate_contextual(windows, contextual_name)
    close_contextual(windows)
    yield wait_idle()

    gps_assert(b.get_chars(), expected, "Autofix failed")
Esempio n. 9
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")
Esempio n. 10
0
def driver():
    # Launch a fuzzing session
    yield idle_modal_dialog(
        lambda: GPS.execute_action("gnatfuzz fuzz workflow"))
    yield wait_for_mdi_child("gnatfuzz fuzz")
    dialog = get_window_by_title("gnatfuzz fuzz")
    get_button_from_label("Execute", dialog).clicked()

    yield wait_for_mdi_child("Fuzz Crashes")

    view = get_widget_by_name("fuzz_crash_list_view")
    model = view.get_model()

    # Wait 20 seconds at most, until messages appear in the "Fuzz crashes" view

    time_waited = 0

    while time_waited < MAX_TIME_MS:
        if len(model) > 0:
            break
        yield timeout(INCREMENTS_MS)
        time_waited += INCREMENTS_MS

    # Test the contents of the model: presence of the crash...
    gps_assert(model[0][0], "1 (Crash)", "wrong contents in the first row")

    # ... and the fact that the faulty parameter (causing integer overflow)
    # is properly found by the fuzzer and displayed in the view.
    gps_assert(
        int(model[0, 0][1]),
        2**31 - 1,
        "wrong value for the parameter which causes the crash",
    )

    # We can stop fuzzing now that we've had one crash
    GPS.execute_action("gnatfuzz fuzz workflow")

    # Click in the view to launch a debug workflow
    click_in_tree(view, path="0", events=double_click_events)

    # Wait 20 seconds at most, until we have the right data in the debugger view

    debugger_text = None

    time_waited = 0

    expected_text = "Y := X + 1"

    while time_waited < MAX_TIME_MS:
        yield timeout(INCREMENTS_MS)
        time_waited += INCREMENTS_MS
        d = None
        try:
            d = GPS.Debugger.get()
        except GPS.Exception:
            pass
        if d is None:
            continue
        debugger_text = d.get_console().get_text()

        # The debugger console should contain this
        if expected_text in debugger_text:
            break

    gps_assert(expected_text in debugger_text, True,
               f"{expected_text} didn't appear in output:\n{debugger_text}")

    # Quit the debugger
    GPS.execute_action("terminate all debuggers")
    yield wait_idle()

    # Restart a fuzz session...
    yield idle_modal_dialog(
        lambda: GPS.execute_action("gnatfuzz fuzz workflow"))
    yield wait_for_mdi_child("gnatfuzz fuzz")
    dialog = get_window_by_title("gnatfuzz fuzz")
    get_button_from_label("Execute", dialog).clicked()

    # ... and kill it immediately
    yield timeout(100)
    GPS.execute_action("gnatfuzz fuzz workflow")

    # And verify that the Fuzz crashes view is empty
    gps_assert(len(model), 0,
               "The Fuzz crashes view should clear when starting a session")
Esempio n. 11
0
File: test.py Progetto: AdaCore/gps
def driver():
    b = GPS.EditorBuffer.get(GPS.File("main.adb"))
    yield wait_tasks()

    # preparations and initial checks
    b.add_special_line(20, "special line")
    b.add_special_line(18, "special line")
    b.add_special_line(10, "special line")
    b.add_special_line(8, "special line")
    yield wait_idle()

    gps_assert(b.debug_dump_all_lines(),
               ['[0] el:1',
                '[0] el:2',
                '[0] el:3',
                '[0] el:4',
                '[0] el:5',
                '[0] el:6',
                '[0] el:7',
                '[0] special:el:0',
                '[0] el:8',
                '[0] el:9',
                '[0] special:el:0',
                '[0] el:10',
                '[0] el:11',
                '[0] el:12',
                '[0] el:13',
                '[0] el:14',
                '[0] el:15',
                '[0] el:16',
                '[0] el:17',
                '[0] special:el:0',
                '[0] el:18',
                '[0] el:19',
                '[0] special:el:0',
                '[0] el:20',
                '[0] el:21',
                '[0] el:22'],
               "the check failed")

    # fold 'if' statment at line 9 and check
    yield wait_until_true(
        lambda: b.has_blocks_information())

    b.at(9, 1).block_fold()
    yield wait_idle()

    gps_assert(b.debug_dump_all_lines(),
               ['[0] el:1',
                '[0] el:2',
                '[0] el:3',
                '[0] el:4',
                '[0] el:5',
                '[0] el:6',
                '[0] el:7',
                '[0] special:el:0',
                '[0] el:8',
                '[0] el:9 (8)',
                '[0] special:el:0',
                '[1] el:10',
                '[1] el:11',
                '[1] el:12',
                '[1] el:13',
                '[1] el:14',
                '[1] el:15',
                '[1] el:16',
                '[1] el:17',
                '[0] special:el:0',
                '[0] el:18',
                '[0] el:19',
                '[0] special:el:0',
                '[0] el:20',
                '[0] el:21',
                '[0] el:22'],
               "the check failed")
    gps_assert(b.get_chars(include_hidden_chars=False), exp1,
               "wrong code after the first folding")

    # fold 'for' statment at line 7 and check
    yield wait_until_true(
        lambda: b.has_blocks_information())

    b.at(7, 1).block_fold()
    yield wait_idle()

    gps_assert(b.debug_dump_all_lines(),
               ['[0] el:1',
                '[0] el:2',
                '[0] el:3',
                '[0] el:4',
                '[0] el:5',
                '[0] el:6',
                '[0] el:7 (12)',
                '[0] special:el:0',
                '[1] el:8',
                '[1] el:9 (8)',
                '[0] special:el:0',
                '[2] el:10',
                '[2] el:11',
                '[2] el:12',
                '[2] el:13',
                '[2] el:14',
                '[2] el:15',
                '[2] el:16',
                '[2] el:17',
                '[0] special:el:0',
                '[1] el:18',
                '[1] el:19',
                '[0] special:el:0',
                '[0] el:20',
                '[0] el:21',
                '[0] el:22'],
               "the check failed")
    gps_assert(b.get_chars(include_hidden_chars=False), exp2,
               "wrong code after the second folding")

    # unfold 'for' statment at line 7 and check
    # that statment is unfolded and 'if' statment
    # is still folded
    yield wait_until_true(
        lambda: b.has_blocks_information())

    b.at(8, 1).block_unfold()
    yield wait_idle()

    gps_assert(b.debug_dump_all_lines(),
               ['[0] el:1',
                '[0] el:2',
                '[0] el:3',
                '[0] el:4',
                '[0] el:5',
                '[0] el:6',
                '[0] el:7',
                '[0] special:el:0',
                '[0] el:8',
                '[0] el:9 (8)',
                '[0] special:el:0',
                '[1] el:10',
                '[1] el:11',
                '[1] el:12',
                '[1] el:13',
                '[1] el:14',
                '[1] el:15',
                '[1] el:16',
                '[1] el:17',
                '[0] special:el:0',
                '[0] el:18',
                '[0] el:19',
                '[0] special:el:0',
                '[0] el:20',
                '[0] el:21',
                '[0] el:22'],
               "the check failed")
    gps_assert(b.get_chars(include_hidden_chars=False), exp1,
               "wrong code after unfolding")
Esempio n. 12
0
def driver():
    GPS.Preference("clangd-BasedOnStyle").set("LLVM")

    b = GPS.EditorBuffer.get(GPS.File("main.cpp"))
    yield wait_tasks()

    # Autoindent file with the LLVM preset
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()

    # Verify that the proper indentation is produced
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, LLVM, "Wrong autoindent")
    b.undo()

    # Autoindent file with the Google preset
    GPS.Preference("clangd-BasedOnStyle").set("Google")
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, Google, "Wrong autoindent")
    b.undo()

    # Autoindent file with the Chromium preset
    GPS.Preference("clangd-BasedOnStyle").set("Chromium")
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, Chromium, "Wrong autoindent")
    b.undo()

    # Autoindent file with the Mozilla preset
    GPS.Preference("clangd-BasedOnStyle").set("Mozilla")
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, Mozilla, "Wrong autoindent")
    b.undo()

    # Autoindent file with the WebKit preset
    GPS.Preference("clangd-BasedOnStyle").set("WebKit")
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, WebKit, "Wrong autoindent")
    b.undo()

    # Autoindent file with the Microsoft preset
    GPS.Preference("clangd-BasedOnStyle").set("Microsoft")
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, Microsoft, "Wrong autoindent")
    b.undo()

    # Autoindent file with the GNU preset
    GPS.Preference("clangd-BasedOnStyle").set("GNU")
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, GNU, "Wrong autoindent")
    b.undo()

    GPS.Preference("clangd-BasedOnStyle").set("LLVM")

    # Autoindent file with the different ContinuationIndentWidth value
    GPS.Preference("clangd-ContinuationIndentWidth").set(4)
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, ContinuationIndentWidth, "Wrong autoindent")
    GPS.Preference("clangd-ContinuationIndentWidth").set(2)
    b.undo()

    #ColumnLimit
    GPS.Preference("Src-Editor-Highlight-Column").set(40)
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, ColumnLimit, "Wrong autoindent")
    GPS.Preference("Src-Editor-Highlight-Column").set(80)
    b.undo()

    #IndentWidth
    GPS.Preference("C-Indent-Level").set(4)
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, IndentWidth, "Wrong autoindent")
    GPS.Preference("C-Indent-Level").set(2)
    b.undo()

    #UseTab will be tested in TC14-011

    #ReflowComments
    GPS.Preference("C-Indent-Comments").set(False)
    GPS.Preference("Src-Editor-Highlight-Column").set(40)
    GPS.execute_action("autoindent file")
    yield wait_language_server('textDocument/formatting', 'C++')
    yield wait_idle()
    txt = b.get_chars(b.beginning_of_buffer(), b.end_of_buffer())
    gps_assert(txt, ReflowComments, "Wrong autoindent")
    GPS.Preference("C-Indent-Comments").set(True)
    GPS.Preference("Src-Editor-Highlight-Column").set(80)
    b.undo()