2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.dumprendertree;
19 import android.content.Intent;
20 import android.os.Bundle;
21 import android.os.Environment;
22 import android.util.Log;
24 import java.io.BufferedOutputStream;
26 import java.io.FileOutputStream;
28 public class Menu extends FileList {
30 private static final int MENU_START = 0x01;
31 private static String LOGTAG = "MenuActivity";
32 static final String LAYOUT_TESTS_LIST_FILE =
33 Environment.getExternalStorageDirectory() + "/android/layout_tests_list.txt";
35 public void onCreate(Bundle icicle) {
36 super.onCreate(icicle);
39 boolean fileFilter(File f) {
40 if (f.getName().startsWith("."))
42 if (f.getName().equalsIgnoreCase("resources"))
46 if (f.getPath().toLowerCase().endsWith("ml"))
51 void processFile(String filename, boolean selection) {
52 Intent intent = new Intent(Intent.ACTION_VIEW);
53 intent.setClass(this, TestShellActivity.class);
54 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
55 intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename);
56 intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, 1);
57 intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, 1);
58 startActivity(intent);
62 void processDirectory(String path, boolean selection) {
63 int testCount = generateTestList(path);
64 Intent intent = new Intent(Intent.ACTION_VIEW);
65 intent.setClass(this, TestShellActivity.class);
66 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
67 intent.putExtra(TestShellActivity.UI_AUTO_TEST, LAYOUT_TESTS_LIST_FILE);
68 intent.putExtra(TestShellActivity.TOTAL_TEST_COUNT, testCount);
69 // TestShellActivity will process this intent once and increment the test index
70 // before running the first test, so pass 0 here to allow for that.
71 intent.putExtra(TestShellActivity.CURRENT_TEST_NUMBER, 0);
72 startActivity(intent);
75 private int generateTestList(String path) {
78 File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
79 BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
80 testCount = FsUtils.writeLayoutTestListRecursively(
81 bos, path, false); // Don't ignore results
84 } catch (Exception e) {
85 Log.e(LOGTAG, "Error when creating test list: " + e.getMessage());