mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2025-04-13 12:30:57 +00:00
java: refactoring of Instrumented Tests
This commit is contained in:
parent
12e560e50e
commit
9a76611330
2 changed files with 43 additions and 8 deletions
12
app/src/androidTest/AndroidManifest.xml
Normal file
12
app/src/androidTest/AndroidManifest.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="org.etlegacy.app"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<instrumentation android:targetPackage="org.etlegacy.app"
|
||||
android:name="android.support.test.runner.AndroidJUnitRunner"/>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -1,13 +1,18 @@
|
|||
package org.etlegacy.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.app.Application;
|
||||
import android.app.Instrumentation;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import com.robotium.solo.Solo;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static android.os.SystemClock.sleep;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
|
@ -19,19 +24,37 @@ import static org.junit.Assert.assertEquals;
|
|||
public class TestETL {
|
||||
|
||||
private Solo solo;
|
||||
Instrumentation instrumentation;
|
||||
InstrumentationRegistry instrumentationRegistry;
|
||||
Application app;
|
||||
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
app = (Application) instrumentationRegistry.getTargetContext().getApplicationContext();
|
||||
|
||||
assertEquals("org.etlegacy.app", appContext.getPackageName());
|
||||
instrumentation = new Instrumentation();
|
||||
instrumentation = instrumentationRegistry.getInstrumentation();
|
||||
instrumentation.runOnMainSync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
instrumentation.callApplicationOnCreate(app);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clickOnNickEntry() throws Exception {
|
||||
// Perform click on Nickname Entry
|
||||
// TODO: Implement
|
||||
|
||||
assertEquals("org.etlegacy.app", app.getPackageName());
|
||||
DisplayMetrics displaymetrics = new DisplayMetrics();
|
||||
|
||||
if (app.getApplicationContext().getClass().getSimpleName() == "ETLActivity") {
|
||||
sleep(10000);
|
||||
solo.drag(0, displaymetrics.widthPixels, 0, displaymetrics.heightPixels / 2, 100);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue