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}} -