Skip to content

Commit db6563f

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
[docs] Add a screenshot test for LMI and remove it from component docs
The component doc for the LMI is very likely never looked up. Instead, just add a screenshot test. Bug: 414332459 Change-Id: I3030d69e0f774e5224f77b84d838d128938042db Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7117244 Reviewed-by: Simon Zünd <[email protected]> Commit-Queue: Simon Zünd <[email protected]> Auto-Submit: Kim-Anh Tran <[email protected]>
1 parent 2e93ad7 commit db6563f

File tree

6 files changed

+62
-94
lines changed

6 files changed

+62
-94
lines changed

front_end/panels/linear_memory_inspector/components/LinearMemoryInspector.test.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import {
6+
assertScreenshot,
67
renderElementIntoDOM,
78
} from '../../../testing/DOMHelpers.js';
89
import {describeWithLocale} from '../../../testing/LocaleHelpers.js';
@@ -15,6 +16,67 @@ import * as LinearMemoryInspectorComponents from './components.js';
1516

1617
const LinearMemoryInspector = LinearMemoryInspectorComponents.LinearMemoryInspector.LinearMemoryInspector;
1718

19+
describeWithLocale('LinearMemoryInspector', () => {
20+
it('renders the inspector', async () => {
21+
const target = document.createElement('div');
22+
target.style.width = 'var(--sys-size-40)';
23+
target.style.height = 'var(--sys-size-30)';
24+
renderElementIntoDOM(target);
25+
const array = [];
26+
const string = 'Hello this is a string from the memory buffer!';
27+
28+
for (let i = 0; i < string.length; ++i) {
29+
array.push(string.charCodeAt(i));
30+
}
31+
32+
for (let i = -1000; i < 1000; ++i) {
33+
array.push(i);
34+
}
35+
36+
const memory = new Uint8Array(array);
37+
const valueTypes = new Set([
38+
LinearMemoryInspectorComponents.ValueInterpreterDisplayUtils.ValueType.FLOAT32,
39+
LinearMemoryInspectorComponents.ValueInterpreterDisplayUtils.ValueType.INT32,
40+
LinearMemoryInspectorComponents.ValueInterpreterDisplayUtils.ValueType.POINTER32
41+
]);
42+
const valueTypeModes = new Map();
43+
44+
LinearMemoryInspectorComponents.LinearMemoryInspector.DEFAULT_VIEW(
45+
{
46+
memory: new Uint8Array(memory),
47+
address: 0,
48+
memoryOffset: 0,
49+
valueTypes,
50+
outerMemoryLength: memory.length,
51+
valueTypeModes,
52+
endianness: LinearMemoryInspectorComponents.ValueInterpreterDisplayUtils.Endianness.LITTLE,
53+
highlightInfo: undefined,
54+
hideValueInspector: false,
55+
currentNavigatorMode: LinearMemoryInspectorComponents.LinearMemoryNavigator.Mode.SUBMITTED,
56+
currentNavigatorAddressLine: '0',
57+
canGoBackInHistory: false,
58+
canGoForwardInHistory: false,
59+
onRefreshRequest: () => {},
60+
onAddressChange: () => {},
61+
onNavigatePage: () => {},
62+
onNavigateHistory: () => false,
63+
onJumpToAddress: () => {},
64+
onDeleteMemoryHighlight: () => {},
65+
onByteSelected: () => {},
66+
onResize: () => {},
67+
onValueTypeToggled: () => {},
68+
onValueTypeModeChanged: () => {},
69+
onEndiannessChanged: () => {},
70+
memorySlice: new Uint8Array(memory),
71+
viewerStart: 0,
72+
},
73+
{},
74+
target,
75+
);
76+
await assertScreenshot('linear_memory_inspector/lmi.png');
77+
});
78+
});
79+
1880
describeWithLocale('LinearMemoryInspector', () => {
1981
let component: LinearMemoryInspectorComponents.LinearMemoryInspector.LinearMemoryInspector;
2082
let view: ViewFunctionStub<typeof LinearMemoryInspector>;

front_end/ui/components/docs/BUILD.gn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ group("docs") {
1717
"./expandable_list",
1818
"./input",
1919
"./legacy_color_invert",
20-
"./linear_memory_inspector",
2120
"./linkifier",
2221
"./markdown_image",
2322
"./markdown_link",

front_end/ui/components/docs/linear_memory_inspector/BUILD.gn

Lines changed: 0 additions & 23 deletions
This file was deleted.

front_end/ui/components/docs/linear_memory_inspector/basic.html

Lines changed: 0 additions & 26 deletions
This file was deleted.

front_end/ui/components/docs/linear_memory_inspector/basic.ts

Lines changed: 0 additions & 44 deletions
This file was deleted.
54 KB
Loading

0 commit comments

Comments
 (0)