Skip to content

Commit

Permalink
Merge pull request #5692 from nextcloud/backport-5688
Browse files Browse the repository at this point in the history
Backport 5688
  • Loading branch information
tobiasKaminsky authored Mar 19, 2020
2 parents d0016ac + adc76aa commit 854ce1a
Show file tree
Hide file tree
Showing 24 changed files with 331 additions and 71 deletions.
11 changes: 11 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
kind: pipeline
type: docker
name: generic

steps:
Expand Down Expand Up @@ -48,6 +49,7 @@ trigger:

---
kind: pipeline
type: docker
name: gplay

steps:
Expand Down Expand Up @@ -116,6 +118,13 @@ services:
- 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"
- su www-data -c "git clone -b master https://github.com/nextcloud/circles.git /var/www/html/apps/circles/"
- apt-get update; apt-get -y install composer
- su www-data -c "cd /var/www/html/apps/circles; composer install"
- su www-data -c "php /var/www/html/occ app:enable -f circles"
- su www-data -c "occ config:app:set circles --value 1 allow_non_ssl_links"
- su www-data -c "occ config:app:set circles --value 1 local_is_non_ssl"
- su www-data -c "php /var/www/html/occ circles:manage:create test public publicCircle
- /usr/local/bin/run.sh

trigger:
Expand All @@ -126,6 +135,7 @@ trigger:
- pull_request
---
kind: pipeline
type: docker
name: analysis

steps:
Expand Down Expand Up @@ -175,6 +185,7 @@ trigger:
- pull_request
---
kind: pipeline
type: docker
name: qa

steps:
Expand Down
27 changes: 27 additions & 0 deletions drawable_resources/circles.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scripts/analysis/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 76 warnings</span>
<span class="mdl-layout-title">Lint Report: 78 warnings</span>
23 changes: 20 additions & 3 deletions scripts/updateScreenshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ if ( [[ ! $(emulator -list-avds | grep uiComparison -c) -eq 0 ]] ); then
(sleep 5; echo "no") | avdmanager create avd -n uiComparison -c 100M -k "system-images;android-27;google_apis;x86" --abi "google_apis/x86"
fi

emulator -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 1>/dev/null &
if [ $1 == "debug" ]; then
emulator -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 1>/dev/null &
else
emulator -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 1>/dev/null &
fi
PID=$(echo $!)

## server
docker run --name=uiComparison nextcloudci/server:server-17 1>/dev/null &
docker run --name=uiComparison nextcloudci/server --entrypoint '/usr/local/bin/initnc.sh' 1>/dev/null &
sleep 5
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' uiComparison)

Expand All @@ -24,13 +28,15 @@ if [[ $IP = "" ]]; then
exit 1
fi

## wait for server to finish
scripts/wait_for_server.sh $IP

## run on server
cp gradle.properties gradle.properties_
sed -i s"/server/$IP/" gradle.properties
scripts/wait_for_emulator.sh

# 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\""
Expand All @@ -40,6 +46,13 @@ docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ grou
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 "su www-data -c \"git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text/\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ app:enable text\""
docker exec uiComparison /bin/sh -c "su www-data -c \"git clone -b master https://github.com/nextcloud/circles.git /var/www/html/apps/circles/\""
docker exec uiComparison /bin/sh -c "apt-get update; apt-get -y install composer"
docker exec uiComparison /bin/sh -c "su www-data -c \"cd /var/www/html/apps/circles; composer install\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ app:enable -f circles\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ config:app:set circles --value 1 allow_non_ssl_links\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ config:app:set circles --value 1 local_is_non_ssl\""
docker exec uiComparison /bin/sh -c "su www-data -c \"php /var/www/html/occ circles:manage:create test public publicCircle\""
docker exec uiComparison /bin/sh -c "/usr/local/bin/run.sh"

## update/create all screenshots
Expand All @@ -59,6 +72,10 @@ docker exec uiComparison /bin/sh -c "/usr/local/bin/run.sh"

mv gradle.properties_ gradle.properties

if [ $1 == "debug" ]; then
exit
fi

# tidy up
kill $PID
docker stop uiComparison
Expand Down
7 changes: 6 additions & 1 deletion scripts/wait_for_server.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env bash

counter=0
status=""
counter=0
checkcounter=0

until [[ $status = "false" ]]; do
status=$(curl 2>/dev/null "http://$1/status.php" | jq .maintenance)
echo "($checkcounter) $status"

if [[ "$status" =~ "false" || "$status" = "" ]]; then
let "counter += 1"
Expand All @@ -14,5 +16,8 @@ until [[ $status = "false" ]]; do
fi
fi

let "checkcounter += 1"
sleep 10
done

echo "($checkcounter) Done"
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@
import com.owncloud.android.AbstractIT;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
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.GetShareesRemoteOperation;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.operations.CreateFolderOperation;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.events.SearchEvent;

import org.greenrobot.eventbus.EventBus;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -67,10 +71,10 @@ public class FileDisplayActivityIT extends AbstractIT {
Manifest.permission.WRITE_EXTERNAL_STORAGE);

