Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility fixes for AGP v3.5.0 #92

Merged
merged 5 commits into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext.versions = [
okreplayVersion : VERSION_NAME,
kotlinVersion : '1.3.30',
okhttpVersion : '3.11.0',
kotlinVersion : '1.3.50',
okhttpVersion : '3.12.2',
appCompatVersion: '1.0.2'
]
ext {
Expand All @@ -10,7 +10,7 @@ ext {
isCi = "true" == System.getenv('CI')

dep = [
androidPlugin : 'com.android.tools.build:gradle:3.4.1',
androidPlugin : 'com.android.tools.build:gradle:3.5.0',
groovyPlugin : 'org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0',
nexusPlugin : 'com.bmuschko:gradle-nexus-plugin:2.3.1',
appcompat : "androidx.appcompat:appcompat:$versions.appCompatVersion",
Expand All @@ -23,11 +23,12 @@ ext {
cglib : "cglib:cglib-nodep:2.2.2",
jsr305 : "com.google.code.findbugs:jsr305:3.0.2",
mockito : 'org.mockito:mockito-core:2.7.13',
okio : 'com.squareup.okio:okio:1.17.2',
okhttp : "com.squareup.okhttp3:okhttp:$versions.okhttpVersion",
mockWebServer : "com.squareup.okhttp3:mockwebserver:$versions.okhttpVersion",
snakeYaml : "org.yaml:snakeyaml:1.16",
kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion",
okreplayPlugin : "com.airbnb.okreplay:gradle-plugin:latest.release",
okreplayPlugin : "com.airbnb.okreplay:gradle-plugin:$VERSION_NAME",
kotlinPlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion",
truth : 'com.google.truth:truth:0.40',
robolectric : "org.robolectric:robolectric:3.3.2",
Expand All @@ -36,6 +37,7 @@ ext {
exclude module: "junit"
}),
espresso : 'androidx.test.espresso:espresso-core:3.1.0',
androidXTestRunner: 'androidx.test:runner:1.2.0',
androidXTestRules : 'androidx.test:rules:1.1.1'
]

Expand Down
4 changes: 2 additions & 2 deletions okreplay-core/src/main/java/okreplay/MemoryTape.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void setInteractions(List<YamlRecordedInteraction> interactions) {
try {
// TODO: it's a complete waste of time using an AtomicInteger when this method is called
// before play in a non-transactional way
Integer index = orderedIndex.get();
int index = orderedIndex.get();
RecordedInteraction interaction = interactions.get(index).toImmutable();
Request nextRequest = interaction == null ? null : interaction.request();
return nextRequest != null && matchRule.isMatch(request, nextRequest);
Expand All @@ -91,7 +91,7 @@ public void setInteractions(List<YamlRecordedInteraction> interactions) {
}

if (mode.isSequential()) {
Integer nextIndex = orderedIndex.getAndIncrement();
int nextIndex = orderedIndex.getAndIncrement();
RecordedInteraction nextInteraction = interactions.get(nextIndex).toImmutable();
if (nextInteraction == null) {
throw new IllegalStateException(String.format("No recording found at position %s",
Expand Down
2 changes: 1 addition & 1 deletion okreplay-core/src/main/java/okreplay/OkReplayConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public Builder withProperties(Properties properties) {
if (properties.containsKey("okreplay.defaultMatchRules")) {
String property = properties.getProperty("okreplay.defaultMatchRules");
List<MatchRule> rules = new ArrayList<>();
for (String s : Arrays.asList(property.split(","))) {
for (String s : property.split(",")) {
rules.add(MatchRules.valueOf(s));
}
defaultMatchRule(ComposedMatchRule.of(rules));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ class OkReplayPlugin
project.tasks.create("pull${targetName}OkReplayTapes", PullTapesTask::class.java)
val clearTapesTask: TapeTask =
project.tasks.create("clear${targetName}OkReplayTapes", ClearTapesTask::class.java)
val globalScope = it.globalScope()
val adbPath = globalScope.androidBuilder.sdkInfo.adb
val adbTimeoutMs = globalScope.extension.adbOptions.timeOutInMs
val extension = project.extensions.getByType(BaseExtension::class.java)
val adbPath = extension.adbExecutable
val adbTimeoutMs = extension.adbOptions.timeOutInMs
val testApplicationId = project.testApplicationId()
val deviceBridge = DeviceBridgeProvider.get(adbPath, adbTimeoutMs, project)
listOf(pullTapesTask, clearTapesTask).forEach {
Expand Down
8 changes: 0 additions & 8 deletions okreplay-junit/src/main/kotlin/okreplay/CharMatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@ internal abstract class CharMatcher : Predicate<Char> {
return matches(character!!)
}

/**
* Returns a string representation of this `CharMatcher`, such as
* `CharMatcher.or(WHITESPACE, JAVA_DIGIT)`.
*/
override fun toString(): String {
return super.toString()
}

// Fast matchers

/** A matcher for which precomputation will not yield any significant benefit. */
Expand Down
12 changes: 9 additions & 3 deletions okreplay-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ android {
lintOptions {
disable 'InvalidPackage'
}

useLibrary 'android.test.runner'
useLibrary 'android.test.base'
useLibrary 'android.test.mock'
}

dependencies {
Expand All @@ -43,19 +47,21 @@ dependencies {
implementation 'com.squareup.retrofit2:converter-moshi:2.3.0'
compileOnly 'com.google.auto.value:auto-value:1.5.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'com.squareup.okio:okio:1.14.0'
implementation dep.okio
implementation dep.okhttp
implementation dep.jsr305
kapt 'com.ryanharter.auto.value:auto-value-moshi:0.4.3'
compileOnly 'com.ryanharter.auto.value:auto-value-moshi-annotations:0.4.3'
testImplementation dep.junit
annotationProcessor 'com.google.auto.value:auto-value:1.5.2'
kapt 'com.google.auto.value:auto-value:1.5.2'
androidTestAnnotationProcessor 'com.google.auto.value:auto-value:1.5.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation project(':okreplay-espresso')
androidTestImplementation dep.androidXAnnotations
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation dep.androidXTestRunner
androidTestImplementation dep.androidXTestRules
androidTestImplementation 'com.squareup.okio:okio:1.14.0'
androidTestImplementation dep.okio
androidTestImplementation dep.okhttp
androidTestImplementation 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package okreplay.sample;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.espresso.IdlingRegistry;
import androidx.test.espresso.IdlingResource;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import com.jakewharton.espresso.OkHttp3IdlingResource;

Expand All @@ -21,7 +22,6 @@
import okreplay.OkReplayRuleChain;
import okreplay.TapeMode;

import static androidx.test.InstrumentationRegistry.getContext;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
Expand All @@ -35,7 +35,7 @@ public class ExampleInstrumentedBarTest {
private final ActivityTestRule<MainActivity> activityTestRule =
new ActivityTestRule<>(MainActivity.class);
private final OkReplayConfig configuration = new OkReplayConfig.Builder()
.tapeRoot(new AndroidTapeRoot(getContext(), getClass()))
.tapeRoot(new AndroidTapeRoot(ApplicationProvider.getApplicationContext(), getClass()))
.defaultMode(TapeMode.READ_WRITE)
.sslEnabled(true)
.interceptor(graph.getOkReplayInterceptor())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package okreplay.sample;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.espresso.IdlingRegistry;
import androidx.test.espresso.IdlingResource;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;

import com.jakewharton.espresso.OkHttp3IdlingResource;

Expand All @@ -22,8 +23,6 @@
import okreplay.OkReplayRuleChain;
import okreplay.TapeMode;

import static androidx.test.InstrumentationRegistry.getContext;
import static androidx.test.InstrumentationRegistry.getTargetContext;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
Expand All @@ -37,8 +36,10 @@ public class ExampleInstrumentedFooTest {
private final DependencyGraph graph = DependencyGraph.Companion.instance();
private final ActivityTestRule<MainActivity> activityTestRule =
new ActivityTestRule<>(MainActivity.class);
private final AssetManager assetManager =
new AssetManager(ApplicationProvider.getApplicationContext());
private final OkReplayConfig configuration = new OkReplayConfig.Builder()
.tapeRoot(new AndroidTapeRoot(new AssetManager(getContext()), getClass().getSimpleName()))
.tapeRoot(new AndroidTapeRoot(assetManager, getClass().getSimpleName()))
.defaultMode(TapeMode.READ_WRITE)
.sslEnabled(true)
.interceptor(graph.getOkReplayInterceptor())
Expand All @@ -60,7 +61,7 @@ public class ExampleInstrumentedFooTest {
@Test
@OkReplay
public void foo() {
assertEquals("okreplay.sample", getTargetContext().getPackageName());
assertEquals("okreplay.sample", ApplicationProvider.getApplicationContext().getPackageName());
onView(withId(R.id.navigation_repositories)).perform(click());
onView(withId(R.id.message)).check(matches(withText(containsString("6502Android"))));
}
Expand Down