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

MainActivityTest_Drawer.testBackupAndBackDeep breaks #151

Closed
TWiStErRob opened this issue Apr 4, 2020 · 8 comments
Closed

MainActivityTest_Drawer.testBackupAndBackDeep breaks #151

TWiStErRob opened this issue Apr 4, 2020 · 8 comments
Labels
a:bug something isn't working as expected in:test unit, or UI tests
Milestone

Comments

@TWiStErRob
Copy link
Owner

TWiStErRob commented Apr 4, 2020

API 21 (consistent failure), API 23 works (3 tries passed)
hangs when whole class is executed
Result: no activity in foreground
Spamming log: I/MonitoringInstr: Unstopped activity count: 1
and the test hangs for 30-ish seconds, then fails.

to make sure it fails:

rem to clear any granted permissions
adb uninstall net.twisterrob.inventory.debug.test
rem Transition animation scale must be normal, the rest doesn't matter.
adb shell settings put global transition_animation_scale 1

image

@TWiStErRob TWiStErRob added a:bug something isn't working as expected in:test unit, or UI tests labels Apr 4, 2020
@TWiStErRob TWiStErRob added this to the v1.1.3 milestone Apr 4, 2020
@TWiStErRob
Copy link
Owner Author

Debugging through each step of the test makes it pass.
Stopping on main.assertHomeScreen(); only still reproduces.

@TWiStErRob
Copy link
Owner Author

TWiStErRob commented Apr 5, 2020

Test execution order is:

  • testSettings
  • testBackupAndBackDeep

and removing all tests, even testSettings still makes it fail.

@TWiStErRob
Copy link
Owner Author

TWiStErRob commented Apr 5, 2020

Not doing

BackupActivityActor backup = main.openBackup().asActor();
backup.close();

makes it pass.


properties.checkOpened() has no effect on the test


Not doing

PropertiesNavigator properties = main.openProperties();
properties.tryClose();

makes it pass too.

@TWiStErRob
Copy link
Owner Author

TWiStErRob commented Apr 5, 2020

An inlined version:

	@Test public void testBackupAndBackDeep() {
		onView(isNavigationDrawer())
				.perform(openContainingDrawer())
				.perform(navigateTo(R.id.action_drawer_properties));
		//onView(isDrawerLayout()).check(matches(areBothDrawersClosed()));
		//onView(isActionBarTitle())
		//		.check(matches(isCompletelyDisplayed()))
		//		.check(matches(withText(R.string.property_list)))
		//;
		//onView(withId(android.R.id.list)).check(matches(isCompletelyDisplayed()));
		//onDrawerDescendant(withText(R.string.property_list))
		//		.check(matches(navigationItemIsHighlighted()));
		{
			onView(isNavigationDrawer())
					.perform(openContainingDrawer())
					.perform(navigateTo(R.id.action_drawer_backup));
			//onView(isDrawerLayout()).check(doesNotExist());
			//onView(isActionBarTitle())
			//		.check(matches(isCompletelyDisplayed()))
			//		.check(matches(withText(R.string.backup_title)))
			//;
			//onView(withId(R.id.backups)).check(matches(isCompletelyDisplayed()));
			Espresso.pressBack();
		}
		Espresso.pressBack();
	}

the matchers don't make a difference.

@TWiStErRob
Copy link
Owner Author

pass: rooms, categories, category_guide, items, sunburst, manage (pressBackExternal because it's separate process)
fail: backup, about, preferences

@TWiStErRob
Copy link
Owner Author

Minimal repro is down to:

onView(isNavigationDrawer()).perform(openContainingDrawer(false));
onView(isNavigationDrawer()).perform(navigateTo(R.id.action_drawer_about));
//onRoot().perform(EspressoExtensions.loopMainThreadForAtLeast(500));
Espresso.pressBack();

and the loopMainThreadForAtLeast makes it pass.

@TWiStErRob
Copy link
Owner Author

When passing MainActivity goes through a restart cycle while AboutActivity is in front.

D/LifecycleMonitor: Lifecycle status change: MainActivity in: PRE_ON_CREATE
D/LifecycleMonitor: Lifecycle status change: MainActivity in: CREATED
D/LifecycleMonitor: Lifecycle status change: MainActivity in: STARTED
D/LifecycleMonitor: Lifecycle status change: MainActivity in: RESUMED
D/LifecycleMonitor: Lifecycle status change: MainActivity in: PAUSED
D/LifecycleMonitor: Lifecycle status change: AboutActivity in: PRE_ON_CREATE
D/LifecycleMonitor: Lifecycle status change: AboutActivity in: CREATED
D/LifecycleMonitor: Lifecycle status change: AboutActivity in: STARTED
D/LifecycleMonitor: Lifecycle status change: AboutActivity in: RESUMED
+D/LifecycleMonitor: Lifecycle status change: MainActivity in: STOPPED
D/LifecycleMonitor: Lifecycle status change: AboutActivity in: PAUSED
+D/LifecycleMonitor: Lifecycle status change: MainActivity in: RESTARTED
+D/LifecycleMonitor: Lifecycle status change: MainActivity in: STARTED
D/LifecycleMonitor: Lifecycle status change: MainActivity in: RESUMED
D/LifecycleMonitor: Lifecycle status change: AboutActivity in: STOPPED
D/LifecycleMonitor: Lifecycle status change: AboutActivity in: DESTROYED
D/LifecycleMonitor: Lifecycle status change: MainActivity in: PAUSED
+D/LifecycleMonitor: Lifecycle status change: MainActivity in: STOPPED
+D/LifecycleMonitor: Lifecycle status change: MainActivity in: DESTROYED

The "added" lines above are missing when a failure happens.

@TWiStErRob
Copy link
Owner Author

Fixed with a workaround: wait for MainActivity to stop, and only act after.
Fixed in svn@3116

TWiStErRob added a commit to TWiStErRob/net.twisterrob.libraries that referenced this issue Feb 24, 2023
[FIX] TWiStErRob/net.twisterrob.inventory#151 by waiting for the MainActivity to be stopped before continuing.
TWiStErRob added a commit that referenced this issue Feb 24, 2023
[FIX] #151 by waiting for the MainActivity to be stopped before continuing.
TWiStErRob added a commit to TWiStErRob/net.twisterrob.travel that referenced this issue Nov 19, 2023
[FIX] TWiStErRob/net.twisterrob.inventory#151 by waiting for the MainActivity to be stopped before continuing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug something isn't working as expected in:test unit, or UI tests
Projects
None yet
Development

No branches or pull requests

1 participant