blob: 9c4b57256eb0227cd0dfd9701df39c5789146d9f [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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
17package com.android.dumprendertree;
18
19import android.content.Intent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020import android.os.Bundle;
Christian Mehlmauer8b85dce2010-07-19 20:11:27 +020021import android.os.Environment;
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070022import android.util.Log;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023
Guang Zhuf92bd422009-06-29 10:40:55 -070024import java.io.BufferedOutputStream;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import java.io.File;
Guang Zhuf92bd422009-06-29 10:40:55 -070026import java.io.FileOutputStream;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027
28public class Menu extends FileList {
Guang Zhuf92bd422009-06-29 10:40:55 -070029
30 private static final int MENU_START = 0x01;
31 private static String LOGTAG = "MenuActivity";
Christian Mehlmauer8b85dce2010-07-19 20:11:27 +020032 static final String LAYOUT_TESTS_LIST_FILE =
33 Environment.getExternalStorageDirectory() + "/android/layout_tests_list.txt";
Guang Zhuf92bd422009-06-29 10:40:55 -070034
35 public void onCreate(Bundle icicle) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036 super.onCreate(icicle);
37 }
Guang Zhuf92bd422009-06-29 10:40:55 -070038
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039 boolean fileFilter(File f) {
40 if (f.getName().startsWith("."))
41 return false;
42 if (f.getName().equalsIgnoreCase("resources"))
43 return false;
44 if (f.isDirectory())
45 return true;
46 if (f.getPath().toLowerCase().endsWith("ml"))
47 return true;
48 return false;
49 }
Guang Zhuf92bd422009-06-29 10:40:55 -070050
51 void processFile(String filename, boolean selection) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -070052 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 startActivity(intent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 }
Guang Zhuf92bd422009-06-29 10:40:55 -070058
59 @Override
60 void processDirectory(String path, boolean selection) {
61 generateTestList(path);
62 Intent intent = new Intent(Intent.ACTION_VIEW);
63 intent.setClass(this, TestShellActivity.class);
64 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
65 intent.putExtra(TestShellActivity.UI_AUTO_TEST, LAYOUT_TESTS_LIST_FILE);
66 startActivity(intent);
67 }
68
69 private void generateTestList(String path) {
70 try {
71 File tests_list = new File(LAYOUT_TESTS_LIST_FILE);
72 BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(tests_list, false));
Steve Blockcf0fd782010-03-09 13:54:09 +000073 FsUtils.findLayoutTestsRecursively(bos, path, false); // Don't ignore results
Guang Zhuf92bd422009-06-29 10:40:55 -070074 bos.flush();
75 bos.close();
76 } catch (Exception e) {
77 Log.e(LOGTAG, "Error when creating test list: " + e.getMessage());
78 }
79 }
80
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081}