Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Feb 28, 2024

This allows relanding flutter/engine#51056. The patch introduced a change where a static member is initialized from View.generateViewId() instead of conditionally using that API. Without an implementation for that in android.jar, the test will fail. The test in here currently is using a fake implementation that creates errors seen below.

See https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8754827734484522225/+/u/run_plugin_test/stdout#L46564_2 for failure. More detailed failure information is available locally in the build folder:

Mockito cannot mock this class: class io.flutter.embedding.android.FlutterActivity.

If you're not sure why you're getting this error, please open an issue on GitHub.


Java               : 17
JVM vendor name    : JetBrains s.r.o.
JVM vendor version : 17.0.7+0-17.0.7b1000.6-10550314
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 17.0.7+0-17.0.7b1000.6-10550314
JVM info           : mixed mode
OS name            : Mac OS X
OS version         : 14.3.1


You are seeing this disclaimer because Mockito is configured to create inlined mocks.
You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.

Underlying exception : org.mockito.exceptions.base.MockitoException: Cannot instrument class io.flutter.embedding.android.FlutterActivity because it or one of its supertypes could not be initialized
	at app//dev.flutter.plugins.integration_test.FlutterDeviceScreenshotTest.getFlutterView_returnsFlutterViewForFlutterActivity(FlutterDeviceScreenshotTest.java:32)
	at java.base@17.0.7/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base@17.0.7/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base@17.0.7/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base@17.0.7/java.lang.reflect.Method.invoke(Unknown Source)
	at app//org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
	at app//org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at app//org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
	at app//org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at app//org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at app//org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at app//org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at app//org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at app//org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at app//org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at app//org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at app//org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at app//org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at app//org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at app//org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at app//org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at java.base@17.0.7/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base@17.0.7/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base@17.0.7/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base@17.0.7/java.lang.reflect.Method.invoke(Unknown Source)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133)
	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71)
	at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
	at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
Caused by: org.mockito.exceptions.base.MockitoException: Cannot instrument class io.flutter.embedding.android.FlutterActivity because it or one of its supertypes could not be initialized
	at app//net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
	at app//net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
	at app//net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
	at app//net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
	... 44 more
Caused by: java.lang.RuntimeException: Method generateViewId in android.view.View not mocked. See http://g.co/androidstudio/not-mocked for details.
	at android.view.View.generateViewId(View.java)
	at io.flutter.embedding.android.FlutterActivity.<clinit>(FlutterActivity.java:218)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Unknown Source)
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.assureInitialization(InlineBytecodeGenerator.java:236)
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.triggerRetransformation(InlineBytecodeGenerator.java:261)
	at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.mockClass(InlineBytecodeGenerator.java:218)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.lambda$mockClass$0(TypeCachingBytecodeGenerator.java:47)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:40)
	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMockType(InlineDelegateByteBuddyMockMaker.java:396)
	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.doCreateMock(InlineDelegateByteBuddyMockMaker.java:355)
	at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMock(InlineDelegateByteBuddyMockMaker.java:334)
	at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.createMock(InlineByteBuddyMockMaker.java:56)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:99)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:88)
	at org.mockito.Mockito.mock(Mockito.java:2087)
	at org.mockito.Mockito.mock(Mockito.java:2002)
	... 44 more

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests framework flutter/packages/flutter repository. See also f: labels. f: integration_test The flutter/packages/integration_test plugin labels Feb 28, 2024
@dnfield
Copy link
Contributor Author

dnfield commented Feb 28, 2024

This is definitely modifying a test, but the bot doesn't understand that.

@gmackall gmackall changed the title Use robolectric/AndroidJUnit4 for integraiton test tests Use robolectric/AndroidJUnit4 for integration test tests Feb 28, 2024
Copy link
Member

@gmackall gmackall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.embedding.android.FlutterView;

