Rename Angular components internal/wrapped properties

A Christmas present for pablogamito@

Test: npm run build:all && npm run test:all
Change-Id: I64c8a80b02de61874e56ea33eeb99f7a0d4afe9b
This commit is contained in:
Kean Mariotti
2022-12-21 15:01:47 +00:00
parent f597e68d34
commit 69a16f877a
3 changed files with 36 additions and 36 deletions

View File

@@ -122,22 +122,22 @@ describe("TimelineComponent", () => {
it("processes active trace input and updates selected traces", () => {
component.activeViewTraceTypes = [TraceType.SURFACE_FLINGER];
expect(component.wrappedActiveTrace).toEqual(TraceType.SURFACE_FLINGER);
expect(component.internalActiveTrace).toEqual(TraceType.SURFACE_FLINGER);
expect(component.selectedTraces).toEqual([TraceType.SURFACE_FLINGER]);
component.activeViewTraceTypes = [TraceType.SURFACE_FLINGER];
expect(component.wrappedActiveTrace).toEqual(TraceType.SURFACE_FLINGER);
expect(component.internalActiveTrace).toEqual(TraceType.SURFACE_FLINGER);
expect(component.selectedTraces).toEqual([TraceType.SURFACE_FLINGER]);
component.activeViewTraceTypes = [TraceType.TRANSACTIONS];
expect(component.wrappedActiveTrace).toEqual(TraceType.TRANSACTIONS);
expect(component.internalActiveTrace).toEqual(TraceType.TRANSACTIONS);
expect(component.selectedTraces).toEqual([
TraceType.SURFACE_FLINGER,
TraceType.TRANSACTIONS
]);
component.activeViewTraceTypes = [TraceType.WINDOW_MANAGER];
expect(component.wrappedActiveTrace).toEqual(TraceType.WINDOW_MANAGER);
expect(component.internalActiveTrace).toEqual(TraceType.WINDOW_MANAGER);
expect(component.selectedTraces).toEqual([
TraceType.SURFACE_FLINGER,
TraceType.TRANSACTIONS,
@@ -145,7 +145,7 @@ describe("TimelineComponent", () => {
]);
component.activeViewTraceTypes = [TraceType.PROTO_LOG];
expect(component.wrappedActiveTrace).toEqual(TraceType.PROTO_LOG);
expect(component.internalActiveTrace).toEqual(TraceType.PROTO_LOG);
expect(component.selectedTraces).toEqual([
TraceType.TRANSACTIONS,
TraceType.WINDOW_MANAGER,
@@ -155,15 +155,15 @@ describe("TimelineComponent", () => {
it("handles undefined active trace input", () => {
component.activeViewTraceTypes = undefined;
expect(component.wrappedActiveTrace).toBeUndefined();
expect(component.internalActiveTrace).toBeUndefined();
expect(component.selectedTraces).toEqual([]);
component.activeViewTraceTypes = [TraceType.SURFACE_FLINGER];
expect(component.wrappedActiveTrace).toEqual(TraceType.SURFACE_FLINGER);
expect(component.internalActiveTrace).toEqual(TraceType.SURFACE_FLINGER);
expect(component.selectedTraces).toEqual([TraceType.SURFACE_FLINGER]);
component.activeViewTraceTypes = undefined;
expect(component.wrappedActiveTrace).toEqual(TraceType.SURFACE_FLINGER);
expect(component.internalActiveTrace).toEqual(TraceType.SURFACE_FLINGER);
expect(component.selectedTraces).toEqual([TraceType.SURFACE_FLINGER]);
});

View File

@@ -284,10 +284,10 @@ export class TimelineComponent implements TimelineComponentDependencyInversion {
throw Error("Timeline component doesn't support viewers with dependencies length !== 1");
}
this.wrappedActiveTrace = types[0];
this.internalActiveTrace = types[0];
if (!this.selectedTraces.includes(this.wrappedActiveTrace)) {
this.selectedTraces.push(this.wrappedActiveTrace);
if (!this.selectedTraces.includes(this.internalActiveTrace)) {
this.selectedTraces.push(this.internalActiveTrace);
}
if (this.selectedTraces.length > this.MAX_SELECTED_TRACES) {
@@ -297,7 +297,7 @@ export class TimelineComponent implements TimelineComponentDependencyInversion {
this.selectedTracesFormControl.setValue(this.selectedTraces);
}
public wrappedActiveTrace: TraceType|undefined = undefined;
public internalActiveTrace: TraceType|undefined = undefined;
@Input() timelineData!: TimelineData;
@Input() availableTraces: TraceType[] = [];
@@ -404,7 +404,7 @@ export class TimelineComponent implements TimelineComponentDependencyInversion {
}
isOptionDisabled(trace: TraceType) {
if (this.wrappedActiveTrace === trace) {
if (this.internalActiveTrace === trace) {
return true;
}
@@ -440,33 +440,33 @@ export class TimelineComponent implements TimelineComponentDependencyInversion {
}
hasPrevEntry(): boolean {
if (!this.wrappedActiveTrace ||
(this.timelineData.getTimelines().get(this.wrappedActiveTrace)?.length ?? 0) === 0) {
if (!this.internalActiveTrace ||
(this.timelineData.getTimelines().get(this.internalActiveTrace)?.length ?? 0) === 0) {
return false;
}
return this.timelineData.getPreviousTimestampFor(this.wrappedActiveTrace) !== undefined;
return this.timelineData.getPreviousTimestampFor(this.internalActiveTrace) !== undefined;
}
hasNextEntry(): boolean {
if (!this.wrappedActiveTrace ||
(this.timelineData.getTimelines().get(this.wrappedActiveTrace)?.length ?? 0) === 0) {
if (!this.internalActiveTrace ||
(this.timelineData.getTimelines().get(this.internalActiveTrace)?.length ?? 0) === 0) {
return false;
}
return this.timelineData.getNextTimestampFor(this.wrappedActiveTrace) !== undefined;
return this.timelineData.getNextTimestampFor(this.internalActiveTrace) !== undefined;
}
moveToPreviousEntry() {
if (!this.wrappedActiveTrace) {
if (!this.internalActiveTrace) {
return;
}
this.timelineData.moveToPreviousTimestampFor(this.wrappedActiveTrace);
this.timelineData.moveToPreviousTimestampFor(this.internalActiveTrace);
}
moveToNextEntry() {
if (!this.wrappedActiveTrace) {
if (!this.internalActiveTrace) {
return;
}
this.timelineData.moveToNextTimestampFor(this.wrappedActiveTrace);
this.timelineData.moveToNextTimestampFor(this.internalActiveTrace);
}
humanElapsedTimeInputChange(event: Event) {

View File

@@ -99,10 +99,10 @@ import {Mapper3D} from "./mapper3d";
<div class="canvas-labels">
</div>
</div>
<div *ngIf="wrappedDisplayIds.length > 1"
<div *ngIf="internalDisplayIds.length > 1"
class="display-button-container">
<button
*ngFor="let displayId of wrappedDisplayIds"
*ngFor="let displayId of internalDisplayIds"
color="primary"
mat-raised-button
(click)="onDisplayIdChange(displayId)"
@@ -177,27 +177,27 @@ import {Mapper3D} from "./mapper3d";
export class RectsComponent implements OnInit, OnDestroy {
@Input() title = "title";
@Input() set rects(rects: Rectangle[]) {
this.wrappedRects = rects;
this.internalRects = rects;
this.drawScene();
}
@Input() set displayIds(ids: number[]) {
this.wrappedDisplayIds = ids;
if (!this.wrappedDisplayIds.includes(this.mapper3d.getCurrentDisplayId())) {
this.mapper3d.setCurrentDisplayId(this.wrappedDisplayIds[0]);
this.internalDisplayIds = ids;
if (!this.internalDisplayIds.includes(this.mapper3d.getCurrentDisplayId())) {
this.mapper3d.setCurrentDisplayId(this.internalDisplayIds[0]);
this.drawScene();
}
}
@Input() set highlightedItems(ids: string[]) {
this.wrappedHighlightedItems = ids.map(id => Number(id));
this.mapper3d.setHighlightedRectIds(this.wrappedHighlightedItems);
this.internalHighlightedItems = ids.map(id => Number(id));
this.mapper3d.setHighlightedRectIds(this.internalHighlightedItems);
this.drawScene();
}
private wrappedRects: Rectangle[] = [];
private wrappedDisplayIds: number[] = [];
private wrappedHighlightedItems: number[] = [];
private internalRects: Rectangle[] = [];
private internalDisplayIds: number[] = [];
private internalHighlightedItems: number[] = [];
private mapper3d: Mapper3D;
private canvas?: Canvas;
@@ -222,7 +222,7 @@ export class RectsComponent implements OnInit, OnDestroy {
this.canvasLabels = canvasContainer.querySelector(".canvas-labels");
this.canvas = new Canvas(this.canvasRects, this.canvasLabels!);
this.mapper3d.setCurrentDisplayId(this.wrappedDisplayIds[0] ?? 0);
this.mapper3d.setCurrentDisplayId(this.internalDisplayIds[0] ?? 0);
this.drawScene();
}
@@ -308,7 +308,7 @@ export class RectsComponent implements OnInit, OnDestroy {
// (rotation, spacing, ...) we can just update the camera and/or update the mesh positions.
// We'd probably need to get rid of the intermediate layer (Scene3D, Rect3D, ... types) and
// work directly with three.js's meshes.
this.mapper3d.setRects(this.wrappedRects);
this.mapper3d.setRects(this.internalRects);
this.canvas?.draw(this.mapper3d.computeScene());
}