Skip to content

Commit

Permalink
[Android] Bump unit test robolectric version to 4.10.3 (#42454)
Browse files Browse the repository at this point in the history
Bumps robolectric version for unit tests to [4.10.3](https://github.com/robolectric/robolectric/releases/tag/robolectric-4.10.3), the latest and greatest. Should support running unit tests with API 33.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
camsim99 committed Jun 2, 2023
1 parent b4250ac commit 4839761
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion shell/platform/android/test/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Unit testing Java code

All Java code in the engine should now be able to be tested with Robolectric 4.7.3
All Java code in the engine should now be able to be tested with Robolectric 4.10.3
and JUnit 4. The test suite has been added after the bulk of the Java code was
first written, so most of these classes do not have existing tests. Ideally code
after this point should be tested, either with unit tests here or with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.RealObject;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowResources;

@Implements(Resources.class)
public class SplashShadowResources {
public class SplashShadowResources extends ShadowResources {
@RealObject private Resources resources;

public static final int SPLASH_DRAWABLE_ID = 191919;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public void draw(Canvas canvas) {
verify(surface, times(1)).lockHardwareCanvas();
verify(surface, times(1)).unlockCanvasAndPost(canvas);
verifyNoMoreInteractions(surface);
verifyNoMoreInteractions(canvas);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,7 @@ public void disposeNullAndroidView() {
PlatformViewFactory viewFactory = mock(PlatformViewFactory.class);
PlatformView platformView = mock(PlatformView.class);

Context context = ApplicationProvider.getApplicationContext();
View androidView = new View(context);
View androidView = mock(View.class);
when(platformView.getView()).thenReturn(androidView);
when(viewFactory.create(any(), eq(platformViewId), any())).thenReturn(platformView);
platformViewsController.getRegistry().registerViewFactory("testType", viewFactory);
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/android/test_runner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ android {
testImplementation "androidx.test:core:1.4.0"
testImplementation "com.google.android.play:core:1.8.0"
testImplementation "com.ibm.icu:icu4j:69.1"
testImplementation "org.robolectric:robolectric:4.7.3"
testImplementation "org.robolectric:robolectric:4.10.3"
testImplementation "junit:junit:4.13.2"
testImplementation "androidx.test.ext:junit:1.1.4-alpha07"

Expand Down

0 comments on commit 4839761

Please sign in to comment.