Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SebaMutuku committed Jun 21, 2022
1 parent e23e4ec commit e062b24
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions android-json-form-wizard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ dependencies {
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.android.support:multidex:1.0.3'
testImplementation project(path: ':android-json-form-wizard')

// PowerMock
def powerMockVersion = '2.0.4'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.vijay.jsonwizard.widgets;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.RadioButton;

import com.vijay.jsonwizard.BaseTest;
import com.vijay.jsonwizard.activities.JsonFormActivity;
Expand Down Expand Up @@ -30,13 +33,18 @@ public class NativeRadioButtonFactoryTest extends BaseTest {
private JsonFormFragment formFragment;
@Mock
private CommonListener listener;
@Mock
private RadioButton radioButton;

private Context context;

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
factory = new NativeRadioButtonFactory();
formUtils = new FormUtils();
jsonFormActivity = Robolectric.buildActivity(JsonFormActivity.class, getJsonFormActivityIntent()).create().get();
context = Mockito.mock(Activity.class);
}

@Test
Expand Down Expand Up @@ -117,4 +125,27 @@ public void testGetCustomTranslatableWidgetFields() {
Assert.assertEquals(4, editableProperties.size());
Assert.assertEquals("options.text", editableProperties.iterator().next());
}

@Test
public void testSelectedButton() throws Exception {
String value = "button";
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", "button");
Whitebox.setInternalState(factory, "context", context);
radioButton = Mockito.mock(RadioButton.class);
Whitebox.invokeMethod(factory, "checkSelectedRadioButton", listener, radioButton, value, jsonObject);


}

@Test
public void testSelectedTranslatedButton() throws Exception {
String value = "{\"value\":\"button\",\"text\":\"text\"}";
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", "button");
Whitebox.setInternalState(factory, "context", context);
radioButton = Mockito.mock(RadioButton.class);
Whitebox.invokeMethod(factory, "checkSelectedRadioButton", listener, radioButton, value, jsonObject);

}
}

0 comments on commit e062b24

Please sign in to comment.