more testing stuff
This commit is contained in:
parent
94f91a9e22
commit
a6fd0ef431
7 changed files with 104 additions and 21 deletions
|
@ -120,6 +120,10 @@ android {
|
|||
variant.outputFile = new File(file.parent, file.name.replace(".apk", "-" + defaultConfig.versionName + ".apk"))
|
||||
}
|
||||
}
|
||||
debug {
|
||||
//makes problems
|
||||
//testCoverageEnabled true
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
|
13
src/androidTest/java/org/ligi/passandroid/BaseTest.java
Normal file
13
src/androidTest/java/org/ligi/passandroid/BaseTest.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package org.ligi.passandroid;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
|
||||
public class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
|
||||
public BaseTest() {
|
||||
super(Activity.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,7 @@
|
|||
package org.ligi.passandroid;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
|
@ -13,26 +11,22 @@ import org.ligi.passandroid.helper.BarcodeHelper;
|
|||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
public class TheBarcodeHelperTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
public class TheBarcodeHelper extends BaseTest {
|
||||
|
||||
public static final BarcodeFormat PDF_417 = BarcodeFormat.PDF_417;
|
||||
|
||||
public TheBarcodeHelperTest() {
|
||||
super(Activity.class);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void test_barcode_qr_format_should_have_correct_output_size() throws Exception {
|
||||
public void QRShouldWork() throws Exception {
|
||||
testFormat(BarcodeFormat.QR_CODE);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void test_barcode_pdf417_format_should_have_correct_output_size() {
|
||||
public void PDF417ShouldWork() {
|
||||
testFormat(BarcodeFormat.PDF_417);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void barcode_aztec_format_writer_should_have_correct_output_size() {
|
||||
public void AZTECFormatShouldWork() {
|
||||
testFormat(BarcodeFormat.AZTEC);
|
||||
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
package org.ligi.passandroid;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import org.ligi.passandroid.helper.CategoryHelper;
|
||||
|
@ -13,12 +11,7 @@ import java.util.Set;
|
|||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
public class TheCategoryHelperTest extends ActivityInstrumentationTestCase2<Activity> {
|
||||
|
||||
|
||||
public TheCategoryHelperTest() {
|
||||
super(Activity.class);
|
||||
}
|
||||
public class TheCategoryHelper extends BaseTest {
|
||||
|
||||
@SmallTest
|
||||
public void test_all_categories_should_b_translated() {
|
|
@ -39,7 +39,7 @@ public class TheEmptyTicketList extends BaseIntegration<TicketListActivity> {
|
|||
}
|
||||
|
||||
@MediumTest
|
||||
public void test_help_goes_to_help() {
|
||||
public void testHelpGoesToHelp() {
|
||||
onView(withId(R.id.menu_help)).perform(click());
|
||||
onView(withId(R.id.help_tv)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package org.ligi.passandroid;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.test.suitebuilder.annotation.MediumTest;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.ligi.passandroid.injections.FixedPassBook;
|
||||
import org.ligi.passandroid.injections.FixedPassListPassStore;
|
||||
import org.ligi.passandroid.model.Passbook;
|
||||
import org.ligi.passandroid.ui.TicketViewActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.action.ViewActions.click;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withId;
|
||||
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
|
||||
@TargetApi(14)
|
||||
public class TheTicketViewActivity extends BaseIntegration<TicketViewActivity> {
|
||||
|
||||
private FixedPassBook act_pass;
|
||||
|
||||
public TheTicketViewActivity() {
|
||||
super(TicketViewActivity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
final ArrayList<Passbook> list = new ArrayList<Passbook>() {{
|
||||
act_pass = new FixedPassBook();
|
||||
add(act_pass);
|
||||
}};
|
||||
|
||||
App.replacePassStore(new FixedPassListPassStore(list));
|
||||
App.getPassStore().setCurrentPass(App.getPassStore().getPassbookAt(0));
|
||||
|
||||
}
|
||||
|
||||
@MediumTest
|
||||
public void testThatDescriptionIsThere() {
|
||||
getActivity();
|
||||
|
||||
onView(withText(act_pass.getDescription())).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@MediumTest
|
||||
public void testDateIsGoneWhenPassbookHasNoDate() {
|
||||
|
||||
getActivity();
|
||||
|
||||
onView(withId(R.id.date)).check(matches(not(isDisplayed())));
|
||||
}
|
||||
|
||||
|
||||
@MediumTest
|
||||
public void testDateIsThereWhenPassbookHasDate() {
|
||||
act_pass.relevantDate = new DateTime();
|
||||
getActivity();
|
||||
|
||||
onView(withId(R.id.date)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
@MediumTest
|
||||
public void test_click_on_barcode_openes_fullscreen_barcode() {
|
||||
getActivity();
|
||||
onView(withId(R.id.barcode_img)).perform(click());
|
||||
|
||||
onView(withId(R.id.fullscreen_image)).check(matches(isDisplayed()));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
|
||||
public class FixedPassBook implements Passbook {
|
||||
|
||||
public DateTime relevantDate;
|
||||
public BarcodeFormat barcodeFormat = BarcodeFormat.AZTEC;
|
||||
|
||||
@Override
|
||||
|
@ -104,12 +105,12 @@ public class FixedPassBook implements Passbook {
|
|||
|
||||
@Override
|
||||
public boolean hasRelevantDate() {
|
||||
return false;
|
||||
return relevantDate != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DateTime getRelevantDate() {
|
||||
return null;
|
||||
return relevantDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue