Skip to content

Commit d18c29c

Browse files
author
dave
committed
#436 test coverage
1 parent 438f970 commit d18c29c

File tree

4 files changed

+58
-22
lines changed

4 files changed

+58
-22
lines changed

embedCONTROLCore/src/main/java/com/thecoderscorner/embedcontrol/core/controlmgr/color/ControlColor.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import com.thecoderscorner.menu.domain.state.PortableColor;
44
import javafx.scene.paint.Color;
55

6+
import java.util.Map;
7+
8+
import static com.thecoderscorner.embedcontrol.core.controlmgr.color.ConditionalColoring.ColorComponentType.*;
9+
610
/**
711
* This represents a color for a control, it has a background and a foreground in portable color format. Portable color
812
* is an API level construct that is not tied to any implementation.
@@ -24,6 +28,26 @@ public class ControlColor {
2428
public static final PortableColor BLUE = new PortableColor(0, 0, 255);
2529
public static final PortableColor GREEN = new PortableColor(0, 255, 0);
2630

31+
public final static Map<ConditionalColoring.ColorComponentType, ControlColor> DEFAULT_LIGHT_COLORS = Map.ofEntries(
32+
Map.entry(CUSTOM, new ControlColor("#000000", "#0A81F7")),
33+
Map.entry(TEXT_FIELD, new ControlColor(BLACK, WHITE)),
34+
Map.entry(HIGHLIGHT, new ControlColor("#000000", "#0A81F7")),
35+
Map.entry(BUTTON, new ControlColor(WHITE, DARK_SLATE_BLUE)),
36+
Map.entry(DIALOG, new ControlColor(WHITE, DARK_BLUE)),
37+
Map.entry(ERROR, new ControlColor(WHITE, RED)),
38+
Map.entry(PENDING, new ControlColor(LIGHT_GRAY, GREY))
39+
);
40+
41+
public final static Map<ConditionalColoring.ColorComponentType, ControlColor> DEFAULT_DARK_COLORS = Map.ofEntries(
42+
Map.entry(CUSTOM, new ControlColor("#FEFFFF", "#2D1E8C")),
43+
Map.entry(TEXT_FIELD, new ControlColor("#FEFFFF", "#000")),
44+
Map.entry(HIGHLIGHT, new ControlColor("#FEFFFF", "#9D5BBA")),
45+
Map.entry(BUTTON, new ControlColor("#FEFFFF", "#33084A")),
46+
Map.entry(DIALOG, new ControlColor("#FEFFFF", "#214F82")),
47+
Map.entry(ERROR, new ControlColor("#FEFFFF", "#A80B0D")),
48+
Map.entry(PENDING, new ControlColor(LIGHT_GRAY, DARK_GREY))
49+
);
50+
2751
private PortableColor fg;
2852
private PortableColor bg;
2953
private boolean inUse;

embedCONTROLCore/src/main/java/com/thecoderscorner/embedcontrol/core/service/GlobalSettings.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,6 @@
1717
* font sizes, control colors, and other setup values.
1818
*/
1919
public class GlobalSettings {
20-
21-
final static Map<ConditionalColoring.ColorComponentType, ControlColor> DEFAULT_LIGHT_COLORS = Map.ofEntries(
22-
Map.entry(CUSTOM, new ControlColor("#000000", "#0A81F7")),
23-
Map.entry(TEXT_FIELD, new ControlColor(BLACK, WHITE)),
24-
Map.entry(HIGHLIGHT, new ControlColor("#000000", "#0A81F7")),
25-
Map.entry(BUTTON, new ControlColor(WHITE, DARK_SLATE_BLUE)),
26-
Map.entry(DIALOG, new ControlColor(WHITE, DARK_BLUE)),
27-
Map.entry(ERROR, new ControlColor(WHITE, RED)),
28-
Map.entry(PENDING, new ControlColor(LIGHT_GRAY, GREY))
29-
);
30-
final static Map<ConditionalColoring.ColorComponentType, ControlColor> DEFAULT_DARK_COLORS = Map.ofEntries(
31-
Map.entry(CUSTOM, new ControlColor("#FEFFFF", "#2D1E8C")),
32-
Map.entry(TEXT_FIELD, new ControlColor("#FEFFFF", "#000")),
33-
Map.entry(HIGHLIGHT, new ControlColor("#FEFFFF", "#9D5BBA")),
34-
Map.entry(BUTTON, new ControlColor("#FEFFFF", "#33084A")),
35-
Map.entry(DIALOG, new ControlColor("#FEFFFF", "#214F82")),
36-
Map.entry(ERROR, new ControlColor("#FEFFFF", "#A80B0D")),
37-
Map.entry(PENDING, new ControlColor(LIGHT_GRAY, DARK_GREY))
38-
);
3920
private static int globalFontSize = 14;
4021

4122
private ControlColor updateColor;

tcMenuGenerator/src/test/java/com/thecoderscorner/menu/editorint/uitests/uimenuitem/UIActionItemAndCoreTest.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import com.thecoderscorner.menu.domain.Rgb32MenuItemBuilder;
1313
import com.thecoderscorner.menu.domain.state.MenuTree;
1414
import com.thecoderscorner.menu.editorui.generator.core.VariableNameGenerator;
15+
import com.thecoderscorner.menu.persist.LocaleMappingHandler;
16+
import com.thecoderscorner.menu.persist.PropertiesLocaleEnabledHandler;
17+
import com.thecoderscorner.menu.persist.SafeBundleLoader;
1518
import javafx.application.Platform;
1619
import javafx.scene.control.TextField;
1720
import javafx.stage.Stage;
@@ -24,6 +27,11 @@
2427
import org.testfx.framework.junit5.Start;
2528
import org.testfx.matcher.control.TextInputControlMatchers;
2629

30+
import java.io.File;
31+
import java.io.IOException;
32+
import java.nio.file.Files;
33+
import java.nio.file.Path;
34+
import java.util.Comparator;
2735
import java.util.HashSet;
2836
import java.util.Set;
2937

@@ -36,13 +44,21 @@
3644
@ExtendWith(ApplicationExtension.class)
3745
public class UIActionItemAndCoreTest extends UIMenuItemTestBase {
3846

47+
private Path tempPath;
48+
3949
@Start
40-
public void setup(Stage stage) {
50+
public void setup(Stage stage) throws IOException {
51+
tempPath = Files.createTempDirectory("i18ntest");
4152
init(stage);
4253
}
4354

4455
@AfterEach
45-
protected void closeWindow() {
56+
protected void closeWindow() throws Exception {
57+
Files.walk(tempPath)
58+
.sorted(Comparator.reverseOrder())
59+
.map(Path::toFile)
60+
.forEach(File::delete);
61+
4662
Platform.runLater(() -> stage.close());
4763
}
4864

@@ -190,4 +206,14 @@ void testSelectingAndClearingReadonlyLocal(FxRobot robot) throws InterruptedExce
190206
assertTrue(captor.getValue().isReadOnly());
191207
assertTrue(captor.getValue().isLocalOnly());
192208
}
209+
210+
@Override
211+
protected LocaleMappingHandler getTestLocaleHandler() throws IOException {
212+
var coreFile = tempPath.resolve("temp.properties");
213+
Files.writeString(coreFile, """
214+
menu.item.name=hello world
215+
""");
216+
217+
return new PropertiesLocaleEnabledHandler(new SafeBundleLoader(tempPath, "temp"));
218+
}
193219
}

tcMenuGenerator/src/test/java/com/thecoderscorner/menu/editorint/uitests/uimenuitem/UIMenuItemTestBase.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.testfx.api.FxRobot;
3434
import org.testfx.matcher.control.TextInputControlMatchers;
3535

36+
import java.io.IOException;
3637
import java.util.Optional;
3738
import java.util.concurrent.CountDownLatch;
3839
import java.util.concurrent.TimeUnit;
@@ -120,11 +121,15 @@ protected void createMainPanel(Optional<UIMenuItem<?>> uiSubItem) throws Interru
120121
Platform.runLater(() -> {
121122
BorderPane borderLayout = new BorderPane();
122123
borderLayout.setMinSize(500, 500);
123-
borderLayout.centerProperty().set(uiSubItem.get().initPanel(menuTree, LocaleMappingHandler.NOOP_IMPLEMENTATION));
124+
borderLayout.centerProperty().set(uiSubItem.get().initPanel(menuTree, getTestLocaleHandler()));
124125
dialogPane.getChildren().add(borderLayout);
125126
stage.show();
126127
latch.countDown();
127128
});
128129
if(!latch.await(2000, TimeUnit.MILLISECONDS)) throw new IllegalStateException("panel timeout");
129130
}
131+
132+
protected LocaleMappingHandler getTestLocaleHandler() throws IOException {
133+
return LocaleMappingHandler.NOOP_IMPLEMENTATION;
134+
}
130135
}

0 commit comments

Comments
 (0)