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

Examples of com.google.collide.client.editor.search.SearchTestsUtil.StubMatchManager


    SearchModel model = SearchModel.createWithManagerAndScheduler(mockContext,
        document,
        mockRenderer,
        mockView,
        new StubMatchManager(document),
        new StubIncrementalScheduler(10, 1000),
        createMockSelectionModel(document));
    // Almost nothing is performed here since there was no previous query
    model.setQuery("");
    model.setQuery("a");
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();
    callback.onSearchDone();
    callback.onSearchBegin();
    callback.onSearchDone();
    callback.onSearchBegin();
    callback.onSearchDone();
    callback.onSearchBegin();
    callback.onSearchDone();
    replay(callback);

    // None of these get called during this test
    Renderer mockRenderer = EasyMock.createNiceMock(Renderer.class);
    replay(mockRenderer);

    SearchModel model = SearchModel.createWithManagerAndScheduler(mockContext,
        document,
        mockRenderer,
        mockView,
        mockMatchManager,
        new StubIncrementalScheduler(10, 1000),
        createMockSelectionModel(document));
    model.setQuery("when", callback);
    assertEquals(1, mockMatchManager.getTotalMatches());

    model.setQuery("When", callback);
    assertEquals(1, mockMatchManager.getTotalMatches());

    model.setQuery("Doug", callback);
    assertEquals(8, mockMatchManager.getTotalMatches());

    model.setQuery("tiger", callback);
    assertEquals(3, mockMatchManager.getTotalMatches());

    model.setQuery("", callback);
    assertEquals(0, mockMatchManager.getTotalMatches());

    // verify
    verify(callback, mockRenderer, mockView, mockContext);
  }
View Full Code Here

    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);
    callback.onSearchBegin();
    callback.onSearchDone();
View Full Code Here

TOP

Related Classes of com.google.collide.client.editor.search.SearchTestsUtil.StubMatchManager

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.