mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
04aa4f1aef
- Extract a common BaseTest class to hold the duplicated setup/tearDown stuff - Convert 2-space indent to 4-space indent in keeping with rest of android code - Prefix class member variables with 'm' - Convert tabs to spaces, remove trailing whitespace - Remove unused imports - Use generics to reduce unchecked warnings
70 lines
2.3 KiB
Java
70 lines
2.3 KiB
Java
#filter substitution
|
|
package @ANDROID_PACKAGE_NAME@.tests;
|
|
|
|
import com.jayway.android.robotium.solo.Solo;
|
|
import @ANDROID_PACKAGE_NAME@.*;
|
|
|
|
import android.app.Activity;
|
|
import android.test.ActivityInstrumentationTestCase2;
|
|
import android.content.Intent;
|
|
import java.util.HashMap;
|
|
|
|
abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
|
private static final String TARGET_PACKAGE_ID = "org.mozilla.gecko";
|
|
private static final String LAUNCH_ACTIVITY_FULL_CLASSNAME="@ANDROID_PACKAGE_NAME@.App";
|
|
|
|
private static Class<Activity> mLauncherActivityClass;
|
|
private Activity mActivity;
|
|
private Solo mSolo;
|
|
protected Driver mDriver;
|
|
protected Assert mAsserter;
|
|
protected Actions mActions;
|
|
|
|
static {
|
|
try {
|
|
mLauncherActivityClass = (Class<Activity>)Class.forName(LAUNCH_ACTIVITY_FULL_CLASSNAME);
|
|
} catch (ClassNotFoundException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
public BaseTest() {
|
|
super(TARGET_PACKAGE_ID, mLauncherActivityClass);
|
|
}
|
|
|
|
@Override
|
|
protected void setUp() throws Exception {
|
|
// Load config file from sdcard (setup by python script)
|
|
String configFile = FennecNativeDriver.getFile("/mnt/sdcard/robotium.config");
|
|
HashMap config = FennecNativeDriver.convertTextToTable(configFile);
|
|
|
|
// Create the intent to be used with all the important arguments.
|
|
Intent i = new Intent(Intent.ACTION_MAIN);
|
|
i.putExtra("args", "-no-remote -profile " + (String)config.get("profile"));
|
|
|
|
// Start the activity
|
|
setActivityIntent(i);
|
|
mActivity = getActivity();
|
|
|
|
// Set up Robotium.solo and Driver objects
|
|
mSolo = new Solo(getInstrumentation(), getActivity());
|
|
mDriver = new FennecNativeDriver(mActivity, mSolo);
|
|
mActions = new FennecNativeActions(mActivity, mSolo, getInstrumentation());
|
|
mDriver.setLogFile((String)config.get("logfile"));
|
|
|
|
mAsserter = new FennecNativeAssert();
|
|
mAsserter.setLogFile((String)config.get("logfile"));
|
|
}
|
|
|
|
@Override
|
|
public void tearDown() throws Exception {
|
|
try {
|
|
mSolo.finalize();
|
|
} catch (Throwable e) {
|
|
e.printStackTrace();
|
|
}
|
|
getActivity().finish();
|
|
super.tearDown();
|
|
}
|
|
}
|