Home | History | Annotate | Download | only in tests
      1 /*
      2  * Copyright (C) 2014 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 
     17 package com.android.graphics.tests;
     18 
     19 import com.android.tradefed.log.LogUtil.CLog;
     20 
     21 import junit.framework.TestCase;
     22 
     23 import org.junit.Assert;
     24 
     25 import java.util.Map;
     26 
     27 public class FlatlandTestFuncTest extends TestCase {
     28 
     29     private final String output = " cmdline: /data/local/tmp/flatland\n" +
     30             "               Scenario               | Resolution  | Time (ms)\n" +
     31             " 16:10 Single Static Window           | 1280 x  800 |   fast\n" +
     32             " 16:10 Single Static Window           | 1920 x 1200 |  3.136\n" +
     33             " 16:10 Single Static Window           | 2560 x 1600 |  5.524\n" +
     34             " 16:10 Single Static Window           | 3840 x 2400 | 11.841\n" +
     35             " 4:3 Single Static Window             | 2048 x 1536 |  4.292\n" +
     36             " 16:10 App -> Home Transition         | 1280 x  800 |  varies\n" +
     37             " 16:10 App -> Home Transition         | 1920 x 1200 |  5.724\n" +
     38             " 16:10 App -> Home Transition         | 2560 x 1600 | 10.033\n" +
     39             " 16:10 App -> Home Transition         | 3840 x 2400 | 22.034\n" +
     40             " 4:3 App -> Home Transition           | 2048 x 1536 |  8.003\n" +
     41             " 16:10 SurfaceView -> Home Transition | 1280 x  800 |   slow\n" +
     42             " 16:10 SurfaceView -> Home Transition | 1920 x 1200 |  7.023\n" +
     43             " 16:10 SurfaceView -> Home Transition | 2560 x 1600 | 12.337\n" +
     44             " 16:10 SurfaceView -> Home Transition | 3840 x 2400 | 27.283\n" +
     45             " 4:3 SurfaceView -> Home Transition   | 2048 x 1536 |  9.918\n";
     46 
     47     public void testPraseResults() throws Exception {
     48         FlatlandTest ft = new FlatlandTest();
     49         ft.parseResult(output);
     50         // "0" represents a "fast" result
     51         String t = ft.mResultMap.get("16:10 Single Static Window 1280 x  800");
     52         Assert.assertTrue(t.equals("0"));
     53 
     54         t = ft.mResultMap.get("16:10 Single Static Window 1920 x 1200");
     55         Assert.assertTrue(t.equals("3.136"));
     56 
     57         t = ft.mResultMap.get("16:10 App -> Home Transition 1280 x  800");
     58         Assert.assertTrue(t.equals("-1"));
     59 
     60         t = ft.mResultMap.get("16:10 SurfaceView -> Home Transition 1280 x  800");
     61         Assert.assertTrue(t.equals("1000"));
     62 
     63         for(Map.Entry<String, String> entry: ft.mResultMap.entrySet()) {
     64             CLog.e("key:%s, value:%s", entry.getKey(), entry.getValue());
     65         }
     66     }
     67 }
     68