Permalink
Browse files

Add ci settings

  • Loading branch information...
gen0083 committed Nov 3, 2016
1 parent 535c437 commit ec8906d8b0c7c3fad0a6d2ce59d34afb69caf334
@@ -7,3 +7,5 @@
/build
/captures
.externalNativeBuild
release.keystore
filteredhatebu_play_api.json
@@ -0,0 +1,48 @@
language: android
android:
components:
- tools
- platform-tools
- build-tools-25.0.0
- android-25
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19
- sys-img-armeabi-v7a-android-19
jdk:
- oraclejdk8
before_install:
- openssl aes-256-cbc -K $encrypted_da784680a32e_key -iv $encrypted_da784680a32e_iv -in encrypted.tar.enc -out encrypted.tar -d
- tar xvf encrypted.tar
- echo $ANDROID_HOME
- mkdir -p $ANDROID_HOME/licenses
- echo -e "e6b7c2ab7fa2298c15165e9583d0acf0b04a2232\n8933bad161af4178b1185d1a37fbf41ea5269c55" > $ANDROID_HOME/licenses/android-sdk-license
env:
global:
- ADB_INSTALL_TIMEOUT=10
- secure: IQ48XiX7PbRLtpX7S0lPjDFLb4IcyKFrjGkhiYtqGdw18vmx6SegkMgilGXYqKMXT5U1lK02Fb4m+H0gO1lZ4qCzaW8HJ2ST6ylXhmYKEoel8ad5ylArAbY6qk8LkDdGEK56EkNdh6xzZxpRkW7XwBE/lD2bOnGh4gw4uNomxwbvQYGHzax2acn25INJ7RMLadirsirzBQUpaESS2k/00qwZp+jLzBh/gYzOWezGNFj1UIPoKXSmZiXBJAWIHzQKcmYp2VGqlYE+m/ggQXrqwx2ipaDSx1mDeVJRV/Zn7flAx/UoopgbMKasJdR9oe5aB5dQMtWCUyRQrsaDkb+l/PnXNjvDpFdB0FgSRHMslW5DggqzorNSEzE7vrEDeBDR4qqs+grPvrQdLh/mviBOs5TfEX7QTh64Mn+g6fgjDVbYjYl0qGcEPQYc3dEyl0vJxKZh7iyLF1n2SRbJ76prT3WU83A7sJ2Quzm0rwYNto2xRoEcEKwzQbwZHDATZjjo5xxR7y0GQiyKPMZ7che6t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vjf9Bd/c3PLhgPf3SnTJdOEMPBIFPuRaWPSinghmJ0qaMC2E8pYjn17u4lz9jatXkAjOg4HTFS2k6ve/W3xSgxxNugs743D06ay6LK3cOhniexeSwtKiYqKrY76SlDIAiKS8M1olUWPHuvvh7jSZADHU6u6JBYf0/cjCcvJ6aBCJLhduxQYPnsepQ8SmCIhTrkZzA+UHPsy5dnxxouuIaD7nSzpXaxjogGD6jtiexgkNcQZBME9mf+6cOfjs40hBowtwu1JmAI4eY46ttcIKpoUV0hRGCi3G+Z9Ujiu56kj5nGP9fXKT7ywiD4gJKltO4F8TBvpqv4nS6p7BBls1RakTG8rqsNXVJpoyQl/PMsnPzSaXbSgYJmzFH1N4A3rQdw9pn7qN0krZQV19oXIgLJa9B0X4iWE6o/+GmiAvjCgfgjnyIikIyZ+soLU=
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
script:
- "./gradlew testProdDebugUnitTest"
- echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- sleep 10
- adb shell settings put global window_animation_scale 0
- adb shell settings put global transition_animation_scale 0
- adb shell settings put global animator_duration_scale 0
- adb shell input keyevent 82
- "./gradlew connectedAndroidTest"
notifications:
slack:
secure: PyCqXWFVULLq19pk2Q2fpKlQp0+ETvWe+n7wV6+Xy7J6KBoKVarQ4bBqWJEUAq9AKn1nzW0WUsyZRA1+QvYHpeQZF+e3ayyTiBJetLfwCRAzW6EHRHRTBBeMwV0v6Aft0k07uJpu3d89+joHo/7Eg7tlvbCgXj1obq9YrXWGmNJnEf0XWbfs6O4pl0tnRDJ90eRJPlWRD6AdMHb+B5N38bJ7YMhEgp+Vd3tZ+PzxOLHMV/LOpA5Eb8dbnJFtVpD2yuo10dggjNSJ2peDocpC1aAV6LkSCgC/UoHJpn2FUT3OnYUyHHyX5lt1Z3BbuYh0DMyockR/cG3ctCl7V63FoOPxEo57xqpgfMIJVU88VgVNF21GFAA8LSrYzJ7hCjP0zcw58iUecm9Fi6G//ZL7HLt66Wf/oqT821vCyZBQI+JSb3/EdpyN6V5wkZ/p5lOjMe+gVophlxElggjo87iH+jDwaEfPm/2nlrasPpR8mx5zFR/WUvJZVy21EQrc8poOw3WQKWHpIdx9uBgPrHDGA4PQ76wJNLy8/pnTBfKfyW9VDLwLl4Qoerj2W9lUIgS68ZtAyecIjV7UcHyzO1rXoDVQLo/q+c4ZC5K7Ca1EdcGhqmhkc85qZUt5p/KnsTXhjVbWe8X1GHBGgTFbQwg8SCcauqTYq4sC24Lpl99eq5o=
email: false
sudo: false
@@ -4,9 +4,12 @@ apply plugin: 'com.cookpad.android.licensetools'
apply plugin: 'io.fabric'
apply plugin: 'com.github.triplet.play'

