Skip to content

Commit

Permalink
Remove most of the javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
codeguru42 committed Feb 18, 2018
1 parent 29520a8 commit 5632385
Show file tree
Hide file tree
Showing 41 changed files with 137 additions and 933 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@
import bbct.android.common.activity.About;
import bbct.android.common.test.rule.SupportFragmentTestRule;

/**
* Tests for {@link About} activity class.
*
* TODO: Add tests for the layout of {@link About}
*/
// TODO: Add tests for the layout of {@link About}
@RunWith(AndroidJUnit4.class)
public class AboutTest {
@Rule
Expand All @@ -45,23 +41,12 @@ public class AboutTest {
private Activity activity;
private Fragment aboutFragment;

/**
* Set up test fixture. This consists of an instance of the {@link About}
* activity.
*
* @throws Exception If an error occurs while chaining to the super class.
*/
@Before
public void setUp() throws Exception {
this.activity = fragmentTestRule.getActivity();
this.aboutFragment = fragmentTestRule.getFragment();
}

/**
* Check preconditions which must hold to guarantee the validity of all
* other tests. Assert that the {@link Activity} to test is not
* <code>null</code>
*/
@Test
public void testPreConditions() {
Assert.assertNotNull(this.activity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
*/
package bbct.android.common.activity.test;

import android.app.Activity;
import android.app.Instrumentation;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.widget.Button;
import android.widget.EditText;

import junit.framework.Assert;

Expand All @@ -43,9 +40,6 @@
import bbct.android.common.test.rule.SupportFragmentTestRule;
import bbct.data.BaseballCard;

/**
* Tests for {@link BaseballCardDetails}.
*/
@RunWith(AndroidJUnit4.class)
public class BaseballCardDetailsAddCardsTest {
@Rule
Expand All @@ -58,14 +52,6 @@ public class BaseballCardDetailsAddCardsTest {
private BaseballCard card = null;
private DatabaseUtil dbUtil;

/**
* Set up test fixture. This consists of an instance of the
* {@link BaseballCardDetails} activity and all of its {@link EditText} and
* {@link Button} views and a list of {@link BaseballCard} data.
*
* @throws Exception
* If an error occurs while chaining to the super class.
*/
@Before
public void setUp() throws Exception {
Instrumentation inst = InstrumentationRegistry.getInstrumentation();
Expand All @@ -79,43 +65,18 @@ public void setUp() throws Exception {
cardInput.close();
}

/**
* Tear down the test fixture by calling {@link Activity#finish()} and
* deleting the app's database.
*
* @throws Exception
* If an error occurs while chaining to the super class.
*/
@After
public void tearDown() throws Exception {
dbUtil.clearDatabase();
}

/**
* Test that baseball card data is correctly added to the database when it
* is entered into the {@link BaseballCardDetails} activity.
*
* @throws Throwable
* If an error occurs while the portion of the test on the UI
* thread runs.
*/
@Test
public void testAddCard() throws Throwable {
BBCTTestUtil.addCard(card);
// BBCTTestUtil.waitForToast(fragmentTestRule.getActivity(), BBCTTestUtil.ADD_MESSAGE);
Assert.assertTrue("Missing card: " + card, dbUtil.containsBaseballCard(card));
}

/**
* Test that baseball card data for multiple cards is correctly added to the
* database when it is entered into the {@link BaseballCardDetails}
* activity. This test enters all data using a single invocation of the
* {@link BaseballCardDetails} activity.
*
* @throws Throwable
* If an error occurs while the portion of the test on the UI
* thread runs.
*/
@Test
public void testAddMultipleCards() throws Throwable {
for (BaseballCard nextCard : this.allCards) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,29 @@
import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.widget.EditText;

import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;

import java.io.InputStream;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import bbct.android.common.R;
import bbct.android.common.activity.BaseballCardDetails;
import bbct.android.common.activity.FragmentTestActivity;
import bbct.android.common.test.BBCTTestUtil;
import bbct.android.common.test.BaseballCardCsvFileReader;
import bbct.android.common.test.DatabaseUtil;
import bbct.data.BaseballCard;
import java.io.InputStream;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withId;

/**
* Tests editing card value and count in a {@link BaseballCardDetails} activity.
*/
public class BaseballCardDetailsEditCardTest extends
ActivityInstrumentationTestCase2<FragmentTestActivity> {
private static final String TEST_NAME = "testEditCard";
Expand All @@ -56,15 +55,6 @@ public class BaseballCardDetailsEditCardTest extends
private BaseballCard newCard = null;
private DatabaseUtil dbUtil = null;

/**
* Creates a {@link TestSuite} containing tests for every possible
* combination of {@link EditText} views in the {@link BaseballCardDetails}
* activity.
*
* @return A {@link TestSuite} containing tests for every possible
* combination of {@link EditText} views in the
* {@link BaseballCardDetails} activity.
*/
public static Test suite() {
Log.d(TAG, "suite()");

Expand All @@ -81,30 +71,13 @@ public static Test suite() {
return suite;
}

/**
* Creates a test which will edit data in the {@link EditText} views
* indicated by the given mask.
*
* @param inputMask
* The {@link EditText} views to edit.
*/
public BaseballCardDetailsEditCardTest(Set<BBCTTestUtil.EditTexts> inputMask) {
super(FragmentTestActivity.class);

this.setName(TEST_NAME);
this.inputMask = inputMask;
}

/**
* Set up test fixture. This consists of an instance of the
* {@link BaseballCardDetails} activity and two {@link BaseballCard} objects
* with the original data when first launching the activity and the new data
* when editing.
*
* @throws Exception
* If an error occurs while chaining to the super class or while
* reading data from the baseball card data asset file.
*/
@Override
public void setUp() throws Exception {
Log.d(TAG, "setUp()");
Expand Down Expand Up @@ -140,12 +113,6 @@ public void setUp() throws Exception {
activity.replaceFragment(fragment);
}

/**
* Tear down the test fixture by deleting the app's database.
*
* @throws Exception
* If an error occurs while chaining to the super class.
*/
@Override
public void tearDown() throws Exception {
this.dbUtil.clearDatabase();
Expand All @@ -155,14 +122,6 @@ public void tearDown() throws Exception {
Log.d(TAG, "tearDown()");
}

/**
* Test that the value and count field can be edited in the
* {@link BaseballCardDetails} activity.
*
* @throws Throwable
* If an error occurs while the portion of the test on the UI
* thread runs.
*/
public void testEditCard() throws Throwable {
Log.d(TAG, "testEditCard()");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@
import android.app.Instrumentation;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;

import junit.framework.Test;
import junit.framework.TestSuite;

import java.io.IOException;
import java.io.InputStream;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;

import bbct.android.common.R;
import bbct.android.common.activity.BaseballCardDetails;
import bbct.android.common.activity.FragmentTestActivity;
import bbct.android.common.test.BBCTTestUtil;
import bbct.android.common.test.BaseballCardCsvFileReader;
import bbct.data.BaseballCard;
import java.io.IOException;
import java.io.InputStream;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import junit.framework.Test;
import junit.framework.TestSuite;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
Expand All @@ -44,10 +45,6 @@
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static bbct.android.common.test.matcher.Matchers.hasErrorText;

/**
* A parameterized test which can test any combination of input in the
* {@link BaseballCardDetails} activity.
*/
public class BaseballCardDetailsPartialInputTest extends
ActivityInstrumentationTestCase2<FragmentTestActivity> {
private static final String CARD_DATA = "cards.csv";
Expand All @@ -57,13 +54,6 @@ public class BaseballCardDetailsPartialInputTest extends
private BaseballCard card = null;
private final Set<BBCTTestUtil.EditTexts> inputFieldsMask;

/**
* Creates a {@link TestSuite} containing every possible combination of
* blank {@link EditText} views in the {@link BaseballCardDetails} activity.
*
* @return A {@link TestSuite} containing every possible combination of
* blank {@link EditText} views in the {@link BaseballCardDetails} activity.
*/
public static Test suite() {
TestSuite suite = new TestSuite();
Set<BBCTTestUtil.EditTexts> editTexts =
Expand All @@ -79,27 +69,13 @@ public static Test suite() {
return suite;
}

/**
* Creates a test which will input data to the {@link EditText} views
* indicated by the given flags.<code>|</code>).
*
* @param inputFieldsFlags The {@link EditText} views to receive input.
*
*/
public BaseballCardDetailsPartialInputTest(Set<BBCTTestUtil.EditTexts> inputFieldsFlags) {
super(FragmentTestActivity.class);

this.setName(TEST_NAME);
this.inputFieldsMask = inputFieldsFlags;
}

/**
* Set up the test fixture for this test. Reads an input CSV file for
* baseball card data to use as input. Finds the {@link EditText} and
* {@link Button} views which will be used during testing.
*
* @throws IOException If an error occurs while reading the CSV file.
*/
@Override
public void setUp() throws IOException {
Instrumentation inst = this.getInstrumentation();
Expand All @@ -113,13 +89,6 @@ public void setUp() throws IOException {
activity.replaceFragment(new BaseballCardDetails());
}

/**
* Validates that {@link BaseballCardDetails} correctly handles missing
* input by setting the error messages of any blank {@link EditText} views.
*
* @throws Throwable If an error occurs while the portion of the test on the
* UI thread runs.
*/
public void testPartialInput() throws Throwable {
Log.d(TAG, "testPartialInput()");
Log.d(TAG, "inputFieldsMask=" + this.inputFieldsMask);
Expand Down
Loading

0 comments on commit 5632385

Please sign in to comment.