Store transition types in enum

Store transition types in enum so easier to type check in Typescript if necessary later on.

Bug: b/196203538

Test: check that the tag trace attached to the bug still uploads
correctly

Change-Id: I2994f58ceb1d49bd82af54fb075369bd70dc1394
This commit is contained in:
Priyanka
2021-08-11 14:22:56 +00:00
parent aa088d1ea2
commit 0bb308f2a8
4 changed files with 54 additions and 13 deletions

View File

@@ -15,18 +15,30 @@
*/
import { Tag } from "../common"
import { Tag } from "../common";
import TransitionType from "./TransitionType";
const transitionTypeMap = new Map([
['ROTATION', TransitionType.ROTATION],
['PIP_ENTER', TransitionType.PIP_ENTER],
['PIP_RESIZE', TransitionType.PIP_RESIZE],
['PIP_EXIT', TransitionType.PIP_EXIT],
['APP_LAUNCH', TransitionType.APP_LAUNCH],
['APP_CLOSE', TransitionType.APP_CLOSE],
['IME_APPEAR', TransitionType.IME_APPEAR],
['IME_DISAPPEAR', TransitionType.IME_DISAPPEAR],
]);
Tag.fromProto = function (proto: any): Tag {
const tag = new Tag(
proto.id,
proto.transition,
transitionTypeMap.get(proto.transition),
proto.isStartTag,
proto.layerId,
proto.windowToken,
proto.taskId
);
return tag
}
return tag;
};
export default Tag;

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2021, 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.
*/
enum TransitionType {
ROTATION = 'ROTATION',
PIP_ENTER = 'PIP_ENTER',
PIP_RESIZE ='PIP_RESIZE',
PIP_EXIT = 'PIP_EXIT',
APP_LAUNCH = 'APP_LAUNCH',
APP_CLOSE = 'APP_CLOSE',
IME_APPEAR = 'IME_APPEAR',
IME_DISAPPEAR = 'IME_DISAPPEAR',
};
export default TransitionType;

View File

@@ -16,6 +16,7 @@
import _ from "lodash";
import { nanos_to_string } from "../transform";
import TransitionType from "../flickerlib/tags/TransitionType";
/**
* Represents a continuous section of the timeline that is rendered into the
@@ -61,14 +62,14 @@ class Transition {
* - An element in the template referenced as 'timeline' (this.$refs.timeline).
*/
const transitionMap = new Map([
['ROTATION', {desc: 'Rotation', color: '#9900ffff'}],
['PIP_ENTER', {desc: 'Entering PIP mode', color: '#4a86e8ff'}],
['PIP_RESIZE', {desc: 'Resizing PIP mode', color: '#2b9e94ff'}],
['PIP_EXIT', {desc: 'Exiting PIP mode', color: 'darkblue'}],
['APP_LAUNCH', {desc: 'Launching app', color: '#ef6befff'}],
['APP_CLOSE', {desc: 'Closing app', color: '#d10ddfff'}],
['IME_APPEAR', {desc: 'IME appearing', color: '#ff9900ff'}],
['IME_DISAPPEAR', {desc: 'IME disappearing', color: '#ad6800ff'}],
[TransitionType.ROTATION, {desc: 'Rotation', color: '#9900ffff'}],
[TransitionType.PIP_ENTER, {desc: 'Entering PIP mode', color: '#4a86e8ff'}],
[TransitionType.PIP_RESIZE, {desc: 'Resizing PIP mode', color: '#2b9e94ff'}],
[TransitionType.PIP_EXIT, {desc: 'Exiting PIP mode', color: 'darkblue'}],
[TransitionType.APP_LAUNCH, {desc: 'Launching app', color: '#ef6befff'}],
[TransitionType.APP_CLOSE, {desc: 'Closing app', color: '#d10ddfff'}],
[TransitionType.IME_APPEAR, {desc: 'IME appearing', color: '#ff9900ff'}],
[TransitionType.IME_DISAPPEAR, {desc: 'IME disappearing', color: '#ad6800ff'}],
]);
export default {

View File

@@ -39,6 +39,6 @@ const logLevel = {
WARN: 'warn',
ERROR: 'error',
WTF: 'wtf',
}
};
export { WebContentScriptMessageType, NAVIGATION_STYLE, logLevel };