Files
openidea/src/features/debugger/__tests__/memoryLayout.test.ts
T
ntbang0901 a3d1e57f3e feat(debugger): memory view for a paused JVM (#2648)
Adds a Memory tab to the Debug tool window for JVM sessions: loaded classes with instance counts and shallow sizes (with deltas between refreshes), read over the HotSpot attach listener (`GC.class_histogram`), falling back to counting reachable objects through the debugger on JDKs that cannot answer while suspended. While paused, a class's instances, an instance's fields and its referrers are listed through a JDWP link (the Kotlin adapter's path, and a jdtls bundle `java/jvm-inspect` for java-debug). Debug launches started by the IDE get `-XX:+StartAttachListener` unless the user's VM options decide otherwise (not on Windows).

New crates: ide-jdwp, ide-jvm-attach, ide-jvm-inspect. The bundled jar rebuilds byte-for-byte from build.py against the pinned JDT LS plugins.

Co-authored-by: ntbang0901 <121003585+ntbang0901@users.noreply.github.com>
2026-11-11 17:10:21 +08:00

37 lines
1.7 KiB
TypeScript

import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
// `.iconButton:disabled { opacity: 0.4 }` (src/ui/Button.module.css) outranks a bare `.rowButton`, so a
// disabled row button (program running, list outdated) would show on every row unless hidden again.
describe.each(["MemoryView", "InstancesPane"])("%s row buttons", (name) => {
const css = readFileSync(`src/features/debugger/memory/${name}.module.css`, "utf8");
it("stay hidden when disabled, outside the hovered or lead row", () => {
expect(css).toMatch(/\.row \.rowButton:disabled \{[^}]*opacity: 0;/);
});
it("show disabled ones faded on the hovered row", () => {
expect(css).toMatch(/\.row:hover \.rowButton:disabled[^{]*\{[^}]*opacity: 0\.4;/);
});
});
// The pane has a fixed height: in a short Debug tool window it squeezed the class table to nothing,
// whose header and footer then painted over the pane, and the pane's last rows fell out of view.
describe("instances pane in a short Memory view", () => {
const read = (name: string) => readFileSync(`src/features/debugger/memory/${name}.module.css`, "utf8");
it("takes at most 60% of the view", () => {
expect(read("InstancesPane")).toMatch(/\.pane \{[^}]*height: min\([^;]*, 60%\);/);
});
it("keeps the squeezed class table from painting over it", () => {
expect(read("MemoryView")).toMatch(/\.table \{[^}]*overflow: hidden;/);
});
it("shrinks before the class table, which keeps a few rows", () => {
expect(read("InstancesPane")).toMatch(/\.pane \{[^}]*flex: 0 1 auto;[^}]*min-height: calc\(/);
expect(read("MemoryView")).toMatch(/\.table \{[^}]*min-height: calc\([^;]*3 \* 22px\);/);
expect(read("MemoryView")).toMatch(/\.root \{[^}]*overflow-y: auto;/);
});
});