android {
apply from: "${System.getenv('HOME')}/.android-mykey/FilteredHatebu.sign.gradle", to: android
ext {
ciBuild = System.getenv("CI") == "true"
travisBuild = System.getenv("TRAVIS") == "true"
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
@@ -24,6 +27,30 @@ android {
prod {
}
}
signingConfigs {
debug {
storeFile rootProject.file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
release {
// Travisでだけリリースビルドを行う
if (travisBuild) {
storeFile rootProject.file('release.keystore')
storePassword System.getenv('filtered_hatebu_pass')
keyAlias System.getenv('filtered_hatebu_alias')
keyPassword System.getenv('filtered_hatebu_key_pass')
}
// ローカルビルド
if (!ciBuild) {
storeFile rootProject.file('release.keystore')
storePassword getProperty('filtered_hatebu_pass')
keyAlias getProperty('filtered_hatebu_alias')
keyPassword getProperty('filtered_hatebu_key_pass')
}
}
}
buildTypes {
debug {
minifyEnabled false
@@ -40,6 +67,9 @@ android {
dataBinding {
enabled = true
}
dexOptions {
preDexLibraries = !ciBuild
}
}

ribbonizer {
@@ -56,7 +86,9 @@ ribbonizer {

play {
track = 'production'
jsonFile = file(System.getenv('HOME') + "/.android-mykey/filteredhatebu_play_api.json")
if (!ciBuild) {
jsonFile = rootProject.file("filteredhatebu_play_api.json")
}
}

dependencies {
@@ -130,3 +162,28 @@ dependencies {
testCompile "org.robolectric:robolectric:3.1.2"
testCompile 'org.mockito:mockito-core:1.10.19'
}

/*
* On Travis-CI androidTest failed as java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
* at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)
*
* This is workaround for it.
*
* Workaround for https://code.google.com/p/android/issues/detail?id=182715
*
* The Android Gradle plugin is creating DataBindingExportBuildInfoTasks for the instrumentation
* APK that generates from the app APKs layouts. This creates duplicate classes in the app and
* instrumentation APK which leads to
* java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
* on older devices.
*
* The workaround is to get the DataBindingExportBuildInfoTasks tasks for the instrumentation APK
* and delete the files right after it creates them.
*/
tasks.withType(com.android.build.gradle.internal.tasks.databinding.DataBindingExportBuildInfoTask) { task ->
if (task.name.endsWith("AndroidTest")) {
task.finalizedBy(tasks.create("${task.name}Workaround") << {
task.output.deleteDir()
})
}
}
@@ -39,7 +39,9 @@
activityTestRule.launchActivity(
HatebuFeedDetailActivity.createIntent(InstrumentationRegistry.getTargetContext(),
item));
CommentLoadIdlingResource idlingResource = new CommentLoadIdlingResource(activityTestRule.getActivity());

CommentLoadIdlingResource idlingResource =
new CommentLoadIdlingResource(activityTestRule.getActivity());
Espresso.registerIdlingResources(idlingResource);

onView(allOf(withId(R.id.comment),
@@ -60,7 +62,9 @@
activityTestRule.launchActivity(
HatebuFeedDetailActivity.createIntent(InstrumentationRegistry.getTargetContext(),
item));
CommentLoadIdlingResource idlingResource = new CommentLoadIdlingResource(activityTestRule.getActivity());

CommentLoadIdlingResource idlingResource = new CommentLoadIdlingResource(
activityTestRule.getActivity());
Espresso.registerIdlingResources(idlingResource);

onView(withId(R.id.comment_status))
@@ -69,7 +73,7 @@
}

private static class CommentLoadIdlingResource implements IdlingResource {
private ResourceCallback callback;
private ResourceCallback callback;
private HatebuFeedDetailActivity activity;

public CommentLoadIdlingResource(HatebuFeedDetailActivity activity) {
@@ -1,7 +1,6 @@
package jp.gcreate.product.filteredhatebu.ui.feedlist;


import android.content.Intent;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.IdlingResource;
import android.support.test.espresso.ViewInteraction;
@@ -24,32 +23,30 @@

import jp.gcreate.product.filteredhatebu.R;

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.assertion.ViewAssertions.doesNotExist;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withClassName;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.anything;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class HatebuFeedActivityTest {
private IdlingResource idlingResource;

@Rule
public ActivityTestRule<HatebuFeedActivity> mActivityTestRule = new ActivityTestRule<>(
HatebuFeedActivity.class, false, false);
public ActivityTestRule<HatebuFeedActivity> mActivityTestRule =
new ActivityTestRule<>(HatebuFeedActivity.class);

@Before
public void setUp() {
mActivityTestRule.launchActivity(new Intent());
mActivityTestRule.getActivity().presenter.initialzieFilterRepository();
idlingResource = new ItemSetIdlingResource( mActivityTestRule.getActivity());
Espresso.registerIdlingResources(idlingResource);
@@ -63,23 +60,15 @@ public void tearDown() {

@Test
public void フィルタを追加したら該当記事が表示されない() {
ViewInteraction recyclerView = onView(
allOf(withId(R.id.recycler_view), isDisplayed()));
recyclerView.perform(actionOnItemAtPosition(0, click()));
onView(allOf(withId(R.id.recycler_view), isDisplayed()))
.perform(actionOnItemAtPosition(0, click()));

ViewInteraction appCompatButton = onView(
allOf(withId(R.id.add_filter_button), withText("フィルタを追加"), isDisplayed()));
appCompatButton.perform(click());
onView(withId(R.id.add_filter_button))
.perform(click());

ViewInteraction appCompatTextView = onView(
allOf(withId(android.R.id.text1), withText("test.com/"),
childAtPosition(
allOf(withClassName(
is("com.android.internal.app.AlertController$RecycleListView")),
withParent(withClassName(is("android.widget.FrameLayout")))),
0),
isDisplayed()));
appCompatTextView.perform(click());
onData(anything())
.atPosition(0)
.perform(click());

pressBack();

@@ -105,15 +94,9 @@ public void tearDown() {
allOf(withId(R.id.add_filter_button), withText("フィルタを追加"), isDisplayed()));
appCompatButton.perform(click());

ViewInteraction appCompatTextView = onView(
allOf(withId(android.R.id.text1), withText("test.com/test/"),
childAtPosition(
allOf(withClassName(
is("com.android.internal.app.AlertController$RecycleListView")),
withParent(withClassName(is("android.widget.FrameLayout")))),
1),
isDisplayed()));
appCompatTextView.perform(click());
onData(anything())
.atPosition(1)
.perform(click());

pressBack();

@@ -168,15 +151,10 @@ public void tearDown() {
isDisplayed()))
.perform(click());

ViewInteraction appCompatTextView = onView(
allOf(withId(android.R.id.text1), withText("test.com/"),
childAtPosition(
allOf(withClassName(
is("com.android.internal.app.AlertController$RecycleListView")),
withParent(withClassName(is("android.widget.FrameLayout")))),
0),
isDisplayed()));
appCompatTextView.perform(click());
// test.comをフィルタに追加
onData(anything())
.atPosition(0)
.perform(click());

pressBack();

@@ -2,13 +2,13 @@

import org.junit.Test;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import rx.Single;
import rx.SingleSubscriber;
import rx.Subscription;
import rx.functions.Action1;
import rx.observers.TestSubscriber;
import rx.schedulers.Schedulers;

import static org.hamcrest.CoreMatchers.is;
@@ -66,14 +66,21 @@ public void call(String s) {

@Test
public void onSuccess後はunsubscribeされる() throws InterruptedException {
TestSubscriber<String> test = new TestSubscriber<>();
// this test is unstable on ci. This code is bad design.
final CountDownLatch latch = new CountDownLatch(1);
final String[] test = {""};
Subscription s = source
.subscribeOn(Schedulers.io())
.subscribe(test);
.subscribe(new Action1<String>() {
@Override
public void call(String s) {
test[0] = s;
latch.countDown();
}
});
assertThat(s.isUnsubscribed(), is(false));
test.awaitTerminalEvent(3, TimeUnit.SECONDS);
test.assertValue("test");
test.onCompleted();
latch.await(5, TimeUnit.SECONDS);
assertThat(test[0], is("test"));
assertThat(s.isUnsubscribed(), is(true));
}
}
@@ -6,8 +6,6 @@

import java.util.List;

import jp.gcreate.product.filteredhatebu.ui.common.FilterGenerator;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

@@ -16,7 +14,7 @@
*/
@RunWith(Enclosed.class)
public class FilterGeneratorTest {
public static class フィルタ候補生成 {
public static class GenerateCandidate {
@Test
public void ホスト部2つサブディレクトリあり() {
List<String> actual = FilterGenerator
@@ -55,7 +53,7 @@
}


public static class ホスト部分 {
public static class Host {
@Test
public void ホスト部2つ() {
String actual = FilterGenerator.getHost("http://test.com/hoge/fuga");
@@ -81,7 +79,7 @@ public void https() {
}
}

public static class サブドメインを除去 {
public static class RemoveSubDomain {

@Test
public void ホスト部が2つ() {
@@ -108,7 +106,7 @@ public void https() {
}
}

public static class サブディレクトリ {
public static class SubDirectory {
@Test
public void サブディレクトリあり() {
String actual = FilterGenerator.getHostAndSubDirectory("http://test.com/subuser/123");
@@ -128,7 +126,7 @@ public void https() {
}
}

public static class サブドメインの除去メソッド {
public static class MethodRemoveSubDomain {
@Test
public void ホスト部が2つ() {
String actual = FilterGenerator.removeSubDomain("test.com/");
Oops, something went wrong.

0 comments on commit ec8906d

Please sign in to comment.