@Test
public void open() throws InterruptedException {
public void open() {
Activity sut = activityRule.launchActivity(null);

Thread.sleep(3000);
shortSleep();

Screenshot.snapActivity(sut).record();
}
Expand All @@ -85,12 +89,13 @@ public void drawer() {
}

@Test
public void showShares() {
public void showShares() throws JSONException {
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());
assertTrue(new CreateFolderRemoteOperation("/shareToCircle/", true).execute(client).isSuccess());

// share folder to user "admin"
assertTrue(new CreateShareRemoteOperation("/shareToAdmin/",
Expand Down Expand Up @@ -119,12 +124,27 @@ public void showShares() {
OCShare.DEFAULT_PERMISSION)
.execute(client).isSuccess());

// share folder to circle
// get share
RemoteOperationResult searchResult = new GetShareesRemoteOperation("publicCircle", 1, 50).execute(client);
assertTrue(searchResult.getLogMessage(), searchResult.isSuccess());

JSONObject resultJson = (JSONObject) searchResult.getData().get(0);
String circleId = resultJson.getJSONObject("value").getString("shareWith");

assertTrue(new CreateShareRemoteOperation("/shareToCircle/",
ShareType.CIRCLE,
circleId,
false,
"",
OCShare.DEFAULT_PERMISSION)
.execute(client).isSuccess());

Activity sut = activityRule.launchActivity(null);

getInstrumentation().waitForIdleSync();

EventBus.getDefault().post(new SearchEvent("",
SearchRemoteOperation.SearchType.SHARED_FILTER));
EventBus.getDefault().post(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER));

getInstrumentation().waitForIdleSync();

Expand All @@ -142,16 +162,14 @@ public void showAccounts() {
}

@Test
public void allFiles() throws InterruptedException {
public void allFiles() {
// ActivityScenario<FileDisplayActivity> sut = ActivityScenario.launch(FileDisplayActivity.class);
FileDisplayActivity sut = activityRule.launchActivity(null);

// given test folder
assertTrue(new CreateFolderOperation("/test/", true).execute(client, getStorageManager()).isSuccess());

// navigate into it
// sut.onActivity(activity -> activity.onBrowsedDownTo(getStorageManager().getFileByPath("/test/")));
//sut.onBrowsedDownTo(getStorageManager().getFileByPath("/test/"));
OCFile test = getStorageManager().getFileByPath("/test/");
sut.setFile(test);
sut.startSyncFolderOperation(test, false);
Expand All @@ -166,9 +184,7 @@ public void allFiles() throws InterruptedException {
.perform(NavigationViewActions.navigateTo(R.id.nav_all_files));

// then should be in root again
Thread.sleep(2000);
shortSleep();
assertEquals(getStorageManager().getFileByPath("/"), sut.getCurrentDir());


}
}
24 changes: 23 additions & 1 deletion src/androidTest/java/com/owncloud/android/AbstractIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public static void beforeAll() {
createDummyFiles();

waitForServer(client, baseUrl);

deleteAllFiles(); // makes sure that no file/folder is in root
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (AuthenticatorException e) {
Expand All @@ -110,6 +112,10 @@ public static void beforeAll() {

@After
public void after() {
deleteAllFiles();
}

public static void deleteAllFiles() {
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
assertTrue(result.getLogMessage(), result.isSuccess());

Expand Down Expand Up @@ -186,7 +192,7 @@ protected void waitForIdleSync() {
protected void openDrawer(IntentsTestRule activityRule) throws InterruptedException {
Activity sut = activityRule.launchActivity(null);

Thread.sleep(3000);
shortSleep();

onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());

Expand All @@ -208,4 +214,20 @@ protected Activity getCurrentActivity() {

return currentActivity;
}

protected void shortSleep() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

protected void longSleep() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
10 changes: 5 additions & 5 deletions src/androidTest/java/com/owncloud/android/ScreenshotsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void gridViewScreenshot() throws InterruptedException {
openOverflowMenu();
onView(anyOf(withText(R.string.action_switch_grid_view), withId(R.id.action_switch_view))).perform(click());

Thread.sleep(1000);
shortSleep();

Screengrab.screenshot("01_gridView");

Expand All @@ -70,12 +70,12 @@ public void gridViewScreenshot() throws InterruptedException {
Assert.assertTrue(true); // if we reach this, everything is ok
}

private void openOverflowMenu() throws InterruptedException {
private void openOverflowMenu() {
try {
Espresso.openContextualActionModeOverflowMenu();
} catch (NoActivityResumedException e) {
ActivityScenario.launch(FileDisplayActivity.class);
Thread.sleep(1000);
shortSleep();
Espresso.openContextualActionModeOverflowMenu();
}
}
Expand Down Expand Up @@ -143,12 +143,12 @@ public void autoUploadScreenshot() {
}

@Test
public void davdroidScreenshot() throws InterruptedException {
public void davdroidScreenshot() {
ActivityScenario.launch(SettingsActivity.class);

onData(PreferenceMatchers.withTitle(R.string.prefs_category_more)).perform(ViewActions.scrollTo());

Thread.sleep(1000);
shortSleep();

Screengrab.screenshot("06_davdroid");

Expand Down
Loading

0 comments on commit 854ce1a

Please sign in to comment.