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 =
30             " cmdline: /data/local/tmp/flatland\n"
31                     + "               Scenario               | Resolution  | Time (ms)\n"
32                     + " 16:10 Single Static Window           | 1280 x  800 |   fast\n"
33                     + " 16:10 Single Static Window           | 1920 x 1200 |  3.136\n"
34                     + " 16:10 Single Static Window           | 2560 x 1600 |  5.524\n"
35                     + " 16:10 Single Static Window           | 3840 x 2400 | 11.841\n"
36                     + " 4:3 Single Static Window             | 2048 x 1536 |  4.292\n"
37                     + " 16:10 App -> Home Transition         | 1280 x  800 |  varies\n"
38                     + " 16:10 App -> Home Transition         | 1920 x 1200 |  5.724\n"
39                     + " 16:10 App -> Home Transition         | 2560 x 1600 | 10.033\n"
40                     + " 16:10 App -> Home Transition         | 3840 x 2400 | 22.034\n"
41                     + " 4:3 App -> Home Transition           | 2048 x 1536 |  8.003\n"
42                     + " 16:10 SurfaceView -> Home Transition | 1280 x  800 |   slow\n"
43                     + " 16:10 SurfaceView -> Home Transition | 1920 x 1200 |  7.023\n"
44                     + " 16:10 SurfaceView -> Home Transition | 2560 x 1600 | 12.337\n"
45                     + " 16:10 SurfaceView -> Home Transition | 3840 x 2400 | 27.283\n"
46                     + " 4:3 SurfaceView -> Home Transition   | 2048 x 1536 |  9.918\n";
47 
testPraseResults()48     public void testPraseResults() throws Exception {
49         FlatlandTest ft = new FlatlandTest();
50         ft.parseResult(output);
51         // "0" represents a "fast" result
52         String t = ft.mResultMap.get("16:10 Single Static Window 1280 x  800");
53         Assert.assertTrue(t.equals("0"));
54 
55         t = ft.mResultMap.get("16:10 Single Static Window 1920 x 1200");
56         Assert.assertTrue(t.equals("3.136"));
57 
58         t = ft.mResultMap.get("16:10 App -> Home Transition 1280 x  800");
59         Assert.assertTrue(t.equals("-1"));
60 
61         t = ft.mResultMap.get("16:10 SurfaceView -> Home Transition 1280 x  800");
62         Assert.assertTrue(t.equals("1000"));
63 
64         for (Map.Entry<String, String> entry : ft.mResultMap.entrySet()) {
65             CLog.e("key:%s, value:%s", entry.getKey(), entry.getValue());
66         }
67     }
68 }
69