Fix FileDisplayActivity screenshot tests

Signed-off-by: Álvaro Brey Vilas <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey Vilas 2022-03-23 10:09:04 +01:00
parent 154755af9b
commit 2e593a034b
No known key found for this signature in database
GPG key ID: 2585783189A62105
2 changed files with 17 additions and 9 deletions

View file

@ -53,12 +53,14 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
@ScreenshotTest
fun open() {
val sut = activityRule.launchActivity(null)
sut.listOfFilesFragment!!.setFabEnabled(false)
shortSleep()
sut.runOnUiThread {
sut.listOfFilesFragment!!.setFabEnabled(false)
sut.resetScrolling()
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
sut.listOfFilesFragment!!.isLoading = false
}
shortSleep()
waitForIdleSync()
screenshot(sut)
@ -103,13 +105,16 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
fun drawer() {
val sut = activityRule.launchActivity(null)
Espresso.onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
sut.listOfFilesFragment!!.setFabEnabled(false)
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
sut.listOfFilesFragment!!.isLoading = false
shortSleep()
sut.runOnUiThread {
sut.hideInfoBox()
sut.resetScrolling()
sut.listOfFilesFragment!!.setFabEnabled(false)
sut.listOfFilesFragment!!.setEmptyListLoadingMessage()
sut.listOfFilesFragment!!.isLoading = false
}
shortSleep()
waitForIdleSync()
screenshot(sut)
}

View file

@ -135,6 +135,7 @@ import java.util.List;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.SearchView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
@ -1267,7 +1268,7 @@ public class FileDisplayActivity extends FileActivity
OCFileListFragment ocFileListFragment = getListOfFilesFragment();
if (ocFileListFragment != null) {
ocFileListFragment.setLoading(mSyncInProgress);
if (!mSyncInProgress) {
if (!mSyncInProgress && !ocFileListFragment.isLoading()) {
// update scrolling when load finishes
if (ocFileListFragment.isEmpty()) {
lockScrolling();
@ -1526,7 +1527,8 @@ public class FileDisplayActivity extends FileActivity
/**
* Prevents content scrolling and toolbar collapse
*/
private void lockScrolling() {
@VisibleForTesting
public void lockScrolling() {
final CoordinatorLayout.LayoutParams coordinatorParams = (CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams();
coordinatorParams.setBehavior(null);
binding.rootLayout.setLayoutParams(coordinatorParams);
@ -1540,7 +1542,8 @@ public class FileDisplayActivity extends FileActivity
/**
* Resets content scrolling and toolbar collapse
*/
private void resetScrolling() {
@VisibleForTesting
public void resetScrolling() {
final CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams();
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
binding.rootLayout.setLayoutParams(params);