Skip to content

Break cyclical test dependency between html and css editor #8600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ide/css.editor/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@
<test-dependency>
<code-name-base>org.netbeans.modules.html.editor</code-name-base>
<recursive/>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.netbeans.modules.html.editor.lib</code-name-base>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import org.netbeans.modules.csl.spi.DefaultLanguageConfig;
import org.netbeans.modules.css.editor.ProjectTestBase;
import org.netbeans.modules.html.editor.gsf.HtmlLanguage;

public class CssGotoDeclarationTest extends ProjectTestBase {

Expand All @@ -30,7 +29,11 @@ public CssGotoDeclarationTest(String testName) {

@Override
protected DefaultLanguageConfig getPreferredLanguage() {
return new HtmlLanguage();
try {
return (DefaultLanguageConfig) Class.forName("org.netbeans.modules.html.editor.gsf.HtmlLanguage").getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException ex) {
throw new RuntimeException(ex);
}
}

public void testClass_01() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import javax.swing.text.Document;
import org.netbeans.modules.css.editor.test.TestBase;
import org.netbeans.modules.css.lib.api.CssParserResult;
import org.netbeans.modules.html.editor.api.gsf.HtmlParserResult;
import org.netbeans.modules.parsing.api.ParserManager;
import org.netbeans.modules.parsing.api.ResultIterator;
import org.netbeans.modules.parsing.api.Source;
Expand Down Expand Up @@ -52,13 +51,13 @@ public void testIncorrectOffsetsConversion() throws ParseException {
// 0 1 2 3 4

//works - html
assertParserResultType(content, 0, HtmlParserResult.class);
assertParserResultType(content, 3, HtmlParserResult.class);
assertParserResultType(content, 48, HtmlParserResult.class);
assertParserResultType(content, 0, "org.netbeans.modules.html.editor.api.gsf.HtmlParserResult");
assertParserResultType(content, 3, "org.netbeans.modules.html.editor.api.gsf.HtmlParserResult");
assertParserResultType(content, 48, "org.netbeans.modules.html.editor.api.gsf.HtmlParserResult");

//works - css
assertParserResultType(content, 12, CssParserResult.class);
assertParserResultType(content, 38, CssParserResult.class);
assertParserResultType(content, 12, CssParserResult.class.getName());
assertParserResultType(content, 38, CssParserResult.class.getName());

//fails between the two styles - returns css instead of html parser result

Expand All @@ -67,7 +66,7 @@ public void testIncorrectOffsetsConversion() throws ParseException {

}

private void assertParserResultType(String content, final int offset, Class resultType) throws ParseException {
private void assertParserResultType(String content, final int offset, String resultType) throws ParseException {
Document doc = getDocument(content);
Source source = Source.create(doc);
final Result[] _result = new Result[1];
Expand All @@ -80,7 +79,7 @@ public void run(ResultIterator resultIterator) throws Exception {

Result result = _result[0];
assertNotNull(result);
assertEquals(resultType, result.getClass());
assertEquals(resultType, result.getClass().getName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@
import org.netbeans.modules.csl.api.Formatter;
import org.netbeans.modules.css.editor.test.TestBase;
import org.netbeans.modules.css.lib.api.CssTokenId;
import org.netbeans.modules.html.editor.api.HtmlKit;
import org.netbeans.modules.html.editor.indent.HtmlIndentTaskFactory;
import org.netbeans.modules.editor.NbEditorKit;
import org.netbeans.modules.editor.indent.spi.IndentTask;
import org.netbeans.modules.web.indent.api.support.AbstractIndenter;
import org.openide.cookies.EditorCookie;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;

public class CssIndenterTest extends TestBase {

Expand All @@ -57,10 +56,12 @@ protected void setUp() throws Exception {
AbstractIndenter.inUnitTestRun = true;
// CssBracketCompleter.unitTestingSupport = true;

CssIndentTaskFactory cssFactory = new CssIndentTaskFactory();
IndentTask.Factory cssFactory = new CssIndentTaskFactory();
MockMimeLookup.setInstances(MimePath.parse("text/css"), cssFactory, CssTokenId.language());
HtmlIndentTaskFactory htmlReformatFactory = new HtmlIndentTaskFactory();
MockMimeLookup.setInstances(MimePath.parse("text/html"), htmlReformatFactory, new HtmlKit("text/x-jsp"), HTMLTokenId.language());

IndentTask.Factory htmlReformatFactory = (IndentTask.Factory) Class.forName("org.netbeans.modules.html.editor.indent.HtmlIndentTaskFactory").getDeclaredConstructor().newInstance();
NbEditorKit htmlKit = (NbEditorKit) Class.forName("org.netbeans.modules.html.editor.api.HtmlKit").getDeclaredConstructor(String.class).newInstance("text/x-jsp");
MockMimeLookup.setInstances(MimePath.parse("text/html"), htmlReformatFactory, htmlKit, HTMLTokenId.language());
}

public static Test xxsuite() throws IOException, BadLocationException {
Expand Down
Loading