Package com.google.collide.client.codeunderstanding.CodeGraphTestUtils

Examples of com.google.collide.client.codeunderstanding.CodeGraphTestUtils.MockCubeClient


      createCodeBlock(freshFileBlock, "3", "bar", CodeBlock.Type.FIELD, 2, 0, 3, 0);
      createCodeBlock(freshFileBlock, "4", "bar.doThis", CodeBlock.Type.FUNCTION, 2, 10, 3, 0);
      response.setFileTreeJson(Jso.serialize(freshFileBlock));
    }

    MockCubeClient cubeClient = MockCubeClient.create();
    UpdateReceiver updateListener = new UpdateReceiver();

    CodeGraphSource codeGraphSource = new CodeGraphSource(cubeClient, updateListener);
    codeGraphSource.setPaused(false);

    // This will immediately fire api call
    cubeClient.setPath("/foo.js");
    try {
      assertEquals("one api call after setDocument", 1, cubeClient.api.collectedCallbacks.size());
      cubeClient.api.collectedCallbacks.get(0).onMessageReceived(response);
    } finally {
      cubeClient.cleanup();
    }
    assertEquals("one update after data received", 1, updateListener.runCount);
    assertTrue("codeGraphSource received update", codeGraphSource.hasUpdate());

    CodeGraphPrefixIndex prefixIndex = new CodeGraphPrefixIndex(
View Full Code Here


    // Environment.
    AppContext appContext = new MockAppContext();
    Editor editor = Editor.create(appContext);
    editor.setDocument(document);
    MockCubeClient cubeClient = MockCubeClient.create();
    cubeClient.setPath(filePath.getPathString());
    ReferenceStore referenceStore = null;
    try {
      referenceStore = new ReferenceStore(cubeClient);
      referenceStore.onDocumentChanged(document, null);
      referenceStore.updateReferences(
          new CubeData(filePath.getPathString(), null, null, null, null, fileReferences));

      LineInfo line1 = document.getLineFinder().findLine(1);
      // Check that there's reference at positions 12 to 17 inclusive (line 2).
      assertNotNull(referenceStore.findReference(line1, 12, true));
      assertNotNull(referenceStore.findReference(line1, 17, true));

      // Make some edits. Just insert some whitespaces before reference.
      // Now the second line is: "var    myvar = defvar;\n"
      document.insertText(document.getFirstLine().getNextLine(), 3, "   ");

      // Test!
      // Now there's nothing at position 13.
      assertNull(referenceStore.findReference(line1, 13, true));

      // And there's reference at 18.
      assertNotNull(referenceStore.findReference(line1, 18, true));

      // Make some more edits, add whitespace inside reference.
      // This should break it.
      // Now the second line is: "var    myvar = d   efvar;\n"
      document.insertText(document.getFirstLine().getNextLine(), 16, "   ");

      // Now there should be nothing at positions 15-23.
      assertNull(referenceStore.findReference(line1, 15, true));
      assertNull(referenceStore.findReference(line1, 18, true));
      assertNull(referenceStore.findReference(line1, 21, true));

      referenceStore.onDocumentChanged(Document.createEmpty(), null);
    } finally {
      if (referenceStore != null) {
        referenceStore.cleanup();
      }
      cubeClient.cleanup();
    }
  }
View Full Code Here

TOP

Related Classes of com.google.collide.client.codeunderstanding.CodeGraphTestUtils.MockCubeClient

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.