diff options
-rw-r--r-- | src/com/android/loganalysis/parser/EventsLogParser.java | 16 | ||||
-rw-r--r-- | tests/src/com/android/loganalysis/parser/EventsLogParserTest.java | 24 |
2 files changed, 36 insertions, 4 deletions
diff --git a/src/com/android/loganalysis/parser/EventsLogParser.java b/src/com/android/loganalysis/parser/EventsLogParser.java index 6620cd6..33afb2f 100644 --- a/src/com/android/loganalysis/parser/EventsLogParser.java +++ b/src/com/android/loganalysis/parser/EventsLogParser.java @@ -39,10 +39,17 @@ public class EventsLogParser implements IParser { // 01-01 01:38:44.863 1037 1111 I sysui_multi_action: // [319,64,321,64,322,99,325,5951,757,761,758,9,759,4,806,com.google.android.gm,871, // com.google.android.gm.welcome.WelcomeTourActivity,905,0] - private static final Pattern TRANSITION_DELAY = Pattern.compile( + private static final Pattern TRANSITION_STARTING_DELAY = Pattern.compile( String.format("%s%s", EVENTS_PREFIX, "I sysui_multi_action: \\[319,(.*),321,(.*)" + ",322,(.*),806,(.*),871,(.*),905.*\\]$")); + // 01-01 01:38:44.863 1037 1111 I sysui_multi_action: + // [319,64,322,99,325,5951,757,761,758,9,759,4,806,com.google.android.gm,871, + // com.google.android.gm.welcome.WelcomeTourActivity,905,0] + private static final Pattern TRANSITION_DELAY = Pattern.compile( + String.format("%s%s", EVENTS_PREFIX, "I sysui_multi_action: \\[319,(.*),322,(.*)" + + ",806,(.*),871,(.*),905.*\\]$")); + // 08-21 17:53:53.876 1053 2135 I sysui_latency: [1,50] private static final Pattern ACTION_LATENCY = Pattern.compile( String.format("%s%s", EVENTS_PREFIX, "I sysui_latency: \\[(?<action>.*)," @@ -67,12 +74,17 @@ public class EventsLogParser implements IParser { String line; while ((line = input.readLine()) != null) { Matcher match = null; - if (((match = matches(TRANSITION_DELAY, line)) != null)) { + if (((match = matches(TRANSITION_STARTING_DELAY, line)) != null)) { TransitionDelayItem delayItem = new TransitionDelayItem(); delayItem.setComponentName(match.group(4) + "/" + match.group(5)); delayItem.setTransitionDelay(Long.parseLong(match.group(1))); delayItem.setStartingWindowDelay(Long.parseLong(match.group(2))); transitionDelayItems.add(delayItem); + } else if (((match = matches(TRANSITION_DELAY, line)) != null)) { + TransitionDelayItem delayItem = new TransitionDelayItem(); + delayItem.setComponentName(match.group(3) + "/" + match.group(4)); + delayItem.setTransitionDelay(Long.parseLong(match.group(1))); + transitionDelayItems.add(delayItem); } } return transitionDelayItems; diff --git a/tests/src/com/android/loganalysis/parser/EventsLogParserTest.java b/tests/src/com/android/loganalysis/parser/EventsLogParserTest.java index b568e57..f811580 100644 --- a/tests/src/com/android/loganalysis/parser/EventsLogParserTest.java +++ b/tests/src/com/android/loganalysis/parser/EventsLogParserTest.java @@ -71,7 +71,7 @@ public class EventsLogParserTest extends TestCase { } /** - * Test for Cold launch transition delay info + * Test for Cold launch transition delay and starting window delay info */ public void testValidTransitionDelay() throws IOException { List<String> lines = Arrays @@ -93,6 +93,26 @@ public class EventsLogParserTest extends TestCase { } /** + * Test for only transition delay in hot launch + */ + public void testOnlyTransitionDelay() throws IOException { + List<String> lines = Arrays + .asList("01-02 08:12:10.849 934 986 I sysui_multi_action: [319,42,322,208,325,84100,757,761,758,9,759,4,806,com.google.android.apps.maps,871,com.google.android.maps.MapsActivity,905,0]", + "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_trigger_nav_btn,802,1]", + "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_source_app,802,1]", + "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,804,799,overview_source_app_index,801,8,802,1]"); + List<TransitionDelayItem> transitionItems = (new EventsLogParser()). + parseTransitionDelayInfo(readInputBuffer(getTempFile(lines))); + assertEquals("Transition Delay items list should have one item", 1, + transitionItems.size()); + assertEquals("Component name not parsed correctly", + "com.google.android.apps.maps/com.google.android.maps.MapsActivity", + transitionItems.get(0).getComponentName()); + assertEquals("Transition delay is not parsed correctly", 42, + transitionItems.get(0).getTransitionDelay()); + } + + /** * Test for same app transition delay items order after parsing from the events log */ public void testTransitionDelayOrder() throws IOException { @@ -141,7 +161,7 @@ public class EventsLogParserTest extends TestCase { */ public void testInvalidTransitionPattern() throws IOException { List<String> lines = Arrays - .asList("01-02 08:11:58.691 934 986 I sysui_multi_action: [319,48,328,37,322,82,325,84088,757,761,758,9,759,4,806,com.google.android.calculator,871,com.android.calculator2.Calculator,905,0]", + .asList("01-02 08:11:58.691 934 986 I sysui_multi_action: [319,48,322,82,325,84088,757,761,758,9,759,4,807,com.google.android.calculator,871,com.android.calculator2.Calculator,905,0]", "01-02 08:12:03.639 934 970 I sysui_multi_action: [757,803,799,window_time_0,802,5]", "01-02 08:12:10.849 934 986 I sysui_multi_action: 319,42,321,59,322,208,325,84100,757,761,758,9,759,4,806,com.google.android.apps.maps,871,com.google.android.maps.MapsActivity,905,0]", "01-02 08:12:16.895 1446 1446 I sysui_multi_action: [757,803,799,overview_trigger_nav_btn,802,1]", |