public class FlutterDeviceScreenshotTest extends AndroidJUnitRunner {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we remove the import of AndroidJUnitRunner too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 28, 2024
@auto-submit auto-submit bot merged commit 835112d into flutter:master Feb 29, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 29, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Feb 29, 2024
flutter/flutter@d00bfe8...e92bca3

2024-02-29 leroux_bruno@yahoo.fr [flutter_tools] Update external link in Android manifest template (flutter/flutter#144302)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 232217f39c3c to d068d980f952 (1 revision) (flutter/flutter#144369)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9e1876141be8 to 232217f39c3c (1 revision) (flutter/flutter#144366)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 61510db94a1c to 9e1876141be8 (1 revision) (flutter/flutter#144362)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 10331db8f748 to 61510db94a1c (5 revisions) (flutter/flutter#144355)
2024-02-29 jmccandless@google.com Docs on the interaction between Shortcuts and text input (flutter/flutter#144328)
2024-02-29 dnfield@google.com Use robolectric/AndroidJUnit4 for integration test tests (flutter/flutter#144348)
2024-02-29 31859944+LongCatIsLooong@users.noreply.github.com Reland "Cache FocusNode.enclosingScope, clean up descendantsAreFocusable (#144207)" (flutter/flutter#144330)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 455c814fe5de to 10331db8f748 (7 revisions) (flutter/flutter#144345)
2024-02-29 dkwingsmt@users.noreply.github.com ReportTiming callback should record the sendFrameToEngine when it was scheduled (flutter/flutter#144212)
2024-02-29 katelovett@google.com Disable flaky golden file test (flutter/flutter#144351)
2024-02-28 jmccandless@google.com Mention SelectionArea in SelectableText docs (flutter/flutter#143784)
2024-02-28 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 6.0.0 to 6.0.1 (flutter/flutter#144344)
2024-02-28 36861262+QuncCccccc@users.noreply.github.com Reland "Reland - Introduce tone-based surfaces and accent color add-ons - Part 2" (flutter/flutter#144273)
2024-02-28 72562119+tgucio@users.noreply.github.com Remove irrelevant comment in TextPainter (flutter/flutter#144308)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
dnfield added a commit to flutter/engine that referenced this pull request Feb 29, 2024
This reverts commit c9381fb.

Reverted in #51056 because it
caused failures in the framework. No changes, but framework test has
been updated to use an actual robolectric implementation to avoid those
failures.

This should not land until
flutter/flutter#144348 has landed in the
framework.

@gaaclarke @johnmccutchan fyi
LouiseHsu pushed a commit to LouiseHsu/packages that referenced this pull request Mar 7, 2024
flutter/flutter@d00bfe8...e92bca3

2024-02-29 leroux_bruno@yahoo.fr [flutter_tools] Update external link in Android manifest template (flutter/flutter#144302)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 232217f39c3c to d068d980f952 (1 revision) (flutter/flutter#144369)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9e1876141be8 to 232217f39c3c (1 revision) (flutter/flutter#144366)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 61510db94a1c to 9e1876141be8 (1 revision) (flutter/flutter#144362)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 10331db8f748 to 61510db94a1c (5 revisions) (flutter/flutter#144355)
2024-02-29 jmccandless@google.com Docs on the interaction between Shortcuts and text input (flutter/flutter#144328)
2024-02-29 dnfield@google.com Use robolectric/AndroidJUnit4 for integration test tests (flutter/flutter#144348)
2024-02-29 31859944+LongCatIsLooong@users.noreply.github.com Reland "Cache FocusNode.enclosingScope, clean up descendantsAreFocusable (#144207)" (flutter/flutter#144330)
2024-02-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from 455c814fe5de to 10331db8f748 (7 revisions) (flutter/flutter#144345)
2024-02-29 dkwingsmt@users.noreply.github.com ReportTiming callback should record the sendFrameToEngine when it was scheduled (flutter/flutter#144212)
2024-02-29 katelovett@google.com Disable flaky golden file test (flutter/flutter#144351)
2024-02-28 jmccandless@google.com Mention SelectionArea in SelectableText docs (flutter/flutter#143784)
2024-02-28 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 6.0.0 to 6.0.1 (flutter/flutter#144344)
2024-02-28 36861262+QuncCccccc@users.noreply.github.com Reland "Reland - Introduce tone-based surfaces and accent color add-ons - Part 2" (flutter/flutter#144273)
2024-02-28 72562119+tgucio@users.noreply.github.com Remove irrelevant comment in TextPainter (flutter/flutter#144308)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 14, 2024
auto-submit bot pushed a commit that referenced this pull request May 22, 2024
May fix #148393.

There are reports on the robolectric issue tracker of >`4.10.3` causing the error we are seeing
robolectric/robolectric#8158
The test doesn't actually need robolectric (and didn't originally use it, or flake before using it), but it was added in #144348. We can safely remove it by mocking the call to `View.generateViewId()`, so try removing it and see if flakes go away.
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request May 31, 2024
May fix flutter#148393.

There are reports on the robolectric issue tracker of >`4.10.3` causing the error we are seeing
robolectric/robolectric#8158
The test doesn't actually need robolectric (and didn't originally use it, or flake before using it), but it was added in flutter#144348. We can safely remove it by mocking the call to `View.generateViewId()`, so try removing it and see if flakes go away.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests autosubmit Merge PR when tree becomes green via auto submit App f: integration_test The flutter/packages/integration_test plugin framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants