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

AlwaysOnKotlin tests fail even with older checkouts #219

Open
yschimke opened this issue Feb 21, 2022 · 6 comments
Open

AlwaysOnKotlin tests fail even with older checkouts #219

yschimke opened this issue Feb 21, 2022 · 6 comments

Comments

@yschimke
Copy link
Contributor

java.lang.IllegalStateException: No compose views found in the app. Is your Activity resumed?
	at androidx.compose.ui.test.TestContext.getAllSemanticsNodes$ui_test_release(TestOwner.kt:96)
	at androidx.compose.ui.test.SemanticsNodeInteraction.fetchSemanticsNodes$ui_test_release(SemanticsNodeInteraction.kt:79)
	at androidx.compose.ui.test.SemanticsNodeInteraction.fetchOneOrDie(SemanticsNodeInteraction.kt:145)
	at androidx.compose.ui.test.SemanticsNodeInteraction.fetchSemanticsNode(SemanticsNodeInteraction.kt:96)

Screen shows

image

This is both at head but also back at 15fdaf1

cc @alexvanyo @shumelchyk

@yschimke
Copy link
Contributor Author

Working fine for me locally on API 28.

@yschimke
Copy link
Contributor Author

Failing differently on API 26

com.example.android.wearable.wear.alwayson.AlwaysOnAppTests > textIsCorrectAfterReturningToActiveMode[test(AVD) - 8.0.0] FAILED 
	java.lang.AssertionError: Failed to assert the following: (Text + EditableText = [Draw count: 9])
	Semantics of the node:
Tests on test(AVD) - 8.0.0 failed: There was 1 failure(s).
Feb 21, 2022 4:56:34 PM com.google.testing.platform.RunnerImpl$Companion summarizeAndLogTestResult
SEVERE: Execute com.example.android.wearable.wear.alwayson.AlwaysOnAppTests.textIsCorrectAfterReturningToActiveMode: FAILED
java.lang.AssertionError: java.lang.AssertionError: Failed to assert the following: (Text + EditableText = [Draw count: 9])
Semantics of the node:
Node #35 at (l=75.0, t=170.0, r=205.0, b=199.0)px, Tag: 'drawCount'
Text = '[Draw count: 8]'
Actions = [GetTextLayoutResult]
Has 4 siblings
Selector used: (TestTag = 'drawCount')

at androidx.compose.ui.test.AssertionsKt.assert(Assertions.kt:270)
at androidx.compose.ui.test.AssertionsKt.assert$default(Assertions.kt:260)
at androidx.compose.ui.test.AssertionsKt.assertTextEquals(Assertions.kt:190)
at androidx.compose.ui.test.AssertionsKt.assertTextEquals$default(Assertions.kt:186)

@castedmo
Copy link
Contributor

So the issue is that the current emulator binary sets the wear emulator to be connected to a charger. This causes the charger experience to cover the whole screen whenever the display goes to ambient.
The long term solution is to wait for a fix that is will be released which sets the wear emulator to not be on a charger by default.
The short term solution is to disconnect the charger before the test with adb emu power ac off

@yschimke
Copy link
Contributor Author

Failing with different errors - #221

com.example.android.wearable.wear.alwayson.MainActivityTests > textIsCorrectAfterFiveSeconds[test(AVD) - 11] FAILED 
	java.lang.AssertionError: Activity never becomes requested state "[STARTED]" (last lifecycle transition = "DESTROYED")
	at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338)

com.example.android.wearable.wear.alwayson.MainActivityTests > textIsCorrectAfterReturningToActiveMode[test(AVD) - 11] FAILED 
	androidx.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'an instance of android.widget.TextView and view.getText() with or without transformation to match: is "Draw count: 9"' doesn't match the selected view.
	Expected: an instance of android.widget.TextView and view.getText() with or without transformation to match: is "Draw count: 9"

@yschimke
Copy link
Contributor Author

As @castedmo pointed out these are the View tests.

@yschimke
Copy link
Contributor Author

Running locally it generally works but there are still some timing issues or behavior change in the emulator breaking the test. Also in the compose test.

It will need someone to investigate and confirm the new behavior is a bug, or update the tests to be more tolerant if it's new expected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants