mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
add ui test
- some small code changes - removed unneeded code Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
56076dfd96
commit
8737d9b835
6 changed files with 78 additions and 17 deletions
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.dialog;
|
||||
|
||||
import android.Manifest;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
public class SyncFileNotEnoughSpaceDialogFragmentTest extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
|
||||
@Test
|
||||
public void showNotEnoughSpaceDialogForFolder() throws InterruptedException {
|
||||
FileDisplayActivity test = activityRule.launchActivity(null);
|
||||
OCFile ocFile = new OCFile("/Document/");
|
||||
ocFile.setFileLength(5000000);
|
||||
|
||||
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 1000);
|
||||
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "1");
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
Screenshot.snap(dialog.getDialog().getWindow().getDecorView()).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void showNotEnoughSpaceDialogForFile() throws InterruptedException {
|
||||
FileDisplayActivity test = activityRule.launchActivity(null);
|
||||
OCFile ocFile = new OCFile("/Video.mp4");
|
||||
ocFile.setFileLength(1000000);
|
||||
|
||||
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 2000);
|
||||
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "2");
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
Screenshot.snap(dialog.getDialog().getWindow().getDecorView()).record();
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@ import android.content.Intent;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.storage.StorageManager;
|
||||
import android.view.ActionMode;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
|
@ -47,16 +46,8 @@ public class SyncFileNotEnoughSpaceDialogFragment extends ConfirmationDialogFrag
|
|||
private static final String ARG_PASSED_FILE = "fragment_parent_caller";
|
||||
private static final int REQUEST_CODE_STORAGE = 20;
|
||||
|
||||
private ActionMode actionMode;
|
||||
private OCFile targetFile;
|
||||
|
||||
public static SyncFileNotEnoughSpaceDialogFragment newInstance(OCFile file, long availableDeviceSpace,
|
||||
ActionMode actionMode) {
|
||||
SyncFileNotEnoughSpaceDialogFragment dialogFragment = newInstance(file, availableDeviceSpace);
|
||||
return dialogFragment;
|
||||
}
|
||||
|
||||
|
||||
public static SyncFileNotEnoughSpaceDialogFragment newInstance(OCFile file, long availableDeviceSpace) {
|
||||
Bundle args = new Bundle();
|
||||
SyncFileNotEnoughSpaceDialogFragment frag = new SyncFileNotEnoughSpaceDialogFragment();
|
||||
|
|
|
@ -26,10 +26,7 @@ package com.owncloud.android.ui.fragment;
|
|||
|
||||
import android.accounts.Account;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
|
@ -46,7 +43,6 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.Button;
|
||||
import android.widget.PopupMenu;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
@ -1123,7 +1119,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
}
|
||||
case R.id.action_download_file:
|
||||
case R.id.action_sync_file: {
|
||||
this.syncAndCheckFiles(checkedFiles);
|
||||
syncAndCheckFiles(checkedFiles);
|
||||
exitSelectionMode();
|
||||
return true;
|
||||
}
|
||||
|
@ -1743,7 +1739,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
|
||||
private void showSpaceErrorDialog(OCFile file, long availableDeviceSpace) {
|
||||
SyncFileNotEnoughSpaceDialogFragment dialog =
|
||||
SyncFileNotEnoughSpaceDialogFragment.newInstance(file, availableDeviceSpace, mActiveActionMode);
|
||||
SyncFileNotEnoughSpaceDialogFragment.newInstance(file, availableDeviceSpace);
|
||||
dialog.setTargetFragment(this, NOT_ENOUGH_SPACE_FRAG_REQUEST_CODE);
|
||||
|
||||
if (getFragmentManager() != null) {
|
||||
|
|
|
@ -1045,8 +1045,7 @@ public class FileOperationsHelper {
|
|||
if (android.os.Build.VERSION.SDK_INT >=
|
||||
android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
availableBytesOnDevice = stat.getBlockSizeLong() * stat.getAvailableBlocksLong();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
availableBytesOnDevice = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue