mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
fix ss test -- require activity crash
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
4b5a901be2
commit
1c41a1f6cb
1 changed files with 72 additions and 42 deletions
|
@ -1,59 +1,89 @@
|
||||||
/*
|
/*
|
||||||
* Nextcloud - Android Client
|
* Nextcloud - Android Client
|
||||||
*
|
*
|
||||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias@kaminsky.me>
|
* SPDX-FileCopyrightText: 2024 Alper Ozturk <alper.ozturk@nextcloud.com>
|
||||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
|
||||||
*/
|
*/
|
||||||
package com.owncloud.android.ui.dialog;
|
package com.owncloud.android.ui.dialog
|
||||||
|
|
||||||
import com.owncloud.android.AbstractIT;
|
import androidx.annotation.UiThread
|
||||||
import com.owncloud.android.datamodel.OCFile;
|
import androidx.test.core.app.launchActivity
|
||||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
import androidx.test.espresso.Espresso.onView
|
||||||
import com.owncloud.android.utils.ScreenshotTest;
|
import androidx.test.espresso.IdlingRegistry
|
||||||
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||||
|
import com.owncloud.android.AbstractIT
|
||||||
|
import com.owncloud.android.datamodel.OCFile
|
||||||
|
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||||
|
import com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragment.Companion.newInstance
|
||||||
|
import com.owncloud.android.utils.EspressoIdlingResource
|
||||||
|
import com.owncloud.android.utils.ScreenshotTest
|
||||||
|
import org.junit.After
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
import org.junit.Rule;
|
class SyncFileNotEnoughSpaceDialogFragmentTest : AbstractIT() {
|
||||||
import org.junit.Test;
|
private val testClassName = "com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragmentTest"
|
||||||
|
|
||||||
import java.util.Objects;
|
@Before
|
||||||
|
fun registerIdlingResource() {
|
||||||
|
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||||
|
}
|
||||||
|
|
||||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
@After
|
||||||
|
fun unregisterIdlingResource() {
|
||||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||||
|
|
||||||
public class SyncFileNotEnoughSpaceDialogFragmentTest extends AbstractIT {
|
|
||||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
|
||||||
true,
|
|
||||||
false);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@ScreenshotTest
|
|
||||||
public void showNotEnoughSpaceDialogForFolder() {
|
|
||||||
FileDisplayActivity test = activityRule.launchActivity(null);
|
|
||||||
OCFile ocFile = new OCFile("/Document/");
|
|
||||||
ocFile.setFileLength(5000000);
|
|
||||||
ocFile.setFolder();
|
|
||||||
|
|
||||||
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 1000);
|
|
||||||
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "1");
|
|
||||||
|
|
||||||
getInstrumentation().waitForIdleSync();
|
|
||||||
|
|
||||||
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ScreenshotTest
|
@ScreenshotTest
|
||||||
public void showNotEnoughSpaceDialogForFile() {
|
@UiThread
|
||||||
FileDisplayActivity test = activityRule.launchActivity(null);
|
fun showNotEnoughSpaceDialogForFolder() {
|
||||||
OCFile ocFile = new OCFile("/Video.mp4");
|
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||||
ocFile.setFileLength(1000000);
|
scenario.onActivity { sut ->
|
||||||
|
val ocFile = OCFile("/Document/").apply {
|
||||||
|
fileLength = 5000000
|
||||||
|
setFolder()
|
||||||
|
}
|
||||||
|
|
||||||
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 2000);
|
onIdleSync {
|
||||||
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "2");
|
EspressoIdlingResource.increment()
|
||||||
|
newInstance(ocFile, 1000).apply {
|
||||||
|
show(sut.supportFragmentManager, "1")
|
||||||
|
}
|
||||||
|
EspressoIdlingResource.decrement()
|
||||||
|
|
||||||
getInstrumentation().waitForIdleSync();
|
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFolder", "")
|
||||||
|
onView(isRoot()).check(matches(isDisplayed()))
|
||||||
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
|
screenshotViaName(sut, screenShotName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@ScreenshotTest
|
||||||
|
@UiThread
|
||||||
|
fun showNotEnoughSpaceDialogForFile() {
|
||||||
|
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||||
|
scenario.onActivity { sut ->
|
||||||
|
val ocFile = OCFile("/Video.mp4").apply {
|
||||||
|
fileLength = 1000000
|
||||||
|
}
|
||||||
|
|
||||||
|
onIdleSync {
|
||||||
|
EspressoIdlingResource.increment()
|
||||||
|
newInstance(ocFile, 2000).apply {
|
||||||
|
show(sut.supportFragmentManager, "2")
|
||||||
|
}
|
||||||
|
EspressoIdlingResource.decrement()
|
||||||
|
|
||||||
|
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFile", "")
|
||||||
|
onView(isRoot()).check(matches(isDisplayed()))
|
||||||
|
screenshotViaName(sut, screenShotName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue