Merge pull request #5300 from nextcloud/sharedSearchAgain

Re-enable shared search and add ui test for list shares
This commit is contained in:
Andy Scherzinger 2020-02-14 13:52:18 +01:00 коммит произвёл GitHub
Родитель 68f06ea158 61027524f7
Коммит 490b292ad9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 156 добавлений и 27 удалений

Просмотреть файл

@ -102,7 +102,21 @@ steps:
services:
- name: server
image: nextcloudci/server:server-3
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
commands:
- /usr/local/bin/initnc.sh
- su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1"
- su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2"
- su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3"
- su www-data -c "php /var/www/html/occ user:setting user2 files quota 1G"
- su www-data -c "php /var/www/html/occ group:add users"
- su www-data -c "php /var/www/html/occ group:adduser users user1"
- su www-data -c "php /var/www/html/occ group:adduser users user2"
- su www-data -c "git clone -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
- su www-data -c "php /var/www/html/occ app:enable activity"
- su www-data -c "git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text/"
- su www-data -c "php /var/www/html/occ app:enable text"
- /usr/local/bin/run.sh
trigger:
branch:

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 18 KiB

Просмотреть файл

@ -1 +1 @@
387
386

Просмотреть файл

@ -15,7 +15,7 @@ emulator -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-window -no
PID=$(echo $!)
## server
docker run --name=uiComparison nextcloudci/server 1>/dev/null &
docker run --name=uiComparison nextcloudci/server:server-17 1>/dev/null &
sleep 5
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' uiComparison)
@ -28,9 +28,19 @@ fi
cp gradle.properties gradle.properties_
sed -i s"/server/$IP/" gradle.properties
scripts/wait_for_emulator.sh
scripts/wait_for_server.sh ${IP}
## update all screenshots
# setup test server
docker exec uiComparison /bin/sh -c "/usr/local/bin/initnc.sh"
docker exec uiComparison /bin/sh -c "su www-data -c \"OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1\""
docker exec uiComparison /bin/sh -c "su www-data -c \"OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2\""
docker exec uiComparison /bin/sh -c "su www-data -c \"OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ user:setting user2 files quota 1G\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:add users\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:adduser users user1\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ group:adduser users user2\""
docker exec uiComparison /bin/sh -c "/usr/local/bin/run.sh"
## update/create all screenshots
./gradlew executeScreenshotTests -Precord
## update screenshots in a class

Просмотреть файл

@ -1,5 +1,19 @@
#!/usr/bin/env bash
upload() {
cd $1
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \;
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
curl -u $GITHUB_USER:$GITHUB_PASSWORD -X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
-d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
exit 1
}
#1: LOG_USERNAME
#2: LOG_PASSWORD
#3: DRONE_BUILD_NUMBER
@ -13,6 +27,9 @@ ID=$3
USER=$1
PASS=$2
TYPE=$4
PR=$5
GITHUB_USER=$6
GITHUB_PASSWORD=$7
REMOTE_FOLDER=$ID-$TYPE
set -e
@ -22,27 +39,30 @@ if [ $TYPE = "IT" ]; then
elif [ $TYPE = "Unit" ]; then
FOLDER=build/reports/tests/testGplayDebugUnitTest
else
FOLDER=build/reports/shot/verification/
FOLDER=build/reports/shot/verification
fi
if [ ! -e $FOLDER ]; then
if [ -e $FOLDER ]; then
upload $FOLDER
else
echo "$TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
curl -u $6:$7 \
-X POST https://api.github.com/repos/nextcloud/android/issues/$5/comments \
curl -u $GITHUB_USER:$GITHUB_PASSWORD \
-X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
-d "{ \"body\" : \"$TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
exit 1
if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
TYPE="IT"
upload "build/reports/androidTests/connected/flavors/GPLAY"
fi
if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
TYPE="Unit"
upload "build/reports/tests/testGplayDebugUnitTest"
fi
if [ -e build/reports/shot/verification ] ; then
TYPE="Screenshot"
upload "build/reports/shot/verification"
fi
fi
cd $FOLDER
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
find . -type f -exec curl -u $USER:$PASS -X PUT $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) --upload-file {} \;
echo "Uploaded failing tests to https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER"
curl -u $6:$7 -X POST https://api.github.com/repos/nextcloud/android/issues/$5/comments \
-d "{ \"body\" : \"$TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
exit 1

Просмотреть файл

