{"id":16351356,"url":"https://github.com/autonomousapps/cappuccino","last_synced_at":"2025-09-15T03:38:10.778Z","repository":{"id":57726636,"uuid":"49230474","full_name":"autonomousapps/Cappuccino","owner":"autonomousapps","description":"A sweeter Espresso. Never write your own IdlingResource again. Never manually turn off system animations again.","archived":false,"fork":false,"pushed_at":"2019-01-21T18:33:38.000Z","size":563,"stargazers_count":255,"open_issues_count":4,"forks_count":18,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-05-11T10:46:08.335Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/autonomousapps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-07T20:59:58.000Z","updated_at":"2024-11-22T09:24:49.000Z","dependencies_parsed_at":"2022-08-30T09:11:31.796Z","dependency_job_id":null,"html_url":"https://github.com/autonomousapps/Cappuccino","commit_stats":null,"previous_names":["metova/cappuccino"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousapps%2FCappuccino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousapps%2FCappuccino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousapps%2FCappuccino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousapps%2FCappuccino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/autonomousapps","download_url":"https://codeload.github.com/autonomousapps/Cappuccino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253668088,"owners_count":21944978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T01:09:12.366Z","updated_at":"2025-05-12T03:32:05.006Z","avatar_url":"https://github.com/autonomousapps.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cappuccino\nA sweeter Espresso. At present, there are two main features of Cappuccino:\n 1. Never write your own IdlingResource again.\n 2. Never manually disable system animations again. By using the `SystemAnimations` class of Cappuccino, along with the new [Cappuccino Animations Gradle plugin](https://plugins.gradle.org/plugin/com.autonomousapps.cappuccino-animations), you can automatically disable and re-enable system animations.\n\n## Current version\n**Cappuccino Android library:** 0.9.1\n\n**Cappuccino Animations Gradle plugin:** 0.9.0\n\n## Minimum supported Android Gradle Plugin version\n3.3-rc03\n\n## Getting Started\nIn your `build.gradle`:\n```gradle\nrepositories {\n    // Either repository will work\n    mavenCentral()\n    jcenter()\n}\n```\n\n```gradle\ndependencies {\n    \n    // ...other dependencies...\n    \n    debugCompile \"com.autonomousapps:cappuccino:${latest_lib_version}\"\n    releaseCompile \"com.autonomousapps:cappuccino-no-op:${latest_lib_version}\"\n}\n```\n\nYou will also want to declare the following Espresso dependencies, if you haven't already:\n```gradle\ndependencies {\n\n    // ...other dependencies...\n\n    androidTestCompile 'com.android.support:support-annotations:24.2.1'\n    androidTestCompile 'com.android.support.test:runner:0.5'\n    androidTestCompile 'com.android.support.test:rules:0.5'\n    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'\n}\n```\n\nCheck [here](https://google.github.io/android-testing-support-library/docs/espresso/setup/) for Espresso setup instructions, and to ensure you're using the latest version.\n\nThat's it! (mostly)\n\n## Automatically disable and re-enable system animations\nIf you want to automatically disable and re-enable system animations, there are (unfortunately, but necessarily) several steps to follow. In summary, they are:\n 1. Apply the Cappuccino Animations plugin.\n 2. Create or modify a `debug/AndroidManifest.xml` or (`[flavor]Debug/AndroidManifest.xml` for each flavor, if you have them), as below.\n 3. Add some code to your test classes, as below.\n\n### Apply the Cappuccino Animations plugin at the top of your `build.gradle`:\n\n```gradle\nbuildscript {\n  repositories {\n    maven { url \"https://plugins.gradle.org/m2/\" }\n  }\n  dependencies {\n    classpath \"gradle.plugin.com.autonomousapps:cappuccino-plugin:${latest_plugin_version}\"\n  }\n}\n\napply plugin: \"com.autonomousapps.cappuccino-animations\"\n```\n\n### Sample `debug/AndroidManifest.xml`\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\u003e\n\n    \u003c!-- Disable animations on debug builds so that the animations do not interfere with Espresso\n         tests. Adding this permission to the manifest is not sufficient - you must also grant the\n         permission over adb! --\u003e\n    \u003cuses-permission android:name=\"android.permission.SET_ANIMATION_SCALE\" /\u003e\n\n\u003c/manifest\u003e\n```\n\n### Sample test class\nIf you have all of your test classes inherit from this class, then you only need to do the following once.\n\n```java\nimport com.autonomousapps.cappuccino.animations.SystemAnimations;\n\npublic class BaseTestClass {\n    @BeforeClass\n    public static void disableAnimations() {\n        SystemAnimations.disableAll(InstrumentationRegistry.getContext());\n    }\n\n    @AfterClass\n    public static void enableAnimations() {\n        SystemAnimations.enableAll(InstrumentationRegistry.getContext());\n    }\n    \n    // ...test code...\n}\n```\n\n## Sample usage\n\n```java\npublic class MainActivity extends AppCompatActivity {\n\n    private TextView mTextHello;\n\n    // Declare your CappuccinoResourceWatcher\n    private CappuccinoResourceWatcher mCappuccinoResourceWatcher;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n            \n        // Get a reference to a CappuccinoResourceWatcher. This also registers it with Cappuccino\n        // It will return a no-op version for release builds.\n        // We pass in 'this' as a convenience. Internally, Cappuccino converts 'this' into a String\n        mCappuccinoResourceWatcher = Cappuccino.newIdlingResourceWatcher(this);\n\n        mTextHello = (TextView) findViewById(R.id.text_hello);\n    }\n\n    @Override\n    protected void onResume() {\n        super.onResume();\n        initViews();\n    }\n\n    private void initViews() {\n        // This tells Cappuccino that the resoure associated with this Activity is busy, \n        // and instrumentation tests should wait...\n        mCappuccinoResourceWatcher.busy();\n        \n        // This is our custom animation, that Espresso knows nothing about, but\n        // Cappuccino does!\n        new Handler().postDelayed(new Runnable() {\n            @Override\n            public void run() {\n                mTextHello.setVisibility(View.VISIBLE);\n                    \n                // ...and this tells Cappuccino that the Activity is now idle, and instrumentation tests\n                // may now proceed\n                mCappuccinoResourceWatcher.idle();\n            }\n        }, 500 /* delay in ms */);\n    }\n}\n```\n    \n...and in a test...\n\n```java\npublic class MainActivityTest {\n\n    // optional\n    @BeforeClass\n    public static void disableAnimations() {\n        SystemAnimations.disableAll(InstrumentationRegistry.getContext());\n    }\n\n    // optional\n    @AfterClass\n    public static void enableAnimations() {\n        SystemAnimations.enableAll(InstrumentationRegistry.getContext());\n    }\n\n    @Before\n    public void setUp() throws Exception {\n        mActivityTestRule.launchActivity(new Intent());\n    }\n\n    @After\n    public void tearDown() throws Exception {\n        Cappuccino.reset();\n    }\n\n    @Rule\n    private ActivityTestRule\u003cMainActivity\u003e mActivityTestRule = new ActivityTestRule\u003c\u003e(MainActivity.class, true, false);\n\n    /**\n     * This test uses the common Espresso idiom for instantiating, registering, and unregistering\n     * custom IdlingResources, but uses our CappuccinoIdlingResource, instead.\n     */\n    @Test\n    public void testCappuccinoIdlingResource() throws Exception {\n        CappuccinoIdlingResource idlingResource = new CappuccinoIdlingResource(mActivityTestRule.getActivity());\n        Espresso.registerIdlingResources(idlingResource);\n        \n        onView(withId(R.id.text_hello)).check(matches(isDisplayed()));\n\n        Espresso.unregisterIdlingResources(idlingResource);\n    }\n\n    /**\n     * As a convenience, Cappuccino permits the following idiom, which keeps track of \n     * CappuccinoIdlingResources in an internal registry, keyed by the name of the object passed in.\n     * In this case, this is our MainActivity, retrieved by calling {@code mActivityTestRule.getActivity()}.\n     */\n    @Test\n    public void testCappuccinoIdlingResource2() throws Exception {\n        Cappuccino.registerIdlingResource(mActivityTestRule.getActivity());\n        \n        onView(withId(R.id.text_hello)).check(matches(isDisplayed()));\n\n        Cappuccino.unregisterIdlingResource(mActivityTestRule.getActivity());\n    }\n}\n```\n\nPlease check out the `cappuccino-sample` module for more sample usages!\n\n# License\n\u003e Copyright 2018 AutonomousApps\n\u003e \n\u003e Licensed under the Apache License, Version 2.0 (the \"License\");\n\u003e you may not use this file except in compliance with the License.\n\u003e You may obtain a copy of the License at\n\u003e \n\u003e  http://www.apache.org/licenses/LICENSE-2.0\n\u003e \n\u003e Unless required by applicable law or agreed to in writing, software\n\u003e distributed under the License is distributed on an \"AS IS\" BASIS,\n\u003e WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\u003e See the License for the specific language governing permissions and\n\u003e limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautonomousapps%2Fcappuccino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautonomousapps%2Fcappuccino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautonomousapps%2Fcappuccino/lists"}