explicit unit tests for config tokens in real source code
This commit is contained in:
parent
8ed1825696
commit
07efe271a4
|
@ -3,6 +3,16 @@ package com.rusefi.ui.livedata;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
public interface SourceCodePainter {
|
public interface SourceCodePainter {
|
||||||
|
SourceCodePainter VOID = new SourceCodePainter() {
|
||||||
|
@Override
|
||||||
|
public void paintBackground(Color color, Range range) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paintForeground(Color color, Range range) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void paintBackground(Color color, Range range);
|
void paintBackground(Color color, Range range);
|
||||||
|
|
||||||
void paintForeground(Color color, Range range);
|
void paintForeground(Color color, Range range);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.rusefi.ui.livedata;
|
package com.rusefi.ui.livedata;
|
||||||
|
|
||||||
public interface VariableValueSource {
|
public interface VariableValueSource {
|
||||||
|
VariableValueSource VOID = name -> null;
|
||||||
|
|
||||||
Object getValue(String name);
|
Object getValue(String name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,19 @@
|
||||||
package com.rusefi.ui.livedata;
|
package com.rusefi.ui.livedata;
|
||||||
|
|
||||||
import com.rusefi.livedata.LiveDataParserPanel;
|
import com.rusefi.livedata.LiveDataParserPanel;
|
||||||
|
import com.rusefi.livedata.LiveDataView;
|
||||||
|
import com.rusefi.livedata.ParseResult;
|
||||||
import org.antlr.v4.runtime.tree.ParseTree;
|
import org.antlr.v4.runtime.tree.ParseTree;
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
@ -50,4 +55,14 @@ public class LiveDataParserTest {
|
||||||
verify(painter).paintBackground(eq(Color.red), any());
|
verify(painter).paintBackground(eq(Color.red), any());
|
||||||
verify(painter).paintBackground(eq(Color.green), any());
|
verify(painter).paintBackground(eq(Color.green), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigurationInRealSourceCode() throws IOException, URISyntaxException {
|
||||||
|
String sourceCode = LiveDataParserPanel.getContent(LiveDataParserPanel.class, LiveDataView.BOOST_CONTROL.getFileName());
|
||||||
|
assertTrue(sourceCode.length() > 100);
|
||||||
|
|
||||||
|
ParseTree tree = LiveDataParserPanel.getParseTree(sourceCode);
|
||||||
|
ParseResult parseResult = LiveDataParserPanel.applyVariables(VariableValueSource.VOID, sourceCode, SourceCodePainter.VOID, tree);
|
||||||
|
assertTrue(!parseResult.getConfigTokens().isEmpty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue