https://wiki.eclipse.org/index.php?title=PDT_Dev2Dev_-_Unit_tests_for_CodeDataResolver_and_ContentAssistSupport&feed=atom&action=history
PDT Dev2Dev - Unit tests for CodeDataResolver and ContentAssistSupport - Revision history
2024-03-19T13:12:18Z
Revision history for this page on the wiki
MediaWiki 1.26.4
https://wiki.eclipse.org/index.php?title=PDT_Dev2Dev_-_Unit_tests_for_CodeDataResolver_and_ContentAssistSupport&diff=60380&oldid=prev
Seva.zend.com at 19:58, 10 November 2007
2007-11-10T19:58:30Z
<p></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 19:58, 10 November 2007</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l60" >Line 60:</td>
<td colspan="2" class="diff-lineno">Line 60:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>That's all folks.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>That's all folks.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>--[[User:seva.zend.com|<del class="diffchange diffchange-inline">seva.zend.com</del>]] 09:40, 21 October 2007 (EDT)</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>--[[User:seva.zend.com|<ins class="diffchange diffchange-inline">Seva Lapsha</ins>]] 09:40, 21 October 2007 (EDT)</div></td></tr>
</table>
Seva.zend.com
https://wiki.eclipse.org/index.php?title=PDT_Dev2Dev_-_Unit_tests_for_CodeDataResolver_and_ContentAssistSupport&diff=56294&oldid=prev
Seva.zend.com: /* Writing Tests */ grammar
2007-10-22T02:40:29Z
<p><span dir="auto"><span class="autocomment">Writing Tests: </span> grammar</span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 02:40, 22 October 2007</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l32" >Line 32:</td>
<td colspan="2" class="diff-lineno">Line 32:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  }</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  }</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Afterwards, you <del class="diffchange diffchange-inline">can </del>just edit the tested .php file, <del class="diffchange diffchange-inline">to </del>see <del class="diffchange diffchange-inline">in </del>which point do you want to get completion/link, <del class="diffchange diffchange-inline">to </del>write down the point location and <del class="diffchange diffchange-inline">to </del>create the tests, like:</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Afterwards, you <ins class="diffchange diffchange-inline">should </ins>just edit the tested .php file, see <ins class="diffchange diffchange-inline">at </ins>which point do you want to get completion/link, write down the point location and create the tests, like:</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  13:// test method completion after literal  operator:</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  13:// test method completion after literal  operator:</div></td></tr>
</table>
Seva.zend.com
https://wiki.eclipse.org/index.php?title=PDT_Dev2Dev_-_Unit_tests_for_CodeDataResolver_and_ContentAssistSupport&diff=56255&oldid=prev
Seva.zend.com: /* Writing Tests */
2007-10-21T14:39:25Z
<p><span dir="auto"><span class="autocomment">Writing Tests</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 14:39, 21 October 2007</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l60" >Line 60:</td>
<td colspan="2" class="diff-lineno">Line 60:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>That's all folks.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>That's all folks.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>--[[User:seva.zend.com|seva.<del class="diffchange diffchange-inline">lapsha@gmail</del>.com]] 09:40, 21 October 2007 (EDT)</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>--[[User:seva.zend.com|seva.<ins class="diffchange diffchange-inline">zend</ins>.com]] 09:40, 21 October 2007 (EDT)</div></td></tr>
</table>
Seva.zend.com
https://wiki.eclipse.org/index.php?title=PDT_Dev2Dev_-_Unit_tests_for_CodeDataResolver_and_ContentAssistSupport&diff=56251&oldid=prev
Seva.zend.com: /* Writing Tests */
2007-10-21T13:41:37Z
<p><span dir="auto"><span class="autocomment">Writing Tests</span></span></p>
<table class='diff diff-contentalign-left'>
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 13:41, 21 October 2007</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l60" >Line 60:</td>
<td colspan="2" class="diff-lineno">Line 60:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>That's all folks.</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>That's all folks.</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>--[[User:<del class="diffchange diffchange-inline">Seva</del>.zend.com|<del class="diffchange diffchange-inline">Seva</del>.<del class="diffchange diffchange-inline">zend</del>.com]] 09:40, 21 October 2007 (EDT)</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>--[[User:<ins class="diffchange diffchange-inline">seva</ins>.zend.com|<ins class="diffchange diffchange-inline">seva</ins>.<ins class="diffchange diffchange-inline">lapsha@gmail</ins>.com]] 09:40, 21 October 2007 (EDT)</div></td></tr>
</table>
Seva.zend.com
https://wiki.eclipse.org/index.php?title=PDT_Dev2Dev_-_Unit_tests_for_CodeDataResolver_and_ContentAssistSupport&diff=56250&oldid=prev
Seva.zend.com: Main content
2007-10-21T13:40:55Z
<p>Main content</p>
<p><b>New page</b></p><div>About a month ago I was honored to fix several bugs related to code links in the PHP Editor, which caused me to develop a light and simple way of testing CodeDataResolver class and yesterday I ported similar solution into test of ContentAssistSupport.<br />
<br />
=Getting Offset=<br />
<br />
The main problem in testing editor related issues is you should operate with offsets, which are not visually exposed. So I built a trivial utility Utils.getOffset() which translates the visual line and position for the specified document to the absolute offset. The utility's declaration is:<br />
<br />
public class lib.org.eclipse.php.test.headless.core.Utils {<br />
public static int getOffset(int line, int offsetAtLine, IDocument testDocument) throws Exception;<br />
}<br />
<br />
It means you can put 2 numbers you see in bottom of your eclipse editor, decrement them by 1 and receive the offset in the document. The only incomfortability of working with the utility is that there is no way to work with hard tabs (\t).<br />
<br />
=Writing Tests=<br />
Since we have the utility, we can easily wrap it with the needed functionality, like:<br />
<br />
public class org.eclipse.php.test.gui.ui.editor.contentassist.TestContentAssistSupport {<br />
private ICompletionProposal[] getProposals(int line, int position) throws Exception {<br />
IDocument document = ''viewer''.getDocument();<br />
int offset = '''Utils.getOffset(line, position, document)''';<br />
''viewer''.setSelectedRange(offset, 0);<br />
return processor.computeCompletionProposals(viewer, offset);<br />
}<br />
}<br />
<br />
and<br />
<br />
public class org.eclipse.php.test.headless.core.util.TestCodeDataResolver {<br />
private CodeData[] resolve(int line, int position) throws Exception {<br />
final int offset = '''Utils.getOffset(line, position, ''testDocument'')''';<br />
return resolve(offset);<br />
}<br />
}<br />
<br />
Afterwards, you can just edit the tested .php file, to see in which point do you want to get completion/link, to write down the point location and to create the tests, like:<br />
<br />
13:// test method completion after literal operator:<br />
14:$var->doSomething() and $var->'''d'''oSomething();<br />
<br />
public void testMethodAfterLiteralOperator() throws Exception {<br />
ICompletionProposal[] computeCompletionProposals = getProposals(13, 30);<br />
Assert.assertEquals(1, computeCompletionProposals.length);<br />
Assert.assertTrue(computeCompletionProposals[0].getDisplayString().startsWith("doSomething()"));<br />
}<br />
<br />
or<br />
46:// test this reference:<br />
47:class Class6 {<br />
48: function function1() {<br />
49: $thi'''s'''->function1();<br />
50: }<br />
<br />
public void testThisReference() throws Exception {<br />
final CodeData[] codeData = resolve(48, 12);<br />
Assert.assertEquals(1, codeData.length);<br />
Assert.assertTrue(codeData[0] instanceof PHPClassData);<br />
Assert.assertEquals("Class6", codeData[0].getName());<br />
final int modifiers = ((PHPClassData)codeData[0]).getModifiers();<br />
Assert.assertEquals(0, modifiers & PHPModifier.INTERFACE);<br />
}<br />
<br />
That's all folks.<br />
--[[User:Seva.zend.com|Seva.zend.com]] 09:40, 21 October 2007 (EDT)</div>
Seva.zend.com