OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 package com.skia; | |
9 | |
10 import android.app.Instrumentation; | |
11 import android.content.Intent; | |
12 import android.test.ActivityUnitTestCase; | |
13 import android.util.Log; | |
14 import java.io.BufferedReader; | |
15 import java.io.InputStream; | |
16 import java.io.InputStreamReader; | |
17 import java.io.IOException; | |
18 import java.lang.StringBuilder; | |
19 | |
20 public class VisualBenchTestActivity extends ActivityUnitTestCase<VisualBenchAct
ivity> { | |
21 private VisualBenchActivity mActivity; | |
22 private Instrumentation mInstrumentation; | |
23 | |
24 public VisualBenchTestActivity() { | |
25 super(VisualBenchActivity.class); | |
26 } | |
27 | |
28 protected void setUp() throws Exception { | |
29 super.setUp(); | |
30 mInstrumentation = getInstrumentation(); | |
31 } | |
32 | |
33 private String getFlags() throws IOException { | |
34 InputStream s = getInstrumentation().getTargetContext().getResources().g
etAssets().open("nanobench_flags.txt"); | |
35 BufferedReader r = new BufferedReader(new InputStreamReader(s)); | |
36 StringBuilder flags = new StringBuilder(); | |
37 String sep = System.getProperty("line.separator"); | |
38 String line; | |
39 while ((line = r.readLine()) != null) { | |
40 flags.append(line); | |
41 flags.append(sep); | |
42 } | |
43 s.close(); | |
44 return flags.toString(); | |
45 } | |
46 | |
47 public void testVisualBench() throws InterruptedException, IOException { | |
48 String pkg = getInstrumentation().getTargetContext().getPackageName(); | |
49 Intent intent = new Intent(getInstrumentation().getTargetContext(), | |
50 VisualBenchActivity.class); | |
51 String args = getFlags(); | |
52 intent.putExtra("cmdLineFlags", args); | |
53 mActivity = launchActivityWithIntent(pkg, VisualBenchActivity.class, int
ent); | |
54 | |
55 assertNotNull("mActivity is null", mActivity); | |
56 Thread.sleep(5000); | |
57 while (!mActivity.isDestroyed()) { | |
58 Log.d("skiatest", "Waiting for subprocess to finish."); | |
59 Thread.sleep(1000); | |
60 } | |
61 } | |
62 } | |
OLD | NEW |