消除视觉夹具导航标签重复
This commit is contained in:
+18
-30
@@ -68,14 +68,6 @@ final class NativeUiVisualAcceptanceFixture {
|
||||
new CaptureSpec("welcome-collapsed-1024.png", View.WELCOME, false, 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<String> NAVIGATION_LABELS = List.of(
|
||||
"Git仓库同步",
|
||||
"Git分支评审",
|
||||
"文本对比",
|
||||
"MyBatis SQL导出",
|
||||
"MyBatis逆向工程",
|
||||
"扫描功能",
|
||||
"API 接口文档导出");
|
||||
|
||||
private static final List<String> REQUIRED_IMAGE_NAMES = CAPTURE_SPECS.stream()
|
||||
.map(CaptureSpec::fileName)
|
||||
@@ -92,10 +84,6 @@ final class NativeUiVisualAcceptanceFixture {
|
||||
return REQUIRED_SCENE_IMAGE_NAMES;
|
||||
}
|
||||
|
||||
static List<String> navigationLabels() {
|
||||
return NAVIGATION_LABELS;
|
||||
}
|
||||
|
||||
static boolean captureEnabled() {
|
||||
return "true".equals(System.getProperty(ENABLED_PROPERTY));
|
||||
}
|
||||
@@ -434,24 +422,6 @@ final class NativeUiVisualAcceptanceFixture {
|
||||
stage.setY(desktop.getMinY() + (desktop.getHeight() - spec.stageHeight()) / 2);
|
||||
}
|
||||
|
||||
private static List<MainWindow.NavItem> navigationItems(Runnable openApiDoc) {
|
||||
return List.of(
|
||||
nav(AppIcon.GIT_SYNC, "Git仓库同步", "同步本地仓库", "git-sync"),
|
||||
nav(AppIcon.GIT_REVIEW, "Git分支评审", "评审分支变更", "git-review"),
|
||||
nav(AppIcon.DIFF, "文本对比", "比较文本差异", "diff"),
|
||||
nav(AppIcon.SQL_EXPORT, "MyBatis SQL导出", "导出查询结果", "mybatisexport"),
|
||||
nav(AppIcon.MYBATIS_GENERATOR, "MyBatis逆向工程", "生成 MyBatis 代码",
|
||||
"mybatisgenerator"),
|
||||
nav(AppIcon.SCANNER, "扫描功能", "扫描代码关键词", "scan"),
|
||||
new MainWindow.NavItem(AppIcon.API_DOC, "API 接口文档导出",
|
||||
"导出接口文档", openApiDoc, "api-doc"));
|
||||
}
|
||||
|
||||
private static MainWindow.NavItem nav(AppIcon icon, String name,
|
||||
String description, String 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);
|
||||
@@ -460,6 +430,24 @@ final class NativeUiVisualAcceptanceFixture {
|
||||
}
|
||||
}
|
||||
|
||||
static List<MainWindow.NavItem> navigationItems(Runnable openApiDoc) {
|
||||
return List.of(
|
||||
nav(AppIcon.GIT_SYNC, "Git仓库同步", "同步本地仓库", "git-sync"),
|
||||
nav(AppIcon.GIT_REVIEW, "Git分支评审", "评审分支变更", "git-review"),
|
||||
nav(AppIcon.DIFF, "文本对比", "比较文本差异", "diff"),
|
||||
nav(AppIcon.SQL_EXPORT, "MyBatis SQL导出", "导出查询结果", "mybatisexport"),
|
||||
nav(AppIcon.MYBATIS_GENERATOR, "MyBatis逆向工程", "生成 MyBatis 代码",
|
||||
"mybatisgenerator"),
|
||||
nav(AppIcon.SCANNER, "扫描功能", "扫描代码关键词", "scan"),
|
||||
new MainWindow.NavItem(AppIcon.API_DOC, "API 接口文档导出",
|
||||
"导出接口文档", openApiDoc, "api-doc"));
|
||||
}
|
||||
|
||||
private static MainWindow.NavItem nav(AppIcon icon, String name,
|
||||
String description, String pluginId) {
|
||||
return new MainWindow.NavItem(icon, name, description, () -> { }, pluginId);
|
||||
}
|
||||
|
||||
private static List<CaptureSpec> sceneCaptureSpecs() {
|
||||
List<CaptureSpec> specs = new ArrayList<>(CAPTURE_SPECS);
|
||||
specs.add(new CaptureSpec(
|
||||
|
||||
+29
-10
@@ -1,13 +1,19 @@
|
||||
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.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
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.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@@ -58,18 +64,31 @@ class NativeUiVisualAcceptanceFixtureContractTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void fixtureUsesTheApprovedSevenNavigationLabelsInOrder() throws Exception {
|
||||
Method navigationLabels = method("navigationLabels");
|
||||
void fixtureRendersTheApprovedSevenNavigationLabelsInOrder() throws Exception {
|
||||
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(
|
||||
"Git仓库同步",
|
||||
"Git分支评审",
|
||||
"文本对比",
|
||||
"MyBatis SQL导出",
|
||||
"MyBatis逆向工程",
|
||||
"扫描功能",
|
||||
"API 接口文档导出"),
|
||||
navigationLabels.invoke(null));
|
||||
"Git仓库同步",
|
||||
"Git分支评审",
|
||||
"文本对比",
|
||||
"MyBatis SQL导出",
|
||||
"MyBatis逆向工程",
|
||||
"扫描功能",
|
||||
"API 接口文档导出"), renderedLabels);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user