-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Toni Möckel
committed
Feb 24, 2017
1 parent
af2ed6a
commit 4f9fc74
Showing
14 changed files
with
735 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
lib/QMBForm/src/test/java/com/quemb/qmbform/AnnotationFormTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.quemb.qmbform; | ||
|
||
import com.quemb.qmbform.annotation.FormDescriptorAnnotationFactory; | ||
import com.quemb.qmbform.annotation.FormElement; | ||
import com.quemb.qmbform.annotation.FormOptionsObjectElement; | ||
import com.quemb.qmbform.descriptor.FormDescriptor; | ||
import com.quemb.qmbform.descriptor.RowDescriptor; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.Robolectric; | ||
import org.robolectric.RobolectricGradleTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import android.app.Activity; | ||
import android.widget.ListView; | ||
|
||
import java.util.Map; | ||
|
||
import static junit.framework.Assert.assertTrue; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
/** | ||
* Created by pmaccamp on 9/14/2015. | ||
*/ | ||
@Config(constants = BuildConfig.class) | ||
@RunWith(RobolectricGradleTestRunner.class) | ||
public class AnnotationFormTest { | ||
private Activity activity; | ||
private TestUserClass testUserClass; | ||
|
||
public class TestUserClass { | ||
@FormElement( | ||
rowDescriptorType = RowDescriptor.FormRowDescriptorTypeInteger, | ||
required = true | ||
) | ||
public int age; | ||
|
||
@FormElement( | ||
rowDescriptorType = RowDescriptor.FormRowDescriptorTypeText, | ||
required = true | ||
) | ||
public String name; | ||
|
||
|
||
public TestUserClass(int age, String name, int bodyfat) { | ||
this.age = age; | ||
this.name = name; | ||
} | ||
} | ||
|
||
@Before | ||
public void setUp() { | ||
activity = Robolectric.buildActivity(Activity.class).create().get(); | ||
testUserClass = new TestUserClass(25, "John", 10); | ||
} | ||
|
||
@Test | ||
public void hasCorrectFormValues() { | ||
FormDescriptorAnnotationFactory factory = new FormDescriptorAnnotationFactory(activity); | ||
FormDescriptor formDescriptor = factory.createFormDescriptorFromAnnotatedClass(testUserClass); | ||
|
||
final FormManager formManager = new FormManager(); | ||
ListView listView = new ListView(activity); | ||
formManager.setup(formDescriptor, listView, activity); | ||
|
||
Map formValues = formDescriptor.getFormValues(); | ||
|
||
assertThat((int) formValues.get("age"), is(25)); | ||
assertThat((String) formValues.get("name"), is("John")); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
|
||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
lib/QMBForm/src/test/java/com/quemb/qmbform/FormBooleanFieldCellTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.quemb.qmbform; | ||
|
||
import com.quemb.qmbform.descriptor.RowDescriptor; | ||
import com.quemb.qmbform.view.FormBooleanFieldCell; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.Robolectric; | ||
import org.robolectric.RobolectricGradleTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import android.app.Activity; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
/** | ||
* Created by tonimoeckel on 02.09.14. | ||
*/ | ||
@Config(constants = BuildConfig.class) | ||
@RunWith(RobolectricGradleTestRunner.class) | ||
public class FormBooleanFieldCellTest { | ||
|
||
|
||
private Activity activity; | ||
|
||
@Before | ||
public void setUp() { | ||
activity = Robolectric.buildActivity(Activity.class).create().get(); | ||
} | ||
|
||
@Test | ||
public void shouldBeDisabled(){ | ||
|
||
RowDescriptor rowDescriptor = RowDescriptor.newInstance("disabled", RowDescriptor.FormRowDescriptorTypeBooleanSwitch); | ||
rowDescriptor.setDisabled(true); | ||
|
||
FormBooleanFieldCell testCell = new FormBooleanFieldCell(activity, rowDescriptor); | ||
|
||
assertThat(testCell.getSwitch().isEnabled(), is(false)); | ||
|
||
} | ||
|
||
@After | ||
public void tearDown() { | ||
|
||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
lib/QMBForm/src/test/java/com/quemb/qmbform/FormButtonFieldCellTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.quemb.qmbform; | ||
|
||
import com.quemb.qmbform.descriptor.RowDescriptor; | ||
import com.quemb.qmbform.descriptor.Value; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.Robolectric; | ||
import org.robolectric.RobolectricGradleTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import android.app.Activity; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.IsNull.nullValue; | ||
|
||
/** | ||
* Created by tonimoeckel on 02.09.14. | ||
*/ | ||
@Config(constants = BuildConfig.class) | ||
@RunWith(RobolectricGradleTestRunner.class) | ||
public class FormButtonFieldCellTest { | ||
private Activity activity; | ||
|
||
@Before | ||
public void setUp() { | ||
activity = Robolectric.buildActivity(Activity.class).create().get(); | ||
} | ||
|
||
@Test | ||
public void shouldBeDisabled(){ | ||
|
||
RowDescriptor rowDescriptor = RowDescriptor.newInstance("pickerDisabled",RowDescriptor.FormRowDescriptorTypeSelectorPickerDialog, "Picker Disabled", new Value<String>("Value")); | ||
rowDescriptor.setDisabled(false); | ||
|
||
assertThat( rowDescriptor.getOnFormRowClickListener(), nullValue()); | ||
|
||
} | ||
|
||
@After | ||
public void tearDown() { | ||
|
||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
lib/QMBForm/src/test/java/com/quemb/qmbform/FormCheckFieldCellTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.quemb.qmbform; | ||
|
||
import com.quemb.qmbform.descriptor.RowDescriptor; | ||
import com.quemb.qmbform.view.FormCheckFieldCell; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.Robolectric; | ||
import org.robolectric.RobolectricGradleTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import android.app.Activity; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
/** | ||
* Created by tonimoeckel on 02.09.14. | ||
*/ | ||
@Config(constants = BuildConfig.class) | ||
@RunWith(RobolectricGradleTestRunner.class) | ||
public class FormCheckFieldCellTest { | ||
|
||
|
||
private Activity activity; | ||
|
||
@Before | ||
public void setUp() { | ||
activity = Robolectric.buildActivity(Activity.class).create().get(); | ||
} | ||
|
||
@Test | ||
public void shouldBeDisabled(){ | ||
|
||
RowDescriptor rowDescriptor = RowDescriptor.newInstance("disabled", RowDescriptor.FormRowDescriptorTypeBooleanCheck); | ||
rowDescriptor.setDisabled(true); | ||
|
||
FormCheckFieldCell testCell = new FormCheckFieldCell(activity, rowDescriptor); | ||
|
||
assertThat(testCell.getCheckBox().isEnabled(), is(false)); | ||
|
||
} | ||
|
||
@After | ||
public void tearDown() { | ||
|
||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
lib/QMBForm/src/test/java/com/quemb/qmbform/FormDateFieldCellTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.quemb.qmbform; | ||
|
||
import com.quemb.qmbform.descriptor.RowDescriptor; | ||
import com.quemb.qmbform.descriptor.Value; | ||
import com.quemb.qmbform.view.FormTimeDialogFieldCell; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.Robolectric; | ||
import org.robolectric.RobolectricGradleTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import android.app.Activity; | ||
|
||
import java.util.Date; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
/** | ||
* Created by tonimoeckel on 02.09.14. | ||
*/ | ||
@Config(constants = BuildConfig.class) | ||
@RunWith(RobolectricGradleTestRunner.class) | ||
public class FormDateFieldCellTest { | ||
|
||
|
||
private Activity activity; | ||
|
||
@Before | ||
public void setUp() { | ||
activity = Robolectric.buildActivity(Activity.class).create().get(); | ||
} | ||
|
||
@Test | ||
public void shouldBeDisabled(){ | ||
RowDescriptor rowDescriptor = RowDescriptor.newInstance("timeDialog",RowDescriptor.FormRowDescriptorTypeTime, "Time Dialog", new Value<Date>(new Date())); | ||
rowDescriptor.setDisabled(true); | ||
|
||
FormTimeDialogFieldCell testCell = new FormTimeDialogFieldCell(activity, rowDescriptor); | ||
|
||
assertThat(testCell.getTextView().isEnabled(), is(false)); | ||
|
||
} | ||
|
||
@After | ||
public void tearDown() { | ||
|
||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
lib/QMBForm/src/test/java/com/quemb/qmbform/FormEditFieldCellTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.quemb.qmbform; | ||
|
||
import com.quemb.qmbform.descriptor.RowDescriptor; | ||
import com.quemb.qmbform.view.FormEditIntegerFieldCell; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.robolectric.Robolectric; | ||
import org.robolectric.RobolectricGradleTestRunner; | ||
import org.robolectric.annotation.Config; | ||
|
||
import android.app.Activity; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
/** | ||
* Created by tonimoeckel on 02.09.14. | ||
*/ | ||
@Config(constants = BuildConfig.class) | ||
@RunWith(RobolectricGradleTestRunner.class) | ||
public class FormEditFieldCellTest { | ||
|
||
|
||
private Activity activity; | ||
|
||
@Before | ||
public void setUp() { | ||
activity = Robolectric.buildActivity(Activity.class).create().get(); | ||
} | ||
|
||
@Test | ||
public void shouldBeDisabled(){ | ||
|
||
RowDescriptor rowDescriptor = RowDescriptor.newInstance("disabled", RowDescriptor.FormRowDescriptorTypeInteger); | ||
rowDescriptor.setDisabled(true); | ||
|
||
FormEditIntegerFieldCell testCell = new FormEditIntegerFieldCell(activity, rowDescriptor); | ||
|
||
assertThat(testCell.getEditText().isEnabled(), is(false)); | ||
|
||
} | ||
|
||
@After | ||
public void tearDown() { | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.