With Android in mind.
public class MainActivity { private Button buttonMain; ... }
bbOfMainActivity._getButtonMain().performClick();
boundBoxOfMainActivity = new BoundBoxOfMainActivity(getActivity()); boundBoxOfMainActivity.boundBox_getButtonMain().performClick(); assertEquals("42", boundBoxOfMainActivity.boundBox_getTextViewMain().getText());
@BoundBox(boundClass = MainActivity.class)
@BoundBox(boundClass=MyActivity.class, maxSuperClass=Activity.class)
@BoundBox( boundClass = A.class, extraFields= {@BoundBoxField(fieldName="foo", fieldClass=String.class)})
@BoundBox(boundClass=A.class,boundBoxPackage="foo",prefixes={"BB","bb"})
@BoundBox(boundClass = MainActivity.class)
foo.super.super.a
(not possible in Java).
public class MainActivity extends Activity {
private Button buttonMain; private TextView textViewMain;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); buttonMain = (Button) findViewById(R.id.button_main); textViewMain = (TextView) findViewById(R.id.textview_main);
buttonMain.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final int result = 42; textViewMain.setText(String.valueOf(result)); } });
} }
@BoundBox(boundClass = MainActivity.class, maxSuperClass = Activity.class) public class MainTest extends ActivityInstrumentationTestCase2<Mainactivity> { BoundBoxOfMainActivity bBoxOfMainActivity; public MainTest() { super(MainActivity.class); } @UiThreadTest public void testCompute() { // given bBoxOfMainActivity = new BoundBoxOfMainActivity(getActivity()); // when bBoxOfMainActivity.boundBox_getButtonMain().performClick();
// then assertEquals("42", bBoxOfMainActivity.boundBox_getTextViewMain().getText()); } }