Package com.google.collide.client.editor.search.SearchTask

Examples of com.google.collide.client.editor.search.SearchTask.SearchTaskExecutor


  public void replaceAllMatches(final String replacement) {
    // TODO: There's an issue relying on the same SearchTask as
    // SearchModel, since they share the same scheduler the searchModel can
    // preempt a replaceAll before it is finish!
    searchTask.searchDocument(new SearchTaskExecutor() {
      @Override
      public boolean onSearchLine(Line line, int number, boolean shouldRenderLine) {
        searchPattern.setLastIndex(0);
        for (MatchResult result = searchPattern.exec(line.getText());
            result != null && result.getGroup(0).length() != 0;
View Full Code Here


  }

  public void testHaltSchedulerSearch() {
    ViewportModel viewport = createMockViewport(document, 5);
    SearchTask task = new SearchTask(document, viewport, scheduler);
    SearchTaskExecutor executor = EasyMock.createMock(SearchTaskExecutor.class);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(true)))
        .andReturn(true).times(5);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.eq(5), EasyMock.eq(false)))
        .andReturn(false);
    replay(executor);

    task.searchDocument(executor, null);
    verify(executor);
View Full Code Here

  }

  public void testDocumentFitsInViewport() {
    SearchTask task = new SearchTask(document, createMockViewport(document, 12), scheduler);

    SearchTaskExecutor executor = EasyMock.createMock(SearchTaskExecutor.class);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(true)))
        .andReturn(true).times(12);
    replay(executor);

    task.searchDocument(executor, null);
    verify(executor);
View Full Code Here

  }

  public void testSchedulerRunsThroughDocument() {
    SearchTask task = new SearchTask(document, createMockViewport(document, 5), scheduler);

    SearchTaskExecutor executor = EasyMock.createMock(SearchTaskExecutor.class);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(true)))
        .andReturn(true).times(5);
    expect(executor.onSearchLine(
        EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(false)))
        .andReturn(true).times(7);
    replay(executor);

    task.searchDocument(executor, null);
View Full Code Here

  public void testDirectionDownWorks() {
    ViewportModel viewport = createMockViewport(document, 5);
    SearchTask task = new SearchTask(document, viewport, scheduler);

    SearchTaskExecutor executor = EasyMock.createMock(SearchTaskExecutor.class);
    expect(executor.onSearchLine(viewport.getTopLine(), 0, true)).andReturn(true);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(true)))
        .andReturn(true).times(3);
    expect(executor.onSearchLine(viewport.getBottomLine(), 4, true)).andReturn(true);

    expect(executor.onSearchLine(
        EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(false)))
        .andReturn(true).times(7);
    replay(executor);

    task.searchDocument(executor, null, SearchDirection.DOWN);
View Full Code Here

  public void testDirectionUpWorks() {
    ViewportModel viewport = createMockViewport(document, 5);
    SearchTask task = new SearchTask(document, viewport, scheduler);

    SearchTaskExecutor executor = EasyMock.createMock(SearchTaskExecutor.class);
    expect(executor.onSearchLine(viewport.getBottomLine(), 4, true)).andReturn(true);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(true)))
        .andReturn(true).times(3);
    expect(executor.onSearchLine(viewport.getTopLine(), 0, true)).andReturn(true);

    expect(executor.onSearchLine(document.getLastLine(), 11, false)).andReturn(true);
    expect(executor.onSearchLine(
        EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(false)))
        .andReturn(true).times(6);
    replay(executor);

    task.searchDocument(executor, null, SearchDirection.UP);
View Full Code Here

    SearchTask task = new SearchTask(document, viewport, scheduler);

    LineInfo lineInfo = viewport.getTopLineInfo();
    lineInfo.moveToNext();

    SearchTaskExecutor executor = EasyMock.createMock(SearchTaskExecutor.class);
    expect(executor.onSearchLine(lineInfo.line(), 1, true)).andReturn(true);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(true)))
        .andReturn(true).times(2);
    expect(executor.onSearchLine(viewport.getBottomLine(), 4, true)).andReturn(true);

    expect(executor.onSearchLine(
        EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(false)))
        .andReturn(true).times(7);
    expect(executor.onSearchLine(viewport.getTopLine(), 0, false)).andReturn(true);
    replay(executor);

    task.searchDocumentStartingAtLine(executor, null, SearchDirection.DOWN, lineInfo);
    verify(executor);
  }
View Full Code Here

  public void testNoWrapWorks() {
    ViewportModel viewport = createMockViewport(document, 5);
    SearchTask task = new SearchTask(document, viewport, scheduler);

    SearchTaskExecutor executor = EasyMock.createMock(SearchTaskExecutor.class);
    expect(executor.onSearchLine(viewport.getBottomLine(), 4, true)).andReturn(true);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(true)))
        .andReturn(true).times(3);
    expect(executor.onSearchLine(viewport.getTopLine(), 0, true)).andReturn(true);
    replay(executor);

    task.setShouldWrapDocument(false);
    task.searchDocument(executor, null, SearchDirection.UP);
    verify(executor);
View Full Code Here

  }

  public void testHaltViewportSearch() {
    ViewportModel viewport = createMockViewport(document, 5);
    SearchTask task = new SearchTask(document, viewport, scheduler);
    SearchTaskExecutor executor = EasyMock.createMock(SearchTaskExecutor.class);
    expect(executor.onSearchLine(viewport.getTopLine(), 0, true)).andReturn(true);
    expect(
        executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.anyInt(), EasyMock.eq(true)))
        .andReturn(true).times(3);
    expect(executor.onSearchLine(EasyMock.anyObject(Line.class), EasyMock.eq(4), EasyMock.eq(true)))
        .andReturn(false);
    replay(executor);

    task.searchDocument(executor, null);
    verify(executor);
View Full Code Here

TOP

Related Classes of com.google.collide.client.editor.search.SearchTask.SearchTaskExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.