1 /*
2  * Copyright (C) 2010 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 vogar;
18 
19 import java.io.File;
20 import java.util.Set;
21 import vogar.commands.VmCommandBuilder;
22 import vogar.tasks.Task;
23 
24 /**
25  * A Mode for running actions. Examples including running in a virtual machine
26  * either on the host or a device or within a specific context such as within an
27  * Activity.
28  */
29 public interface Mode {
30     /**
31      * Initializes the temporary directories and harness necessary to run
32      * actions.
33      */
installTasks()34     Set<Task> installTasks();
35 
executeActionTask(Action action, boolean useLargeTimeout)36     Task executeActionTask(Action action, boolean useLargeTimeout);
37 
38     /**
39      * Hook method called after action compilation.
40      */
installActionTasks(Action action, File jar)41     Set<Task> installActionTasks(Action action, File jar);
42 
43     /**
44      * Deletes files and releases any resources required for the execution of
45      * the given action.
46      */
cleanupTasks(Action action)47     Set<Task> cleanupTasks(Action action);
48 
49     /**
50      * Returns a VM for action execution.
51      *
52      * @param workingDirectory the working directory of the target process. If
53      *     the process runs on another device, this is the working directory of
54      *     the device.
55      */
newVmCommandBuilder(Action action, File workingDirectory)56     VmCommandBuilder newVmCommandBuilder(Action action, File workingDirectory);
57 
58     /**
59      * Returns the classpath containing JUnit and the dalvik annotations
60      * required for action execution.
61      */
getRuntimeClasspath(Action action)62     Classpath getRuntimeClasspath(Action action);
63 }
64