消除视觉夹具导航标签重复
This commit is contained in:
@@ -68,14 +68,6 @@ final class NativeUiVisualAcceptanceFixture {
|
|||||||
new CaptureSpec("welcome-collapsed-1024.png", View.WELCOME, false, 1024, 768),
|
new CaptureSpec("welcome-collapsed-1024.png", View.WELCOME, false, 1024, 768),
|
||||||
new CaptureSpec("running-1024.png", View.RUNNING, true, 1024, 768));
|
new CaptureSpec("running-1024.png", View.RUNNING, true, 1024, 768));
|
||||||
private static final List<CaptureSpec> SCENE_CAPTURE_SPECS = sceneCaptureSpecs();
|
private static final List<CaptureSpec> SCENE_CAPTURE_SPECS = sceneCaptureSpecs();
|
||||||
private static final List<String> NAVIGATION_LABELS = List.of(
|
|
||||||
"Git仓库同步",
|
|
||||||
"Git分支评审",
|
|
||||||
"文本对比",
|
|
||||||
"MyBatis SQL导出",
|
|
||||||
"MyBatis逆向工程",
|
|
||||||
"扫描功能",
|
|
||||||
"API 接口文档导出");
|
|
||||||
|
|
||||||
private static final List<String> REQUIRED_IMAGE_NAMES = CAPTURE_SPECS.stream()
|
private static final List<String> REQUIRED_IMAGE_NAMES = CAPTURE_SPECS.stream()
|
||||||
.map(CaptureSpec::fileName)
|
.map(CaptureSpec::fileName)
|
||||||
@@ -92,10 +84,6 @@ final class NativeUiVisualAcceptanceFixture {
|
|||||||
return REQUIRED_SCENE_IMAGE_NAMES;
|
return REQUIRED_SCENE_IMAGE_NAMES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<String> navigationLabels() {
|
|
||||||
return NAVIGATION_LABELS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean captureEnabled() {
|
static boolean captureEnabled() {
|
||||||
return "true".equals(System.getProperty(ENABLED_PROPERTY));
|
return "true".equals(System.getProperty(ENABLED_PROPERTY));
|
||||||
}
|
}
|
||||||
@@ -434,7 +422,15 @@ final class NativeUiVisualAcceptanceFixture {
|
|||||||
stage.setY(desktop.getMinY() + (desktop.getHeight() - spec.stageHeight()) / 2);
|
stage.setY(desktop.getMinY() + (desktop.getHeight() - spec.stageHeight()) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<MainWindow.NavItem> navigationItems(Runnable openApiDoc) {
|
private static <T> T field(Object target, String name, Class<T> type)
|
||||||
|
throws ReflectiveOperationException {
|
||||||
|
Field field = target.getClass().getDeclaredField(name);
|
||||||
|
field.setAccessible(true);
|
||||||
|
return type.cast(field.get(target));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<MainWindow.NavItem> navigationItems(Runnable openApiDoc) {
|
||||||
return List.of(
|
return List.of(
|
||||||
nav(AppIcon.GIT_SYNC, "Git仓库同步", "同步本地仓库", "git-sync"),
|
nav(AppIcon.GIT_SYNC, "Git仓库同步", "同步本地仓库", "git-sync"),
|
||||||
nav(AppIcon.GIT_REVIEW, "Git分支评审", "评审分支变更", "git-review"),
|
nav(AppIcon.GIT_REVIEW, "Git分支评审", "评审分支变更", "git-review"),
|
||||||
@@ -452,14 +448,6 @@ final class NativeUiVisualAcceptanceFixture {
|
|||||||
return new MainWindow.NavItem(icon, name, description, () -> { }, pluginId);
|
return new MainWindow.NavItem(icon, name, description, () -> { }, pluginId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T field(Object target, String name, Class<T> type)
|
|
||||||
throws ReflectiveOperationException {
|
|
||||||
Field field = target.getClass().getDeclaredField(name);
|
|
||||||
field.setAccessible(true);
|
|
||||||
return type.cast(field.get(target));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<CaptureSpec> sceneCaptureSpecs() {
|
private static List<CaptureSpec> sceneCaptureSpecs() {
|
||||||
List<CaptureSpec> specs = new ArrayList<>(CAPTURE_SPECS);
|
List<CaptureSpec> specs = new ArrayList<>(CAPTURE_SPECS);
|
||||||
specs.add(new CaptureSpec(
|
specs.add(new CaptureSpec(
|
||||||
|
|||||||
+23
-4
@@ -1,13 +1,19 @@
|
|||||||
package com.example.workutils.system.ui;
|
package com.example.workutils.system.ui;
|
||||||
|
|
||||||
|
import com.example.workutils.system.ui.shell.NavigationRail;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.ToggleButton;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.example.workutils.system.ui.FxTestSupport.fx;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
@@ -58,8 +64,22 @@ class NativeUiVisualAcceptanceFixtureContractTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void fixtureUsesTheApprovedSevenNavigationLabelsInOrder() throws Exception {
|
void fixtureRendersTheApprovedSevenNavigationLabelsInOrder() throws Exception {
|
||||||
Method navigationLabels = method("navigationLabels");
|
List<String> renderedLabels = fx(() -> {
|
||||||
|
NavigationRail rail = new NavigationRail(
|
||||||
|
NativeUiVisualAcceptanceFixture.navigationItems(() -> { }), item -> { });
|
||||||
|
VBox root = new VBox(rail);
|
||||||
|
new Scene(root, DesignTokens.NAV_EXPANDED_WIDTH, 480);
|
||||||
|
root.applyCss();
|
||||||
|
root.layout();
|
||||||
|
|
||||||
|
VBox itemBox = assertInstanceOf(
|
||||||
|
VBox.class, rail.lookup(".navigation-rail-items"));
|
||||||
|
return itemBox.getChildren().stream()
|
||||||
|
.map(ToggleButton.class::cast)
|
||||||
|
.map(ToggleButton::getText)
|
||||||
|
.toList();
|
||||||
|
});
|
||||||
|
|
||||||
assertEquals(List.of(
|
assertEquals(List.of(
|
||||||
"Git仓库同步",
|
"Git仓库同步",
|
||||||
@@ -68,8 +88,7 @@ class NativeUiVisualAcceptanceFixtureContractTest {
|
|||||||
"MyBatis SQL导出",
|
"MyBatis SQL导出",
|
||||||
"MyBatis逆向工程",
|
"MyBatis逆向工程",
|
||||||
"扫描功能",
|
"扫描功能",
|
||||||
"API 接口文档导出"),
|
"API 接口文档导出"), renderedLabels);
|
||||||
navigationLabels.invoke(null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user