Skip to content

Instantly share code, notes, and snippets.

View ardock's full-sized avatar

ardock ardock

  • Barcelona, Catalonia, Spain
View GitHub Profile
@ardock
ardock / docker_images.md
Created April 26, 2017 14:42 — forked from solarce/docker_images.md
A quick list of the Travis Docker containers on quay.io that you can `docker pull`

The following is a list of public Docker images Travis uses for our container based builds. You can grab them with docker pull quay.io/travisci/travis-$lang.

  • Do note that they are large in size, 800MB - 1.8G

Images:

@ardock
ardock / PermissionUtil.java
Created August 20, 2016 08:19 — forked from andhie/PermissionUtil.java
Marshmallow Permission Level
public static void printPermissions(Context context) {
PackageInfo android;
try {
android = context.getPackageManager().getPackageInfo("android", PackageManager.GET_PERMISSIONS);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
return;
}
PermissionInfo[] permissions = android.permissions;
@ardock
ardock / PermissionGranter.java
Last active August 16, 2016 08:51 — forked from rocboronat/PermissionGranter.java
Tap the "allow" button while running an Android instrumental test using UIAutomator
package com.fewlaps.android.permissiongranter;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import android.support.v4.content.ContextCompat;
@ardock
ardock / .travis.yml
Created March 13, 2016 17:48 — forked from BanzaiMan/.travis.yml
Accept Google's new Android SDK license (June 26, 2014)
language: android
android:
components:
- build-tools-19.0.3
- android-19
- sysimg-19
- extra-android-support
licenses:
- android-sdk-license-5be876d5 # new license!
- '.*intel.+'
@ardock
ardock / MyTest.java
Created February 28, 2016 12:00 — forked from romainpiel/MyTest.java
Source for https://medium.com/p/3f6f4179652e - "RecyclerView and espresso, a complicated story"
RecyclerViewInteraction.<Item>onRecyclerView(withId(R.id.recyclerview))
.withItems(items)
.check(new ItemViewAssertion<Item>() {
@Override
public void check(Item item, View view, NoMatchingViewException e) {
matches(hasDescendant(withText(item.getDisplayName())))
.check(view, e);
}
});
@ardock
ardock / espresso_2_static_imports
Created December 8, 2015 04:49 — forked from Tadas44/espresso_2_static_imports
Espresso 2 common static imports
import static android.support.test.espresso.Espresso.onData;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.Espresso.pressBack;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.swipeUp;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
@ardock
ardock / MyInstrumentationTestCase.java
Created November 8, 2015 18:57 — forked from xrigau/MyInstrumentationTestCase.java
Disable Animations for Espresso tests v2.0
package com.novoda.espresso;
import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase2;
import com.mypackage.EntryPointActivity;
public class EspressoInstrumentationTestCase extends ActivityInstrumentationTestCase2<EntryPointActivity> {
private SystemAnimations systemAnimations;
@ardock
ardock / BaseStatelessBlackBoxEspressoTest.java
Created November 8, 2015 04:13 — forked from daj/BaseStatelessBlackBoxEspressoTest.java
The set of changes required to disable animations any time Espresso tests run. These instructions will only work on emulators and on rooted devices. This is based on the instructions in: https://code.google.com/p/android-test-kit/wiki/DisablingAnimations
public abstract class BaseStatelessBlackBoxEspressoTest<T extends Activity> extends ActivityInstrumentationTestCase2<T> {
private SystemAnimations mSystemAnimations;
public BaseStatelessBlackBoxEspressoTest(Class clazz) {
super(clazz);
}
@Override
protected void setUp() throws Exception {
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/