mirror of https://github.com/rusefi/rusefi-1.git
annotate_if #3358
This commit is contained in:
parent
8318978077
commit
d1afb8eee2
|
@ -1,30 +1,26 @@
|
||||||
package com.rusefi.ui.livedata;
|
package com.rusefi.ui.livedata;
|
||||||
|
|
||||||
import com.rusefi.livedata.LiveDataParserPanel;
|
import com.rusefi.livedata.LiveDataParserPanel;
|
||||||
import org.antlr.v4.runtime.ParserRuleContext;
|
|
||||||
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.jetbrains.annotations.NotNull;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Matchers.eq;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
public class LiveDataParserTest {
|
public class LiveDataParserTest {
|
||||||
@Test
|
@Test
|
||||||
public void testParsing() throws IOException {
|
public void testParsing() {
|
||||||
Map<String, Object> values = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
Map<String, Object> values = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
values.put("engineTooSlow", Boolean.TRUE);
|
values.put("engineTooSlow", Boolean.TRUE);
|
||||||
values.put("engineTooFast", Boolean.FALSE);
|
values.put("engineTooFast", Boolean.FALSE);
|
||||||
|
|
||||||
VariableValueSource valueSource = new VariableValueSource() {
|
VariableValueSource valueSource = values::get;
|
||||||
@Override
|
|
||||||
public Object getValue(String name) {
|
|
||||||
return values.get(name);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
String sourceCode = "bool AcState::getAcState(DECLARE_ENGINE_PARAMETER_SIGNATURE) {\n" +
|
String sourceCode = "bool AcState::getAcState(DECLARE_ENGINE_PARAMETER_SIGNATURE) {\n" +
|
||||||
"\tauto rpm = Sensor::getOrZero(SensorType::Rpm);\n" +
|
"\tauto rpm = Sensor::getOrZero(SensorType::Rpm);\n" +
|
||||||
|
@ -43,24 +39,15 @@ public class LiveDataParserTest {
|
||||||
"return ff;\n" +
|
"return ff;\n" +
|
||||||
"}";
|
"}";
|
||||||
|
|
||||||
SourceCodePainter painter = new SourceCodePainter() {
|
SourceCodePainter painter = mock(SourceCodePainter.class);
|
||||||
@Override
|
|
||||||
public void paintBackground(Color color, Range range) {
|
|
||||||
System.out.println("paint " + color + " " + range);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void paintForeground(Color color, Range range) {
|
|
||||||
System.out.println("paintForeground");
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ParseTree tree = LiveDataParserPanel.getParseTree(sourceCode);
|
ParseTree tree = LiveDataParserPanel.getParseTree(sourceCode);
|
||||||
new ParseTreeWalker().walk(new PrintCPP14ParserListener(), tree);
|
new ParseTreeWalker().walk(new PrintCPP14ParserListener(), tree);
|
||||||
|
|
||||||
|
|
||||||
LiveDataParserPanel.applyVariables(valueSource, sourceCode, painter, tree);
|
LiveDataParserPanel.applyVariables(valueSource, sourceCode, painter, tree);
|
||||||
|
verify(painter, times(2)).paintForeground(eq(Color.blue), any());
|
||||||
|
|
||||||
|
verify(painter).paintBackground(eq(Color.red), any());
|
||||||
|
verify(painter).paintBackground(eq(Color.green), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,6 @@
|
||||||
<orderEntry type="library" name="dfu_java" level="project" />
|
<orderEntry type="library" name="dfu_java" level="project" />
|
||||||
<orderEntry type="module" module-name="proxy_server" scope="TEST" />
|
<orderEntry type="module" module-name="proxy_server" scope="TEST" />
|
||||||
<orderEntry type="library" name="antlr" level="project" />
|
<orderEntry type="library" name="antlr" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="mockito-all-1.10.19" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
Loading…
Reference in New Issue