Home | History | Annotate | Download | only in parser
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.loganalysis.parser;
     17 
     18 import com.android.loganalysis.item.ActivityServiceItem;
     19 
     20 import junit.framework.TestCase;
     21 
     22 import java.util.Arrays;
     23 import java.util.List;
     24 
     25 /**
     26  * Unit tests for {@link ActivityServiceParser}
     27  */
     28 public class ActivityServiceParserTest extends TestCase {
     29 
     30     /**
     31      * Test that normal input is parsed.
     32      */
     33     public void testActivityServiceParser() {
     34         List<String> inputBlock = Arrays.asList(
     35                 "SERVICE com.google.android.gms/"
     36                 + "com.google.android.location.internal.GoogleLocationManagerService f4c9e9d "
     37                 + "pid=1494",
     38                 "Client:",
     39                 " nothing to dump",
     40                 "Location Request History By Package:",
     41                 "Interval effective/min/max 1/0/0[s] Duration: 140[minutes] "
     42                 + "[com.google.android.gms, PRIORITY_NO_POWER, UserLocationProducer] "
     43                 + "Num requests: 2 Active: true",
     44                 "Interval effective/min/max 284/285/3600[s] Duration: 140[minutes] "
     45                 + "[com.google.android.googlequicksearchbox, PRIORITY_BALANCED_POWER_ACCURACY] "
     46                 + "Num requests: 5 Active: true",
     47                 "FLP WakeLock Count:",
     48                 "SERVICE com.android.server.telecom/.components.BluetoothPhoneService 98ab pid=802",
     49                 "Interval effective/min/max 1/0/0[s] Duration: 140[minutes] "
     50                 + "[com.google.android.gms, PRIORITY_NO_POWER, UserLocationProducer] "
     51                 + "Num requests: 2 Active: true",
     52                 "");
     53 
     54         ActivityServiceItem activityService = new ActivityServiceParser().parse(inputBlock);
     55         assertNotNull(activityService.getLocationDumps());
     56         assertEquals(activityService.getLocationDumps().getLocationClients().size(), 2);
     57     }
     58 }
     59 
     60