@ -8,7 +8,7 @@ until [[ $status = "false" ]]; do
if [[ "$status" =~ "false" || "$status" = "" ]]; then
let "counter += 1"
if [[ $counter -gt 2 ]]; then
if [[ $counter -gt 10 ]]; then
echo "Failed to wait for server"
exit 1
fi

Просмотреть файл

@ -28,8 +28,17 @@ import android.app.Activity;
import com.facebook.testing.screenshot.Screenshot;
import com.owncloud.android.AbstractIT;
import com.owncloud.android.R;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.events.SearchEvent;
import org.greenrobot.eventbus.EventBus;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@ -40,6 +49,8 @@ import androidx.test.rule.GrantPermissionRule;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
import static junit.framework.TestCase.assertTrue;
public class FileDisplayActivityIT extends AbstractIT {
@ -69,6 +80,53 @@ public class FileDisplayActivityIT extends AbstractIT {
Screenshot.snapActivity(sut).record();
}
@Test
public void showShares() {
assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToGroup/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareViaLink/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/noShare/", true).execute(client).isSuccess());
// share folder to user "admin"
assertTrue(new CreateShareRemoteOperation("/shareToAdmin/",
ShareType.USER,
"admin",
false,
"",
OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER)
.execute(client).isSuccess());
// share folder via public link
assertTrue(new CreateShareRemoteOperation("/shareViaLink/",
ShareType.PUBLIC_LINK,
"",
true,
"",
OCShare.READ_PERMISSION_FLAG)
.execute(client).isSuccess());
// share folder to group
Assert.assertTrue(new CreateShareRemoteOperation("/shareToGroup/",
ShareType.GROUP,
"users",
false,
"",
OCShare.DEFAULT_PERMISSION)
.execute(client).isSuccess());
Activity sut = activityRule.launchActivity(null);
getInstrumentation().waitForIdleSync();
EventBus.getDefault().post(new SearchEvent("",
SearchRemoteOperation.SearchType.SHARED_FILTER));
getInstrumentation().waitForIdleSync();
Screenshot.snapActivity(sut).record();
}
@Test
public void showAccounts() {
Activity sut = activityRule.launchActivity(null);

Просмотреть файл

@ -17,11 +17,16 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientFactory;
import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.utils.FileStorageUtils;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
@ -42,6 +47,7 @@ import androidx.test.runner.lifecycle.Stage;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static org.junit.Assert.assertTrue;
/**
@ -102,6 +108,22 @@ public abstract class AbstractIT {
}
}
@After
public void after() {
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
assertTrue(result.getLogMessage(), result.isSuccess());
for (Object object : result.getData()) {
RemoteFile remoteFile = (RemoteFile) object;
if (!remoteFile.getRemotePath().equals("/")) {
assertTrue(new RemoveFileRemoteOperation(remoteFile.getRemotePath())
.execute(client).isSuccess());
}
}
}
FileDataStorageManager getStorageManager() {
return new FileDataStorageManager(account, targetContext.getContentResolver());
}

Просмотреть файл

@ -473,7 +473,7 @@ public abstract class DrawerActivity extends ToolbarActivity
}
break;
case R.id.nav_shared:
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_SEARCH),
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER),
menuItem.getItemId());
break;
case R.id.nav_recently_modified:

Просмотреть файл

@ -191,7 +191,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
protected SearchType currentSearchType;
protected boolean searchFragment;
protected SearchEvent searchEvent;
protected AsyncTask remoteOperationAsyncTask;
protected AsyncTask<Void, Void, Boolean> remoteOperationAsyncTask;
protected String mLimitToMimeType;
@Inject DeviceInfo deviceInfo;
@ -388,6 +388,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
currentSearchType = SearchType.RECENTLY_MODIFIED_SEARCH;
break;
case SHARED_FILTER:
currentSearchType = SearchType.SHARED_FILTER;
break;
default:
// do nothing
break;
@ -1587,7 +1591,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
}
};
remoteOperationAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, true);
remoteOperationAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
@Subscribe(threadMode = ThreadMode.BACKGROUND)
@ -1700,7 +1704,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
return event != null &&
event.getSearchType() != null &&
(!TextUtils.isEmpty(event.getSearchQuery()) ||
event.searchType == SearchRemoteOperation.SearchType.SHARED_SEARCH);
event.searchType == SearchRemoteOperation.SearchType.SHARED_SEARCH ||
event.searchType == SearchRemoteOperation.SearchType.SHARED_FILTER);
}
private void syncAndCheckFiles(Collection<OCFile> files) {