From c1541c1bd41aa6a5ab2aaee504f927f66fc5987b Mon Sep 17 00:00:00 2001 From: Priyanka Patel Date: Tue, 16 Aug 2022 08:33:28 +0000 Subject: [PATCH] (Rects View Review Changes) Create SF viewer. Review changes for ag/19482843 (in separate CL as requested). Bug: b/238089034 Test: npm run test:all Change-Id: I9d2f99090f2e2125271b702c8a1dc409f112b776 --- tools/winscope-ng/src/app/app.module.ts | 2 - .../components/adb_proxy.component.spec.ts | 6 +- .../src/app/components/adb_proxy.component.ts | 2 +- .../src/app/components/app.component.ts | 20 ++-- .../collect_traces.component.spec.ts | 4 +- .../components/collect_traces.component.ts | 39 +++----- .../components/trace_config.component.spec.ts | 4 +- .../app/components/trace_config.component.ts | 2 +- .../app/components/trace_view.component.ts | 15 ++- .../trace_view_header.component.spec.ts | 5 +- .../components/trace_view_header.component.ts | 33 ++----- .../upload_traces.component.spec.ts | 2 +- .../app/components/upload_traces.component.ts | 10 +- tools/winscope-ng/src/app/loaded_trace.ts | 2 +- .../winscope-ng/src/app/trace_coordinator.ts | 17 +--- tools/winscope-ng/src/app/trace_icons.ts | 2 +- tools/winscope-ng/src/app/trace_info.ts | 2 +- .../src/common/utils/bigint_utils.ts | 20 ---- tools/winscope-ng/src/styles.css | 8 ++ .../test/e2e/viewer_surface_flinger.spec.ts | 2 +- .../src/trace_collection/proxy_client.ts | 2 +- .../{canvas.service.ts => canvas_graphics.ts} | 37 ++++--- .../src/viewers/rects.component.spec.ts | 23 ++--- .../src/viewers/rects.component.ts | 97 +++++++++---------- .../rects_utils.spec.ts} | 6 +- .../rects_utils.ts} | 4 +- tools/winscope-ng/src/viewers/viewer.ts | 1 + .../viewer_surface_flinger/presenter.ts} | 46 ++++----- .../viewer_surface_flinger/ui_data.ts} | 9 +- .../viewer_surface_flinger.component.spec.ts | 6 +- .../viewer_surface_flinger.component.ts | 5 +- .../viewer_surface_flinger.ts | 14 ++- .../viewer_window_manager}/presenter.ts | 18 ++-- .../viewer_window_manager}/ui_data.ts | 0 .../viewer_window_manager.component.spec.ts | 2 +- .../viewer_window_manager.component.ts | 2 +- .../viewer_window_manager.ts | 8 +- tools/winscope-ng/tsconfig.json | 2 - 38 files changed, 208 insertions(+), 271 deletions(-) delete mode 100644 tools/winscope-ng/src/common/utils/bigint_utils.ts rename tools/winscope-ng/src/viewers/{canvas.service.ts => canvas_graphics.ts} (93%) rename tools/winscope-ng/src/{common/utils/matrix_utils.spec.ts => viewers/rects_utils.spec.ts} (89%) rename tools/winscope-ng/src/{common/utils/matrix_utils.ts => viewers/rects_utils.ts} (94%) rename tools/winscope-ng/src/{presenters/presenter_surface_flinger.ts => viewers/viewer_surface_flinger/presenter.ts} (70%) rename tools/winscope-ng/src/{ui_data/ui_data_surface_flinger.ts => viewers/viewer_surface_flinger/ui_data.ts} (91%) rename tools/winscope-ng/src/{presenters => viewers/viewer_window_manager}/presenter.ts (73%) rename tools/winscope-ng/src/{ui_data => viewers/viewer_window_manager}/ui_data.ts (100%) diff --git a/tools/winscope-ng/src/app/app.module.ts b/tools/winscope-ng/src/app/app.module.ts index 5695d5938..92c3da9d8 100644 --- a/tools/winscope-ng/src/app/app.module.ts +++ b/tools/winscope-ng/src/app/app.module.ts @@ -31,7 +31,6 @@ import { PropertiesComponent } from "viewers/properties.component"; import { RectsComponent } from "viewers/rects.component"; import { TraceViewHeaderComponent } from "./components/trace_view_header.component"; import { TraceViewComponent } from "./components/trace_view.component"; -import { CanvasService } from "viewers/canvas.service"; @NgModule({ declarations: [ @@ -70,7 +69,6 @@ import { CanvasService } from "viewers/canvas.service"; MatSliderModule, MatRadioModule ], - providers: [CanvasService], bootstrap: [AppComponent] }) export class AppModule { } diff --git a/tools/winscope-ng/src/app/components/adb_proxy.component.spec.ts b/tools/winscope-ng/src/app/components/adb_proxy.component.spec.ts index fab9a5c66..1e7187aa6 100644 --- a/tools/winscope-ng/src/app/components/adb_proxy.component.spec.ts +++ b/tools/winscope-ng/src/app/components/adb_proxy.component.spec.ts @@ -16,13 +16,13 @@ import { CommonModule } from "@angular/common"; import { ComponentFixture, TestBed } from "@angular/core/testing"; import { AdbProxyComponent } from "./adb_proxy.component"; -import { proxyClient, ProxyState } from "../../trace_collection/proxy_client"; +import { proxyClient, ProxyState } from "trace_collection/proxy_client"; import { MatIconModule } from "@angular/material/icon"; import { MatFormFieldModule } from "@angular/material/form-field"; import { MatInputModule } from "@angular/material/input"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { MatButtonModule } from "@angular/material/button"; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core"; +import { NO_ERRORS_SCHEMA } from "@angular/core"; describe("AdbProxyComponent", () => { let fixture: ComponentFixture; @@ -40,7 +40,7 @@ describe("AdbProxyComponent", () => { MatButtonModule ], declarations: [AdbProxyComponent], - schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA] + schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); fixture = TestBed.createComponent(AdbProxyComponent); component = fixture.componentInstance; diff --git a/tools/winscope-ng/src/app/components/adb_proxy.component.ts b/tools/winscope-ng/src/app/components/adb_proxy.component.ts index 70bf5f69c..2f80b5766 100644 --- a/tools/winscope-ng/src/app/components/adb_proxy.component.ts +++ b/tools/winscope-ng/src/app/components/adb_proxy.component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { Component, Input, Output, EventEmitter } from "@angular/core"; -import { proxyClient, ProxyClient, ProxyState } from "../../trace_collection/proxy_client"; +import { proxyClient, ProxyClient, ProxyState } from "trace_collection/proxy_client"; @Component({ selector: "adb-proxy", diff --git a/tools/winscope-ng/src/app/components/app.component.ts b/tools/winscope-ng/src/app/components/app.component.ts index be4f1c1d5..b854e370f 100644 --- a/tools/winscope-ng/src/app/components/app.component.ts +++ b/tools/winscope-ng/src/app/components/app.component.ts @@ -17,7 +17,7 @@ import { Component, Injector, Inject, ViewEncapsulation, Input } from "@angular/ import { createCustomElement } from "@angular/elements"; import { TraceCoordinator } from "../trace_coordinator"; import { proxyClient, ProxyState } from "trace_collection/proxy_client"; -import { PersistentStore } from "../../common/persistent_store"; +import { PersistentStore } from "common/persistent_store"; import { ViewerWindowManagerComponent } from "viewers/viewer_window_manager/viewer_window_manager.component"; import { ViewerSurfaceFlingerComponent } from "viewers/viewer_surface_flinger/viewer_surface_flinger.component"; import { TraceViewComponent } from "./trace_view.component"; @@ -36,7 +36,7 @@ import { Viewer } from "viewers/viewer"; *ngIf="dataLoaded" step="1" min="0" - [max]="traceCoordinator.getTimestamps().length -1" + [max]="this.allTimestamps.length-1" aria-label="units" [value]="currentTimestampIndex" (input)="updateCurrentTimestamp($event)" @@ -72,8 +72,9 @@ export class AppComponent { store: PersistentStore = new PersistentStore(); @Input() dataLoaded = false; viewersCreated = false; - currentTimestamp: Timestamp; + currentTimestamp?: Timestamp; currentTimestampIndex = 0; + allTimestamps: Timestamp[] = []; constructor( @Inject(Injector) injector: Injector @@ -95,6 +96,7 @@ export class AppComponent { onDataLoadedChange(dataLoaded: boolean) { if (dataLoaded && !this.viewersCreated) { + this.allTimestamps = this.traceCoordinator.getTimestamps(); this.traceCoordinator.createViewers(); this.createViewerElements(); this.currentTimestampIndex = 0; @@ -108,8 +110,10 @@ export class AppComponent { const viewersDiv = document.querySelector("div#viewers")!; viewersDiv.innerHTML = ""; + let cardCounter = 0; this.traceCoordinator.getViewers().forEach((viewer: Viewer) => { const traceView = document.createElement("trace-view"); + (traceView as any).title = viewer.getTitle(); (traceView as any).dependencies = viewer.getDependencies(); (traceView as any).showTrace = true; traceView.addEventListener("saveTraces", ($event: any) => { @@ -118,15 +122,15 @@ export class AppComponent { viewersDiv.appendChild(traceView); const traceCard = traceView.querySelector(".trace-card")!; - traceCard.id = `card-${viewer.getDependencies()}`; + traceCard.id = `card-${cardCounter}`; + (traceView as any).cardId = cardCounter; + cardCounter++; const traceCardContent = traceCard.querySelector(".trace-card-content")!; const view = viewer.getView(); (view as any).showTrace = (traceView as any).showTrace; traceCardContent.appendChild(view); }); - this.currentTimestampIndex = 0; - this.notifyCurrentTimestamp(); } updateCurrentTimestamp(event: MatSliderChange) { @@ -137,13 +141,13 @@ export class AppComponent { } public notifyCurrentTimestamp() { - this.currentTimestamp = this.traceCoordinator.getTimestamps()[this.currentTimestampIndex]; + this.currentTimestamp = this.allTimestamps[this.currentTimestampIndex]; this.traceCoordinator.notifyCurrentTimestamp(this.currentTimestamp); } public toggleTimestamp() { if (this.currentTimestampIndex===0) { - this.currentTimestampIndex = this.traceCoordinator.getTimestamps().length-1; + this.currentTimestampIndex = this.allTimestamps.length-1; } else { this.currentTimestampIndex = 0; } diff --git a/tools/winscope-ng/src/app/components/collect_traces.component.spec.ts b/tools/winscope-ng/src/app/components/collect_traces.component.spec.ts index 8a9e53de0..b021204dd 100644 --- a/tools/winscope-ng/src/app/components/collect_traces.component.spec.ts +++ b/tools/winscope-ng/src/app/components/collect_traces.component.spec.ts @@ -24,7 +24,7 @@ import { MatListModule } from "@angular/material/list"; import { MatButtonModule } from "@angular/material/button"; import { MatProgressBarModule } from "@angular/material/progress-bar"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core"; +import { NO_ERRORS_SCHEMA } from "@angular/core"; describe("CollectTracesComponent", () => { let fixture: ComponentFixture; @@ -47,7 +47,7 @@ describe("CollectTracesComponent", () => { WebAdbComponent, TraceConfigComponent, ], - schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA] + schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); fixture = TestBed.createComponent(CollectTracesComponent); component = fixture.componentInstance; diff --git a/tools/winscope-ng/src/app/components/collect_traces.component.ts b/tools/winscope-ng/src/app/components/collect_traces.component.ts index d62425ad9..c9939bb4f 100644 --- a/tools/winscope-ng/src/app/components/collect_traces.component.ts +++ b/tools/winscope-ng/src/app/components/collect_traces.component.ts @@ -13,14 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Component, Inject, Input, Output, EventEmitter, NgZone } from "@angular/core"; +import { Component, Inject, Input, Output, EventEmitter, OnInit, OnDestroy } from "@angular/core"; import { ProxyConnection } from "trace_collection/proxy_connection"; import { Connection } from "trace_collection/connection"; import { setTraces } from "trace_collection/set_traces"; -import { ProxyState } from "../../trace_collection/proxy_client"; -import { traceConfigurations, configMap, SelectionConfiguration, EnableConfiguration } from "../../trace_collection/trace_collection_utils"; +import { ProxyState } from "trace_collection/proxy_client"; +import { traceConfigurations, configMap, SelectionConfiguration, EnableConfiguration } from "trace_collection/trace_collection_utils"; import { TraceCoordinator } from "app/trace_coordinator"; -import { PersistentStore } from "../../common/persistent_store"; +import { PersistentStore } from "common/persistent_store"; @Component({ @@ -33,9 +33,9 @@ import { PersistentStore } from "../../common/persistent_store";
- + - +
@@ -116,28 +116,20 @@ import { PersistentStore } from "../../common/persistent_store"; ".mat-checkbox-checked .mat-checkbox-background {transform: scale(0.7); font-size: 10;}" ] }) -export class CollectTracesComponent { +export class CollectTracesComponent implements OnInit, OnDestroy { objectKeys = Object.keys; isAdbProxy = true; traceConfigurations = traceConfigurations; connect: Connection = new ProxyConnection(); setTraces = setTraces; - - @Input() - store: PersistentStore = new PersistentStore(); - - @Input() - traceCoordinator: TraceCoordinator; - - @Output() - traceCoordinatorChange = new EventEmitter(); - dataLoaded = false; - @Output() - dataLoadedChange = new EventEmitter(); + @Input() store!: PersistentStore; + @Input() traceCoordinator!: TraceCoordinator; - constructor(@Inject(NgZone) private ngZone: NgZone) { + @Output() dataLoadedChange = new EventEmitter(); + + ngOnInit() { if (this.isAdbProxy) { this.connect = new ProxyConnection(); } else { @@ -278,11 +270,8 @@ export class CollectTracesComponent { this.traceCoordinator.clearData(); await this.traceCoordinator.addTraces(this.connect.adbData()); - - this.ngZone.run(() => { - this.dataLoaded = true; - this.dataLoadedChange.emit(this.dataLoaded); - }); + this.dataLoaded = true; + this.dataLoadedChange.emit(this.dataLoaded); console.log("finished loading data!"); } diff --git a/tools/winscope-ng/src/app/components/trace_config.component.spec.ts b/tools/winscope-ng/src/app/components/trace_config.component.spec.ts index 858e94cb9..2a53befcb 100644 --- a/tools/winscope-ng/src/app/components/trace_config.component.spec.ts +++ b/tools/winscope-ng/src/app/components/trace_config.component.spec.ts @@ -21,7 +21,7 @@ import { MatFormFieldModule } from "@angular/material/form-field"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { MatInputModule } from "@angular/material/input"; import { MatSelectModule } from "@angular/material/select"; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core"; +import { NO_ERRORS_SCHEMA } from "@angular/core"; describe("TraceConfigComponent", () => { let fixture: ComponentFixture; @@ -39,7 +39,7 @@ describe("TraceConfigComponent", () => { BrowserAnimationsModule ], declarations: [TraceConfigComponent], - schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA] + schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); fixture = TestBed.createComponent(TraceConfigComponent); component = fixture.componentInstance; diff --git a/tools/winscope-ng/src/app/components/trace_config.component.ts b/tools/winscope-ng/src/app/components/trace_config.component.ts index 89ffd0efc..357ba5f97 100644 --- a/tools/winscope-ng/src/app/components/trace_config.component.ts +++ b/tools/winscope-ng/src/app/components/trace_config.component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { Component, Input } from "@angular/core"; -import { EnableConfiguration, SelectionConfiguration, TraceConfiguration } from "../../trace_collection/trace_collection_utils"; +import { EnableConfiguration, SelectionConfiguration, TraceConfiguration } from "trace_collection/trace_collection_utils"; @Component({ selector: "trace-config", diff --git a/tools/winscope-ng/src/app/components/trace_view.component.ts b/tools/winscope-ng/src/app/components/trace_view.component.ts index 0a5f27374..cfb56e594 100644 --- a/tools/winscope-ng/src/app/components/trace_view.component.ts +++ b/tools/winscope-ng/src/app/components/trace_view.component.ts @@ -29,8 +29,10 @@ import { TraceType } from "common/trace/trace_type"; @@ -41,14 +43,11 @@ import { TraceType } from "common/trace/trace_type"; `, }) export class TraceViewComponent { - @Input() - dependencies: TraceType[]; - - @Input() - showTrace: boolean; - - @Output() - saveTraces = new EventEmitter(); + @Input() title!: string; + @Input() dependencies!: TraceType[]; + @Input() showTrace = true; + @Input() cardId = 0; + @Output() saveTraces = new EventEmitter(); TRACE_INFO = TRACE_INFO; diff --git a/tools/winscope-ng/src/app/components/trace_view_header.component.spec.ts b/tools/winscope-ng/src/app/components/trace_view_header.component.spec.ts index f23546e2e..6a80064a1 100644 --- a/tools/winscope-ng/src/app/components/trace_view_header.component.spec.ts +++ b/tools/winscope-ng/src/app/components/trace_view_header.component.spec.ts @@ -18,7 +18,6 @@ import { ComponentFixture, TestBed } from "@angular/core/testing"; import { TraceViewHeaderComponent } from "./trace_view_header.component"; import { MatIconModule } from "@angular/material/icon"; import { MatButtonModule } from "@angular/material/button"; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from "@angular/core"; import { TraceType } from "common/trace/trace_type"; describe("TraceViewHeaderComponent", () => { @@ -33,8 +32,7 @@ describe("TraceViewHeaderComponent", () => { MatIconModule, MatButtonModule ], - declarations: [TraceViewHeaderComponent], - schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA] + declarations: [TraceViewHeaderComponent] }).compileComponents(); fixture = TestBed.createComponent(TraceViewHeaderComponent); component = fixture.componentInstance; @@ -85,6 +83,7 @@ describe("TraceViewHeaderComponent", () => { }); it("check that title is displayed", () => { + component.title = "Surface Flinger, Window Manager"; fixture.detectChanges(); const title = htmlElement.querySelector(".trace-card-title-text"); expect(title).toBeTruthy(); diff --git a/tools/winscope-ng/src/app/components/trace_view_header.component.ts b/tools/winscope-ng/src/app/components/trace_view_header.component.ts index 848550c87..a298d8507 100644 --- a/tools/winscope-ng/src/app/components/trace_view_header.component.ts +++ b/tools/winscope-ng/src/app/components/trace_view_header.component.ts @@ -33,7 +33,7 @@ import html2canvas from "html2canvas"; - {{getTitle()}} + {{title}} -