Skip to content

Commit

Permalink
Add ui test for list shares
Browse files Browse the repository at this point in the history
add test user to drone
switch back to master
use "waitForIdleSync" instead of sleep

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
  • Loading branch information
tobiasKaminsky committed Feb 4, 2020
1 parent f7d7a0c commit 4c21739
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 7 deletions.
16 changes: 15 additions & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,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:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 13 additions & 3 deletions scripts/updateScreenshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/wait_for_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,16 @@
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.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;

Expand All @@ -40,6 +48,8 @@
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 {
Expand Down Expand Up @@ -69,6 +79,53 @@ public void drawer() {
Screenshot.snapActivity(sut).record();
}

@Test
public void showShares() throws InterruptedException {
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,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));

getInstrumentation().waitForIdleSync();

Screenshot.snapActivity(sut).record();
}

@Test
public void showAccounts() {
Activity sut = activityRule.launchActivity(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ private void selectNavigationItem(final MenuItem menuItem) {
break;
case R.id.nav_shared:
handleSearchEvents(new SearchEvent("",
SearchRemoteOperation.SearchType.SHARED_SEARCH,
SearchRemoteOperation.SearchType.SHARED_FILTER,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR),
menuItem.getItemId());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ protected void prepareCurrentSearch(SearchEvent event) {
currentSearchType = SearchType.RECENTLY_MODIFIED_SEARCH;
break;

case SHARED_FILTER:
currentSearchType = SearchType.SHARED_FILTER;
break;

default:
// do nothing
break;
Expand Down Expand Up @@ -1716,7 +1720,8 @@ public void exitSelectionMode() {
private boolean isSearchEventSet(SearchEvent event) {
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)
&& event.getUnsetType() != null;
}

Expand Down

0 comments on commit 4c21739

Please sign in to comment.