示例#1
0
def test_driver():
    main = GPS.File("main.adb")

    s = dialogs.Search()
    yield s.open_and_yield()
    s.pattern.set_text('project')
    s.replace_text.set_text('DUMMY')
    yield s.yield_close()

    s = dialogs.Search()
    yield s.open_and_yield()
    gps_assert(s.pattern.get_text(), "project", "The pattern is wrong")
    gps_assert(s.replace_text.get_text(), "DUMMY", "The replace text is wrong")
    yield s.yield_close()
示例#2
0
def test_driver():
    # Force the incremental mode
    GPS.Preference("Search-Incremental").set(True)

    # Open a file and select some text
    buf = GPS.EditorBuffer.get(GPS.File("main.adb"))
    view = buf.current_view()
    buf.select(buf.at(2, 4), buf.at(2, 7))
    verify_loc(view, 2, 7, "Wrong location via EditorBuffer")

    # Open the search dialog, it should not change the selection in the buffer
    s = dialogs.Search()
    yield s.open_and_yield(docked=True)
    verify_loc(view, 2, 4, "Wrong location at the start of the search")

    # The focus is in the Search view:
    # the "Search" action should find the next match
    GPS.execute_action(SEARCH_ACTION)
    verify_loc(view, 2, 4, "Wrong location after the second search")

    # Give the focus to the editor and move the cursor
    GPS.MDI.get("main.adb").raise_window()
    yield wait_idle()
    view.goto(buf.at(1, 1))
    yield wait_idle()

    # The cursor has been moved by the user => The "Search" action should not
    # change the cursor location, give the focus to the Search view
    # and preselect the "Find" entry
    GPS.execute_action(SEARCH_ACTION)
    verify_loc(view, 1, 1, "Search failed when the cursor is in the editor")
    gps_assert(s.pattern.get_selection_bounds(), (0, 3),
               "The entry text should be preselectioned")
示例#3
0
def run_test():
    buf = GPS.EditorBuffer.get(GPS.File("foo.adb"))
    yield wait_idle()
    view = buf.current_view()
    expected = buf.get_chars()
    default_selection = get_selection(buf)

    buf.select()
    gps_assert(get_selection(buf), expected,
               "A selection should have been done")

    # Open the search view to change the focus
    s = dialogs.Search()
    yield s.open_and_yield()
    while get_selection(buf) != default_selection:
        yield timeout(100)

    # The selection should have been stopped and the buffer should still work
    gps_assert(get_selection(buf), default_selection,
               "The selection should have been stopped")
    buf.insert(buf.at(1, 1), TEXT)
    buf.delete(buf.at(1, 1), buf.at(1, len(TEXT)))
    yield wait_idle()
    gps_assert(buf.get_chars(), expected,
               "The buffer doesn't seems to work properly")
示例#4
0
文件: test.py 项目: AdaCore/gps
def driver():
    s = dialogs.Search()
    yield s.open_and_yield()
    s.set_scope(dialogs.Search.Context.FILES_FROM_PROJECT)
    s.pattern.set_text("imported")
    yield wait_idle()
    yield s.yield_find_all()
    yield wait_idle()

    messages = GPS.Locations.list_locations("Search for: imported", "a.gpr")
    gps_assert(str(messages[0]), EXPECTED, "Wrong search result")
