The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.dumprendertree; |
| 18 | |
| 19 | import android.content.Intent; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.os.Bundle; |
Christian Mehlmauer | 8b85dce | 2010-07-19 20:11:27 +0200 | [diff] [blame] | 21 | import android.os.Environment; |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 22 | import android.util.Log; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | |
Guang Zhu | f92bd42 | 2009-06-29 10:40:55 -0700 | [diff] [blame] | 24 | import java.io.BufferedOutputStream; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import java.io.File; |
Guang Zhu | f92bd42 | 2009-06-29 10:40:55 -0700 | [diff] [blame] | 26 | import java.io.FileOutputStream; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
| 28 | public class Menu extends FileList { |
Guang Zhu | f92bd42 | 2009-06-29 10:40:55 -0700 | [diff] [blame] | 29 | |
| 30 | private static final int MENU_START = 0x01; |
| 31 | private static String LOGTAG = "MenuActivity"; |
Christian Mehlmauer | 8b85dce | 2010-07-19 20:11:27 +0200 | [diff] [blame] | 32 | static final String LAYOUT_TESTS_LIST_FILE = |
| 33 | Environment.getExternalStorageDirectory() + "/android/layout_tests_list.txt"; |
Guang Zhu | f92bd42 | 2009-06-29 10:40:55 -0700 | [diff] [blame] | 34 | |
| 35 | public void onCreate(Bundle icicle) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | super.onCreate(icicle); |
| 37 | } |
Guang Zhu | f92bd42 | 2009-06-29 10:40:55 -0700 | [diff] [blame] | 38 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | 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 Zhu | f92bd42 | 2009-06-29 10:40:55 -0700 | [diff] [blame] | 50 | |
| 51 | void processFile(String filename, boolean selection) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 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 | startActivity(intent); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | } |
Guang Zhu | f92bd42 | 2009-06-29 10:40:55 -0700 | [diff] [blame] | 58 | |
| 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 Block | cf0fd78 | 2010-03-09 13:54:09 +0000 | [diff] [blame] | 73 | FsUtils.findLayoutTestsRecursively(bos, path, false); // Don't ignore results |
Guang Zhu | f92bd42 | 2009-06-29 10:40:55 -0700 | [diff] [blame] | 74 | 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | } |