Skip to content

Commit b12d19c

Browse files
committed
Cleanup automated tests
1 parent a662538 commit b12d19c

File tree

3 files changed

+31
-52
lines changed

3 files changed

+31
-52
lines changed
+26-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
package glslplugin;
22

3+
import com.intellij.openapi.util.io.FileUtil;
4+
import com.intellij.psi.PsiFileFactory;
35
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
6+
import glslplugin.lang.parser.GLSLFile;
7+
8+
import java.io.File;
9+
import java.io.IOException;
410

511
/**
6-
* Created by wyozi on 19.12.2015.
12+
* Base for light test cases
713
*/
8-
public class LightGLSLTestCase extends LightPlatformCodeInsightFixtureTestCase {
14+
public abstract class LightGLSLTestCase extends LightPlatformCodeInsightFixtureTestCase {
15+
916
@Override
1017
protected String getTestDataPath() {
11-
return TestUtils.getTestDataPath();
18+
return new File("testdata").getAbsolutePath();
19+
}
20+
21+
private File getTestFile(String fileName){
22+
return new File(new File(getTestDataPath()), fileName);
23+
}
24+
25+
public GLSLFile parseFile(String filePath){
26+
final String testFileContent;
27+
try {
28+
testFileContent = FileUtil.loadFile(getTestFile(filePath), "UTF-8", true);
29+
assertNotNull(testFileContent);
30+
} catch (IOException e) {
31+
throw new RuntimeException(e);
32+
}
33+
34+
return ((GLSLFile) PsiFileFactory.getInstance(getProject()).createFileFromText("dummy.glsl", GLSLSupportLoader.GLSL, testFileContent));
1235
}
1336
}

test/glslplugin/TestUtils.java

-46
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
package glslplugin.lang;
22

33
import glslplugin.LightGLSLTestCase;
4-
import glslplugin.TestUtils;
54
import glslplugin.lang.parser.GLSLFile;
65

76
/**
7+
* Test if the versions are inferred correctly
8+
*
89
* Created by wyozi on 19.12.2015.
910
*/
1011
public class VersionDirectiveTest extends LightGLSLTestCase {
12+
1113
@Override
1214
protected String getTestDataPath() {
1315
return super.getTestDataPath() + "/lang/version";
1416
}
1517

1618
public void testDefaultVersion() {
17-
GLSLFile file = TestUtils.parseFile(getProject(), getTestDataPath() + "/defaultVersion.glsl");
19+
GLSLFile file = parseFile("defaultVersion.glsl");
1820
assertEquals(GLSLFile.GLSL_DEFAULT_VERSION, file.getGLSLVersion());
1921
}
2022

2123
public void testSpecifiedVersion() {
22-
GLSLFile file = TestUtils.parseFile(getProject(), getTestDataPath() + "/specifiedVersion.glsl");
24+
GLSLFile file = parseFile("specifiedVersion.glsl");
2325
assertEquals(330, file.getGLSLVersion());
2426
}
2527
}

0 commit comments

Comments
 (0)