Merge "Show all displays in surface flinger trace"
This commit is contained in:
BIN
tools/winscope/src/test/fixtures/traces/elapsed_and_real_timestamp/SurfaceFlinger_multidisplay.pb
vendored
Normal file
BIN
tools/winscope/src/test/fixtures/traces/elapsed_and_real_timestamp/SurfaceFlinger_multidisplay.pb
vendored
Normal file
Binary file not shown.
@@ -38,6 +38,10 @@ class UnitTestUtils extends CommonTestUtils {
|
||||
return await UnitTestUtils.getTraceEntry('traces/elapsed_timestamp/SurfaceFlinger.pb');
|
||||
}
|
||||
|
||||
static async getMultiDisplayLayerTraceEntry(): Promise<LayerTraceEntry> {
|
||||
return await UnitTestUtils.getTraceEntry('traces/elapsed_and_real_timestamp/SurfaceFlinger_multidisplay.pb');
|
||||
}
|
||||
|
||||
static async getImeTraceEntries(): Promise<Map<TraceType, any>> {
|
||||
let surfaceFlingerEntry: LayerTraceEntry | undefined;
|
||||
{
|
||||
|
||||
@@ -114,4 +114,19 @@ describe('RectsComponent', () => {
|
||||
slider?.dispatchEvent(new MouseEvent('mousedown'));
|
||||
expect(Canvas.prototype.draw).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('draws display buttons', () => {
|
||||
component.displayIds = [0, 1, 2];
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
const displayButtonContainer = htmlElement.querySelector(".display-button-container");
|
||||
expect(displayButtonContainer).toBeTruthy();
|
||||
|
||||
const buttons = Array.from(displayButtonContainer?.querySelectorAll('button') ?? []);
|
||||
expect(buttons.length).toBe(3);
|
||||
|
||||
const buttonValues = buttons.map((it) => it.textContent?.trim());
|
||||
expect(buttonValues).toEqual(["0", "1", "2"]);
|
||||
})
|
||||
});
|
||||
|
||||
@@ -121,7 +121,8 @@ export class Presenter {
|
||||
};
|
||||
return rect;
|
||||
}) ?? [];
|
||||
this.displayIds = [];
|
||||
this.displayIds = this.entry.displays.map((it: any) => it.layerStackId)
|
||||
this.displayIds.sort();
|
||||
const rects = this.getLayersForRectsView()
|
||||
.sort(this.compareLayerZ)
|
||||
.map((it: any) => {
|
||||
@@ -136,6 +137,7 @@ export class Presenter {
|
||||
};
|
||||
return rect;
|
||||
});
|
||||
|
||||
return this.rectsToUiData(rects.concat(displayRects));
|
||||
}
|
||||
|
||||
|
||||
@@ -213,4 +213,20 @@ describe('PresenterSurfaceFlinger', () => {
|
||||
) ?? [];
|
||||
expect(nonTerminalChildren.length).toEqual(3);
|
||||
});
|
||||
|
||||
it('handles displays with no visible layers', async () => {
|
||||
presenter.notifyCurrentTraceEntries(await getEntriesWithMultiDisplaySfTrace());
|
||||
expect(uiData.displayIds.length).toEqual(5);
|
||||
// we want the ids to be sorted
|
||||
expect(uiData.displayIds).toEqual([0,2,3,4,5]);
|
||||
});
|
||||
|
||||
async function getEntriesWithMultiDisplaySfTrace(): Promise<Map<TraceType, any>> {
|
||||
const entries = new Map<TraceType, any>();
|
||||
const entry: LayerTraceEntry = await UnitTestUtils.getMultiDisplayLayerTraceEntry();
|
||||
|
||||
entries.set(TraceType.SURFACE_FLINGER, [entry, null]);
|
||||
|
||||
return entries;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -131,6 +131,7 @@ export class Presenter {
|
||||
}
|
||||
return rect;
|
||||
}) ?? [];
|
||||
this.displayIds.sort();
|
||||
return this.rectsToUiData(rects.concat(displayRects));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user