/** testClasses */ public void testClassesIds() { this.setupTestContext("contentAssist/class-id-proposal.css"); int offset = this.cursorOffsets.get(0); ITextViewer viewer = AssertUtil.createTextViewer(document); // add on "." to test class proposals document.set(document.get() + "."); offset++; // looking for .testclass#a#b ICompletionProposal[] proposals = processor.doComputeCompletionProposals(viewer, offset, '\t', false); AssertUtil.assertProposalApplies(document, ".testclass", proposals, offset); // test for #a offset = document.getLength() - 1; document.set(document.get() + "#"); offset++; proposals = processor.doComputeCompletionProposals(viewer, offset, '\t', false); AssertUtil.assertProposalApplies(document, "#a", proposals, offset); // test for #b offset = document.getLength() - 1; document.set(document.get() + "#"); offset++; proposals = processor.doComputeCompletionProposals(viewer, offset, '\t', false); AssertUtil.assertProposalApplies(document, "#b", proposals, offset); }
/** testIds */ public void testIds() { this.setupTestContext("contentAssist/id-proposal.css"); int offset = this.cursorOffsets.get(0); ITextViewer viewer = AssertUtil.createTextViewer(document); // add on "#" to test id proposals document.set(document.get() + "#"); offset++; ICompletionProposal[] proposals = processor.doComputeCompletionProposals(viewer, offset, '\t', false); AssertUtil.assertProposalFound("#testid", proposals); }
/** testClasses */ public void testColorProposalsBackground() { this.setupTestContext("contentAssist/color-proposal.css"); int offset = this.cursorOffsets.get(0); ITextViewer viewer = AssertUtil.createTextViewer(document); // add on "#" to test color proposals String toInsert = "p {background:#}"; document.set(document.get() + toInsert); offset += toInsert.length() - 1; // cursor before } ICompletionProposal[] proposals = processor.doComputeCompletionProposals(viewer, offset, '\t', false); AssertUtil.assertProposalApplies(document, "#CCCCCC", proposals, offset); }
/** testClasses */ public void testClassesChild() { this.setupTestContext("contentAssist/class-proposal.css"); int offset = this.cursorOffsets.get(0); ITextViewer viewer = AssertUtil.createTextViewer(document); // add on "p." to test class proposals document.set(document.get() + "p."); offset += 2; ICompletionProposal[] proposals = processor.doComputeCompletionProposals(viewer, offset, '\t', false); AssertUtil.assertProposalFound(".testclass", proposals); }
/** * @param source * @param trigger * @param proposalCount * @param proposalToChoose * @param postCompletion * @param point */ protected void assertCompletionCorrect( String source, char trigger, int proposalCount, String proposalToChoose, String postCompletion, Point point) { IFileStore fileStore = createFileStore("proposal_tests", "css", source); this.setupTestContext(fileStore); int offset = this.cursorOffsets.get(0); ITextViewer viewer = AssertUtil.createTextViewer(document); ICompletionProposal[] proposals = processor.doComputeCompletionProposals(viewer, offset, trigger, false); if (proposalCount >= 0) { assertEquals(proposalCount, proposals.length); } if (proposalToChoose != null) { AssertUtil.assertProposalFound(proposalToChoose, proposals); AssertUtil.assertProposalApplies( postCompletion, document, proposalToChoose, proposals, offset, point); } }