Skip to content

Commit

Permalink
Fix issues caused by use of FB internal things (#2574)
Browse files Browse the repository at this point in the history
Summary:
Thanks for submitting a PR! Please read these instructions carefully:

- [X] Explain the **motivation** for making this change.
- [X] Provide a **test plan** demonstrating that the code is solid.
- [X] Match the **code formatting** of the rest of the codebase.
- [X] Target the `master` branch

## Motivation (required)

A test class was added in commit 9aa485d (FB internal D24799754 (9aa485d)) which relies on FB internal classes and configuration to compile, this meant that the GitHub PR verification action would fail the compilation test due to not having these resources available. This PR replaces the internal stuff with things available to the GitHub verification action;

* WithTestDefaultsRunner is an internal Facebook test runner which is unavailable in this repo, so I've replaced it with the Robolectric runner
* PowerMock wasn't in the build.gradle dependencies (but is probably in the BUCK dependencies internally), so I've added it.

Fixes: #2567

## Test Plan (required)

If this compiles and the tests completes we're all good.

## Next Steps

Sign the [CLA][2], if you haven't already.

Small pull requests are much easier to review and more likely to get merged. Make sure the PR does only one thing, otherwise please split it.

Make sure all **tests pass** on [Circle CI][4]. PRs that break tests are unlikely to be merged.

For more info, see the [Contributing guide][4].

[1]: https://medium.com/martinkonicek/what-is-a-test-plan-8bfc840ec171#.y9lcuqqi9
[2]: https://code.facebook.com/cla
[3]: http://circleci.com/gh/facebook/fresco
[4]: https://github.com/facebook/fresco/blob/master/CONTRIBUTING.md

Pull Request resolved: #2574

Reviewed By: defHLT

Differential Revision: D25850530

Pulled By: oprisnik

fbshipit-source-id: b291ae389cb93126f7e74cae3f0adc155f364645
  • Loading branch information
alsutton authored and facebook-github-bot committed Jan 15, 2021
1 parent 0dcdfc5 commit 0aa2f09
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
object FrescoConfig {
const val buildToolsVersion = "29.0.3"

const val compileSdkVersion = 28
const val compileSdkVersion = 29
const val minSdkVersion = 14
const val samplesMinSdkVersion = 15
const val targetSdkVersion = 28
Expand Down
3 changes: 3 additions & 0 deletions drawee/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ dependencies {
testImplementation Deps.jsr305
testImplementation TestDeps.junit
testImplementation TestDeps.mockitoCore
testImplementation(TestDeps.Powermock.apiMockito) {
exclude group: 'org.mockito', module: 'mockito-all'
}
testImplementation(TestDeps.robolectric) {
exclude group: 'commons-logging', module: 'commons-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.LooperMode;
import org.robolectric.shadows.ShadowLooper;

@RunWith(RobolectricTestRunner.class)
@LooperMode(LooperMode.Mode.LEGACY) // Required for pausing and unpausing looper
public class DeferredReleaserStressTest {
private static final int K = 1000;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.SystemClock;
import com.facebook.testing.robolectric.v4.WithTestDefaultsRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.robolectric.RobolectricTestRunner;

/** Tests {@link FadeDrawable.OnFadeListener} */
@RunWith(WithTestDefaultsRunner.class)
@RunWith(RobolectricTestRunner.class)
@PrepareForTest({
// SystemClock.class,
Rect.class,
Expand Down
1 change: 1 addition & 0 deletions fbcore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
compileOnly Deps.javaxAnnotation
compileOnly Deps.AndroidX.androidxAnnotation

testImplementation Deps.inferAnnotation
testImplementation project(':mockito-config')
testImplementation Deps.jsr305
testImplementation TestDeps.junit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.Shadows;
import org.robolectric.annotation.Config;
import org.robolectric.annotation.LooperMode;
import org.robolectric.shadows.ShadowLooper;

@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@LooperMode(LooperMode.Mode.LEGACY) // Required for pausing and unpausing the looper
public class HandlerExecutorServiceImplTest {

private AtomicInteger mCounter = new AtomicInteger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,15 @@ public void delegateFetchStateIsRecreatedOnRequeue() {

assertThat(recordingNetworkFetcher.createdFetchStates).hasSize(1);
assertThat(fetchState.delegatedState)
.isSameAs(recordingNetworkFetcher.createdFetchStates.get(0));
.isSameInstanceAs(recordingNetworkFetcher.createdFetchStates.get(0));

// Simulate a failure in fetchState, triggering a requeue.
getOnlyElement(recordingNetworkFetcher.callbacks.get(fetchState.delegatedState))
.onFailure(new Exception());

assertThat(recordingNetworkFetcher.createdFetchStates).hasSize(2);
assertThat(fetchState.delegatedState)
.isSameAs(recordingNetworkFetcher.createdFetchStates.get(1));
.isSameInstanceAs(recordingNetworkFetcher.createdFetchStates.get(1));

Map<String, String> extrasMap = fetcher.getExtraMap(fetchState, 123);
assertThat(extrasMap).containsEntry("requeueCount", "1");
Expand Down
1 change: 1 addition & 0 deletions samples/gestures/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies {

implementation project(':drawee-backends:drawee-pipeline')

testImplementation Deps.inferAnnotation
testImplementation TestDeps.junit
testImplementation TestDeps.mockitoCore
testImplementation(TestDeps.robolectric) {
Expand Down

0 comments on commit 0aa2f09

Please sign in to comment.