From 70c6fb8c881d80511abd15e6907ccaa3c62975d6 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Wed, 31 May 2023 09:41:07 +0000 Subject: [PATCH 1/5] Add pre-upload hook to run Winscope tests Test: make a change and repo upload -c . Fixes: 282179210 Change-Id: I70fdf3f17f8d539d00e42e528d1c7d4091696372 --- PREUPLOAD.cfg | 8 ++++++++ tools/winscope/hooks/pre-upload | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 PREUPLOAD.cfg create mode 100755 tools/winscope/hooks/pre-upload diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg new file mode 100644 index 000000000..60ec99db1 --- /dev/null +++ b/PREUPLOAD.cfg @@ -0,0 +1,8 @@ +# Per-project `repo upload` hook settings. +# https://android.googlesource.com/platform/tools/repohooks + +[Options] +ignore_merged_commits = true + +[Hook Scripts] +winscope = ./tools/winscope/hooks/pre-upload ${PREUPLOAD_FILES} diff --git a/tools/winscope/hooks/pre-upload b/tools/winscope/hooks/pre-upload new file mode 100755 index 000000000..bd9c1be69 --- /dev/null +++ b/tools/winscope/hooks/pre-upload @@ -0,0 +1,19 @@ +#!/bin/sh + +WINSCOPE_SRC_PATTERN="tools/winscope/" + +match=false +for file in "$@" +do + if echo $file | grep --quiet "$WINSCOPE_SRC_PATTERN" + then + match=true + fi +done + +# If there are changes to winscope files and npm is installed +if $match && (which node > /dev/null) +then + echo "Running winscope presubmit tests..." + npm run test:presubmit --prefix $WINSCOPE_SRC_PATTERN +fi From 9336f610f0b451a18f89330daa73e2bee14adae0 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Thu, 1 Jun 2023 16:49:33 +0000 Subject: [PATCH 2/5] Add CUJ trace parser to Winscope Bug: 265791272 Test: npm run test:all Change-Id: Ibb62236c405ab44caf94c9ac66ef34cbef4a0111 --- tools/winscope/src/app/trace_info.ts | 7 ++ tools/winscope/src/app/trace_pipeline.ts | 12 ++- tools/winscope/src/parsers/abstract_parser.ts | 4 +- tools/winscope/src/parsers/parser_eventlog.ts | 2 +- .../src/parsers/traces_parser_cujs.ts | 90 +++++++++++++++++++ .../src/parsers/traces_parser_cujs_test.ts | 66 ++++++++++++++ tools/winscope/src/trace/flickerlib/common.js | 4 + tools/winscope/src/trace/trace_type.ts | 4 +- 8 files changed, 182 insertions(+), 7 deletions(-) create mode 100644 tools/winscope/src/parsers/traces_parser_cujs.ts create mode 100644 tools/winscope/src/parsers/traces_parser_cujs_test.ts diff --git a/tools/winscope/src/app/trace_info.ts b/tools/winscope/src/app/trace_info.ts index 5cad268bd..af238bd5d 100644 --- a/tools/winscope/src/app/trace_info.ts +++ b/tools/winscope/src/app/trace_info.ts @@ -30,6 +30,7 @@ const TAG_ICON = 'details'; const TRACE_ERROR_ICON = 'warning'; const EVENT_LOG_ICON = 'description'; const TRANSITION_ICON = 'animation'; +const CUJ_ICON = 'label'; interface TraceInfoMap { [key: number]: { @@ -161,4 +162,10 @@ export const TRACE_INFO: TraceInfoMap = { color: '#EC407A', downloadArchiveDir: 'transition', }, + [TraceType.CUJS]: { + name: 'Cujs', + icon: CUJ_ICON, + color: '#EC407A', + downloadArchiveDir: 'eventlog', + }, }; diff --git a/tools/winscope/src/app/trace_pipeline.ts b/tools/winscope/src/app/trace_pipeline.ts index 8ab16b70f..8a9a472c0 100644 --- a/tools/winscope/src/app/trace_pipeline.ts +++ b/tools/winscope/src/app/trace_pipeline.ts @@ -16,6 +16,7 @@ import {FunctionUtils, OnProgressUpdateType} from 'common/function_utils'; import {ParserError, ParserFactory} from 'parsers/parser_factory'; +import {TracesParserCujs} from 'parsers/traces_parser_cujs'; import {TracesParserTransitions} from 'parsers/traces_parser_transitions'; import {FrameMapper} from 'trace/frame_mapper'; import {LoadedTrace} from 'trace/loaded_trace'; @@ -43,9 +44,14 @@ class TracePipeline { ); this.parsers = parsers.map((it) => it.parser); - const tracesParser = new TracesParserTransitions(this.parsers); - if (tracesParser.canProvideEntries()) { - this.parsers.push(tracesParser); + const tracesParsers = [ + new TracesParserTransitions(this.parsers), + new TracesParserCujs(this.parsers), + ]; + for (const tracesParser of tracesParsers) { + if (tracesParser.canProvideEntries()) { + this.parsers.push(tracesParser); + } } for (const parser of parsers) { diff --git a/tools/winscope/src/parsers/abstract_parser.ts b/tools/winscope/src/parsers/abstract_parser.ts index 91e2dea72..60637423b 100644 --- a/tools/winscope/src/parsers/abstract_parser.ts +++ b/tools/winscope/src/parsers/abstract_parser.ts @@ -20,7 +20,7 @@ import {Timestamp, TimestampType} from 'trace/timestamp'; import {TraceFile} from 'trace/trace_file'; import {TraceType} from 'trace/trace_type'; -abstract class AbstractParser implements Parser { +abstract class AbstractParser implements Parser { protected traceFile: TraceFile; protected decodedEntries: any[] = []; private timestamps: Map = new Map(); @@ -78,7 +78,7 @@ abstract class AbstractParser implements Parser { return this.timestamps.get(type); } - getEntry(index: number, timestampType: TimestampType): object { + getEntry(index: number, timestampType: TimestampType): T { return this.processDecodedEntry(index, timestampType, this.decodedEntries[index]); } diff --git a/tools/winscope/src/parsers/parser_eventlog.ts b/tools/winscope/src/parsers/parser_eventlog.ts index 629c9435f..902e80c49 100644 --- a/tools/winscope/src/parsers/parser_eventlog.ts +++ b/tools/winscope/src/parsers/parser_eventlog.ts @@ -19,7 +19,7 @@ import {RealTimestamp, Timestamp, TimestampType} from 'trace/timestamp'; import {TraceType} from 'trace/trace_type'; import {AbstractParser} from './abstract_parser'; -class ParserEventLog extends AbstractParser { +class ParserEventLog extends AbstractParser { override getTraceType(): TraceType { return TraceType.EVENT_LOG; } diff --git a/tools/winscope/src/parsers/traces_parser_cujs.ts b/tools/winscope/src/parsers/traces_parser_cujs.ts new file mode 100644 index 000000000..cd82eed5e --- /dev/null +++ b/tools/winscope/src/parsers/traces_parser_cujs.ts @@ -0,0 +1,90 @@ +/* + * Copyright 2023, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {Cuj, CujTrace, EventLog, Transition} from 'trace/flickerlib/common'; +import {Parser} from 'trace/parser'; +import {Timestamp, TimestampType} from 'trace/timestamp'; +import {TraceType} from 'trace/trace_type'; +import {AbstractTracesParser} from './abstract_traces_parser'; +import {ParserEventLog} from './parser_eventlog'; + +export class TracesParserCujs extends AbstractTracesParser { + private readonly eventLogTrace: ParserEventLog | undefined; + private readonly descriptors: string[]; + + constructor(parsers: Array>) { + super(parsers); + + const eventlogTraces = this.parsers.filter((it) => it.getTraceType() === TraceType.EVENT_LOG); + if (eventlogTraces.length > 0) { + this.eventLogTrace = eventlogTraces[0] as ParserEventLog; + } + + if (this.eventLogTrace !== undefined) { + this.descriptors = this.eventLogTrace.getDescriptors(); + } else { + this.descriptors = []; + } + } + + override canProvideEntries(): boolean { + return this.eventLogTrace !== undefined; + } + + getLengthEntries(): number { + return this.getDecodedEntries().length; + } + + getEntry(index: number, timestampType: TimestampType): Transition { + return this.getDecodedEntries()[index]; + } + + private cujTrace: CujTrace | undefined; + getDecodedEntries(): Cuj[] { + if (this.eventLogTrace === undefined) { + throw new Error('eventLogTrace not defined'); + } + + if (this.cujTrace === undefined) { + const events: Event[] = []; + + for (let i = 0; i < this.eventLogTrace.getLengthEntries(); i++) { + events.push(this.eventLogTrace.getEntry(i, TimestampType.REAL)); + } + + this.cujTrace = new EventLog(events).cujTrace; + } + + return this.cujTrace.entries; + } + + override getDescriptors(): string[] { + return this.descriptors; + } + + getTraceType(): TraceType { + return TraceType.CUJS; + } + + override getTimestamp(type: TimestampType, transition: Transition): undefined | Timestamp { + if (type === TimestampType.ELAPSED) { + return new Timestamp(type, BigInt(transition.timestamp.elapsedNanos.toString())); + } else if (type === TimestampType.REAL) { + return new Timestamp(type, BigInt(transition.timestamp.unixNanos.toString())); + } + return undefined; + } +} diff --git a/tools/winscope/src/parsers/traces_parser_cujs_test.ts b/tools/winscope/src/parsers/traces_parser_cujs_test.ts new file mode 100644 index 000000000..41b0997af --- /dev/null +++ b/tools/winscope/src/parsers/traces_parser_cujs_test.ts @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {assertDefined} from 'common/assert_utils'; +import {UnitTestUtils} from 'test/unit/utils'; +import {Cuj} from 'trace/flickerlib/common'; +import {Parser} from 'trace/parser'; +import {Timestamp, TimestampType} from 'trace/timestamp'; +import {TraceType} from 'trace/trace_type'; +import {TracesParserCujs} from './traces_parser_cujs'; + +describe('ParserCujs', () => { + let parser: Parser; + + beforeAll(async () => { + const eventLogParser = assertDefined( + await UnitTestUtils.getParser('traces/eventlog.winscope') + ) as Parser; + + parser = new TracesParserCujs([eventLogParser]); + }); + + it('has expected trace type', () => { + expect(parser.getTraceType()).toEqual(TraceType.CUJS); + }); + + it('provides elapsed timestamps', () => { + const timestamps = parser.getTimestamps(TimestampType.ELAPSED)!; + + expect(timestamps.length).toEqual(16); + + const expected = [ + new Timestamp(TimestampType.ELAPSED, 2661012770462n), + new Timestamp(TimestampType.ELAPSED, 2661012874914n), + new Timestamp(TimestampType.ELAPSED, 2661012903966n), + ]; + expect(timestamps.slice(0, 3)).toEqual(expected); + }); + + it('provides real timestamps', () => { + const expected = [ + new Timestamp(TimestampType.REAL, 1681207048025446000n), + new Timestamp(TimestampType.REAL, 1681207048025551000n), + new Timestamp(TimestampType.REAL, 1681207048025580000n), + ]; + + const timestamps = parser.getTimestamps(TimestampType.REAL)!; + + expect(timestamps.length).toEqual(16); + + expect(timestamps.slice(0, 3)).toEqual(expected); + }); +}); diff --git a/tools/winscope/src/trace/flickerlib/common.js b/tools/winscope/src/trace/flickerlib/common.js index 7cce4678d..278e26bb0 100644 --- a/tools/winscope/src/trace/flickerlib/common.js +++ b/tools/winscope/src/trace/flickerlib/common.js @@ -62,6 +62,8 @@ const Event = require('flicker').android.tools.common.traces.events.Event; const FlickerEvent = require('flicker').android.tools.common.traces.events.FlickerEvent; const FocusEvent = require('flicker').android.tools.common.traces.events.FocusEvent; const EventLogParser = require('flicker').android.tools.common.parsers.events.EventLogParser; +const CujTrace = require('flicker').android.tools.common.parsers.events.CujTrace; +const Cuj = require('flicker').android.tools.common.parsers.events.Cuj; // Transitions const Transition = require('flicker').android.tools.common.traces.wm.Transition; @@ -313,6 +315,8 @@ export { FlickerEvent, FocusEvent, EventLogParser, + CujTrace, + Cuj, // Transitions Transition, TransitionType, diff --git a/tools/winscope/src/trace/trace_type.ts b/tools/winscope/src/trace/trace_type.ts index 9d1277f51..7264af70a 100644 --- a/tools/winscope/src/trace/trace_type.ts +++ b/tools/winscope/src/trace/trace_type.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {Event, Transition} from 'trace/flickerlib/common'; +import {Cuj, Event, Transition} from 'trace/flickerlib/common'; import {LayerTraceEntry} from './flickerlib/layers/LayerTraceEntry'; import {WindowManagerState} from './flickerlib/windows/WindowManagerState'; import {LogMessage} from './protolog'; @@ -38,6 +38,7 @@ export enum TraceType { WM_TRANSITION, SHELL_TRANSITION, TRANSITION, + CUJS, TAG, ERROR, TEST_TRACE_STRING, @@ -63,6 +64,7 @@ export interface TraceEntryTypeMap { [TraceType.WM_TRANSITION]: object; [TraceType.SHELL_TRANSITION]: object; [TraceType.TRANSITION]: Transition; + [TraceType.CUJS]: Cuj; [TraceType.TAG]: object; [TraceType.ERROR]: object; [TraceType.TEST_TRACE_STRING]: string; From bc966c455c4926e8d835c09a8f4240e049fce048 Mon Sep 17 00:00:00 2001 From: Kean Mariotti Date: Tue, 30 May 2023 20:11:06 +0000 Subject: [PATCH 3/5] Optimize bugreport loading Fix: b/269342535 Test: npm run test:all Change-Id: I89e03fff08fe1c7e7169a6eeb08efeda04d098d0 --- .../abt_chrome_extension_protocol.ts | 7 +- tools/winscope/src/app/mediator.ts | 4 +- tools/winscope/src/app/trace_pipeline.ts | 31 ++++++++ tools/winscope/src/app/trace_pipeline_test.ts | 68 ++++++++++++++++++ tools/winscope/src/common/file_utils.ts | 3 +- tools/winscope/src/common/time_utils.ts | 1 - tools/winscope/src/test/common/file_impl.ts | 6 +- tools/winscope/src/test/common/utils.ts | 9 ++- ...ta-UPB2.230407.019-2023-05-30-14-33-48.txt | 6 ++ .../bugreports/bugreport_stripped.zip | Bin 1035771 -> 1035794 bytes .../test/fixtures/bugreports/main_entry.txt | 1 + tools/winscope/src/trace/trace_file.ts | 4 +- 12 files changed, 127 insertions(+), 13 deletions(-) create mode 100644 tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt create mode 100644 tools/winscope/src/test/fixtures/bugreports/main_entry.txt diff --git a/tools/winscope/src/abt_chrome_extension/abt_chrome_extension_protocol.ts b/tools/winscope/src/abt_chrome_extension/abt_chrome_extension_protocol.ts index a8aba832f..787cc2eab 100644 --- a/tools/winscope/src/abt_chrome_extension/abt_chrome_extension_protocol.ts +++ b/tools/winscope/src/abt_chrome_extension/abt_chrome_extension_protocol.ts @@ -26,14 +26,15 @@ export class AbtChromeExtensionProtocol implements BuganizerAttachmentsDownloadE static readonly ABT_EXTENSION_ID = 'mbbaofdfoekifkfpgehgffcpagbbjkmj'; private onAttachmentsDownloadStart: OnBuganizerAttachmentsDownloadStart = FunctionUtils.DO_NOTHING; - private onttachmentsDownloaded: OnBuganizerAttachmentsDownloaded = FunctionUtils.DO_NOTHING_ASYNC; + private onAttachmentsDownloaded: OnBuganizerAttachmentsDownloaded = + FunctionUtils.DO_NOTHING_ASYNC; setOnBuganizerAttachmentsDownloadStart(callback: OnBuganizerAttachmentsDownloadStart) { this.onAttachmentsDownloadStart = callback; } setOnBuganizerAttachmentsDownloaded(callback: OnBuganizerAttachmentsDownloaded) { - this.onttachmentsDownloaded = callback; + this.onAttachmentsDownloaded = callback; } run() { @@ -83,7 +84,7 @@ export class AbtChromeExtensionProtocol implements BuganizerAttachmentsDownloadE }); const files = await Promise.all(filesBlobPromises); - await this.onttachmentsDownloaded(files); + await this.onAttachmentsDownloaded(files); } private isOpenBuganizerResponseMessage( diff --git a/tools/winscope/src/app/mediator.ts b/tools/winscope/src/app/mediator.ts index 3544a2cd6..60ee7eab8 100644 --- a/tools/winscope/src/app/mediator.ts +++ b/tools/winscope/src/app/mediator.ts @@ -83,7 +83,7 @@ export class Mediator { } ); - this.crossToolProtocol.setOnTimestampReceived(async (timestamp: Timestamp) => { + this.crossToolProtocol.setOnTimestampReceived((timestamp: Timestamp) => { this.onRemoteTimestampReceived(timestamp); }); @@ -203,7 +203,7 @@ export class Mediator { private async processRemoteFilesReceived(files: File[]) { this.resetAppToInitialState(); - this.processFiles(files); + await this.processFiles(files); } private async processFiles(files: File[]) { diff --git a/tools/winscope/src/app/trace_pipeline.ts b/tools/winscope/src/app/trace_pipeline.ts index 8ab16b70f..cad4c6120 100644 --- a/tools/winscope/src/app/trace_pipeline.ts +++ b/tools/winscope/src/app/trace_pipeline.ts @@ -37,6 +37,7 @@ class TracePipeline { traceFiles: TraceFile[], onLoadProgressUpdate: OnProgressUpdateType = FunctionUtils.DO_NOTHING ): Promise { + traceFiles = await this.filterBugreportFilesIfNeeded(traceFiles); const [parsers, parserErrors] = await this.parserFactory.createParsers( traceFiles, onLoadProgressUpdate @@ -111,6 +112,36 @@ class TracePipeline { this.files = new Map(); } + private async filterBugreportFilesIfNeeded(files: TraceFile[]): Promise { + const bugreportMainEntry = files.find((file) => file.file.name === 'main_entry.txt'); + if (!bugreportMainEntry) { + return files; + } + + const bugreportName = (await bugreportMainEntry.file.text()).trim(); + const isBugreport = files.find((file) => file.file.name === bugreportName) !== undefined; + if (!isBugreport) { + return files; + } + + const BUGREPORT_TRACE_DIRS = ['FS/data/misc/wmtrace/', 'FS/data/misc/perfetto-traces/']; + const isFileWithinBugreportTraceDir = (file: TraceFile) => { + for (const traceDir of BUGREPORT_TRACE_DIRS) { + if (file.file.name.startsWith(traceDir)) { + return true; + } + } + return false; + }; + + const fileBelongsToBugreport = (file: TraceFile) => + file.parentArchive === bugreportMainEntry.parentArchive; + + return files.filter((file) => { + return isFileWithinBugreportTraceDir(file) || !fileBelongsToBugreport(file); + }); + } + private getCommonTimestampType(): TimestampType { if (this.commonTimestampType !== undefined) { return this.commonTimestampType; diff --git a/tools/winscope/src/app/trace_pipeline_test.ts b/tools/winscope/src/app/trace_pipeline_test.ts index 20e01a07c..46c670177 100644 --- a/tools/winscope/src/app/trace_pipeline_test.ts +++ b/tools/winscope/src/app/trace_pipeline_test.ts @@ -39,6 +39,74 @@ describe('TracePipeline', () => { expect(traceEntries.get(TraceType.SURFACE_FLINGER)?.length).toBeGreaterThan(0); }); + it('can load bugreport and ignores non-trace dirs', async () => { + expect(tracePipeline.getLoadedTraces().length).toEqual(0); + + // Could be any file, we just need an instance of File to be used as a fake bugreport archive + const bugreportArchive = await UnitTestUtils.getFixtureFile( + 'bugreports/bugreport_stripped.zip' + ); + + const bugreportFiles = [ + new TraceFile( + await UnitTestUtils.getFixtureFile('bugreports/main_entry.txt', 'main_entry.txt'), + bugreportArchive + ), + new TraceFile( + await UnitTestUtils.getFixtureFile( + 'bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt', + 'bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt' + ), + bugreportArchive + ), + new TraceFile( + await UnitTestUtils.getFixtureFile( + 'traces/elapsed_and_real_timestamp/SurfaceFlinger.pb', + 'FS/data/misc/wmtrace/surface_flinger.bp' + ), + bugreportArchive + ), + new TraceFile( + await UnitTestUtils.getFixtureFile( + 'traces/elapsed_and_real_timestamp/Transactions.pb', + 'FS/data/misc/wmtrace/transactions.bp' + ), + bugreportArchive + ), + new TraceFile( + await UnitTestUtils.getFixtureFile( + 'traces/elapsed_and_real_timestamp/WindowManager.pb', + 'FS/data/misc/ignored-dir/window_manager.bp' + ), + bugreportArchive + ), + ]; + + // Corner case: + // A plain trace file is loaded along the bugreport -> trace file must not be ignored + // + // Note: + // The even weirder corner case where two bugreports are loaded at the same time is + // currently not properly handled. + const plainTraceFile = new TraceFile( + await UnitTestUtils.getFixtureFile( + 'traces/elapsed_and_real_timestamp/InputMethodClients.pb', + 'would-be-ignored-if-was-part-of-bugreport/input_method_clients.pb' + ) + ); + + const mergedFiles = bugreportFiles.concat([plainTraceFile]); + const errors = await tracePipeline.loadTraceFiles(mergedFiles); + expect(errors.length).toEqual(0); + tracePipeline.buildTraces(); + const traces = tracePipeline.getTraces(); + + expect(traces.getTrace(TraceType.SURFACE_FLINGER)).toBeDefined(); + expect(traces.getTrace(TraceType.TRANSACTIONS)).toBeDefined(); + expect(traces.getTrace(TraceType.WINDOW_MANAGER)).toBeUndefined(); // ignored + expect(traces.getTrace(TraceType.INPUT_METHOD_CLIENTS)).toBeDefined(); + }); + it('is robust to invalid trace files', async () => { const invalidTraceFiles = [ new TraceFile(await UnitTestUtils.getFixtureFile('winscope_homepage.png')), diff --git a/tools/winscope/src/common/file_utils.ts b/tools/winscope/src/common/file_utils.ts index 447e043ad..ac2b688a7 100644 --- a/tools/winscope/src/common/file_utils.ts +++ b/tools/winscope/src/common/file_utils.ts @@ -61,9 +61,8 @@ class FileUtils { // Ignore directories continue; } else { - const name = FileUtils.removeDirFromFileName(filename); const fileBlob = await file.async('blob'); - const unzippedFile = new File([fileBlob], name); + const unzippedFile = new File([fileBlob], filename); unzippedFiles.push(unzippedFile); } diff --git a/tools/winscope/src/common/time_utils.ts b/tools/winscope/src/common/time_utils.ts index 876c3c1e8..42d6cf109 100644 --- a/tools/winscope/src/common/time_utils.ts +++ b/tools/winscope/src/common/time_utils.ts @@ -128,7 +128,6 @@ export class TimeUtils { } static formattedKotlinTimestamp(time: any, timestampType: TimestampType): string { - console.log('time', time); if (timestampType === TimestampType.ELAPSED) { return TimeUtils.format(new ElapsedTimestamp(BigInt(time.elapsedNanos.toString()))); } diff --git a/tools/winscope/src/test/common/file_impl.ts b/tools/winscope/src/test/common/file_impl.ts index 8ad842bcf..315bbe1b4 100644 --- a/tools/winscope/src/test/common/file_impl.ts +++ b/tools/winscope/src/test/common/file_impl.ts @@ -46,7 +46,11 @@ class FileImpl { } text(): Promise { - throw new Error('Not implemented!'); + const utf8Decoder = new TextDecoder(); + const text = utf8Decoder.decode(this.buffer); + return new Promise((resolve) => { + resolve(text); + }); } } diff --git a/tools/winscope/src/test/common/utils.ts b/tools/winscope/src/test/common/utils.ts index d7f1e8853..8c81a6394 100644 --- a/tools/winscope/src/test/common/utils.ts +++ b/tools/winscope/src/test/common/utils.ts @@ -18,9 +18,12 @@ import * as path from 'path'; import {FileImpl} from './file_impl'; class CommonTestUtils { - static async getFixtureFile(filename: string): Promise { - const buffer = CommonTestUtils.loadFixture(filename); - return new FileImpl(buffer, filename) as unknown as File; + static async getFixtureFile( + srcFilename: string, + dstFilename: string = srcFilename + ): Promise { + const buffer = CommonTestUtils.loadFixture(srcFilename); + return new FileImpl(buffer, dstFilename) as unknown as File; } static loadFixture(filename: string): ArrayBuffer { diff --git a/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt b/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt new file mode 100644 index 000000000..c02add504 --- /dev/null +++ b/tools/winscope/src/test/fixtures/bugreports/bugreport-codename_beta-UPB2.230407.019-2023-05-30-14-33-48.txt @@ -0,0 +1,6 @@ +======================================================== +== dumpstate: 2023-05-30 14:33:48 +======================================================== + +# ORIGINAL CONTENTS REMOVED TO AVOID INFORMATION LEAKS + diff --git a/tools/winscope/src/test/fixtures/bugreports/bugreport_stripped.zip b/tools/winscope/src/test/fixtures/bugreports/bugreport_stripped.zip index 36a2e7300ec5f7b3ec60a0ee44ebd6f0fc4f9bcc..c91a59532348846784ae4037148b755cbbdb0934 100644 GIT binary patch delta 1538 zcmbtUeN02%|3gNZBzGb*sEBr6mwGId*} zG16@+Alohz4aq<|#Zj`xRHw6Xe5|bP)IW?76FYo zch5cN-rqUr{xMke`kO`LTc~t|R-iRUoHfEbziDojAap#7M(fFs^+}wkmeQ1_GO{!j zv-zCCAAU=D2Fnbz>TbU6=4|O13ZW+$gbb0j#5#qGJ=J>#sAUe`zxC)Ezs<9%Qr#hs zI3U_-tR!>wN$LGhPhN_0g1F)C?qgO8Km!qtMn62#F$&njliUJ%HhH9-V3hk72=eQMsWWY+mDsPUPUHx!MOsZdA zaMpm9h$f8-Y^9x%DZ~*vU*X&D;0nKf2>wN|=ssj=Xl^l?TWsymX>EsXHIF4BrXs!b zpoosc$%v9obYUc`Hc_at4D>a;q&kSlE03OPG? zouJe6!Zuzn@Hx4>Ue71y=83))eZ^|>Y?u`&L{r4#>~nw}4`vGtqT%?CzK-N;BI>(7kT zZQ@j%>R0u^O?Bo*?u}Yi=Hq8;t$ocGdDySR-s}39p3&h>L8&D634FhI@e1BYf$F;_aT|O-n#3BqvyAK$ zI|ABALGDcAJeV*{!Gy0OK2ZwXC6Sxi8{zt^0tw{zDXa$`+DSt%PKbOx455=W)DNU; z8gmhs{gx?#yf^{AwO4T#efe6DU{er{nvw=q^WE_&SG9_rHIB#9grwD zP?Uju;m1d*tz_>EE`*S;%)kzgj1l(?HfD?c5wCj4p7>>>hwnWqS delta 1664 zcmaJ>ZA_b06h3cT`o1mgdl_GaeYk>dY>?RoXtxOjCrgF4z}SQ(iz{PsM$`?M5Sbe1 zjHVz{QqbKWE(*)yGP3|lV`>(4W^3sOU0_SlOmqhI2O2}rmZ*^p&u!@k8SyqJ={@H> z&$;LHIUP7(`R|97V?|t+00LyZ*3$?pr&lY1M`(jhkwZ7QiOy-~{;baD1^p+#=PgtN zu<$;MRF;XbWT3OpY?N&0g-I#-e1-#{5?C`2;D{8!7%lLwn<$-2)=3Tvbo};R%{c_J z@R|jFs9WEK1+FaY&+v5uyfmDjl=s%5(WY1jZ{nBINP)p^?yFmQ;p%q%{3&#@z*^J* zn@b1#&0FYu<3#VQ^_)z}o}(Z4IDmaD9zm&Lf$NV`r6!|8VjH> z+V2})VsP4n%NG#%(}DKsdlvv$I05WW>f^36C@GHvRaE99W%m1R9GV18iY7x#L6f8L zuKR7mWAhL5!Y>~jU*0v(10zUKzn!4ATWkuK#isnZUd;=E`9?!eJqI&GDUQcCP}7LA zoUHzB!R{DQqNSp#(9|x+h?uswh!?oFLzOqHWB_01CN(klYC=vp8qk84j`_(Rst=2@ z)4afZD38cVyzk}2`(O{oM8q9$X+6<=>_q3uQ;&9bcQ!ty27Z6m(P!?hSXXx{aI(#5 zDv%v$=D<=|t26KL=?ZVv*7c2!>HBt;^y+-RNz3$NmrCqV-?lidmLj9I*m&DetS|n? zpr1C#@~aM4Sq^8Ed^zw=I`+T|E#DrTVD-`1JcdJ}UcG7_^lnIOLdCN8KiEcMmt3Z> zXiCS#vP+WD<#hlzQMQSGlM+9YlP5(?oN?^<{%IVJLxqK5fC(0r=c%+5cE%7Bw=tNAgAwpNC^Uc9t0ZPQU5k~y0yVm?_ro%NDu@mgV1XlS#KD5c{z1s!hVvT3VL zQN|dQv_3%6=^Y;txgeeMMc`Zg2;VqLYy6QO&$4TMh>rS+$&@LL{zI}+Cn+kTY9<_Z zE}pp-68~4@w8Kv}veH_~(_z{XAo?xIQjDpu0JIUpDCtmGq;ny$I@Y;ng5*gxiz2NL zi}7(d Date: Wed, 31 May 2023 07:05:17 +0000 Subject: [PATCH 4/5] Change displayed trace descriptors Descriptor before: 'Transitions (wm_transition_trace.winscope (bugreport.zip), shell_transition_trace.winscope (bugreport.zip))' Descriptor after: 'wm_transition_trace.winscope (bugreport.zip), shell_transition_trace.winscope (bugreport.zip)' Fix: b/285561971 Test: load trace and check the displayed descriptor Change-Id: Ia96c58d563036c68e2d9ab428a94051a23a6a5b9 --- tools/winscope/src/app/components/app_component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/winscope/src/app/components/app_component.ts b/tools/winscope/src/app/components/app_component.ts index 512b19815..f249c0c06 100644 --- a/tools/winscope/src/app/components/app_component.ts +++ b/tools/winscope/src/app/components/app_component.ts @@ -356,7 +356,7 @@ export class AppComponent implements TraceDataListener { return ''; } - return `${TRACE_INFO[trace.type].name} (${trace.descriptors.join(', ')})`; + return `${trace.descriptors.join(', ')}`; } private getActiveTrace(view: View): LoadedTrace | undefined { From 24965f613d2f2b2b48d56cc3adcf0eb666855ccb Mon Sep 17 00:00:00 2001 From: Kean Mariotti Date: Wed, 31 May 2023 08:51:17 +0000 Subject: [PATCH 5/5] Add 'npm run test:presubmit' script Fix: b/285562786 Test: npm run test:presubmit Change-Id: Ieddaf47c6737fe49d485bf4d81d2b711e4334cd2 --- tools/winscope/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/winscope/package.json b/tools/winscope/package.json index 5eaa4e6b5..ef27d793a 100644 --- a/tools/winscope/package.json +++ b/tools/winscope/package.json @@ -19,6 +19,7 @@ "test:unit": "webpack --config webpack.config.unit_test.js && jasmine dist/unit_test/bundle.js", "test:component": "npx karma start", "test:e2e": "rm -rf dist/e2e_test && npx tsc -p ./src/test/e2e && npx protractor protractor.config.js", + "test:presubmit": "npm run test:unit && npm run test:component && npm run format:check && npm run tslint:check && npm run eslint:check && npm run deps_graph:check_cycles", "test:all": "npm run test:unit && npm run test:component && npm run test:e2e && npm run format:check && npm run tslint:check && npm run eslint:check && npm run deps_graph:check_cycles" }, "private": true,