Merge changes I0cfdff9f,Ic9ae610c

* changes:
  Add correction factor in video time calculation
  Fix format errors
This commit is contained in:
Kean Mariotti
2023-01-18 14:06:34 +00:00
committed by Android (Google) Code Review
6 changed files with 29 additions and 21 deletions

View File

@@ -20,20 +20,21 @@ describe('Viewer ScreenRecording', () => {
beforeAll(async () => {
browser.manage().timeouts().implicitlyWait(1000);
browser.get('file://' + E2eTestUtils.getProductionIndexHtmlPath());
}),
it('processes trace and renders view', async () => {
await E2eTestUtils.uploadFixture(
'traces/elapsed_and_real_timestamp/screen_recording_metadata_v2.mp4'
);
await E2eTestUtils.closeSnackBarIfNeeded();
await E2eTestUtils.clickViewTracesButton();
});
const viewer = element(by.css('viewer-screen-recording'));
expect(await viewer.isPresent()).toBeTruthy();
it('processes trace and renders view', async () => {
await E2eTestUtils.uploadFixture(
'traces/elapsed_and_real_timestamp/screen_recording_metadata_v2.mp4'
);
await E2eTestUtils.closeSnackBarIfNeeded();
await E2eTestUtils.clickViewTracesButton();
const video = element(by.css('viewer-screen-recording video'));
expect(await video.isPresent()).toBeTruthy();
expect(await video.getAttribute('src')).toContain('blob:');
expect(await video.getAttribute('currentTime')).toEqual('0');
});
const viewer = element(by.css('viewer-screen-recording'));
expect(await viewer.isPresent()).toBeTruthy();
const video = element(by.css('viewer-screen-recording video'));
expect(await video.isPresent()).toBeTruthy();
expect(await video.getAttribute('src')).toContain('blob:');
expect(await video.getAttribute('currentTime')).toBeCloseTo(0, 0.001);
});
});

View File

@@ -39,7 +39,9 @@ class UnitTestUtils extends CommonTestUtils {
}
static async getMultiDisplayLayerTraceEntry(): Promise<LayerTraceEntry> {
return await UnitTestUtils.getTraceEntry('traces/elapsed_and_real_timestamp/SurfaceFlinger_multidisplay.pb');
return await UnitTestUtils.getTraceEntry(
'traces/elapsed_and_real_timestamp/SurfaceFlinger_multidisplay.pb'
);
}
static async getImeTraceEntries(): Promise<Map<TraceType, any>> {

View File

@@ -17,12 +17,17 @@
import {Timestamp} from './timestamp';
class ScreenRecordingUtils {
// Video time correction epsilon. Without correction, we could display the previous frame.
// This correction was already present in the legacy Winscope.
private static readonly EPSILON_SECONDS = 0.00001;
static timestampToVideoTimeSeconds(firstTimestamp: Timestamp, currentTimestamp: Timestamp) {
if (firstTimestamp.getType() !== currentTimestamp.getType()) {
throw new Error('Attempted to use timestamps with different type');
}
const videoTimeSeconds =
Number(currentTimestamp.getValueNs() - firstTimestamp.getValueNs()) / 1000000000;
Number(currentTimestamp.getValueNs() - firstTimestamp.getValueNs()) / 1000000000 +
ScreenRecordingUtils.EPSILON_SECONDS;
return videoTimeSeconds;
}
}

View File

@@ -120,13 +120,13 @@ describe('RectsComponent', () => {
fixture.detectChanges();
const displayButtonContainer = htmlElement.querySelector(".display-button-container");
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"]);
})
expect(buttonValues).toEqual(['0', '1', '2']);
});
});

View File

@@ -121,7 +121,7 @@ export class Presenter {
};
return rect;
}) ?? [];
this.displayIds = this.entry.displays.map((it: any) => it.layerStackId)
this.displayIds = this.entry.displays.map((it: any) => it.layerStackId);
this.displayIds.sort();
const rects = this.getLayersForRectsView()
.sort(this.compareLayerZ)

View File

@@ -218,7 +218,7 @@ describe('PresenterSurfaceFlinger', () => {
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]);
expect(uiData.displayIds).toEqual([0, 2, 3, 4, 5]);
});
async function getEntriesWithMultiDisplaySfTrace(): Promise<Map<TraceType, any>> {