示例#5
0
def test_driver():
    # Disable this preference to avoid losing focus when clicking
    # on 'Find all'

    GPS.Preference("locations-auto-jump-to-first").set(False)

    # Select an area in the editor

    buf = GPS.EditorBuffer.get(GPS.File("main.adb"))
    editor_view = buf.current_view()

    editor_view.goto(buf.at(1, 1).end_of_line())
    editor_view.goto(buf.at(4, 1), extend_selection=True)

    # Open the Search view and check that we have highlighted
    # the editor's selected area

    s = dialogs.Search()
    yield s.open_and_yield()
    yield wait_idle()

    gps_assert(
        buf.debug_dump_line_highlighting(),
        EXPECTED_LINE_HIGHLIGHTING,
        "The editor's selected area has not been highlighted when "
        + "opening the Search view")

    # Search for 'Integer': verify that the search area is still highlighted
    # and that results are correctly highlighted too.

    s.pattern.set_text("Integer")
    yield s.yield_find_all()

    gps_assert(
        buf.debug_dump_line_highlighting(),
        EXPECTED_LINE_HIGHLIGHTING,
        "The editor's selected area should still be highlighted "
        + "since the Search view has still the focus")

    gps_assert(
        buf.debug_dump_syntax_highlighting("Search results").strip(),
        EXPECTED_SYNTAX_HIGHLIGHTING.strip(),
        "'Find all' results are not correctly highlighted")

    # Open another view to remove the focus from the Search view:
    # the editor's selected area should not be highlighted anymore

    GPS.execute_action("open Files")
    gps_assert(
        buf.debug_dump_line_highlighting(),
        EXPECTED_NO_HIGHLIGHTING,
        "The editor's selected area should not be highlighted "
        + "anymore once the Search view loses the focus")
示例#6
0
def test_driver():
    main = GPS.File("main.adb")
    buf = GPS.EditorBuffer.get(main)
    buf.current_view().goto(buf.at(11, 1))

    s = dialogs.Search()
    yield s.open_and_yield()
    s.pattern.set_text('Result')

    send_key_event(GDK_RETURN, shift=1)
    yield wait_idle()

    gps_assert(buf.current_view().cursor(), buf.at(9, 14),
               "Shift-Enter did not search backwards")
示例#7
0
def test_driver():
    s = dialogs.Search()
    yield s.open_and_yield()

    s.set_scope(dialogs.Search.Context.FILES_FROM_PROJECT)
    s.pattern.set_text('Hello')
    s.replace_text.set_text('Bom Dia')

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

    buffer = GPS.EditorBuffer.get(GPS.File("main.adb"))

    gps_assert(buffer.get_chars().rstrip(), EXPECTED_AFTER_REPLACE,
               "The 'replace all' did not work properly")
示例#8
0
文件: test.py 项目: AdaCore/gps
def run_test():
    GPS.EditorBuffer.get(File("bar.adb"))
    GPS.EditorBuffer.get(File("bar.ads"))
    yield wait_tasks()

    execute_action("/Window/Floating")
    b = GPS.EditorBuffer.get(File("foo.adb"))
    yield wait_idle()

    s = dialogs.Search()
    yield s.open_and_yield()
    yield timeout(100)
    execute_action("exit search")

    current_view = GPS.MDI.current()
    gps_assert(current_view.name(short=True), "foo.adb",
               "foo.adb should be focused")
示例#9
0
def test_driver():
    GPS.Preference("Ask-Confirmation-For-Replace-All").set(False)
    buf = GPS.EditorBuffer.get(GPS.File("main.adb"))

    s = dialogs.Search()
    yield s.open_and_yield()
    s.set_scope(dialogs.Search.Context.CURRENT_FILE)
    s.regexp.set_active(True)
    s.pattern.set_text('new Generic_Heap_Vector[ ]*\(([^,]+),[^)]*\)')
    s.replace_text.set_text('new Generic_Heap_Vector (\\1)')

    yield s.yield_replace_all()
    yield wait_tasks(other_than=known_tasks)
    gps_assert(
        buf.get_chars(buf.at(5, 4), buf.at(5, 86)),
        "package P_MC2_CMS_Sub_Sub_Step_V is new " +
        "Generic_Heap_Vector (Mc2_Cms_Sub_Sub_Step);", "Replace does not work")
    buf.undo()
示例#10
0
def test_driver():
    buf = GPS.EditorBuffer.get(GPS.File("main.adb"))

    s = dialogs.Search()
    yield s.open_and_yield()

    s.set_scope(dialogs.Search.Context.CURRENT_FILE)
    s.pattern.set_text('Hello')

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

    gps_assert(len(GPS.Locations.list_categories()) != 0,
               True,
               "Locations view should have search results after find all")

    GPS.execute_action("find next")
    yield wait_tasks(other_than=known_tasks)

    gps_assert(len(GPS.Locations.list_categories()) != 0,
               True,
               "Locations view should still have search results after " +
               "find next")