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.util.Log;
23 import java.io.BufferedOutputStream;
25 import java.io.FileOutputStream;
27 public class Menu extends FileList {
29 private static final int MENU_START = 0x01;
30 private static String LOGTAG = "MenuActivity";
31 static final String LAYOUT_TESTS_LIST_FILE = "/sdcard/android/layout_tests_list.txt";
33 public void onCreate(Bundle icicle) {
34 super.onCreate(icicle);
37 boolean fileFilter(File f) {
38 if (f.getName().startsWith("."))
40 if (f.getName().equalsIgnoreCase("resources"))
44 if (f.getPath().toLowerCase().endsWith("ml"))
49 void processFile(String filename, boolean selection) {
50 Intent intent = new Intent(Intent.ACTION_VIEW);
51 intent.setClass(this, TestShellActivity.class);
52 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
53 intent.putExtra(TestShellActivity.TEST_URL, "file://" + filename);
54 startActivity(intent);
58 void processDirectory(String path, boolean selection) {
59 generateTestList(path);
60 Intent intent = new Intent(Intent.ACTION_VIEW);
61 intent.setClass(this, TestShellActivity.class);
62 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
63 intent.putExtra(TestShellActivity.UI_AUTO_TEST, LAYOUT_TESTS_LIST_FILE);
64 startActivity(intent);
67 private void generateTestList(String path) {
69 File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
70 BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
71 FsUtils.findLayoutTestsRecursively(bos, path, false); // Don't ignore results
74 } catch (Exception e) {
75 Log.e(LOGTAG, "Error when creating test list: " + e.getMessage());