Package com.google.collide.client.editor

Examples of com.google.collide.client.editor.ViewportModel


    }

    @Override
    public boolean onDefaultInput(SignalEvent event, char character) {
      int key = KeyCodeMap.getKeyFromEvent(event);
      ViewportModel viewport = getInputController().getViewportModel();

      switch (key) {
        case KeyCodeMap.ARROW_LEFT:
        case KeyCodeMap.ARROW_RIGHT:
          viewport.shiftHorizontally(key == KeyCodeMap.ARROW_RIGHT);
          return true;

        case KeyCodeMap.ARROW_UP:
        case KeyCodeMap.ARROW_DOWN:
          viewport.shiftVertically(key == KeyCodeMap.ARROW_DOWN, false);
          return true;

        case KeyCodeMap.PAGE_UP:
        case KeyCodeMap.PAGE_DOWN:
          viewport.shiftVertically(key == KeyCodeMap.PAGE_DOWN, true);
          return true;

        case KeyCodeMap.HOME:
        case KeyCodeMap.END:
          viewport.jumpTo(key == KeyCodeMap.END);
          return true;
      }

      return false;
    }
View Full Code Here


    mockRenderer.addLineRenderer(anyObject(LineRenderer.class));
    mockRenderer.removeLineRenderer(anyObject(LineRenderer.class));
    replay(mockRenderer);

    AppContext mockContext = createMockContext();
    ViewportModel mockView = createMockViewport(document, 4);

    SearchModel model = SearchModel.createWithManagerAndScheduler(mockContext,
        document,
        mockRenderer,
        mockView,
View Full Code Here

  public void testSetQueryReturnsNumberOfMatches() {
    Document document = createDocument();

    AppContext mockContext = createMockContext();
    ViewportModel mockView = createMockViewport(document, 4);
    StubMatchManager mockMatchManager = new StubMatchManager(document);

    // Setup Callback
    SearchProgressListener callback = EasyMock.createMock(SearchProgressListener.class);
    callback.onSearchBegin();
View Full Code Here

  public void testCallbackCalledWhenAllLinesFitInViewport() {
    Document document = createDocument();

    AppContext mockContext = createMockContext();
    ViewportModel mockView =
        createMockViewport(document, SearchTestsUtil.DOCUMENT_LINES.size() - 1);
    StubMatchManager mockMatchManager = new StubMatchManager(document);

    // Setup Callback
    SearchProgressListener callback = EasyMock.createMock(SearchProgressListener.class);
View Full Code Here

  public void testMatchManagerIsCalledCorrectly() {
    Document document = createDocument();

    AppContext mockContext = createMockContext();
    ViewportModel mockView = createMockViewport(document, 4);

    // Let's test the behavior towards match manager this time
    SearchMatchManager mockMatchManager = EasyMock.createMock(SearchMatchManager.class);
    mockMatchManager.clearMatches();
    expectLastCall().times(2);
View Full Code Here

   * Creates a viewport from a document
   *
   * @param lines Number of lines to include in viewport
   */
  public static ViewportModel createMockViewport(Document document, int lines) {
    ViewportModel mockViewport = EasyMock.createMock(ViewportModel.class);

    Line curLine = document.getFirstLine();
    expect(mockViewport.getTopLine()).andReturn(curLine).anyTimes();
    expect(mockViewport.getTopLineNumber()).andReturn(0).anyTimes();
    expect(mockViewport.getTopLineInfo()).andAnswer(lineInfoFactory(curLine, 0)).anyTimes();
    for (int i = 0; i < lines - 1 && curLine.getNextLine() != null; i++) {
      curLine = curLine.getNextLine();
    }
    expect(mockViewport.getBottomLine()).andReturn(curLine).anyTimes();
    expect(mockViewport.getBottomLineNumber()).andReturn(lines - 1).anyTimes();
    expect(mockViewport.getBottomLineInfo()).andAnswer(
        lineInfoFactory(curLine, lines - 1)).anyTimes();

    replay(mockViewport);
    return mockViewport;
  }
View Full Code Here

    task.searchDocument(executor, null);
    verify(executor);
  }

  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);
View Full Code Here

    task.searchDocument(executor, null, SearchDirection.DOWN);
    verify(executor);
  }

  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);
View Full Code Here

    task.searchDocument(executor, null, SearchDirection.UP);
    verify(executor);
  }

  public void testStartingAtLineWorks() {
    ViewportModel viewport = createMockViewport(document, 5);
    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

    task.searchDocumentStartingAtLine(executor, null, SearchDirection.DOWN, lineInfo);
    verify(executor);
  }

  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

TOP

Related Classes of com.google.collide.client.editor.ViewportModel

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.