Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A testing DSL for Android views and activities

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 assets
Octocat-spinner-32 src
Octocat-spinner-32 README.markdown
Octocat-spinner-32 pom.xml
README.markdown

Calculon

"Calculon never does two takes!"

Calculon is a testing DSL for Google Android. It allows you to write functional tests using cool stuff like this:

public class FooTest extends FunctionalTest<FooActivity> {

    public FooTest() {
        super("com.example", FooActivity.class);
    }

    public void testFooAndBarStuff() {

        // direct assertion on current activity
        assertThat().inPortraitMode();
        assertThat().viewExists(R.id.launch_bar_button);

        // assert specific condition on current activity
        assertThat().satisfies(new Predicate<Activity>() {
            public boolean check(Activity target) {
                return target.isTaskRoot();
            }
        });

        // a view assertion that performs an activity check
        Activity barActivity = assertThat(R.id.launch_bar_button).click().starts(BarActivity.class);
        // other activity objects are also testable
        assertThat(barActivity).inLandscapeMode();

        // a direct view assertion
        assertThat(R.id.button_2).isVisible();
        // a view assertion that performs a check on another view
        assertThat(R.id.button_2).click().implies(R.id.launch_bar_button).isGone();
        // assert a specific condition on another view
        assertThat(R.id.button_2).click().implies(R.id.launch_bar_button).satisfies(
            new Predicate<View>() {
                public boolean check(View view) {
                    return view.getVisibility() == View.GONE;
                }
            });

        // a key event assertion on an activity
        assertThat(barActivity).keyDown(KeyEvent.KEYCODE_X).finishesActivity();
    }
}
Something went wrong with that request. Please try again.