Fix rects top coordinate computation
Bug: b/258678577
Test: npm run build:unit && npm run test:unit
Change-Id: Ie51d68bcf34dbb32503f2c80e4cfd7d9906fe870
diff --git a/tools/winscope-ng/src/app/trace_coordinator.ts b/tools/winscope-ng/src/app/trace_coordinator.ts
index 369effc..f8ea84d 100644
--- a/tools/winscope-ng/src/app/trace_coordinator.ts
+++ b/tools/winscope-ng/src/app/trace_coordinator.ts
@@ -100,10 +100,7 @@
public createViewers() {
const activeTraceTypes = this.parsers.map(parser => parser.getTraceType());
- console.log("active trace types: ", activeTraceTypes);
-
this.viewers = new ViewerFactory().createViewers(new Set<TraceType>(activeTraceTypes));
- console.log("created viewers: ", this.viewers);
// Make sure to update the viewers active entries as soon as they are created.
if (this.timelineCoordinator.currentTimestamp) {
diff --git a/tools/winscope-ng/src/viewers/viewer_surface_flinger/presenter.spec.ts b/tools/winscope-ng/src/viewers/viewer_surface_flinger/presenter.spec.ts
index 09b686a..61db08e 100644
--- a/tools/winscope-ng/src/viewers/viewer_surface_flinger/presenter.spec.ts
+++ b/tools/winscope-ng/src/viewers/viewer_surface_flinger/presenter.spec.ts
@@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import { Presenter } from "./presenter";
-import { UiData } from "./ui_data";
-import { UserOptions } from "viewers/common/user_options";
-import { TraceType } from "common/trace/trace_type";
-import { LayerTraceEntry } from "common/trace/flickerlib/common";
-import { HierarchyTreeNode, PropertiesTreeNode } from "viewers/common/ui_tree_utils";
-import { UnitTestUtils } from "test/unit/utils";
-import { HierarchyTreeBuilder } from "test/unit/hierarchy_tree_builder";
+import {Presenter} from "./presenter";
+import {UiData} from "./ui_data";
+import {UserOptions} from "viewers/common/user_options";
+import {TraceType} from "common/trace/trace_type";
+import {LayerTraceEntry} from "common/trace/flickerlib/common";
+import {HierarchyTreeNode, PropertiesTreeNode} from "viewers/common/ui_tree_utils";
+import {UnitTestUtils} from "test/unit/utils";
+import {HierarchyTreeBuilder} from "test/unit/hierarchy_tree_builder";
describe("PresenterSurfaceFlinger", () => {
let presenter: Presenter;
@@ -44,48 +44,58 @@
});
});
- it("can notify current trace entries", () => {
+ it("processes current trace entries", () => {
presenter.notifyCurrentTraceEntries(entries);
- const filteredUiDataRectLabels = uiData.rects?.filter(rect => rect.isVisible != undefined)
- .map(rect => rect.label);
+
+ expect(uiData.rects.length).toBeGreaterThan(0);
+ expect(uiData.highlightedItems?.length).toEqual(0);
+ expect(uiData.displayIds).toContain(0);
const hierarchyOpts = uiData.hierarchyUserOptions ?
Object.keys(uiData.hierarchyUserOptions) : null;
+ expect(hierarchyOpts).toBeTruthy();
const propertyOpts = uiData.propertiesUserOptions ?
Object.keys(uiData.propertiesUserOptions) : null;
- expect(uiData.highlightedItems?.length).toEqual(0);
- expect(filteredUiDataRectLabels?.length).toEqual(7);
- expect(uiData.displayIds).toContain(0);
- expect(hierarchyOpts).toBeTruthy();
expect(propertyOpts).toBeTruthy();
-
- // does not check specific tree values as tree generation method may change
expect(Object.keys(uiData.tree!).length > 0).toBeTrue();
});
- it("can handle unavailable trace entry", () => {
+ it("handles unavailable trace entry", () => {
presenter.notifyCurrentTraceEntries(entries);
+ expect(uiData.tree).toBeDefined();
expect(Object.keys(uiData.tree!).length > 0).toBeTrue();
+
const emptyEntries = new Map<TraceType, any>();
presenter.notifyCurrentTraceEntries(emptyEntries);
expect(uiData.tree).toBeFalsy();
});
- it("can update pinned items", () => {
+ it("creates input data for rects view", () => {
+ presenter.notifyCurrentTraceEntries(entries);
+ expect(uiData.rects.length).toBeGreaterThan(0);
+ expect(uiData.rects[0].topLeft).toEqual({x: 0, y: -0});
+ expect(uiData.rects[0].bottomRight).toEqual({x: 1080, y: -118});
+ expect(uiData.rects[0].width).toEqual(1080);
+ expect(uiData.rects[0].height).toEqual(118);
+ });
+
+ it("updates pinned items", () => {
expect(uiData.pinnedItems).toEqual([]);
+
const pinnedItem = new HierarchyTreeBuilder().setName("FirstPinnedItem")
.setStableId("TestItem 4").setLayerId(4).build();
presenter.updatePinnedItems(pinnedItem);
expect(uiData.pinnedItems).toContain(pinnedItem);
});
- it("can update highlighted items", () => {
+ it("updates highlighted items", () => {
expect(uiData.highlightedItems).toEqual([]);
+
const id = "4";
presenter.updateHighlightedItems(id);
expect(uiData.highlightedItems).toContain(id);
});
- it("can update hierarchy tree", () => {
+ it("updates hierarchy tree", () => {
//change flat view to true
const userOptions: UserOptions = {
showDiff: {
@@ -115,7 +125,7 @@
expect(uiData.tree?.children.length).toEqual(94);
});
- it("can filter hierarchy tree", () => {
+ it("filters hierarchy tree", () => {
const userOptions: UserOptions = {
showDiff: {
name: "Show diff",
@@ -143,14 +153,14 @@
});
- it("can set new properties tree and associated ui data", () => {
+ it("sets properties tree and associated ui data", () => {
presenter.notifyCurrentTraceEntries(entries);
presenter.newPropertiesTree(selectedTree);
// does not check specific tree values as tree transformation method may change
expect(uiData.propertiesTree).toBeTruthy();
});
- it("can update properties tree", () => {
+ it("updates properties tree", () => {
//change flat view to true
const userOptions: UserOptions = {
showDiff: {
@@ -171,13 +181,13 @@
presenter.notifyCurrentTraceEntries(entries);
presenter.newPropertiesTree(selectedTree);
expect(uiData.propertiesTree?.diffType).toBeFalsy();
+
presenter.updatePropertiesTree(userOptions);
expect(uiData.propertiesUserOptions).toEqual(userOptions);
- //check that diff type added
expect(uiData.propertiesTree?.diffType).toBeTruthy();
});
- it("can filter properties tree", () => {
+ it("filters properties tree", () => {
presenter.notifyCurrentTraceEntries(entries);
presenter.newPropertiesTree(selectedTree);
let nonTerminalChildren = uiData.propertiesTree?.children?.filter(
diff --git a/tools/winscope-ng/src/viewers/viewer_surface_flinger/presenter.ts b/tools/winscope-ng/src/viewers/viewer_surface_flinger/presenter.ts
index 31ac22e..59f8d09 100644
--- a/tools/winscope-ng/src/viewers/viewer_surface_flinger/presenter.ts
+++ b/tools/winscope-ng/src/viewers/viewer_surface_flinger/presenter.ts
@@ -183,7 +183,7 @@
}
const newRect: Rectangle = {
- topLeft: {x: rect.left, y: rect.top},
+ topLeft: {x: rect.left, y: -rect.top},
bottomRight: {x: rect.right, y: -rect.bottom},
height: rect.height,
width: rect.width,
diff --git a/tools/winscope-ng/src/viewers/viewer_window_manager/presenter.spec.ts b/tools/winscope-ng/src/viewers/viewer_window_manager/presenter.spec.ts
index d67059c..b078e67 100644
--- a/tools/winscope-ng/src/viewers/viewer_window_manager/presenter.spec.ts
+++ b/tools/winscope-ng/src/viewers/viewer_window_manager/presenter.spec.ts
@@ -47,7 +47,7 @@
});
});
- it("can notify current trace entries", () => {
+ it("processes current trace entries", () => {
presenter.notifyCurrentTraceEntries(entries);
const filteredUiDataRectLabels = uiData.rects?.filter(rect => rect.isVisible != undefined)
.map(rect => rect.label);
@@ -65,7 +65,7 @@
expect(Object.keys(uiData.tree!).length > 0).toBeTrue();
});
- it("can handle unavailable trace entry", () => {
+ it("handles unavailable trace entry", () => {
presenter.notifyCurrentTraceEntries(entries);
expect(Object.keys(uiData.tree!).length > 0).toBeTrue();
const emptyEntries = new Map<TraceType, any>();
@@ -73,7 +73,16 @@
expect(uiData.tree).toBeFalsy();
});
- it("can update pinned items", () => {
+ it("creates input data for rects view", () => {
+ presenter.notifyCurrentTraceEntries(entries);
+ expect(uiData.rects.length).toBeGreaterThan(0);
+ expect(uiData.rects[0].topLeft).toEqual({x: 0, y: -2326});
+ expect(uiData.rects[0].bottomRight).toEqual({x: 1080, y: -2400});
+ expect(uiData.rects[0].width).toEqual(1080);
+ expect(uiData.rects[0].height).toEqual(74);
+ });
+
+ it("updates pinned items", () => {
presenter.notifyCurrentTraceEntries(entries);
expect(uiData.pinnedItems).toEqual([]);
@@ -84,14 +93,14 @@
expect(uiData.pinnedItems).toContain(pinnedItem);
});
- it("can update highlighted items", () => {
+ it("updates highlighted items", () => {
expect(uiData.highlightedItems).toEqual([]);
const id = "4";
presenter.updateHighlightedItems(id);
expect(uiData.highlightedItems).toContain(id);
});
- it("can update hierarchy tree", () => {
+ it("updates hierarchy tree", () => {
//change flat view to true
const userOptions: UserOptions = {
showDiff: {
@@ -120,7 +129,7 @@
expect(uiData.tree?.children.length).toEqual(72);
});
- it("can filter hierarchy tree", () => {
+ it("filters hierarchy tree", () => {
const userOptions: UserOptions = {
showDiff: {
name: "Show diff",
@@ -148,14 +157,14 @@
});
- it("can set new properties tree and associated ui data", () => {
+ it("sets properties tree and associated ui data", () => {
presenter.notifyCurrentTraceEntries(entries);
presenter.newPropertiesTree(selectedTree);
// does not check specific tree values as tree transformation method may change
expect(uiData.propertiesTree).toBeTruthy();
});
- it("can update properties tree", () => {
+ it("updates properties tree", () => {
//change flat view to true
const userOptions: UserOptions = {
showDiff: {
@@ -182,7 +191,7 @@
expect(uiData.propertiesTree?.diffType).toBeTruthy();
});
- it("can filter properties tree", () => {
+ it("filters properties tree", () => {
presenter.notifyCurrentTraceEntries(entries);
presenter.newPropertiesTree(selectedTree);
diff --git a/tools/winscope-ng/src/viewers/viewer_window_manager/presenter.ts b/tools/winscope-ng/src/viewers/viewer_window_manager/presenter.ts
index a6af004..23e85f8 100644
--- a/tools/winscope-ng/src/viewers/viewer_window_manager/presenter.ts
+++ b/tools/winscope-ng/src/viewers/viewer_window_manager/presenter.ts
@@ -183,7 +183,7 @@
}
const newRect: Rectangle = {
- topLeft: {x: rect.left, y: rect.top},
+ topLeft: {x: rect.left, y: -rect.top},
bottomRight: {x: rect.right, y: -rect.bottom},
height: rect.height,
width: rect.width,