Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c9d100b04 | ||
|
|
c65d50a8ee | ||
|
|
d85063ef67 | ||
|
|
d3fb6a2ab6 | ||
|
|
18b9b0f147 | ||
|
|
f1dfd44f07 | ||
|
|
3d934ed9fa | ||
|
|
f35ef1b320 | ||
|
|
7daf2bfa5d | ||
|
|
7e08278246 | ||
|
|
bee0c7b4a1 | ||
|
|
babbd23bf2 | ||
|
|
92301735af | ||
|
|
5d21b3668d | ||
|
|
cd2c2d858b | ||
|
|
898708cfc8 | ||
|
|
ff0dd4ace4 | ||
|
|
90b368b25b | ||
|
|
5b22cbe038 | ||
|
|
2d1dc5775d | ||
|
|
7cb9cc3bbb | ||
|
|
b0053d1481 | ||
|
|
9db4585224 | ||
|
|
8d82203c15 | ||
|
|
81d75ad5dd | ||
|
|
5ad6cafb92 | ||
|
|
c8863c61b0 | ||
|
|
251af8f0ef | ||
|
|
433e1c0c16 | ||
|
|
ad4e3832bc | ||
|
|
a361df0b4c | ||
|
|
54adf9823e | ||
|
|
66d9465e11 | ||
|
|
3d73a2336f | ||
|
|
a255c27f4f | ||
|
|
d1131702f6 | ||
|
|
60856c6146 | ||
|
|
67e6c3402c | ||
|
|
d745a2cbbf | ||
|
|
111daf1162 | ||
|
|
c9d3641136 | ||
|
|
f7ab5d90dc | ||
|
|
607ed3115e | ||
|
|
93104917a7 | ||
|
|
a2b95c5766 | ||
|
|
a0179aa6b6 | ||
|
|
a28fafaaab | ||
|
|
d521a9f36c | ||
|
|
3c5549adac | ||
|
|
fcf81e5d89 | ||
|
|
c7984a706c | ||
|
|
68cae46c96 | ||
|
|
1d3c2e98a9 | ||
|
|
cc750123a7 | ||
|
|
e9733ad744 | ||
|
|
7f339f9fe0 | ||
|
|
78128ff5dc | ||
|
|
ba0005d930 | ||
|
|
6469fdb658 | ||
|
|
0d381c8233 | ||
|
|
07aff36578 | ||
|
|
9f4d90f48b | ||
|
|
d60a2a6a3f | ||
|
|
5c5cdbb0a2 | ||
|
|
6f38bf7a8b | ||
|
|
5f426223b2 | ||
|
|
111713f52e | ||
|
|
24c84de9cd | ||
|
|
02686e462a | ||
|
|
69476bba29 | ||
|
|
60b1f3702e | ||
|
|
528cd23cc0 | ||
|
|
e35dfbffc9 | ||
|
|
98bc395799 | ||
|
|
afc54de8f1 | ||
|
|
2c96094f21 | ||
|
|
75c8359781 | ||
|
|
372e478bfd | ||
|
|
be3c0db309 | ||
|
|
b8fb7358b3 | ||
|
|
663c0beda5 | ||
|
|
a930d9b6e1 | ||
|
|
8ef4e04312 | ||
|
|
eedb5008bb | ||
|
|
29a0c138c7 | ||
|
|
0976f7abe2 | ||
|
|
f7d886037a | ||
|
|
c9c0ae9e46 | ||
|
|
e02b9adf8a | ||
|
|
fdb4489e38 | ||
|
|
130503a6e3 | ||
|
|
af924761b7 | ||
|
|
e7cd9ce6bc | ||
|
|
ddd7b901da | ||
|
|
0a062ea937 | ||
|
|
ef1aaead0c | ||
|
|
8f1d7b5b95 | ||
|
|
774beec484 | ||
|
|
6b6e7c7f2c | ||
|
|
4c547c2de2 | ||
|
|
d1bd1dd16e | ||
|
|
a514ad81a0 | ||
|
|
ed229267d2 | ||
|
|
080dc4047f | ||
|
|
f744a2351d | ||
|
|
7d14c90b7d | ||
|
|
6c8d52119f | ||
|
|
76c20b22db | ||
|
|
3bba95365c | ||
|
|
81654379f9 | ||
|
|
376ad933fb | ||
|
|
c981833bc1 | ||
|
|
cdf0c97001 | ||
|
|
cb27c7b413 | ||
|
|
8966803e39 | ||
|
|
919539846f | ||
|
|
17a19bd4be | ||
|
|
0be925f00e | ||
|
|
1000c9b83f | ||
|
|
4931122392 | ||
|
|
2bd5b1cb27 | ||
|
|
e1bb072588 | ||
|
|
675e6dc4d5 | ||
|
|
3a324f11e6 | ||
|
|
681263cc7f | ||
|
|
10580c9579 | ||
|
|
7a9cf103b4 | ||
|
|
2248911da0 | ||
|
|
6fda99a633 | ||
|
|
eed4293c43 | ||
|
|
d6890111bb | ||
|
|
a3487adbdf | ||
|
|
57919b63c7 | ||
|
|
5dfeb14412 | ||
|
|
10b5113299 | ||
|
|
e0c15717f7 | ||
|
|
ed94dfb139 | ||
|
|
623a0e9c59 | ||
|
|
907e9f0b26 | ||
|
|
1bf3425ab2 | ||
|
|
933c61d0c9 | ||
|
|
b39d3d4182 | ||
|
|
d852aff107 | ||
|
|
8e97d363fe | ||
|
|
cb6ccbe650 | ||
|
|
121c6c1f23 | ||
|
|
4d040fba86 | ||
|
|
2dfde203c8 | ||
|
|
c5e624f1e2 | ||
|
|
f4684f15c1 | ||
|
|
14cec7d029 | ||
|
|
4fad4403fc | ||
|
|
95c2db021f | ||
|
|
8cf7ba60b5 | ||
|
|
a8db8ef38f | ||
|
|
7861eb787e | ||
|
|
196b16d1d3 | ||
|
|
4f97110ab3 | ||
|
|
2150295acc | ||
|
|
de0467381c | ||
|
|
5a9d578018 | ||
|
|
75b9fa8551 | ||
|
|
72b9dd069a | ||
|
|
51f48549c3 | ||
|
|
1b1823db0a | ||
|
|
65a2b895f5 | ||
|
|
81bb72344c | ||
|
|
8a2bd6370d | ||
|
|
88a609fc0e | ||
|
|
ffa19f0fa9 | ||
|
|
8957d5a525 | ||
|
|
df72d84f91 | ||
|
|
c4fc2f52ea | ||
|
|
ad12be8218 | ||
|
|
0ab788d116 | ||
|
|
7a3ef013d1 | ||
|
|
acbb2f06bf | ||
|
|
b29767b648 | ||
|
|
d17dd38589 | ||
|
|
78cc80266a | ||
|
|
d1adb2bf74 | ||
|
|
faab13ca92 | ||
|
|
1cf178893a | ||
|
|
a56a34079b | ||
|
|
e753f8ea3d | ||
|
|
404f43fad4 | ||
|
|
9a07418e51 | ||
|
|
7b1522e86a | ||
|
|
be977dda31 | ||
|
|
aa5cf6b5ae | ||
|
|
f7e08a724b | ||
|
|
990673077f | ||
|
|
cc1c4e9b11 | ||
|
|
cc18577efa | ||
|
|
db6c1ba055 | ||
|
|
3b89449939 | ||
|
|
4336082bb7 | ||
|
|
93183cf9b2 | ||
|
|
e4335583cf | ||
|
|
7932a2a876 | ||
|
|
818ff4f11d | ||
|
|
7dd42f0bac | ||
|
|
ca7cdc9524 | ||
|
|
4e31f15c09 | ||
|
|
0896ad7c17 | ||
|
|
2edc1320ea | ||
|
|
493d0b76ee | ||
|
|
9b73819256 | ||
|
|
34c27204d4 | ||
|
|
d96b4e4c6c | ||
|
|
234c8d33ee | ||
|
|
b46af2b5fa | ||
|
|
ea0c09dd49 | ||
|
|
a2743f206a | ||
|
|
3730eff7ae | ||
|
|
aef8ee5384 | ||
|
|
69414303a8 | ||
|
|
7bb49bd610 | ||
|
|
94b26cc28e | ||
|
|
2ed70f279d | ||
|
|
2916c82a5b | ||
|
|
b6d09c42a9 | ||
|
|
8585e44d4b | ||
|
|
7cda9b5e8d | ||
|
|
27fc8c6540 | ||
|
|
a7b90ed588 | ||
|
|
419b14afcf | ||
|
|
be9d4facce | ||
|
|
89edfe518b | ||
|
|
6b3c4621b7 | ||
|
|
d8d24908da | ||
|
|
4eadfac145 | ||
|
|
9c066bbe2a | ||
|
|
2562a84352 | ||
|
|
a884bab878 | ||
|
|
e3121bf18d | ||
|
|
909fb2187f | ||
|
|
1b62bb93cb | ||
|
|
fd1d391d2b | ||
|
|
b047dccd56 | ||
|
|
b39bceb607 | ||
|
|
31ac25f8d0 | ||
|
|
3c87c8fc67 | ||
|
|
eb722457ca | ||
|
|
c56e2c3d21 | ||
|
|
6b431a388e | ||
|
|
5e6038ef1d | ||
|
|
3f254ee348 | ||
|
|
13593fb7f7 | ||
|
|
f9b232fb49 | ||
|
|
0af29bf500 | ||
|
|
9cd108d229 | ||
|
|
ed9afe8c6c | ||
|
|
c650e55af9 | ||
|
|
277f08b941 | ||
|
|
8e7ce3c7a1 | ||
|
|
d52b1cc6ba | ||
|
|
d137302dab | ||
|
|
93528534aa | ||
|
|
1126823db9 | ||
|
|
73bc3735d4 | ||
|
|
a6dd338c79 | ||
|
|
fd47348f1b | ||
|
|
0f67f4b1e1 | ||
|
|
a06057acfa | ||
|
|
eda28d67a6 | ||
|
|
2192bdcf39 | ||
|
|
4bb0a3c176 | ||
|
|
325e6005c5 | ||
|
|
ee3e92c805 | ||
|
|
19d37ef49d | ||
|
|
0acae91fdf | ||
|
|
f6e8636cfa | ||
|
|
ba62819180 | ||
|
|
cee5b45b84 | ||
|
|
05748959e9 | ||
|
|
969c0d3916 | ||
|
|
726e4ca7b4 | ||
|
|
444dcd000e | ||
|
|
551628d4fe | ||
|
|
9f7f28c7c1 | ||
|
|
5fa9f7420d | ||
|
|
db5b0752f8 | ||
|
|
7cbfc58036 | ||
|
|
3d7e8b770a | ||
|
|
f1a70ccb32 | ||
|
|
d721941032 | ||
|
|
f07e14fd30 | ||
|
|
7af28a1c36 | ||
|
|
e5f56152b0 | ||
|
|
4a4ad20e66 | ||
|
|
74e68d6b8e | ||
|
|
a887a4c32b | ||
|
|
50b19e5d77 | ||
|
|
bcb1262064 | ||
|
|
214689bc0d | ||
|
|
ed4917db14 | ||
|
|
815e30166e | ||
|
|
40d40c32b1 | ||
|
|
51365fa7c3 | ||
|
|
3848346f4a | ||
|
|
3c7fe3a405 | ||
|
|
8c9841f033 | ||
|
|
ff4a0a7030 | ||
|
|
197552a488 | ||
|
|
beb45efc0b | ||
|
|
10f6ec94fa | ||
|
|
738291b2fa | ||
|
|
14fd15e9ae | ||
|
|
4073cd235c | ||
|
|
cc517ffcfd | ||
|
|
98d1b5e2b9 | ||
|
|
3102c23d2c | ||
|
|
32a0d1c309 | ||
|
|
212b3a6ef9 | ||
|
|
fd7b722ac4 | ||
|
|
0207e70323 | ||
|
|
fb5ae37a38 | ||
|
|
ced60bf59b | ||
|
|
3c609a329f | ||
|
|
9a0d1085ed | ||
|
|
a5142483a4 | ||
|
|
1edaffeafe | ||
|
|
b2ff37505e | ||
|
|
ebbedb46a0 | ||
|
|
dfe2e5dbd4 | ||
|
|
c1f5817f3f | ||
|
|
9f23230bf1 | ||
|
|
fbfdf1104a | ||
|
|
bf587f1a65 | ||
|
|
dbae9443eb | ||
|
|
e13a3ca7cb | ||
|
|
79f4270bb9 | ||
|
|
5f73a5ec75 | ||
|
|
0ad81bdd29 | ||
|
|
8af257d54f | ||
|
|
a7088c8c87 | ||
|
|
5b76892ab1 | ||
|
|
7005cdef2e | ||
|
|
643454c1d7 | ||
|
|
20d2ef989d | ||
|
|
dfc94f4505 | ||
|
|
8f0e4eab60 | ||
|
|
93d0875883 | ||
|
|
947e4a1b10 | ||
|
|
c55e9b8fd2 | ||
|
|
2b5c39095d | ||
|
|
348ae4435a | ||
|
|
a22b0724ae | ||
|
|
c42c24be80 | ||
|
|
7e03aa39b5 | ||
|
|
097434916e | ||
|
|
728de81736 | ||
|
|
5609b5041e | ||
|
|
d36c2d35a5 | ||
|
|
741cc24d11 | ||
|
|
5288548e70 | ||
|
|
e0d5676151 | ||
|
|
7ed4e2b24e | ||
|
|
58ba15ac95 | ||
|
|
fe1cd33c26 | ||
|
|
c3f838d445 | ||
|
|
2f60b75fc5 | ||
|
|
f6e7c44596 | ||
|
|
1017e3ac3b | ||
|
|
2913918232 | ||
|
|
ca7350fa8a | ||
|
|
2c5fb2b2f9 | ||
|
|
d70502f747 | ||
|
|
38c28332e2 | ||
|
|
bd5c9dfa1e | ||
|
|
db4a7ee8f5 | ||
|
|
066fef03c2 | ||
|
|
741fb410f1 | ||
|
|
961e6c179a | ||
|
|
22657040bd | ||
|
|
a9dc3f5787 | ||
|
|
e5ec91b5a7 | ||
|
|
1ecd64f128 | ||
|
|
6dfb4c7ef6 | ||
|
|
56a1fc868d | ||
|
|
83d4aaf1ab | ||
|
|
01d9d2e437 | ||
|
|
98d930b8ab | ||
|
|
0fa902d2d2 | ||
|
|
1f5352f2ec | ||
|
|
72fce1dd1e | ||
|
|
9e633b91b5 | ||
|
|
37fdd97c29 | ||
|
|
cb0ae700db | ||
|
|
9f3e1857db | ||
|
|
f0a608acde | ||
|
|
4a791dda86 | ||
|
|
3e05624064 | ||
|
|
33dfc9651a | ||
|
|
14172fd1f0 | ||
|
|
b18ff7404e | ||
|
|
ed8819ec86 | ||
|
|
a424706368 | ||
|
|
7ced94d42e | ||
|
|
0aed8aaa86 | ||
|
|
c5abe938bd | ||
|
|
4e52f7f970 | ||
|
|
a43933082d | ||
|
|
374bb21c33 | ||
|
|
558f1775de | ||
|
|
934e1f406a | ||
|
|
7732ff065b | ||
|
|
9e6fa5c769 | ||
|
|
59fddce138 | ||
|
|
e503106960 | ||
|
|
96aecac8ed | ||
|
|
ab3dff9e1b | ||
|
|
2bbaf7b21d | ||
|
|
9370cbab09 | ||
|
|
388301082d | ||
|
|
4bdd27ffe0 | ||
|
|
fb1bb6905c | ||
|
|
3a28b84e9d | ||
|
|
94d7506cb5 | ||
|
|
ab0ea3e8d9 | ||
|
|
eb08f75257 | ||
|
|
e40893a136 | ||
|
|
5f185326ab | ||
|
|
a9f689044d | ||
|
|
7360bbabfe | ||
|
|
0f9ec55d7a | ||
|
|
7802fabf0e | ||
|
|
f6f401aa0d | ||
|
|
123593fc4e | ||
|
|
a9b8bf7f3a | ||
|
|
0630142792 | ||
|
|
7306bc096d | ||
|
|
a475af6ac6 | ||
|
|
c048fe2121 | ||
|
|
ace90ef2ad | ||
|
|
1b1a58ed8c | ||
|
|
6e7cdededb | ||
|
|
cc06c8b613 | ||
|
|
347abae8aa | ||
|
|
6a6913b17e | ||
|
|
28279bc3c1 | ||
|
|
663537f304 | ||
|
|
39bb258648 | ||
|
|
a33cc9d278 | ||
|
|
73c22d4e8f | ||
|
|
7b88e39572 | ||
|
|
6f31f92a3f | ||
|
|
f499fb3ee8 | ||
|
|
d053177cf7 | ||
|
|
8e5f893812 | ||
|
|
7f1ba75b7d | ||
|
|
b6b57fa06e | ||
|
|
adac921f5c | ||
|
|
78b879d10f | ||
|
|
7c5948b61a | ||
|
|
0b15433cda | ||
|
|
228a44fc87 | ||
|
|
094416e8e3 | ||
|
|
2d6c25ab0f | ||
|
|
34eaf9d6db | ||
|
|
fd7cf51a4b | ||
|
|
3e3d80d08c | ||
|
|
fa9804d742 | ||
|
|
7d000f964e | ||
|
|
e95caf3572 |
No files matched your search
@@ -22,13 +22,14 @@ steps:
|
||||
- emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
|
||||
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
- sed -i s"#server#server#" gradle.properties
|
||||
- sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport && scripts/deleteOutdatedComments.sh "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew combinedTestReport
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
@@ -55,6 +56,8 @@ steps:
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
environment:
|
||||
EVAL: true
|
||||
commands:
|
||||
- BRANCH='stable18' /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
@@ -101,13 +104,14 @@ steps:
|
||||
- scripts/checkIfRunDrone.sh $GIT_USERNAME $GIT_TOKEN $DRONE_PULL_REQUEST || exit 0
|
||||
- emulator-headless -avd android-27 -no-snapshot -gpu swiftshader_indirect -no-window -no-audio -skin 500x833 &
|
||||
- sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
- sed -i s"#1#5#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
|
||||
- ./gradlew assembleGplay
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew jacocoTestGplayDebugUnitTestReport && scripts/deleteOutdatedComments.sh "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Unit" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew createGplayDebugCoverageReport -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.owncloud.android.utils.ScreenshotTest && scripts/deleteOutdatedComments.sh "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "IT" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- ./gradlew combinedTestReport
|
||||
- curl -o codecov.sh https://codecov.io/bash
|
||||
- bash ./codecov.sh -t fc506ba4-33c3-43e4-a760-aada38c24fd5
|
||||
@@ -136,6 +140,8 @@ steps:
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
environment:
|
||||
EVAL: true
|
||||
commands:
|
||||
- /usr/local/bin/initnc.sh
|
||||
- echo 127.0.0.1 server >> /etc/hosts
|
||||
@@ -186,8 +192,7 @@ steps:
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "stable" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- scripts/runAllScreenshotCombinations "stable" false
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
@@ -209,26 +214,6 @@ steps:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
image: nextcloudci/server:server-17 # also change in updateScreenshots.sh
|
||||
commands:
|
||||
- BRANCH='stable18' /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 stable18 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 stable18 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 "php /var/www/html/occ app:enable end_to_end_encryption"
|
||||
- /usr/local/bin/run.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -261,8 +246,8 @@ steps:
|
||||
- ./gradlew assembleGplayDebug
|
||||
- scripts/wait_for_emulator.sh
|
||||
- ./gradlew installGplayDebugAndroidTest
|
||||
- scripts/wait_for_server.sh "server"
|
||||
- ./gradlew gplayDebugExecuteScreenshotTests -Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest || scripts/uploadReport.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER "master" "Screenshot" $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
- sed -i s"#5#1#" ./src/androidTest/java/com/nextcloud/client/RetryTestRule.kt
|
||||
- scripts/runAllScreenshotCombinations "master" false
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
settings:
|
||||
@@ -284,27 +269,6 @@ steps:
|
||||
- failure
|
||||
branch:
|
||||
- master
|
||||
|
||||
services:
|
||||
- name: server
|
||||
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"
|
||||
- su www-data -c "git clone -b master https://github.com/nextcloud/end_to_end_encryption/ /var/www/html/apps/end_to_end_encryption/"
|
||||
- su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption"
|
||||
- /usr/local/bin/run.sh
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
@@ -388,7 +352,7 @@ steps:
|
||||
- sed -i "/qa/,/\}/ s/versionCode .*/versionCode $DRONE_BUILD_NUMBER/" build.gradle
|
||||
- sed -i "/qa/,/\}/ s/versionName .*/versionName \"$DRONE_BUILD_NUMBER\"/" build.gradle
|
||||
- ./gradlew assembleQaDebug
|
||||
- /opt/android-sdk-linux/build-tools/*/apksigner sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
- $(find /opt/android-sdk-linux/build-tools/*/apksigner | sort | tail -n1) sign --ks-pass pass:$KS_PASS --key-pass pass:$KEY_PASS --ks-key-alias key0 --ks scripts/QA_keystore.jks build/outputs/apk/qa/debug/qa-debug-*.apk
|
||||
- scripts/uploadArtifact.sh $LOG_USERNAME $LOG_PASSWORD $DRONE_BUILD_NUMBER $DRONE_PULL_REQUEST $GIT_USERNAME $GIT_TOKEN
|
||||
|
||||
trigger:
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# You can add one username per supported platform and one custom link
|
||||
custom: https://www.bountysource.com/teams/nextcloud/issues?tracker_ids=38838206
|
||||
custom: https://nextcloud.com/include/
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Install NDK
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
- name: Build with Gradle
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
|
||||
@@ -16,7 +16,7 @@ jobs:
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Install NDK
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" --sdk_root=${ANDROID_SDK_ROOT}
|
||||
- name: Build generic
|
||||
run: |
|
||||
mkdir -p $HOME/.gradle
|
||||
|
||||
@@ -47,3 +47,5 @@ fastlane/Fastfile
|
||||
|
||||
# scan temporary files
|
||||
**/fastlane/test_output
|
||||
/fastlane/vendor/
|
||||
/.bundle/
|
||||
@@ -1,3 +1,11 @@
|
||||
## 3.12.1 (July, 07, 2020)
|
||||
|
||||
- UI does not hang when changing auto upload
|
||||
- fix crash on contacts backup settings
|
||||
- bugfixes
|
||||
|
||||
For a full list, please see https://github.com/nextcloud/android/milestone/49
|
||||
|
||||
## 3.12.0 (June, 10, 2020)
|
||||
|
||||
- add circle support for searching/displaying
|
||||
|
||||
@@ -379,6 +379,7 @@ Generally, whenever you need:
|
||||
* media playback
|
||||
* networking
|
||||
* logging
|
||||
* notifications management
|
||||
|
||||
we have something more suitable.
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Autogenerated by fastlane
|
||||
#
|
||||
# Ensure this file is checked in to source control!
|
||||
|
||||
source "https://rubygems.org"
|
||||
|
||||
gem 'fastlane'
|
||||
|
||||
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
|
||||
eval_gemfile(plugins_path) if File.exist?(plugins_path)
|
||||
@@ -0,0 +1,180 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (3.0.2)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.1.0)
|
||||
aws-partitions (1.343.0)
|
||||
aws-sdk-core (3.104.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
aws-partitions (~> 1, >= 1.239.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
jmespath (~> 1.0)
|
||||
aws-sdk-kms (1.36.0)
|
||||
aws-sdk-core (~> 3, >= 3.99.0)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sdk-s3 (1.75.0)
|
||||
aws-sdk-core (~> 3, >= 3.104.1)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.1)
|
||||
aws-sigv4 (1.2.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.3)
|
||||
claide (1.0.3)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander-fastlane (4.4.6)
|
||||
highline (~> 1.7.2)
|
||||
declarative (0.0.20)
|
||||
declarative-option (0.1.0)
|
||||
digest-crc (0.6.1)
|
||||
rake (~> 13.0)
|
||||
domain_name (0.5.20190701)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
dotenv (2.7.6)
|
||||
emoji_regex (3.0.0)
|
||||
excon (0.75.0)
|
||||
faraday (0.17.3)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
faraday-cookie_jar (0.0.6)
|
||||
faraday (>= 0.7.4)
|
||||
http-cookie (~> 1.0.0)
|
||||
faraday_middleware (0.14.0)
|
||||
faraday (>= 0.7.4, < 1.0)
|
||||
fastimage (2.1.7)
|
||||
fastlane (2.152.0)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
addressable (>= 2.3, < 3.0.0)
|
||||
aws-sdk-s3 (~> 1.0)
|
||||
babosa (>= 1.0.3, < 2.0.0)
|
||||
bundler (>= 1.12.0, < 3.0.0)
|
||||
colored
|
||||
commander-fastlane (>= 4.4.6, < 5.0.0)
|
||||
dotenv (>= 2.1.1, < 3.0.0)
|
||||
emoji_regex (>= 0.1, < 4.0)
|
||||
excon (>= 0.71.0, < 1.0.0)
|
||||
faraday (>= 0.17, < 1.0)
|
||||
faraday-cookie_jar (~> 0.0.6)
|
||||
faraday_middleware (>= 0.13.1, < 2.0)
|
||||
fastimage (>= 2.1.0, < 3.0.0)
|
||||
gh_inspector (>= 1.1.2, < 2.0.0)
|
||||
google-api-client (>= 0.37.0, < 0.39.0)
|
||||
google-cloud-storage (>= 1.15.0, < 2.0.0)
|
||||
highline (>= 1.7.2, < 2.0.0)
|
||||
json (< 3.0.0)
|
||||
jwt (>= 2.1.0, < 3)
|
||||
mini_magick (>= 4.9.4, < 5.0.0)
|
||||
multipart-post (~> 2.0.0)
|
||||
plist (>= 3.1.0, < 4.0.0)
|
||||
rubyzip (>= 2.0.0, < 3.0.0)
|
||||
security (= 0.1.3)
|
||||
simctl (~> 1.6.3)
|
||||
slack-notifier (>= 2.0.0, < 3.0.0)
|
||||
terminal-notifier (>= 2.0.0, < 3.0.0)
|
||||
terminal-table (>= 1.4.5, < 2.0.0)
|
||||
tty-screen (>= 0.6.3, < 1.0.0)
|
||||
tty-spinner (>= 0.8.0, < 1.0.0)
|
||||
word_wrap (~> 1.0.0)
|
||||
xcodeproj (>= 1.13.0, < 2.0.0)
|
||||
xcpretty (~> 0.3.0)
|
||||
xcpretty-travis-formatter (>= 0.0.3)
|
||||
fastlane-plugin-huawei_appgallery_connect (1.0.9)
|
||||
gh_inspector (1.1.3)
|
||||
google-api-client (0.38.0)
|
||||
addressable (~> 2.5, >= 2.5.1)
|
||||
googleauth (~> 0.9)
|
||||
httpclient (>= 2.8.1, < 3.0)
|
||||
mini_mime (~> 1.0)
|
||||
representable (~> 3.0)
|
||||
retriable (>= 2.0, < 4.0)
|
||||
signet (~> 0.12)
|
||||
google-cloud-core (1.5.0)
|
||||
google-cloud-env (~> 1.0)
|
||||
google-cloud-errors (~> 1.0)
|
||||
google-cloud-env (1.3.3)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
google-cloud-errors (1.0.1)
|
||||
google-cloud-storage (1.26.2)
|
||||
addressable (~> 2.5)
|
||||
digest-crc (~> 0.4)
|
||||
google-api-client (~> 0.33)
|
||||
google-cloud-core (~> 1.2)
|
||||
googleauth (~> 0.9)
|
||||
mini_mime (~> 1.0)
|
||||
googleauth (0.13.0)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
jwt (>= 1.4, < 3.0)
|
||||
memoist (~> 0.16)
|
||||
multi_json (~> 1.11)
|
||||
os (>= 0.9, < 2.0)
|
||||
signet (~> 0.14)
|
||||
highline (1.7.10)
|
||||
http-cookie (1.0.3)
|
||||
domain_name (~> 0.5)
|
||||
httpclient (2.8.3)
|
||||
jmespath (1.4.0)
|
||||
json (2.3.1)
|
||||
jwt (2.2.1)
|
||||
memoist (0.16.2)
|
||||
mini_magick (4.10.1)
|
||||
mini_mime (1.0.2)
|
||||
multi_json (1.15.0)
|
||||
multipart-post (2.0.0)
|
||||
nanaimo (0.3.0)
|
||||
naturally (2.2.0)
|
||||
os (1.1.0)
|
||||
plist (3.5.0)
|
||||
public_suffix (4.0.5)
|
||||
rake (13.0.1)
|
||||
representable (3.0.4)
|
||||
declarative (< 0.1.0)
|
||||
declarative-option (< 0.2.0)
|
||||
uber (< 0.2.0)
|
||||
retriable (3.1.2)
|
||||
rouge (2.0.7)
|
||||
rubyzip (2.3.0)
|
||||
security (0.1.3)
|
||||
signet (0.14.0)
|
||||
addressable (~> 2.3)
|
||||
faraday (>= 0.17.3, < 2.0)
|
||||
jwt (>= 1.5, < 3.0)
|
||||
multi_json (~> 1.10)
|
||||
simctl (1.6.8)
|
||||
CFPropertyList
|
||||
naturally
|
||||
slack-notifier (2.3.2)
|
||||
terminal-notifier (2.0.0)
|
||||
terminal-table (1.8.0)
|
||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
||||
tty-cursor (0.7.1)
|
||||
tty-screen (0.8.1)
|
||||
tty-spinner (0.9.3)
|
||||
tty-cursor (~> 0.7)
|
||||
uber (0.1.0)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.7)
|
||||
unicode-display_width (1.7.0)
|
||||
word_wrap (1.0.0)
|
||||
xcodeproj (1.17.1)
|
||||
CFPropertyList (>= 2.3.3, < 4.0)
|
||||
atomos (~> 0.1.3)
|
||||
claide (>= 1.0.2, < 2.0)
|
||||
colored2 (~> 3.1)
|
||||
nanaimo (~> 0.3.0)
|
||||
xcpretty (0.3.0)
|
||||
rouge (~> 2.0.7)
|
||||
xcpretty-travis-formatter (1.0.0)
|
||||
xcpretty (~> 0.2, >= 0.0.7)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
fastlane
|
||||
fastlane-plugin-huawei_appgallery_connect
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
||||
@@ -1,10 +1,11 @@
|
||||
import com.github.spotbugs.snom.SpotBugsTask
|
||||
|
||||
// Gradle build file
|
||||
//
|
||||
// This project was started in Eclipse and later moved to Android Studio. In the transition, both IDEs were supported.
|
||||
// Due to this, the files layout is not the usual in new projects created with Android Studio / gradle. This file
|
||||
// merges declarations usually split in two separates build.gradle file, one for global settings of the project in
|
||||
// its root folder, another one for the app module in subfolder of root.
|
||||
import com.github.spotbugs.SpotBugsTask
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.3.72'
|
||||
@@ -20,13 +21,11 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.3'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.4') {
|
||||
exclude group: 'org.codehaus.groovy', module: 'groovy-all'
|
||||
}
|
||||
classpath 'gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:1.6.6'
|
||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
||||
classpath('com.hiya:jacoco-android:0.2')
|
||||
classpath 'gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.9.1"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.11.0"
|
||||
classpath "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
|
||||
classpath 'com.karumi:shot:4.3.0'
|
||||
}
|
||||
@@ -39,7 +38,7 @@ apply plugin: 'kotlin-android-extensions'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'pmd'
|
||||
apply plugin: 'jacoco-android'
|
||||
apply plugin: 'com.hiya.jacoco-android'
|
||||
apply plugin: 'com.github.spotbugs'
|
||||
apply plugin: 'io.gitlab.arturbosch.detekt'
|
||||
apply plugin: 'shot'
|
||||
@@ -51,7 +50,7 @@ configurations {
|
||||
exclude group: 'com.google.firebase', module: 'firebase-core'
|
||||
exclude group: 'com.google.firebase', module: 'firebase-analytics'
|
||||
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitely
|
||||
exclude group: 'org.jetbrains', module: 'annotations-java5' // via prism4j, already using annotations explicitly
|
||||
|
||||
// check for updates every build
|
||||
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
|
||||
@@ -60,15 +59,16 @@ configurations {
|
||||
|
||||
ext {
|
||||
jacocoVersion = "0.8.2"
|
||||
daggerVersion = "2.27"
|
||||
markwonVersion = "4.4.0"
|
||||
daggerVersion = "2.28.3"
|
||||
markwonVersion = "4.5.0"
|
||||
prismVersion = "2.0.0"
|
||||
androidLibraryVersion = "interceptor-SNAPSHOT"
|
||||
butterknifeVersion = "10.2.3"
|
||||
androidLibraryVersion = "master-SNAPSHOT"
|
||||
|
||||
travisBuild = System.getenv("TRAVIS") == "true"
|
||||
|
||||
// allows for -Dpre-dex=false to be set
|
||||
preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
|
||||
// allows for -D pre-dex=false to be set
|
||||
preDexEnabled = "true" == System.getProperty("pre-dex", "true")
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -99,9 +99,7 @@ for (TaskExecutionRequest tr : getGradle().getStartParameter().getTaskRequests()
|
||||
}
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
toolVersion = '3.1.12'
|
||||
}
|
||||
|
||||
|
||||
android {
|
||||
lintOptions {
|
||||
@@ -126,7 +124,7 @@ android {
|
||||
compileSdkVersion 29
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 17
|
||||
minSdkVersion 18
|
||||
targetSdkVersion 29
|
||||
|
||||
// arguments to be passed to functional tests
|
||||
@@ -196,7 +194,7 @@ android {
|
||||
// see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
|
||||
|
||||
dexOptions {
|
||||
// Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
|
||||
// Skip pre-dexing when running on Travis CI or when disabled via -D pre-dex=false.
|
||||
preDexLibraries = preDexEnabled && !travisBuild
|
||||
}
|
||||
|
||||
@@ -238,41 +236,33 @@ android {
|
||||
android.applicationVariants.all { variant ->
|
||||
String variantName = variant.name
|
||||
String capVariantName = variantName.substring(0, 1).toUpperCase() + variantName.substring(1)
|
||||
tasks.register("spotbugs${capVariantName}", SpotBugsTask) {
|
||||
tasks.register("spotbugs${capVariantName}Report", SpotBugsTask) {
|
||||
ignoreFailures = true // should continue checking
|
||||
effort = "max"
|
||||
reportLevel = "medium"
|
||||
classes = fileTree("$project.buildDir/intermediates/javac/${variantName}/classes/")
|
||||
excludeFilter = file("${project.rootDir}/spotbugs-filter.xml")
|
||||
pluginClasspath = project.configurations.spotbugsPlugins
|
||||
source = fileTree('src/main/java')
|
||||
classpath = files()
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
|
||||
reports {
|
||||
xml.enabled = false
|
||||
html.enabled = true
|
||||
html {
|
||||
enabled = true
|
||||
destination = file("$project.buildDir/reports/spotbugs/spotbugs.html")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebug', 'pmd', 'lint', 'ktlint', 'detekt'
|
||||
check.dependsOn 'checkstyle', 'spotbugsGplayDebugReport', 'pmd', 'lint', 'ktlint', 'detekt'
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
enabled true
|
||||
}
|
||||
|
||||
viewBinding {
|
||||
enabled true
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
viewBinding true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,21 +288,22 @@ dependencies {
|
||||
implementation 'org.apache.jackrabbit:jackrabbit-webdav:2.13.1' // remove after entire switch to lib v2
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.2.0'
|
||||
implementation 'com.jakewharton:disklrucache:2.0.2'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0-rc01'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.exifinterface:exifinterface:1.2.0'
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
|
||||
implementation "androidx.work:work-runtime:2.3.4"
|
||||
implementation "androidx.work:work-runtime-ktx:2.3.4"
|
||||
implementation "androidx.work:work-runtime:2.4.0"
|
||||
implementation "androidx.work:work-runtime-ktx:2.4.0"
|
||||
implementation "androidx.fragment:fragment:1.2.5"
|
||||
implementation 'com.github.albfernandez:juniversalchardet:2.0.3' // need this version for Android <7
|
||||
compileOnly 'com.google.code.findbugs:annotations:2.0.1'
|
||||
implementation 'commons-io:commons-io:2.7'
|
||||
implementation 'com.jakewharton:butterknife:10.2.1'
|
||||
kapt 'com.jakewharton:butterknife-compiler:10.2.1'
|
||||
implementation "com.jakewharton:butterknife:$butterknifeVersion"
|
||||
kapt "com.jakewharton:butterknife-compiler:$butterknifeVersion"
|
||||
implementation 'org.greenrobot:eventbus:3.2.0'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.6'
|
||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.0'
|
||||
implementation 'org.lukhnos:nnio:0.2'
|
||||
implementation 'org.bouncycastle:bcpkix-jdk15on:1.65'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
@@ -330,7 +321,8 @@ dependencies {
|
||||
implementation 'androidx.annotation:annotation:1.1.0'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
|
||||
implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido:2.5.1'
|
||||
implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido:4.1.0'
|
||||
implementation 'com.github.cotechde.hwsecurity:hwsecurity-fido2:4.1.0'
|
||||
|
||||
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1'
|
||||
spotbugsPlugins 'com.mebigfatguy.fb-contrib:fb-contrib:7.4.7'
|
||||
@@ -341,7 +333,7 @@ dependencies {
|
||||
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
||||
|
||||
ktlint "com.pinterest:ktlint:0.36.0"
|
||||
ktlint "com.pinterest:ktlint:0.37.2"
|
||||
implementation 'org.conscrypt:conscrypt-android:2.4.0'
|
||||
|
||||
// Shimmer animation
|
||||
@@ -360,16 +352,16 @@ dependencies {
|
||||
|
||||
// dependencies for local unit tests
|
||||
testImplementation 'junit:junit:4.13'
|
||||
testImplementation 'org.mockito:mockito-core:3.3.3'
|
||||
testImplementation 'org.mockito:mockito-core:3.4.6'
|
||||
testImplementation 'androidx.test:core:1.2.0'
|
||||
testImplementation 'org.powermock:powermock-core:2.0.7'
|
||||
testImplementation 'org.powermock:powermock-module-junit4:2.0.7'
|
||||
testImplementation 'org.powermock:powermock-api-mockito2:2.0.7'
|
||||
testImplementation 'org.json:json:20200518'
|
||||
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
||||
kaptAndroidTest "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
kaptTest "com.google.dagger:dagger-compiler:$daggerVersion"
|
||||
testImplementation 'androidx.arch.core:core-testing:2.1.0'
|
||||
testImplementation 'io.mockk:mockk:1.10.0'
|
||||
testImplementation 'io.mockk:mockk-android:1.10.0'
|
||||
|
||||
// dependencies for instrumented tests
|
||||
// JUnit4 Rules
|
||||
@@ -382,7 +374,20 @@ dependencies {
|
||||
// Espresso core
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0'
|
||||
androidTestImplementation 'org.mockito:mockito-core:3.3.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-web:3.2.0'
|
||||
|
||||
// Mocking support
|
||||
androidTestImplementation 'com.github.tmurakami:dexopener:2.0.5' // required to allow mocking on API 27 and older
|
||||
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
androidTestImplementation 'org.mockito:mockito-core:3.4.4'
|
||||
androidTestImplementation("org.mockito:mockito-android:3.4.6") {
|
||||
exclude group: "net.bytebuddy", module: "byte-buddy-android"
|
||||
}
|
||||
androidTestImplementation 'net.bytebuddy:byte-buddy:1.10.14'
|
||||
androidTestImplementation "net.bytebuddy:byte-buddy-android:1.10.14"
|
||||
androidTestImplementation "io.mockk:mockk-android:1.10.0"
|
||||
androidTestImplementation 'androidx.arch.core:core-testing:2.0.1'
|
||||
|
||||
// UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
|
||||
// androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||
// fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
|
||||
@@ -400,9 +405,10 @@ dependencies {
|
||||
// androidJacocoAnt "org.jacoco:org.jacoco.agent:${jacocoVersion}"
|
||||
|
||||
implementation "com.github.stateless4j:stateless4j:2.6.0"
|
||||
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
|
||||
androidTestImplementation "org.mockito:mockito-android:3.3.3"
|
||||
androidTestImplementation 'net.bytebuddy:byte-buddy:1.10.11'
|
||||
}
|
||||
|
||||
spotbugs {
|
||||
toolVersion = '3.1.12'
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
@@ -425,17 +431,15 @@ android.applicationVariants.all { variant ->
|
||||
tasks.register("combinedTestReport", JacocoReport) {
|
||||
|
||||
reports {
|
||||
xml.enabled = true
|
||||
html.enabled = true
|
||||
xml.enabled true
|
||||
html.enabled true
|
||||
csv.enabled false
|
||||
}
|
||||
|
||||
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
|
||||
def debugTree = fileTree(dir: "$project.buildDir/intermediates/classes/gplay/debug", excludes: fileFilter)
|
||||
def mainSrc = "$project.projectDir/src/main/java"
|
||||
|
||||
sourceDirectories = files([mainSrc])
|
||||
classDirectories = files([debugTree])
|
||||
executionData = fileTree(dir: project.buildDir, includes: [
|
||||
additionalSourceDirs.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
sourceDirectories.setFrom files(subprojects.sourceSets.main.allSource.srcDirs)
|
||||
classDirectories.setFrom files(subprojects.sourceSets.main.output)
|
||||
executionData.setFrom project.fileTree(dir: project.buildDir, includes: [
|
||||
'jacoco/testGplayDebugUnitTest.exec', 'outputs/code-coverage/connected/flavors/GPLAY/*coverage.ec'
|
||||
])
|
||||
}
|
||||
|
||||
@@ -83,14 +83,14 @@ complexity:
|
||||
ignoreStringsRegex: '$^'
|
||||
TooManyFunctions:
|
||||
active: true
|
||||
thresholdInFiles: 11
|
||||
thresholdInClasses: 11
|
||||
thresholdInInterfaces: 11
|
||||
thresholdInObjects: 11
|
||||
thresholdInFiles: 15
|
||||
thresholdInClasses: 15
|
||||
thresholdInInterfaces: 15
|
||||
thresholdInObjects: 15
|
||||
thresholdInEnums: 11
|
||||
ignoreDeprecated: false
|
||||
ignoreDeprecated: true
|
||||
ignorePrivate: false
|
||||
ignoreOverridden: false
|
||||
ignoreOverridden: true
|
||||
|
||||
empty-blocks:
|
||||
active: true
|
||||
|
||||
@@ -8,6 +8,9 @@ fastlane_version "2.58.0"
|
||||
# export FASTLANE_NEXTCLOUD_KEY_ALIAS=""
|
||||
# export FASTLANE_NEXTCLOUD_KEY_PASSWORD=""
|
||||
# export FASTLANE_NEXTCLOUD_GITHUB_API_TOKEN=""
|
||||
# export FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_ID=""
|
||||
# export FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_SECRET=""
|
||||
# export FASTLANE_NEXTCLOUD_HUAWEI_APP_ID=""
|
||||
|
||||
skip_docs
|
||||
|
||||
@@ -36,19 +39,14 @@ lane :screenshotsTablet do
|
||||
end
|
||||
|
||||
desc "Release phase 1: make gplay/generic for RC, then test it"
|
||||
lane :releasePhase1_RC do
|
||||
lane :RC_releasePhase1 do
|
||||
disableLogger()
|
||||
makeReleases()
|
||||
enableLogger()
|
||||
end
|
||||
|
||||
desc "Release phase 1: make gplay/generic for FINAL, then test it"
|
||||
lane :releasePhase1_Final do
|
||||
makeReleases()
|
||||
end
|
||||
|
||||
desc "Release phase 2 for RC: checks, tag, upload gplay to playstore with values from build.gradle"
|
||||
lane :releasePhase2_RC do |options|
|
||||
lane :RC_releasePhase2 do |options|
|
||||
info = androidVersion
|
||||
checkChangelog(info)
|
||||
checkLibrary_RC()
|
||||
@@ -61,8 +59,13 @@ lane :releasePhase2_RC do |options|
|
||||
createChangelogPullRequest_RC(info)
|
||||
end
|
||||
|
||||
desc "Release phase 1: make gplay/generic for FINAL, then test it"
|
||||
lane :Final_releasePhase1 do
|
||||
makeReleases()
|
||||
end
|
||||
|
||||
desc "Release phase 2 for FINAL: checks, tag, upload gplay to playstore with values from build.gradle"
|
||||
lane :releasePhase2_Final do |options|
|
||||
lane :Final_releasePhase2 do |options|
|
||||
info = androidVersion
|
||||
checkChangelog(info)
|
||||
checkLibrary_Final()
|
||||
@@ -70,6 +73,7 @@ lane :releasePhase2_Final do |options|
|
||||
checkIfAPKexists()
|
||||
tag(info)
|
||||
uploadToPlaystore_Final(info)
|
||||
uploadToHuawei_Final(info)
|
||||
createGithubRelease_Final(info)
|
||||
fdroidMergeRequest_Final(info)
|
||||
createChangelogPullRequest_Final(info)
|
||||
@@ -116,6 +120,19 @@ lane :beautifyPhone do
|
||||
sh("adb shell am broadcast -a com.android.systemui.demo -e command battery -e plugged false -e level 100")
|
||||
end
|
||||
|
||||
# to install
|
||||
# bundle exec fastlane add_plugin huawei_appgallery_connect
|
||||
# bundle install --path build/vendor/bundle
|
||||
private_lane :uploadToHuawei_Final do |options|
|
||||
huawei_appgallery_connect(
|
||||
client_id: ENV["FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_ID"],
|
||||
client_secret: ENV["FASTLANE_NEXTCLOUD_HUAWEI_CLIENT_SECRET"],
|
||||
app_id: ENV["FASTLANE_NEXTCLOUD_HUAWEI_APP_ID"],
|
||||
apk_path: "release/nextcloud-" + options["versionCode"] + ".apk",
|
||||
submit_for_review: true,
|
||||
)
|
||||
end
|
||||
|
||||
## private lanes
|
||||
|
||||
desc "Build debug and test APK for screenshots"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Autogenerated by fastlane
|
||||
#
|
||||
# Ensure this file is checked in to source control!
|
||||
|
||||
gem 'fastlane-plugin-huawei_appgallery_connect'
|
||||
gem 'fastlane-plugin-huawei_appgallery_connect'
|
||||
@@ -1,6 +1,6 @@
|
||||
#Wed Aug 21 07:03:37 CEST 2019
|
||||
#Fri May 29 07:39:21 CEST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
@@ -55,4 +55,12 @@
|
||||
<issue id="NewApi" severity="error">
|
||||
<ignore path="build" />
|
||||
</issue>
|
||||
|
||||
<issue id="ObsoleteLintCustomCheck" severity="warning">
|
||||
<ignore path="**/fragment-1.2.5/**/lint.jar" />
|
||||
<ignore path="**/work-runtime-2.**/**/lint.jar" />
|
||||
<ignore path="**/jetified-butterknife-runtime-10.**/**/lint.jar" />
|
||||
<ignore path="**/jetified-dagger-lint-aar-2.28.**/**/lint.jar" />
|
||||
<ignore path="**/jetified-annotation-experimental-1.**/**/lint.jar" />
|
||||
</issue>
|
||||
</lint>
|
||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 6.7 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 8.7 KiB |
|
After Width: | Height: | Size: 17 KiB |
@@ -1 +1 @@
|
||||
373
|
||||
329
|
||||
@@ -47,7 +47,7 @@ require 'xmlsimple'
|
||||
|
||||
# run FindBugs
|
||||
puts "running FindBugs..."
|
||||
system './gradlew assembleGplayDebug'
|
||||
system './gradlew assembleGplayDebug 1>/dev/null'
|
||||
|
||||
# confirm that assemble ran w/out error
|
||||
result = $?.to_i
|
||||
@@ -56,7 +56,7 @@ if result != 0
|
||||
exit 1
|
||||
end
|
||||
|
||||
system './gradlew spotbugsGplayDebug'
|
||||
system './gradlew spotbugsGplayDebugReport 1>/dev/null 2>&1'
|
||||
|
||||
# find FindBugs report file
|
||||
findbugs_reports = Dir.glob(FINDBUGS_REPORT_FILE)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
DO NOT TOUCH; GENERATED BY DRONE
|
||||
<span class="mdl-layout-title">Lint Report: 95 warnings</span>
|
||||
<span class="mdl-layout-title">Lint Report: 81 warnings</span>
|
||||
@@ -56,7 +56,7 @@ end
|
||||
|
||||
# run Lint
|
||||
puts "running Lint..."
|
||||
system './gradlew clean lint'
|
||||
system './gradlew clean lint 1>/dev/null'
|
||||
|
||||
# confirm that Lint ran w/out error
|
||||
result = $?.to_i
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "1: record: true/false
|
||||
2: class name
|
||||
3: method name
|
||||
4: darkMode / \"all\" to run all screenshot combinations
|
||||
5: color"
|
||||
|
||||
exit
|
||||
fi
|
||||
|
||||
sed -i s'#<bool name="is_beta">false</bool>#<bool name="is_beta">true</bool>#'g src/main/res/values/setup.xml
|
||||
|
||||
emulator -writable-system -avd uiComparison -no-snapshot -gpu swiftshader_indirect -no-audio -skin 500x833 &
|
||||
|
||||
cd src/androidTest/java
|
||||
|
||||
class=$(find | grep $2 | grep -E "java$|kt$" | head -n1|sed s'/\//\./'g | sed s'#^\.\.##' | sed s'#\.java##'| sed s'#\.kt##')
|
||||
|
||||
if [[ -z $class ]]; then
|
||||
echo "Class not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd ../../../
|
||||
|
||||
if [ $1 == "true" ] ; then
|
||||
record="-Precord"
|
||||
else
|
||||
record=""
|
||||
fi
|
||||
|
||||
if [ -e $3 ] ; then
|
||||
method=""
|
||||
else
|
||||
method="#$3"
|
||||
|
||||
# check if method exists
|
||||
if [[ $(grep -c $3 $(find | grep $2 | grep -E "java$|kt$" | head -n1)) -eq 0 ]]; then
|
||||
echo "Method not found!"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e $4 ] ; then
|
||||
darkMode=""
|
||||
else
|
||||
darkMode="-Pandroid.testInstrumentationRunnerArguments.DARKMODE=$4"
|
||||
fi
|
||||
|
||||
if [ -e $5 ] ; then
|
||||
color=""
|
||||
else
|
||||
color="-Pandroid.testInstrumentationRunnerArguments.COLOR=$5"
|
||||
fi
|
||||
|
||||
if [[ $4 = "all" ]]; then
|
||||
scripts/runAllScreenshotCombinations "noCI" "$1" "-Pandroid.testInstrumentationRunnerArguments.class=$class$method"
|
||||
else
|
||||
./gradlew gplayDebugExecuteScreenshotTests $record \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
|
||||
-Pandroid.testInstrumentationRunnerArguments.class=$class$method \
|
||||
$darkMode \
|
||||
$color
|
||||
fi
|
||||
|
||||
|
||||
sed -i s'#<bool name="is_beta">true</bool>#<bool name="is_beta">false</bool>#'g src/main/res/values/setup.xml
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BRANCH=$1
|
||||
TYPE=$2
|
||||
PR=$3
|
||||
GITHUB_USER=$4
|
||||
GITHUB_PASSWORD=$5
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
|
||||
# delete all old comments, matching this type
|
||||
oldComments=$(curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
|
||||
## $1 noCI/stable/master: wether to run deleteOutdatedComments.sh or uploadReport.sh
|
||||
## $2 true/false: record or verify screenshots
|
||||
## $3 classMethod: piped from androidScreenshotTest
|
||||
|
||||
if [[ $2 = "true" ]]; then
|
||||
record="-Precord"
|
||||
else
|
||||
record=""
|
||||
fi
|
||||
|
||||
classMethod=$3
|
||||
|
||||
while read line
|
||||
do
|
||||
darkMode=$(echo "$line" | cut -d" " -f1)
|
||||
color=$(echo "$line" | cut -d" " -f2)
|
||||
|
||||
echo "Run $color on $darkMode mode"
|
||||
|
||||
if [[ $1 = "noCI" ]]; then
|
||||
./gradlew --console plain gplayDebugExecuteScreenshotTests \
|
||||
$record \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
|
||||
-Pandroid.testInstrumentationRunnerArguments.COLOR="$color" \
|
||||
-Pandroid.testInstrumentationRunnerArguments.DARKMODE="$darkMode" \
|
||||
$classMethod </dev/null > /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
exit
|
||||
fi
|
||||
else
|
||||
./gradlew gplayDebugExecuteScreenshotTests \
|
||||
$record \
|
||||
-Pandroid.testInstrumentationRunnerArguments.annotation=com.owncloud.android.utils.ScreenshotTest \
|
||||
-Pandroid.testInstrumentationRunnerArguments.COLOR="$color" \
|
||||
-Pandroid.testInstrumentationRunnerArguments.DARKMODE="$darkMode" \
|
||||
&& scripts/deleteOutdatedComments.sh "$1-$darkMode-$color" "Screenshot" "$DRONE_PULL_REQUEST" \
|
||||
"$GIT_USERNAME" "$GIT_TOKEN" \
|
||||
|| scripts/uploadReport.sh "$LOG_USERNAME" "$LOG_PASSWORD" "$DRONE_BUILD_NUMBER" \
|
||||
"$1-$darkMode-$color" "Screenshot" "$DRONE_PULL_REQUEST" "$GIT_USERNAME" "$GIT_TOKEN"
|
||||
fi
|
||||
done < scripts/screenshotCombinations
|
||||
@@ -0,0 +1 @@
|
||||
light blue
|
||||
@@ -1,6 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
deleteOldComments() {
|
||||
# delete all old comments, matching this type
|
||||
echo "Deleting old comments for $BRANCH_TYPE"
|
||||
oldComments=$(curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X GET https://api.github.com/repos/nextcloud/android/issues/$PR/comments | jq --arg TYPE $BRANCH_TYPE '.[] | (.id |tostring) + "|" + (.user.login | test("nextcloud-android-bot") | tostring) + "|" + (.body | test([$TYPE]) | tostring)'| grep "true|true" | tr -d "\"" | cut -f1 -d"|")
|
||||
count=$(echo $oldComments | grep true | wc -l)
|
||||
echo "Found $count old comments"
|
||||
|
||||
echo $oldComments | while read comment ; do
|
||||
echo "Deleting comment: $comment"
|
||||
curl 2>/dev/null -u $GITHUB_USER:$GITHUB_PASSWORD -X DELETE https://api.github.com/repos/nextcloud/android/issues/comments/$comment
|
||||
done
|
||||
}
|
||||
|
||||
upload() {
|
||||
deleteOldComments
|
||||
|
||||
cd $1
|
||||
|
||||
find . -type d -exec curl -u $USER:$PASS -X MKCOL $URL/$REMOTE_FOLDER/$(echo {} | sed s#\./##) \;
|
||||
@@ -9,7 +24,7 @@ upload() {
|
||||
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 \" }"
|
||||
-d "{ \"body\" : \"$BRANCH_TYPE test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/$REMOTE_FOLDER \" }"
|
||||
|
||||
exit 1
|
||||
}
|
||||
@@ -17,10 +32,11 @@ upload() {
|
||||
#1: LOG_USERNAME
|
||||
#2: LOG_PASSWORD
|
||||
#3: DRONE_BUILD_NUMBER
|
||||
#4: TYPE (IT or Unit)
|
||||
#5: DRONE_PULL_REQUEST
|
||||
#6: GIT_USERNAME
|
||||
#7: GIT_TOKEN
|
||||
#4: BRANCH (stable or master)
|
||||
#5: TYPE (IT or Unit)
|
||||
#6: DRONE_PULL_REQUEST
|
||||
#7: GIT_USERNAME
|
||||
#8: GIT_TOKEN
|
||||
|
||||
URL=https://nextcloud.kaminsky.me/remote.php/webdav/android-integrationTests
|
||||
ID=$3
|
||||
@@ -31,7 +47,8 @@ TYPE=$5
|
||||
PR=$6
|
||||
GITHUB_USER=$7
|
||||
GITHUB_PASSWORD=$8
|
||||
REMOTE_FOLDER=$ID-$TYPE
|
||||
REMOTE_FOLDER=$ID-$TYPE-$BRANCH
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
|
||||
set -e
|
||||
|
||||
@@ -46,24 +63,28 @@ fi
|
||||
if [ -e $FOLDER ]; then
|
||||
upload $FOLDER
|
||||
else
|
||||
echo "$BRANCH-$TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
||||
deleteOldComments
|
||||
echo "$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed."
|
||||
|
||||
curl -u $GITHUB_USER:$GITHUB_PASSWORD \
|
||||
-X POST https://api.github.com/repos/nextcloud/android/issues/$PR/comments \
|
||||
-d "{ \"body\" : \"$BRANCH-$TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
||||
-d "{ \"body\" : \"$BRANCH_TYPE test failed, but no output was generated. Maybe a preliminary stage failed. \" }"
|
||||
|
||||
if [ -e build/reports/androidTests/connected/flavors/GPLAY ] ; then
|
||||
TYPE="IT"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/androidTests/connected/flavors/GPLAY"
|
||||
fi
|
||||
|
||||
if [ -e build/reports/tests/testGplayDebugUnitTest ] ; then
|
||||
TYPE="Unit"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/tests/testGplayDebugUnitTest"
|
||||
fi
|
||||
|
||||
if [ -e build/reports/shot/verification ] ; then
|
||||
TYPE="Screenshot"
|
||||
BRANCH_TYPE=$BRANCH-$TYPE
|
||||
upload "build/reports/shot/verification"
|
||||
fi
|
||||
fi
|
||||
@@ -32,6 +32,7 @@
|
||||
<Or>
|
||||
<Class name="~.*BindingImpl"/>
|
||||
<Class name="~.*\.DataBinderMapperImpl" />
|
||||
<Class name="~.*Binding" />
|
||||
</Or>
|
||||
</Match>
|
||||
|
||||
|
||||
@@ -31,6 +31,4 @@
|
||||
android:sharedUserId="${applicationId}.uid">
|
||||
|
||||
<uses-sdk tools:overrideLibrary="android_libs.ub_uiautomator, tools.fastlane.screengrab" />
|
||||
|
||||
<application android:name="com.owncloud.android.TestApp"></application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,17 @@
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
N:Mustermann;Erika;;Dr.;
|
||||
FN:Dr. Erika Mustermann
|
||||
ORG:Wikimedia
|
||||
ROLE:Kommunikation
|
||||
TITLE:Redaktion & Gestaltung
|
||||
PHOTO;VALUE=URL;TYPE=JPEG:http://commons.wikimedia.org/wiki/File:Erika_Mustermann_2010.jpg
|
||||
TEL;TYPE=WORK,VOICE:+49 221 9999123
|
||||
TEL;TYPE=HOME,VOICE:+49 221 1234567
|
||||
ADR;TYPE=HOME:;;Heidestraße 17;Köln;;51147;Germany
|
||||
EMAIL;TYPE=PREF,INTERNET:[email protected]
|
||||
URL:http://de.wikipedia.org/
|
||||
REV:2014-03-01T22:11:10Z
|
||||
END:VCARD
|
||||
|
||||
## from https://de.wikipedia.org/wiki/VCard#vCard_3.0 on 27.07.2020
|
||||
@@ -25,7 +25,6 @@ package com.nextcloud.client;
|
||||
import android.Manifest;
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.ui.activities.ActivitiesActivity;
|
||||
@@ -60,16 +59,13 @@ public class ActivitiesActivityIT extends AbstractIT {
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
sut.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sut.emptyContentContainer.setVisibility(View.VISIBLE);
|
||||
sut.recyclerView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
sut.runOnUiThread(() -> {
|
||||
sut.emptyContentContainer.setVisibility(View.VISIBLE);
|
||||
sut.recyclerView.setVisibility(View.INVISIBLE);
|
||||
});
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
screenshot(sut);
|
||||
}
|
||||
}
|
||||
@@ -24,18 +24,24 @@ package com.nextcloud.client;
|
||||
|
||||
import android.accounts.AccountManager;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.datamodel.ArbitraryDataProvider;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.lib.resources.users.GetPrivateKeyOperation;
|
||||
import com.owncloud.android.lib.resources.users.GetPublicKeyOperation;
|
||||
import com.owncloud.android.lib.resources.users.SendCSROperation;
|
||||
import com.owncloud.android.lib.resources.users.StorePrivateKeyOperation;
|
||||
import com.owncloud.android.operations.DownloadFileOperation;
|
||||
import com.owncloud.android.operations.GetCapabilitiesOperation;
|
||||
import com.owncloud.android.operations.RemoveFileOperation;
|
||||
import com.owncloud.android.utils.CsrHelper;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
@@ -52,19 +58,24 @@ import java.io.IOException;
|
||||
import java.security.KeyPair;
|
||||
import java.security.PrivateKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.owncloud.android.lib.resources.status.OwnCloudVersion.nextcloud_19;
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
public class EndToEndRandomIT extends AbstractIT {
|
||||
public class EndToEndRandomIT extends AbstractOnServerIT {
|
||||
public enum Action {
|
||||
CREATE_FOLDER,
|
||||
GO_INTO_FOLDER,
|
||||
GO_UP,
|
||||
UPLOAD_FILE
|
||||
UPLOAD_FILE,
|
||||
DOWNLOAD_FILE,
|
||||
DELETE_FILE,
|
||||
}
|
||||
|
||||
private static ArbitraryDataProvider arbitraryDataProvider;
|
||||
@@ -79,7 +90,13 @@ public class EndToEndRandomIT extends AbstractIT {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
public void before() throws IOException {
|
||||
OCCapability capability = getStorageManager().getCapability(account.name);
|
||||
|
||||
if (capability.getVersion().equals(new OwnCloudVersion("0.0.0"))) {
|
||||
// fetch new one
|
||||
assertTrue(new GetCapabilitiesOperation().execute(client, getStorageManager()).isSuccess());
|
||||
}
|
||||
// tests only for NC19+
|
||||
assumeTrue(getStorageManager()
|
||||
.getCapability(account.name)
|
||||
@@ -87,6 +104,8 @@ public class EndToEndRandomIT extends AbstractIT {
|
||||
.isNewerOrEqual(nextcloud_19)
|
||||
);
|
||||
|
||||
// make sure that every file is available, even after tests that remove source file
|
||||
createDummyFiles();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,6 +132,14 @@ public class EndToEndRandomIT extends AbstractIT {
|
||||
uploadFile(i);
|
||||
break;
|
||||
|
||||
case DOWNLOAD_FILE:
|
||||
downloadFile(i);
|
||||
break;
|
||||
|
||||
case DELETE_FILE:
|
||||
deleteFile(i);
|
||||
break;
|
||||
|
||||
default:
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "]" + " Unknown action: " + nextAction);
|
||||
break;
|
||||
@@ -198,6 +225,14 @@ public class EndToEndRandomIT extends AbstractIT {
|
||||
deleteFile(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void downloadFile() throws Exception {
|
||||
init();
|
||||
|
||||
uploadFile(1);
|
||||
downloadFile(1);
|
||||
}
|
||||
|
||||
private void init() throws Exception {
|
||||
// create folder
|
||||
createFolder(rootEncFolder);
|
||||
@@ -260,17 +295,149 @@ public class EndToEndRandomIT extends AbstractIT {
|
||||
|
||||
private void uploadFile(int i) throws IOException {
|
||||
String fileName = RandomString.make(5) + ".txt";
|
||||
createFile(fileName, new Random().nextInt(50000));
|
||||
String path = currentFolder.getRemotePath() + fileName;
|
||||
|
||||
File file;
|
||||
if (new Random().nextBoolean()) {
|
||||
file = createFile(fileName, new Random().nextInt(50000));
|
||||
} else {
|
||||
file = createFile(fileName, 500000 + new Random().nextInt(50000));
|
||||
}
|
||||
|
||||
String remotePath = currentFolder.getRemotePath() + fileName;
|
||||
|
||||
Log_OC.d(this,
|
||||
"[" + i + "/" + actionCount + "] " +
|
||||
"Upload file to: " + currentFolder.getDecryptedRemotePath() + fileName);
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getSavePath(account.name) + File.separator + fileName,
|
||||
path,
|
||||
OCUpload ocUpload = new OCUpload(file.getAbsolutePath(),
|
||||
remotePath,
|
||||
account.name);
|
||||
uploadOCUpload(ocUpload);
|
||||
shortSleep();
|
||||
|
||||
OCFile parentFolder = getStorageManager()
|
||||
.getFileByEncryptedRemotePath(new File(ocUpload.getRemotePath()).getParent() + "/");
|
||||
String uploadedFileName = new File(ocUpload.getRemotePath()).getName();
|
||||
|
||||
String decryptedPath = parentFolder.getDecryptedRemotePath() + uploadedFileName;
|
||||
|
||||
OCFile uploadedFile = getStorageManager().getFileByDecryptedRemotePath(decryptedPath);
|
||||
verifyStoragePath(uploadedFile);
|
||||
|
||||
// verify storage path
|
||||
refreshFolder(currentFolder.getRemotePath());
|
||||
uploadedFile = getStorageManager().getFileByDecryptedRemotePath(decryptedPath);
|
||||
verifyStoragePath(uploadedFile);
|
||||
|
||||
// verify that encrypted file is on server
|
||||
assertTrue(new ReadFileRemoteOperation(currentFolder.getRemotePath() + uploadedFile.getEncryptedFileName())
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
|
||||
// verify that unencrypted file is not on server
|
||||
assertFalse(new ReadFileRemoteOperation(currentFolder.getDecryptedRemotePath() + fileName)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
private void downloadFile(int i) {
|
||||
ArrayList<OCFile> files = new ArrayList<>();
|
||||
for (OCFile file : getStorageManager().getFolderContent(currentFolder, false)) {
|
||||
if (!file.isFolder()) {
|
||||
files.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (files.isEmpty()) {
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "] No files in: " + currentFolder.getDecryptedRemotePath());
|
||||
return;
|
||||
}
|
||||
|
||||
OCFile fileToDownload = files.get(new Random().nextInt(files.size()));
|
||||
assertNotNull(fileToDownload.getRemoteId());
|
||||
|
||||
Log_OC.d(this,
|
||||
"[" + i + "/" + actionCount + "] " + "Download file: " +
|
||||
currentFolder.getDecryptedRemotePath() + fileToDownload.getDecryptedFileName());
|
||||
|
||||
assertTrue(new DownloadFileOperation(account, fileToDownload, targetContext)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
|
||||
assertTrue(new File(fileToDownload.getStoragePath()).exists());
|
||||
verifyStoragePath(fileToDownload);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithCopy() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_COPY);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertTrue(originalFile.exists());
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithMove() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_MOVE);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertFalse(originalFile.exists());
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithForget() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_FORGET);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertTrue(originalFile.exists());
|
||||
assertFalse(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUploadWithDelete() throws Exception {
|
||||
init();
|
||||
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
currentFolder.getRemotePath() + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_DELETE);
|
||||
|
||||
File originalFile = new File(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt");
|
||||
OCFile uploadedFile = fileDataStorageManager.getFileByDecryptedRemotePath(currentFolder.getRemotePath() +
|
||||
"nonEmpty.txt");
|
||||
|
||||
assertFalse(originalFile.exists());
|
||||
assertFalse(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
|
||||
private void deleteFile(int i) {
|
||||
@@ -281,7 +448,13 @@ public class EndToEndRandomIT extends AbstractIT {
|
||||
}
|
||||
}
|
||||
|
||||
if (files.isEmpty()) {
|
||||
Log_OC.d(this, "[" + i + "/" + actionCount + "] No files in: " + currentFolder.getDecryptedRemotePath());
|
||||
return;
|
||||
}
|
||||
|
||||
OCFile fileToDelete = files.get(new Random().nextInt(files.size()));
|
||||
assertNotNull(fileToDelete.getRemoteId());
|
||||
|
||||
Log_OC.d(this,
|
||||
"[" + i + "/" + actionCount + "] " +
|
||||
@@ -395,4 +568,65 @@ public class EndToEndRandomIT extends AbstractIT {
|
||||
private String generateMnemonicString() {
|
||||
return "1 2 3 4 5 6";
|
||||
}
|
||||
|
||||
public void after() {
|
||||
// remove all encrypted files
|
||||
OCFile root = fileDataStorageManager.getFileByDecryptedRemotePath("/");
|
||||
removeFolder(root);
|
||||
|
||||
// List<OCFile> files = fileDataStorageManager.getFolderContent(root, false);
|
||||
//
|
||||
// for (OCFile child : files) {
|
||||
// removeFolder(child);
|
||||
// }
|
||||
|
||||
assertEquals(0, fileDataStorageManager.getFolderContent(root, false).size());
|
||||
|
||||
super.after();
|
||||
}
|
||||
|
||||
private void removeFolder(OCFile folder) {
|
||||
Log_OC.d(this, "Start removing content of folder: " + folder.getDecryptedRemotePath());
|
||||
|
||||
List<OCFile> children = fileDataStorageManager.getFolderContent(folder, false);
|
||||
|
||||
// remove children
|
||||
for (OCFile child : children) {
|
||||
if (child.isFolder()) {
|
||||
removeFolder(child);
|
||||
|
||||
// remove folder
|
||||
Log_OC.d(this, "Remove folder: " + child.getDecryptedRemotePath());
|
||||
if (!folder.isEncrypted() && child.isEncrypted()) {
|
||||
assertTrue(new ToggleEncryptionRemoteOperation(child.getLocalId(),
|
||||
child.getRemotePath(),
|
||||
false)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
|
||||
OCFile f = getStorageManager().getFileByEncryptedRemotePath(child.getRemotePath());
|
||||
f.setEncrypted(false);
|
||||
getStorageManager().saveFile(f);
|
||||
|
||||
child.setEncrypted(false);
|
||||
}
|
||||
} else {
|
||||
Log_OC.d(this, "Remove file: " + child.getDecryptedRemotePath());
|
||||
}
|
||||
|
||||
assertTrue(new RemoveFileOperation(child, false, account, false, targetContext)
|
||||
.execute(client, getStorageManager())
|
||||
.isSuccess()
|
||||
);
|
||||
}
|
||||
|
||||
Log_OC.d(this, "Finished removing content of folder: " + folder.getDecryptedRemotePath());
|
||||
}
|
||||
|
||||
private void verifyStoragePath(OCFile file) {
|
||||
assertEquals(FileStorageUtils.getSavePath(account.name) +
|
||||
currentFolder.getDecryptedRemotePath() +
|
||||
file.getDecryptedFileName(),
|
||||
file.getStoragePath());
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,7 @@ package com.nextcloud.client;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
|
||||
@@ -38,7 +37,6 @@ 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 com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.junit.Assert;
|
||||
@@ -56,7 +54,7 @@ import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentat
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
public class FileDisplayActivityIT extends AbstractIT {
|
||||
public class FileDisplayActivityIT extends AbstractOnServerIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
@@ -66,31 +64,7 @@ public class FileDisplayActivityIT extends AbstractIT {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
shortSleep();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void drawer() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
waitForIdleSync();
|
||||
shortSleep();
|
||||
sut.getListOfFilesFragment().setFabEnabled(false);
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
// @ScreenshotTest // todo run without real server
|
||||
public void showShares() {
|
||||
assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
|
||||
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
|
||||
@@ -151,7 +125,7 @@ public class FileDisplayActivityIT extends AbstractIT {
|
||||
shortSleep();
|
||||
shortSleep();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -159,7 +133,7 @@ public class FileDisplayActivityIT extends AbstractIT {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
// given test folder
|
||||
assertTrue(new CreateFolderOperation("/test/", account, targetContext)
|
||||
assertTrue(new CreateFolderOperation("/test/", user, targetContext)
|
||||
.execute(client, getStorageManager())
|
||||
.isSuccess());
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
* Copyright (C) 2019 Tobias Kaminsky
|
||||
* Copyright (C) 2019 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
|
||||
@@ -25,20 +25,24 @@ package com.nextcloud.client;
|
||||
import android.Manifest;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.NotificationsActivity;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
|
||||
public class NotificationsActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<NotificationsActivity> activityRule = new IntentsTestRule<>(NotificationsActivity.class,
|
||||
true,
|
||||
false);
|
||||
public class FileDisplayActivityScreenshotIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<FileDisplayActivity> activityRule = new IntentsTestRule<>(FileDisplayActivity.class,
|
||||
true,
|
||||
false);
|
||||
|
||||
@Rule
|
||||
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
|
||||
@@ -46,7 +50,25 @@ public class NotificationsActivityIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
public void open() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
sut.getListOfFilesFragment().setFabEnabled(false);
|
||||
sut.getListOfFilesFragment().setEmptyListLoadingMessage();
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void drawer() {
|
||||
FileDisplayActivity sut = activityRule.launchActivity(null);
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
|
||||
sut.getListOfFilesFragment().setFabEnabled(false);
|
||||
sut.getListOfFilesFragment().setEmptyListLoadingMessage();
|
||||
|
||||
screenshot(sut);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ package com.nextcloud.client;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
@@ -51,7 +50,7 @@ public class FirstRunActivityIT extends AbstractIT {
|
||||
public void open() {
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import org.junit.runners.model.Statement
|
||||
/**
|
||||
* C&p from https://stackoverflow.com/questions/45635833/how-can-i-use-flakytest-annotation-now on 18.03.2020
|
||||
*/
|
||||
class RetryTestRule(val retryCount: Int = 5) : TestRule {
|
||||
class RetryTestRule(val retryCount: Int = 1) : TestRule {
|
||||
|
||||
companion object {
|
||||
private val TAG = RetryTestRule::class.java.simpleName
|
||||
|
||||
@@ -24,18 +24,29 @@ package com.nextcloud.client;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.facebook.testing.screenshot.ScreenshotRunner;
|
||||
import com.owncloud.android.TestApp;
|
||||
import com.github.tmurakami.dexopener.DexOpener;
|
||||
|
||||
import androidx.test.runner.AndroidJUnitRunner;
|
||||
|
||||
public class ScreenshotTestRunner extends AndroidJUnitRunner {
|
||||
|
||||
@Override
|
||||
public Application newApplication(ClassLoader cl, String className, Context context) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
return super.newApplication(cl, TestApp.class.getName(), context);
|
||||
public Application newApplication(ClassLoader cl, String className, Context context)
|
||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
|
||||
/*
|
||||
* Initialize DexOpener only on API below 28 to enable mocking of Kotlin classes.
|
||||
* On API 28+ the platform supports mocking natively.
|
||||
*/
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
DexOpener.install(this);
|
||||
}
|
||||
|
||||
return super.newApplication(cl, className, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,6 @@ package com.nextcloud.client;
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
@@ -49,8 +48,8 @@ public class SettingsActivityIT extends AbstractIT {
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void open() {
|
||||
Activity test = activityRule.launchActivity(null);
|
||||
Activity sut = activityRule.launchActivity(null);
|
||||
|
||||
Screenshot.snapActivity(test).record();
|
||||
screenshot(sut);
|
||||
}
|
||||
}
|
||||
@@ -23,17 +23,25 @@
|
||||
package com.nextcloud.client;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.datamodel.MediaFolderType;
|
||||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem;
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
|
||||
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment;
|
||||
import com.owncloud.android.utils.ScreenshotTest;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.rule.GrantPermissionRule;
|
||||
|
||||
import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
|
||||
|
||||
|
||||
public class SyncedFoldersActivityIT extends AbstractIT {
|
||||
@Rule public IntentsTestRule<SyncedFoldersActivity> activityRule = new IntentsTestRule<>(SyncedFoldersActivity.class,
|
||||
@@ -49,4 +57,35 @@ public class SyncedFoldersActivityIT extends AbstractIT {
|
||||
public void openDrawer() {
|
||||
super.openDrawer(activityRule);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
public void testSyncedFolderDialog() {
|
||||
SyncedFolderDisplayItem item = new SyncedFolderDisplayItem(1,
|
||||
"/sdcard/DCIM/",
|
||||
"/InstantUpload/",
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
"test@https://server.com",
|
||||
0,
|
||||
0,
|
||||
true,
|
||||
1000,
|
||||
"Name",
|
||||
MediaFolderType.IMAGE,
|
||||
false);
|
||||
SyncedFolderPreferencesDialogFragment sut = SyncedFolderPreferencesDialogFragment.newInstance(item, 0);
|
||||
|
||||
Intent intent = new Intent(targetContext, SyncedFoldersActivity.class);
|
||||
SyncedFoldersActivity activity = activityRule.launchActivity(intent);
|
||||
|
||||
sut.show(activity.getSupportFragmentManager(), "");
|
||||
|
||||
getInstrumentation().waitForIdleSync();
|
||||
shortSleep();
|
||||
|
||||
screenshot(Objects.requireNonNull(sut.requireDialog().getWindow()).getDecorView());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz <[email protected]>
|
||||
* Copyright (C) 2020 Chris Narkiewicz
|
||||
* 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.nextcloud.client.account
|
||||
|
||||
import android.os.Parcel
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotSame
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class MockUserTest {
|
||||
|
||||
private companion object {
|
||||
const val ACCOUNT_NAME = "test_account_name"
|
||||
const val ACCOUNT_TYPE = "test_account_type"
|
||||
}
|
||||
|
||||
@Test
|
||||
fun mock_user_is_parcelable() {
|
||||
// GIVEN
|
||||
// mock user instance
|
||||
val original = MockUser(ACCOUNT_NAME, ACCOUNT_TYPE)
|
||||
|
||||
// WHEN
|
||||
// instance is serialized into Parcel
|
||||
// instance is retrieved from Parcel
|
||||
val parcel = Parcel.obtain()
|
||||
parcel.setDataPosition(0)
|
||||
parcel.writeParcelable(original, 0)
|
||||
parcel.setDataPosition(0)
|
||||
val retrieved = parcel.readParcelable<User>(User::class.java.classLoader)
|
||||
|
||||
// THEN
|
||||
// retrieved instance in distinct
|
||||
// instances are equal
|
||||
assertNotSame(original, retrieved)
|
||||
assertTrue(retrieved is MockUser)
|
||||
assertEquals(original, retrieved)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun mock_user_has_platform_account() {
|
||||
// GIVEN
|
||||
// mock user instance
|
||||
val mock = MockUser(ACCOUNT_NAME, ACCOUNT_TYPE)
|
||||
|
||||
// THEN
|
||||
// can convert to platform account
|
||||
val account = mock.toPlatformAccount()
|
||||
assertEquals(ACCOUNT_NAME, account.name)
|
||||
assertEquals(ACCOUNT_TYPE, account.type)
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ import android.accounts.OperationCanceledException;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||
import com.owncloud.android.lib.common.OwnCloudClientManager;
|
||||
@@ -48,7 +48,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class OwnCloudClientManagerTest extends AbstractIT {
|
||||
public class OwnCloudClientManagerTest extends AbstractOnServerIT {
|
||||
|
||||
/**
|
||||
* Like on files app we create & store an account in Android's account manager.
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.os.Bundle;
|
||||
|
||||
import com.nextcloud.client.preferences.AppPreferences;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.owncloud.android.AbstractIT;
|
||||
import com.owncloud.android.AbstractOnServerIT;
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -17,7 +17,7 @@ import static junit.framework.TestCase.assertNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
public class UserAccountManagerImplTest extends AbstractIT {
|
||||
public class UserAccountManagerImplTest extends AbstractOnServerIT {
|
||||
|
||||
private AccountManager accountManager;
|
||||
|
||||
|
||||
@@ -41,9 +41,11 @@ class EtmActivityTest : AbstractIT() {
|
||||
@Before
|
||||
fun before() {
|
||||
// tests only on NC 18
|
||||
Assume.assumeTrue(storageManager
|
||||
.getCapability(account.name)
|
||||
.version.compareTo(OwnCloudVersion.nextcloud_18) == 0)
|
||||
Assume.assumeTrue(
|
||||
storageManager
|
||||
.getCapability(account.name)
|
||||
.version.compareTo(OwnCloudVersion.nextcloud_18) == 0
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files
|
||||
|
||||
import android.net.Uri
|
||||
import com.nextcloud.client.account.Server
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nhaarman.mockitokotlin2.mock
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Parameterized
|
||||
import org.junit.runners.Suite
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
import java.net.URI
|
||||
|
||||
@RunWith(Suite::class)
|
||||
@Suite.SuiteClasses(
|
||||
DeepLinkHandlerTest.DeepLinkPattern::class,
|
||||
DeepLinkHandlerTest.FileDeepLink::class
|
||||
)
|
||||
class DeepLinkHandlerTest {
|
||||
|
||||
@RunWith(Parameterized::class)
|
||||
class DeepLinkPattern {
|
||||
|
||||
companion object {
|
||||
val FILE_ID = 1234
|
||||
val SERVER_BASE_URLS = listOf(
|
||||
"http://hostname.net",
|
||||
"https://hostname.net",
|
||||
"http://hostname.net/subdir1",
|
||||
"https://hostname.net/subdir1",
|
||||
"http://hostname.net/subdir1/subdir2",
|
||||
"https://hostname.net/subdir1/subdir2",
|
||||
"http://hostname.net/subdir1/subdir2/subdir3",
|
||||
"https://hostname.net/subdir1/subdir2/subdir3"
|
||||
)
|
||||
val INDEX_PHP_PATH = listOf(
|
||||
"",
|
||||
"/index.php"
|
||||
)
|
||||
|
||||
@Parameterized.Parameters
|
||||
@JvmStatic
|
||||
fun urls(): Array<Array<Any>> {
|
||||
val testInput = mutableListOf<Array<Any>>()
|
||||
SERVER_BASE_URLS.forEach { baseUrl ->
|
||||
INDEX_PHP_PATH.forEach { indexPath ->
|
||||
val url = "$baseUrl$indexPath/f/$FILE_ID"
|
||||
testInput.add(arrayOf(baseUrl, indexPath, "$FILE_ID", url))
|
||||
}
|
||||
}
|
||||
return testInput.toTypedArray()
|
||||
}
|
||||
}
|
||||
|
||||
@Parameterized.Parameter(0)
|
||||
lateinit var baseUrl: String
|
||||
|
||||
@Parameterized.Parameter(1)
|
||||
lateinit var indexPath: String
|
||||
|
||||
@Parameterized.Parameter(2)
|
||||
lateinit var fileId: String
|
||||
|
||||
@Parameterized.Parameter(3)
|
||||
lateinit var url: String
|
||||
|
||||
@Test
|
||||
fun matches_deep_link_patterns() {
|
||||
val match = DeepLinkHandler.DEEP_LINK_PATTERN.matchEntire(url)
|
||||
assertNotNull("Url [$url] does not match pattern", match)
|
||||
assertEquals(baseUrl, match?.groupValues?.get(DeepLinkHandler.BASE_URL_GROUP_INDEX))
|
||||
assertEquals(indexPath, match?.groupValues?.get(DeepLinkHandler.INDEX_PATH_GROUP_INDEX))
|
||||
assertEquals(fileId, match?.groupValues?.get(DeepLinkHandler.FILE_ID_GROUP_INDEX))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_trailing_path_allowed_after_file_id() {
|
||||
val invalidUrl = "$url/"
|
||||
val match = DeepLinkHandler.DEEP_LINK_PATTERN.matchEntire(invalidUrl)
|
||||
assertNull(match)
|
||||
}
|
||||
}
|
||||
|
||||
class FileDeepLink {
|
||||
|
||||
companion object {
|
||||
const val OTHER_SERVER_BASE_URL = "https://someotherserver.net"
|
||||
const val SERVER_BASE_URL = "https://server.net"
|
||||
const val FILE_ID = "1234567890"
|
||||
val DEEP_LINK = Uri.parse("$SERVER_BASE_URL/index.php/f/$FILE_ID")
|
||||
|
||||
fun createMockUser(serverBaseUrl: String): User {
|
||||
val user = mock<User>()
|
||||
val uri = URI.create(serverBaseUrl)
|
||||
val server = Server(uri = uri, version = OwnCloudVersion.nextcloud_19)
|
||||
whenever(user.server).thenReturn(server)
|
||||
return user
|
||||
}
|
||||
}
|
||||
|
||||
@Mock
|
||||
lateinit var userAccountManager: UserAccountManager
|
||||
lateinit var allUsers: List<User>
|
||||
lateinit var handler: DeepLinkHandler
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
whenever(userAccountManager.allUsers).thenAnswer { allUsers }
|
||||
allUsers = emptyList()
|
||||
handler = DeepLinkHandler(userAccountManager)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_user_can_open_file() {
|
||||
// GIVEN
|
||||
// no user capable of opening the file
|
||||
allUsers = listOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link is valid
|
||||
// no user can open the file
|
||||
assertNotNull(match)
|
||||
assertEquals(0, match?.users?.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun single_user_can_open_file() {
|
||||
// GIVEN
|
||||
// multiple users registered
|
||||
// one user capable of opening the link
|
||||
val matchingUser = createMockUser(SERVER_BASE_URL)
|
||||
allUsers = listOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
matchingUser,
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link can be opened by single user
|
||||
assertNotNull(match)
|
||||
assertSame(matchingUser, match?.users?.get(0))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun multiple_users_can_open_file() {
|
||||
// GIVEN
|
||||
// mutltiple users registered
|
||||
// multiple users capable of opening the link
|
||||
val matchingUsers = setOf(
|
||||
createMockUser(SERVER_BASE_URL),
|
||||
createMockUser(SERVER_BASE_URL)
|
||||
)
|
||||
val otherUsers = setOf(
|
||||
createMockUser(OTHER_SERVER_BASE_URL),
|
||||
createMockUser(OTHER_SERVER_BASE_URL)
|
||||
)
|
||||
allUsers = listOf(matchingUsers, otherUsers).flatten()
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// link can be opened by multiple matching users
|
||||
assertNotNull(match)
|
||||
assertEquals(matchingUsers, match?.users?.toSet())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun match_contains_extracted_file_id() {
|
||||
// WHEN
|
||||
// valid deep file link is parsed
|
||||
val match = handler.parseDeepLink(DEEP_LINK)
|
||||
|
||||
// THEN
|
||||
// file id is returned
|
||||
assertEquals(FILE_ID, match?.fileId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun no_match_for_invalid_link() {
|
||||
// GIVEN
|
||||
// invalid deep link
|
||||
val invalidLink = Uri.parse("http://www.dodgylink.com/index.php")
|
||||
|
||||
// WHEN
|
||||
// deep link is parsed
|
||||
val match = handler.parseDeepLink(invalidLink)
|
||||
|
||||
// THEN
|
||||
// no match
|
||||
assertNull(match)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files.downloader
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider.getApplicationContext
|
||||
import androidx.test.rule.ServiceTestRule
|
||||
import com.nextcloud.client.account.MockUser
|
||||
import io.mockk.MockKAnnotations
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
||||
class DownloaderServiceTest {
|
||||
|
||||
@get:Rule
|
||||
val service = ServiceTestRule.withTimeout(3, TimeUnit.SECONDS)
|
||||
|
||||
val user = MockUser()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
}
|
||||
|
||||
@Test(expected = TimeoutException::class)
|
||||
fun cannot_bind_to_service_without_user() {
|
||||
val intent = DownloaderService.createBindIntent(getApplicationContext(), user)
|
||||
intent.removeExtra(DownloaderService.EXTRA_USER)
|
||||
service.bindService(intent)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun bind_with_user() {
|
||||
val intent = DownloaderService.createBindIntent(getApplicationContext(), user)
|
||||
val binder = service.bindService(intent)
|
||||
assertTrue(binder is DownloaderService.Binder)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,519 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files.downloader
|
||||
|
||||
import com.nextcloud.client.account.User
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import io.mockk.CapturingSlot
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.clearAllMocks
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.verify
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Suite
|
||||
import java.util.UUID
|
||||
|
||||
@RunWith(Suite::class)
|
||||
@Suite.SuiteClasses(
|
||||
RegistryTest.Pending::class,
|
||||
RegistryTest.Start::class,
|
||||
RegistryTest.Progress::class,
|
||||
RegistryTest.Complete::class,
|
||||
RegistryTest.GetTransfers::class,
|
||||
RegistryTest.IsRunning::class
|
||||
)
|
||||
class RegistryTest {
|
||||
|
||||
abstract class Base {
|
||||
companion object {
|
||||
const val MAX_TRANSFER_THREADS = 4
|
||||
const val PROGRESS_FULL = 100
|
||||
const val PROGRESS_HALF = 50
|
||||
}
|
||||
|
||||
@MockK
|
||||
lateinit var user: User
|
||||
|
||||
lateinit var file: OCFile
|
||||
|
||||
@MockK
|
||||
lateinit var onTransferStart: (UUID, Request) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var onTransferChanged: (Transfer) -> Unit
|
||||
|
||||
internal lateinit var registry: Registry
|
||||
|
||||
@Before
|
||||
fun setUpBase() {
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
file = OCFile("/test/path")
|
||||
registry = Registry(onTransferStart, onTransferChanged, MAX_TRANSFER_THREADS)
|
||||
resetMocks()
|
||||
}
|
||||
|
||||
fun resetMocks() {
|
||||
clearAllMocks()
|
||||
every { onTransferStart(any(), any()) } answers {}
|
||||
every { onTransferChanged(any()) } answers {}
|
||||
}
|
||||
}
|
||||
|
||||
class Pending : Base() {
|
||||
|
||||
@Test
|
||||
fun inserting_pending_transfer() {
|
||||
// GIVEN
|
||||
// registry has no pending transfers
|
||||
assertEquals(0, registry.pending.size)
|
||||
|
||||
// WHEN
|
||||
// new transfer requests added
|
||||
val addedTransfersCount = 10
|
||||
for (i in 0 until addedTransfersCount) {
|
||||
val request = Request(user, file)
|
||||
registry.add(request)
|
||||
}
|
||||
|
||||
// THEN
|
||||
// transfer is added to the pending queue
|
||||
assertEquals(addedTransfersCount, registry.pending.size)
|
||||
}
|
||||
}
|
||||
|
||||
class Start : Base() {
|
||||
|
||||
companion object {
|
||||
const val ENQUEUED_REQUESTS_COUNT = 10
|
||||
}
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
for (i in 0 until ENQUEUED_REQUESTS_COUNT) {
|
||||
registry.add(Request(user, file))
|
||||
}
|
||||
assertEquals(ENQUEUED_REQUESTS_COUNT, registry.pending.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun starting_transfer() {
|
||||
// WHEN
|
||||
// started
|
||||
registry.startNext()
|
||||
|
||||
// THEN
|
||||
// up to max threads requests are started
|
||||
// start callback is triggered
|
||||
// update callback is triggered on transfer transition
|
||||
// started transfers are in running state
|
||||
assertEquals(
|
||||
"Transfers not moved to running queue",
|
||||
MAX_TRANSFER_THREADS,
|
||||
registry.running.size
|
||||
)
|
||||
assertEquals(
|
||||
"Transfers not moved from pending queue",
|
||||
ENQUEUED_REQUESTS_COUNT - MAX_TRANSFER_THREADS,
|
||||
registry.pending.size
|
||||
)
|
||||
verify(exactly = MAX_TRANSFER_THREADS) { onTransferStart(any(), any()) }
|
||||
val startedTransfers = mutableListOf<Transfer>()
|
||||
verify(exactly = MAX_TRANSFER_THREADS) { onTransferChanged(capture(startedTransfers)) }
|
||||
assertEquals(
|
||||
"Callbacks not invoked for running transfers",
|
||||
MAX_TRANSFER_THREADS,
|
||||
startedTransfers.size
|
||||
)
|
||||
startedTransfers.forEach {
|
||||
assertEquals("Transfer not placed into running state", TransferState.RUNNING, it.state)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun start_is_ignored_if_no_more_free_threads() {
|
||||
// WHEN
|
||||
// max number of running transfers
|
||||
registry.startNext()
|
||||
assertEquals(MAX_TRANSFER_THREADS, registry.running.size)
|
||||
clearAllMocks()
|
||||
|
||||
// WHEN
|
||||
// starting more transfers
|
||||
registry.startNext()
|
||||
|
||||
// THEN
|
||||
// no more transfers can be started
|
||||
assertEquals(MAX_TRANSFER_THREADS, registry.running.size)
|
||||
verify(exactly = 0) { onTransferStart(any(), any()) }
|
||||
}
|
||||
}
|
||||
|
||||
class Progress : Base() {
|
||||
|
||||
var uuid: UUID = UUID.randomUUID()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
val request = Request(user, file)
|
||||
uuid = registry.add(request)
|
||||
registry.startNext()
|
||||
assertEquals(uuid, request.uuid)
|
||||
assertEquals(1, registry.running.size)
|
||||
resetMocks()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun transfer_progress_is_updated() {
|
||||
// GIVEN
|
||||
// a transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer progress is updated
|
||||
val progressHalf = 50
|
||||
registry.progress(uuid, progressHalf)
|
||||
|
||||
// THEN
|
||||
// progress is updated
|
||||
// update callback is invoked
|
||||
val transfer = mutableListOf<Transfer>()
|
||||
verify { onTransferChanged(capture(transfer)) }
|
||||
assertEquals(1, transfer.size)
|
||||
assertEquals(progressHalf, transfer.first().progress)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updates_for_non_running_transfers_are_ignored() {
|
||||
// GIVEN
|
||||
// transfer is not running
|
||||
registry.complete(uuid, true)
|
||||
assertEquals(0, registry.running.size)
|
||||
resetMocks()
|
||||
|
||||
// WHEN
|
||||
// progress for a non-running transfer is updated
|
||||
registry.progress(uuid, PROGRESS_HALF)
|
||||
|
||||
// THEN
|
||||
// progress update is ignored
|
||||
verify(exactly = 0) { onTransferChanged(any()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updates_for_non_existing_transfers_are_ignored() {
|
||||
// GIVEN
|
||||
// some transfer is running
|
||||
|
||||
// WHEN
|
||||
// progress is updated for non-existing transfer
|
||||
val nonExistingTransferId = UUID.randomUUID()
|
||||
registry.progress(nonExistingTransferId, PROGRESS_HALF)
|
||||
|
||||
// THEN
|
||||
// progress uppdate is ignored
|
||||
verify(exactly = 0) { onTransferChanged(any()) }
|
||||
}
|
||||
}
|
||||
|
||||
class Complete : Base() {
|
||||
|
||||
lateinit var uuid: UUID
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
uuid = registry.add(Request(user, file))
|
||||
registry.startNext()
|
||||
registry.progress(uuid, PROGRESS_FULL)
|
||||
resetMocks()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun complete_successful_transfer_with_updated_file() {
|
||||
// GIVEN
|
||||
// a transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer is completed
|
||||
// file has been updated
|
||||
val updatedFile = OCFile("/updated/file")
|
||||
registry.complete(uuid, true, updatedFile)
|
||||
|
||||
// THEN
|
||||
// transfer is completed successfully
|
||||
// status carries updated file
|
||||
val slot = CapturingSlot<Transfer>()
|
||||
verify { onTransferChanged(capture(slot)) }
|
||||
assertEquals(TransferState.COMPLETED, slot.captured.state)
|
||||
assertSame(slot.captured.file, updatedFile)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun complete_successful_transfer() {
|
||||
// GIVEN
|
||||
// a transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer is completed
|
||||
// file is not updated
|
||||
registry.complete(uuid = uuid, success = true, file = null)
|
||||
|
||||
// THEN
|
||||
// transfer is completed successfully
|
||||
// status carries previous file
|
||||
val slot = CapturingSlot<Transfer>()
|
||||
verify { onTransferChanged(capture(slot)) }
|
||||
assertEquals(TransferState.COMPLETED, slot.captured.state)
|
||||
assertSame(slot.captured.file, file)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun complete_failed_transfer() {
|
||||
// GIVEN
|
||||
// a transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer is failed
|
||||
registry.complete(uuid, false)
|
||||
|
||||
// THEN
|
||||
// transfer is completed successfully
|
||||
val slot = CapturingSlot<Transfer>()
|
||||
verify { onTransferChanged(capture(slot)) }
|
||||
assertEquals(TransferState.FAILED, slot.captured.state)
|
||||
}
|
||||
}
|
||||
|
||||
class GetTransfers : Base() {
|
||||
|
||||
val pendingTransferFile = OCFile("/pending")
|
||||
val runningTransferFile = OCFile("/running")
|
||||
val completedTransferFile = OCFile("/completed")
|
||||
|
||||
lateinit var pendingTransferId: UUID
|
||||
lateinit var runningTransferId: UUID
|
||||
lateinit var completedTransferId: UUID
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
completedTransferId = registry.add(Request(user, completedTransferFile))
|
||||
registry.startNext()
|
||||
registry.complete(completedTransferId, true)
|
||||
|
||||
runningTransferId = registry.add(Request(user, runningTransferFile))
|
||||
registry.startNext()
|
||||
|
||||
pendingTransferId = registry.add(Request(user, pendingTransferFile))
|
||||
resetMocks()
|
||||
|
||||
assertEquals(1, registry.pending.size)
|
||||
assertEquals(1, registry.running.size)
|
||||
assertEquals(1, registry.completed.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_path_searches_pending_queue() {
|
||||
// GIVEN
|
||||
// file transfer is pending
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(pendingTransferFile)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(pendingTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_id_searches_pending_queue() {
|
||||
// GIVEN
|
||||
// file transfer is pending
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(pendingTransferId)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(pendingTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_path_searches_running_queue() {
|
||||
// GIVEN
|
||||
// file transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(runningTransferFile)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(runningTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_id_searches_running_queue() {
|
||||
// GIVEN
|
||||
// file transfer is running
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(runningTransferId)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(runningTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_path_searches_completed_queue() {
|
||||
// GIVEN
|
||||
// file transfer is pending
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(completedTransferFile)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(completedTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun get_by_id_searches_completed_queue() {
|
||||
// GIVEN
|
||||
// file transfer is pending
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved
|
||||
val transfer = registry.getTransfer(completedTransferId)
|
||||
|
||||
// THEN
|
||||
// transfer from pending queue is returned
|
||||
assertNotNull(transfer)
|
||||
assertEquals(completedTransferId, transfer?.uuid)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun not_found_by_path() {
|
||||
// GIVEN
|
||||
// no transfer for a file
|
||||
val nonExistingTransferFile = OCFile("/non-nexisting/transfer")
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved for a file
|
||||
val transfer = registry.getTransfer(nonExistingTransferFile)
|
||||
|
||||
// THEN
|
||||
// no transfer is found
|
||||
assertNull(transfer)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun not_found_by_id() {
|
||||
// GIVEN
|
||||
// no transfer for an id
|
||||
val nonExistingId = UUID.randomUUID()
|
||||
|
||||
// WHEN
|
||||
// transfer status is retrieved for a file
|
||||
val transfer = registry.getTransfer(nonExistingId)
|
||||
|
||||
// THEN
|
||||
// no transfer is found
|
||||
assertNull(transfer)
|
||||
}
|
||||
}
|
||||
|
||||
class IsRunning : Base() {
|
||||
|
||||
@Test
|
||||
fun no_requests() {
|
||||
// WHEN
|
||||
// all queues empty
|
||||
assertEquals(0, registry.pending.size)
|
||||
assertEquals(0, registry.running.size)
|
||||
assertEquals(0, registry.completed.size)
|
||||
|
||||
// THEN
|
||||
// not running
|
||||
assertFalse(registry.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun request_pending() {
|
||||
// WHEN
|
||||
// request is enqueued
|
||||
registry.add(Request(user, OCFile("/path/alpha/1")))
|
||||
assertEquals(1, registry.pending.size)
|
||||
assertEquals(0, registry.running.size)
|
||||
assertEquals(0, registry.completed.size)
|
||||
|
||||
// THEN
|
||||
// is running
|
||||
assertTrue(registry.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun request_running() {
|
||||
// WHEN
|
||||
// request is running
|
||||
registry.add(Request(user, OCFile("/path/alpha/1")))
|
||||
registry.startNext()
|
||||
assertEquals(0, registry.pending.size)
|
||||
assertEquals(1, registry.running.size)
|
||||
assertEquals(0, registry.completed.size)
|
||||
|
||||
// THEN
|
||||
// is running
|
||||
assertTrue(registry.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun request_completed() {
|
||||
// WHEN
|
||||
// request is running
|
||||
val id = registry.add(Request(user, OCFile("/path/alpha/1")))
|
||||
registry.startNext()
|
||||
registry.complete(id, true)
|
||||
assertEquals(0, registry.pending.size)
|
||||
assertEquals(0, registry.running.size)
|
||||
assertEquals(1, registry.completed.size)
|
||||
|
||||
// THEN
|
||||
// is not running
|
||||
assertFalse(registry.isRunning)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files.downloader
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import com.nextcloud.client.account.MockUser
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class TransferManagerConnectionTest {
|
||||
|
||||
lateinit var connection: TransferManagerConnection
|
||||
|
||||
@MockK
|
||||
lateinit var context: Context
|
||||
|
||||
@MockK
|
||||
lateinit var firstDownloadListener: (Transfer) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var secondDownloadListener: (Transfer) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var firstStatusListener: (TransferManager.Status) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var secondStatusListener: (TransferManager.Status) -> Unit
|
||||
|
||||
@MockK
|
||||
lateinit var binder: DownloaderService.Binder
|
||||
|
||||
val file get() = OCFile("/path")
|
||||
val componentName = ComponentName("", DownloaderService::class.java.simpleName)
|
||||
val user = MockUser()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
connection = TransferManagerConnection(context, user)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listeners_are_set_after_connection() {
|
||||
// GIVEN
|
||||
// not connected
|
||||
// listener is added
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
connection.registerTransferListener(secondDownloadListener)
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// all listeners are passed to the service
|
||||
val listeners = mutableListOf<(Transfer) -> Unit>()
|
||||
verify { binder.registerTransferListener(capture(listeners)) }
|
||||
assertEquals(listOf(firstDownloadListener, secondDownloadListener), listeners)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listeners_are_set_immediately_when_connected() {
|
||||
// GIVEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// WHEN
|
||||
// listeners are added
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
|
||||
// THEN
|
||||
// listener is forwarded to service
|
||||
verify { binder.registerTransferListener(firstDownloadListener) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun listeners_are_removed_when_unbinding() {
|
||||
// GIVEN
|
||||
// service is bound
|
||||
// service has some listeners
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
connection.registerTransferListener(secondDownloadListener)
|
||||
|
||||
// WHEN
|
||||
// service unbound
|
||||
connection.unbind()
|
||||
|
||||
// THEN
|
||||
// listeners removed from service
|
||||
verify { binder.removeTransferListener(firstDownloadListener) }
|
||||
verify { binder.removeTransferListener(secondDownloadListener) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun missed_updates_are_delivered_on_connection() {
|
||||
// GIVEN
|
||||
// not bound
|
||||
// has listeners
|
||||
// download is scheduled and is progressing
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
connection.registerTransferListener(secondDownloadListener)
|
||||
|
||||
val request1 = Request(user, file)
|
||||
connection.enqueue(request1)
|
||||
val download1 = Transfer(request1.uuid, TransferState.RUNNING, 50, request1.file, request1)
|
||||
|
||||
val request2 = Request(user, file)
|
||||
connection.enqueue(request2)
|
||||
val download2 = Transfer(request2.uuid, TransferState.RUNNING, 50, request2.file, request1)
|
||||
|
||||
every { binder.getTransfer(request1.uuid) } returns download1
|
||||
every { binder.getTransfer(request2.uuid) } returns download2
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// listeners receive current download state for pending downloads
|
||||
val firstListenerNotifications = mutableListOf<Transfer>()
|
||||
verify { firstDownloadListener(capture(firstListenerNotifications)) }
|
||||
assertEquals(listOf(download1, download2), firstListenerNotifications)
|
||||
|
||||
val secondListenerNotifications = mutableListOf<Transfer>()
|
||||
verify { secondDownloadListener(capture(secondListenerNotifications)) }
|
||||
assertEquals(listOf(download1, download2), secondListenerNotifications)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun downloader_status_updates_are_delivered_on_connection() {
|
||||
// GIVEN
|
||||
// not bound
|
||||
// has status listeners
|
||||
val mockStatus: TransferManager.Status = mockk()
|
||||
every { binder.status } returns mockStatus
|
||||
connection.registerStatusListener(firstStatusListener)
|
||||
connection.registerStatusListener(secondStatusListener)
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// downloader status is delivered
|
||||
verify { firstStatusListener(mockStatus) }
|
||||
verify { secondStatusListener(mockStatus) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun downloader_status_not_requested_if_no_listeners() {
|
||||
// GIVEN
|
||||
// not bound
|
||||
// no status listeners
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// downloader status is not requested
|
||||
verify(exactly = 0) { binder.status }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun not_running_if_not_connected() {
|
||||
// GIVEN
|
||||
// downloader is running
|
||||
// connection not bound
|
||||
every { binder.isRunning } returns true
|
||||
|
||||
// THEN
|
||||
// not running
|
||||
assertFalse(connection.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun is_running_from_binder_if_connected() {
|
||||
// GIVEN
|
||||
// service bound
|
||||
every { binder.isRunning } returns true
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// WHEN
|
||||
// is runnign flag accessed
|
||||
val isRunning = connection.isRunning
|
||||
|
||||
// THEN
|
||||
// call delegated to binder
|
||||
assertTrue(isRunning)
|
||||
verify(exactly = 1) { binder.isRunning }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun missed_updates_not_tracked_before_listeners_registered() {
|
||||
// GIVEN
|
||||
// not bound
|
||||
// some downloads requested without listener
|
||||
val request = Request(user, file)
|
||||
connection.enqueue(request)
|
||||
val download = Transfer(request.uuid, TransferState.RUNNING, 50, request.file, request)
|
||||
connection.registerTransferListener(firstDownloadListener)
|
||||
every { binder.getTransfer(request.uuid) } returns download
|
||||
|
||||
// WHEN
|
||||
// service is bound
|
||||
connection.onServiceConnected(componentName, binder)
|
||||
|
||||
// THEN
|
||||
// missed updates not redelivered
|
||||
verify(exactly = 0) { firstDownloadListener(any()) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
/**
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.files.downloader
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.core.ManualAsyncRunner
|
||||
import com.nextcloud.client.core.OnProgressCallback
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.OwnCloudClient
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.mockk
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.Suite
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
@RunWith(Suite::class)
|
||||
@Suite.SuiteClasses(
|
||||
TransferManagerTest.Enqueue::class,
|
||||
TransferManagerTest.TransferStatusUpdates::class
|
||||
)
|
||||
class TransferManagerTest {
|
||||
|
||||
abstract class Base {
|
||||
|
||||
companion object {
|
||||
const val MAX_TRANSFER_THREADS = 4
|
||||
}
|
||||
|
||||
@MockK
|
||||
lateinit var user: User
|
||||
|
||||
@MockK
|
||||
lateinit var client: OwnCloudClient
|
||||
|
||||
@MockK
|
||||
lateinit var mockTaskFactory: DownloadTask.Factory
|
||||
|
||||
/**
|
||||
* All task mock functions created during test run are
|
||||
* stored here.
|
||||
*/
|
||||
lateinit var downloadTaskMocks: MutableList<DownloadTask>
|
||||
lateinit var runner: ManualAsyncRunner
|
||||
lateinit var transferManager: TransferManagerImpl
|
||||
|
||||
/**
|
||||
* Response value for all download tasks
|
||||
*/
|
||||
var downloadTaskResult: Boolean = true
|
||||
|
||||
/**
|
||||
* Progress values posted by all download task mocks before
|
||||
* returning result value
|
||||
*/
|
||||
var taskProgress = listOf<Int>()
|
||||
|
||||
@Before
|
||||
fun setUpBase() {
|
||||
MockKAnnotations.init(this, relaxed = true)
|
||||
MockitoAnnotations.initMocks(this)
|
||||
downloadTaskMocks = mutableListOf()
|
||||
runner = ManualAsyncRunner()
|
||||
transferManager = TransferManagerImpl(
|
||||
runner = runner,
|
||||
taskFactory = mockTaskFactory,
|
||||
threads = MAX_TRANSFER_THREADS
|
||||
)
|
||||
downloadTaskResult = true
|
||||
every { mockTaskFactory.create() } answers { createMockTask() }
|
||||
}
|
||||
|
||||
private fun createMockTask(): DownloadTask {
|
||||
val task = mockk<DownloadTask>()
|
||||
every { task.download(any(), any(), any()) } answers {
|
||||
taskProgress.forEach {
|
||||
arg<OnProgressCallback<Int>>(1).invoke(it)
|
||||
}
|
||||
val request = arg<Request>(0)
|
||||
DownloadTask.Result(request.file, downloadTaskResult)
|
||||
}
|
||||
downloadTaskMocks.add(task)
|
||||
return task
|
||||
}
|
||||
}
|
||||
|
||||
class Enqueue : Base() {
|
||||
|
||||
@Test
|
||||
fun enqueued_download_is_started_immediately() {
|
||||
// GIVEN
|
||||
// downloader has no running downloads
|
||||
|
||||
// WHEN
|
||||
// download is enqueued
|
||||
val file = OCFile("/path")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
|
||||
// THEN
|
||||
// download is started immediately
|
||||
val download = transferManager.getTransfer(request.uuid)
|
||||
assertEquals(TransferState.RUNNING, download?.state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun enqueued_downloads_are_pending_if_running_queue_is_full() {
|
||||
// GIVEN
|
||||
// downloader is downloading max simultaneous files
|
||||
for (i in 0 until MAX_TRANSFER_THREADS) {
|
||||
val file = OCFile("/running/download/path/$i")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
val runningDownload = transferManager.getTransfer(request.uuid)
|
||||
assertEquals(runningDownload?.state, TransferState.RUNNING)
|
||||
}
|
||||
|
||||
// WHEN
|
||||
// another download is enqueued
|
||||
val file = OCFile("/path")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
|
||||
// THEN
|
||||
// download is pending
|
||||
val download = transferManager.getTransfer(request.uuid)
|
||||
assertEquals(TransferState.PENDING, download?.state)
|
||||
}
|
||||
}
|
||||
|
||||
class TransferStatusUpdates : Base() {
|
||||
|
||||
@get:Rule
|
||||
val rule = InstantTaskExecutorRule()
|
||||
|
||||
val file = OCFile("/path")
|
||||
|
||||
@Test
|
||||
fun download_task_completes() {
|
||||
// GIVEN
|
||||
// download is running
|
||||
// download is being observed
|
||||
val downloadUpdates = mutableListOf<Transfer>()
|
||||
transferManager.registerTransferListener { downloadUpdates.add(it) }
|
||||
transferManager.enqueue(Request(user, file))
|
||||
|
||||
// WHEN
|
||||
// download task finishes successfully
|
||||
runner.runOne()
|
||||
|
||||
// THEN
|
||||
// listener is notified about status change
|
||||
assertEquals(TransferState.RUNNING, downloadUpdates[0].state)
|
||||
assertEquals(TransferState.COMPLETED, downloadUpdates[1].state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun download_task_fails() {
|
||||
// GIVEN
|
||||
// download is running
|
||||
// download is being observed
|
||||
val downloadUpdates = mutableListOf<Transfer>()
|
||||
transferManager.registerTransferListener { downloadUpdates.add(it) }
|
||||
transferManager.enqueue(Request(user, file))
|
||||
|
||||
// WHEN
|
||||
// download task fails
|
||||
downloadTaskResult = false
|
||||
runner.runOne()
|
||||
|
||||
// THEN
|
||||
// listener is notified about status change
|
||||
assertEquals(TransferState.RUNNING, downloadUpdates[0].state)
|
||||
assertEquals(TransferState.FAILED, downloadUpdates[1].state)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun download_progress_is_updated() {
|
||||
// GIVEN
|
||||
// download is running
|
||||
val downloadUpdates = mutableListOf<Transfer>()
|
||||
transferManager.registerTransferListener { downloadUpdates.add(it) }
|
||||
transferManager.enqueue(Request(user, file))
|
||||
|
||||
// WHEN
|
||||
// download progress updated 4 times before completion
|
||||
taskProgress = listOf(25, 50, 75, 100)
|
||||
runner.runOne()
|
||||
|
||||
// THEN
|
||||
// listener receives 6 status updates
|
||||
// transition to running
|
||||
// 4 progress updates
|
||||
// completion
|
||||
assertEquals(6, downloadUpdates.size)
|
||||
if (downloadUpdates.size >= 6) {
|
||||
assertEquals(TransferState.RUNNING, downloadUpdates[0].state)
|
||||
assertEquals(25, downloadUpdates[1].progress)
|
||||
assertEquals(50, downloadUpdates[2].progress)
|
||||
assertEquals(75, downloadUpdates[3].progress)
|
||||
assertEquals(100, downloadUpdates[4].progress)
|
||||
assertEquals(TransferState.COMPLETED, downloadUpdates[5].state)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun download_task_is_created_only_for_running_downloads() {
|
||||
// WHEN
|
||||
// multiple downloads are enqueued
|
||||
for (i in 0 until MAX_TRANSFER_THREADS * 2) {
|
||||
transferManager.enqueue(Request(user, file))
|
||||
}
|
||||
|
||||
// THEN
|
||||
// download task is created only for running downloads
|
||||
assertEquals(MAX_TRANSFER_THREADS, downloadTaskMocks.size)
|
||||
}
|
||||
}
|
||||
|
||||
class RunningStatusUpdates : Base() {
|
||||
|
||||
@get:Rule
|
||||
val rule = InstantTaskExecutorRule()
|
||||
|
||||
@Test
|
||||
fun is_running_flag_on_enqueue() {
|
||||
// WHEN
|
||||
// download is enqueued
|
||||
val file = OCFile("/path/to/file")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
|
||||
// THEN
|
||||
// is running changes
|
||||
assertTrue(transferManager.isRunning)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun is_running_flag_on_completion() {
|
||||
// GIVEN
|
||||
// a download is in progress
|
||||
val file = OCFile("/path/to/file")
|
||||
val request = Request(user, file)
|
||||
transferManager.enqueue(request)
|
||||
assertTrue(transferManager.isRunning)
|
||||
|
||||
// WHEN
|
||||
// download is processed
|
||||
runner.runOne()
|
||||
|
||||
// THEN
|
||||
// downloader is not running
|
||||
assertFalse(transferManager.isRunning)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.integration.deck
|
||||
package com.nextcloud.client.integrations.deck
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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.nextcloud.client.jobs
|
||||
|
||||
import android.Manifest
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import androidx.work.WorkManager
|
||||
import com.nextcloud.client.core.ClockImpl
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.operations.DownloadFileOperation
|
||||
import ezvcard.Ezvcard
|
||||
import ezvcard.VCard
|
||||
import junit.framework.Assert.assertEquals
|
||||
import junit.framework.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class ContactsBackupIT : AbstractOnServerIT() {
|
||||
val workmanager = WorkManager.getInstance(targetContext)
|
||||
private val backgroundJobManager = BackgroundJobManagerImpl(workmanager, ClockImpl())
|
||||
|
||||
@get:Rule
|
||||
val writeContactsRule = GrantPermissionRule.grant(Manifest.permission.WRITE_CONTACTS)
|
||||
|
||||
@get:Rule
|
||||
val readContactsRule = GrantPermissionRule.grant(Manifest.permission.READ_CONTACTS)
|
||||
|
||||
private val vcard: String = "vcard.vcf"
|
||||
|
||||
@Test
|
||||
fun importExport() {
|
||||
val intArray = IntArray(1)
|
||||
intArray[0] = 0
|
||||
|
||||
// import file to local contacts
|
||||
backgroundJobManager.startImmediateContactsImport(null, null, getFile(vcard).absolutePath, intArray)
|
||||
|
||||
shortSleep()
|
||||
|
||||
// export contact
|
||||
backgroundJobManager.startImmediateContactsBackup(user)
|
||||
|
||||
longSleep()
|
||||
|
||||
val backupFolder: String = targetContext.resources.getString(R.string.contacts_backup_folder) +
|
||||
OCFile.PATH_SEPARATOR
|
||||
|
||||
refreshFolder("/")
|
||||
longSleep()
|
||||
|
||||
refreshFolder(backupFolder)
|
||||
longSleep()
|
||||
|
||||
val backupOCFile = storageManager.getFolderContent(
|
||||
storageManager.getFileByDecryptedRemotePath(backupFolder),
|
||||
false
|
||||
)[0]
|
||||
|
||||
assertTrue(DownloadFileOperation(account, backupOCFile, AbstractIT.targetContext).execute(client).isSuccess)
|
||||
|
||||
val backupFile = File(backupOCFile.storagePath)
|
||||
|
||||
// verify same
|
||||
val originalCards: ArrayList<VCard> = ArrayList()
|
||||
originalCards.addAll(Ezvcard.parse(getFile(vcard)).all())
|
||||
|
||||
val backupCards: ArrayList<VCard> = ArrayList()
|
||||
backupCards.addAll(Ezvcard.parse(backupFile).all())
|
||||
|
||||
assertEquals(originalCards.size, backupCards.size)
|
||||
assertEquals(originalCards[0].formattedName.toString(), backupCards[0].formattedName.toString())
|
||||
}
|
||||
}
|
||||
@@ -243,10 +243,7 @@ class MigrationsManagerTest {
|
||||
// pending migrations
|
||||
// mandatory migrations are passing
|
||||
// one migration is optional and fails
|
||||
assertEquals("Fixture should provide 1 optional, failing migration",
|
||||
1,
|
||||
migrations.count { !it.mandatory }
|
||||
)
|
||||
assertEquals("Fixture should provide 1 optional, failing migration", 1, migrations.count { !it.mandatory })
|
||||
val optionalFailingMigration = migrations.first { !it.mandatory }
|
||||
whenever(optionalFailingMigration.run()).thenThrow(RuntimeException())
|
||||
|
||||
|
||||
@@ -7,17 +7,22 @@ import android.accounts.OperationCanceledException;
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.testing.screenshot.Screenshot;
|
||||
import com.nextcloud.client.RetryTestRule;
|
||||
import com.facebook.testing.screenshot.internal.TestNameDetector;
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.client.device.BatteryStatus;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.network.Connectivity;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.preferences.AppPreferencesImpl;
|
||||
import com.nextcloud.client.preferences.DarkMode;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
@@ -27,24 +32,15 @@ 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.e2ee.ToggleEncryptionRemoteOperation;
|
||||
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.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
@@ -52,6 +48,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.espresso.contrib.DrawerActions;
|
||||
import androidx.test.espresso.intent.rule.IntentsTestRule;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
@@ -69,13 +66,16 @@ import static org.junit.Assert.assertTrue;
|
||||
*/
|
||||
|
||||
public abstract class AbstractIT {
|
||||
@Rule public RetryTestRule retryTestRule = new RetryTestRule();
|
||||
//@Rule public RetryTestRule retryTestRule = new RetryTestRule();
|
||||
|
||||
protected static OwnCloudClient client;
|
||||
protected static Account account;
|
||||
protected static User user;
|
||||
protected static Context targetContext;
|
||||
protected static String DARK_MODE = "";
|
||||
protected static String COLOR = "";
|
||||
|
||||
private Activity currentActivity;
|
||||
protected Activity currentActivity;
|
||||
|
||||
protected FileDataStorageManager fileDataStorageManager =
|
||||
new FileDataStorageManager(account, targetContext.getContentResolver());
|
||||
@@ -83,39 +83,32 @@ public abstract class AbstractIT {
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
try {
|
||||
// clean up
|
||||
targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
|
||||
AccountManager platformAccountManager = AccountManager.get(targetContext);
|
||||
|
||||
Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"));
|
||||
String loginName = arguments.getString("TEST_SERVER_USERNAME");
|
||||
String password = arguments.getString("TEST_SERVER_PASSWORD");
|
||||
|
||||
Account temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
if (!accountManager.exists(temp)) {
|
||||
AccountManager platformAccountManager = AccountManager.get(targetContext);
|
||||
platformAccountManager.addAccountExplicitly(temp, password, null);
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
Integer.toString(UserAccountManager.ACCOUNT_VERSION));
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
|
||||
for (Account account : platformAccountManager.getAccounts()) {
|
||||
if (account.type.equalsIgnoreCase("nextcloud")) {
|
||||
platformAccountManager.removeAccountExplicitly(account);
|
||||
}
|
||||
}
|
||||
|
||||
Account temp = new Account("test@https://server.com", MainApp.getAccountType(targetContext));
|
||||
platformAccountManager.addAccountExplicitly(temp, "password", null);
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, "https://server.com");
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, "test");
|
||||
|
||||
final UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
account = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
|
||||
account = userAccountManager.getAccountByName("test@https://server.com");
|
||||
|
||||
if (account == null) {
|
||||
throw new ActivityNotFoundException();
|
||||
}
|
||||
|
||||
Optional<User> optionalUser = userAccountManager.getUser(account.name);
|
||||
user = optionalUser.orElseThrow(IllegalAccessError::new);
|
||||
|
||||
client = OwnCloudClientFactory.createOwnCloudClient(account, targetContext);
|
||||
|
||||
createDummyFiles();
|
||||
|
||||
waitForServer(client, baseUrl);
|
||||
|
||||
deleteAllFiles(); // makes sure that no file/folder is in root
|
||||
} catch (OperationCanceledException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AuthenticatorException e) {
|
||||
@@ -125,37 +118,64 @@ public abstract class AbstractIT {
|
||||
} catch (AccountUtils.AccountNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
deleteAllFiles();
|
||||
}
|
||||
Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
|
||||
|
||||
public static void deleteAllFiles() {
|
||||
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
// color
|
||||
String colorParameter = arguments.getString("COLOR");
|
||||
if (!TextUtils.isEmpty(colorParameter)) {
|
||||
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(account,
|
||||
targetContext.getContentResolver());
|
||||
|
||||
for (Object object : result.getData()) {
|
||||
RemoteFile remoteFile = (RemoteFile) object;
|
||||
String colorHex = null;
|
||||
COLOR = colorParameter;
|
||||
switch (colorParameter) {
|
||||
case "red":
|
||||
colorHex = "#7c0000";
|
||||
break;
|
||||
|
||||
if (!remoteFile.getRemotePath().equals("/")) {
|
||||
if (remoteFile.isEncrypted()) {
|
||||
assertTrue(new ToggleEncryptionRemoteOperation(remoteFile.getLocalId(),
|
||||
remoteFile.getRemotePath(),
|
||||
false)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
}
|
||||
case "green":
|
||||
colorHex = "#00ff00";
|
||||
break;
|
||||
|
||||
assertTrue(new RemoveFileRemoteOperation(remoteFile.getRemotePath())
|
||||
.execute(client)
|
||||
.isSuccess()
|
||||
);
|
||||
case "white":
|
||||
colorHex = "#ffffff";
|
||||
break;
|
||||
|
||||
case "black":
|
||||
colorHex = "#000000";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (colorHex != null) {
|
||||
OCCapability capability = fileDataStorageManager.getCapability(account.name);
|
||||
capability.setServerColor(colorHex);
|
||||
fileDataStorageManager.saveCapabilities(capability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dark / light
|
||||
String darkModeParameter = arguments.getString("DARKMODE");
|
||||
|
||||
if (darkModeParameter != null) {
|
||||
if (darkModeParameter.equalsIgnoreCase("dark")) {
|
||||
DARK_MODE = "dark";
|
||||
AppPreferencesImpl.fromContext(targetContext).setDarkThemeMode(DarkMode.DARK);
|
||||
MainApp.setAppTheme(DarkMode.DARK);
|
||||
} else {
|
||||
DARK_MODE = "light";
|
||||
}
|
||||
}
|
||||
|
||||
if (DARK_MODE.equalsIgnoreCase("light") && COLOR.equalsIgnoreCase("blue")) {
|
||||
// use already existing names
|
||||
DARK_MODE = "";
|
||||
COLOR = "";
|
||||
}
|
||||
}
|
||||
|
||||
protected FileDataStorageManager getStorageManager() {
|
||||
return fileDataStorageManager;
|
||||
@@ -165,16 +185,48 @@ public abstract class AbstractIT {
|
||||
return AccountManager.get(targetContext).getAccounts();
|
||||
}
|
||||
|
||||
private static void createDummyFiles() throws IOException {
|
||||
new File(FileStorageUtils.getSavePath(account.name)).mkdirs();
|
||||
protected static void createDummyFiles() throws IOException {
|
||||
File tempPath = new File(FileStorageUtils.getTemporalPath(account.name));
|
||||
if (!tempPath.exists()) {
|
||||
assertTrue(tempPath.mkdirs());
|
||||
}
|
||||
|
||||
assertTrue(tempPath.exists());
|
||||
|
||||
createFile("empty.txt", 0);
|
||||
createFile("nonEmpty.txt", 100);
|
||||
createFile("chunkedFile.txt", 500000);
|
||||
}
|
||||
|
||||
public static void createFile(String name, int iteration) throws IOException {
|
||||
File file = new File(FileStorageUtils.getSavePath(account.name) + File.separator + name);
|
||||
protected static File getDummyFile(String name) throws IOException {
|
||||
File file = new File(FileStorageUtils.getTemporalPath(account.name) + File.pathSeparator + name);
|
||||
|
||||
if (file.exists()) {
|
||||
return file;
|
||||
} else {
|
||||
switch (name) {
|
||||
case "empty.txt":
|
||||
return createFile("empty.txt", 0);
|
||||
|
||||
case "nonEmpty.txt":
|
||||
return createFile("nonEmpty.txt", 100);
|
||||
|
||||
case "chunkedFile.txt":
|
||||
return createFile("chunkedFile.txt", 500000);
|
||||
|
||||
default:
|
||||
return createFile(name, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static File createFile(String name, int iteration) throws IOException {
|
||||
File tempPath = new File(FileStorageUtils.getTemporalPath(account.name));
|
||||
if (!tempPath.exists()) {
|
||||
assertTrue(tempPath.mkdirs());
|
||||
}
|
||||
|
||||
File file = new File(FileStorageUtils.getTemporalPath(account.name) + File.separator + name);
|
||||
file.createNewFile();
|
||||
|
||||
FileWriter writer = new FileWriter(file);
|
||||
@@ -184,28 +236,8 @@ public abstract class AbstractIT {
|
||||
}
|
||||
writer.flush();
|
||||
writer.close();
|
||||
}
|
||||
|
||||
private static void waitForServer(OwnCloudClient client, Uri baseUrl) {
|
||||
GetMethod get = new GetMethod(baseUrl + "/status.php");
|
||||
|
||||
try {
|
||||
int i = 0;
|
||||
while (client.executeMethod(get) != HttpStatus.SC_OK && i < 3) {
|
||||
System.out.println("wait…");
|
||||
Thread.sleep(60 * 1000);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == 3) {
|
||||
Assert.fail("Server not ready!");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
protected File getFile(String filename) throws IOException {
|
||||
@@ -229,7 +261,7 @@ public abstract class AbstractIT {
|
||||
|
||||
waitForIdleSync();
|
||||
|
||||
Screenshot.snapActivity(sut).record();
|
||||
screenshot(sut);
|
||||
}
|
||||
|
||||
protected Activity getCurrentActivity() {
|
||||
@@ -263,7 +295,7 @@ public abstract class AbstractIT {
|
||||
}
|
||||
|
||||
public OCFile createFolder(String remotePath) {
|
||||
TestCase.assertTrue(new CreateFolderOperation(remotePath, account, targetContext)
|
||||
TestCase.assertTrue(new CreateFolderOperation(remotePath, user, targetContext)
|
||||
.execute(client, getStorageManager())
|
||||
.isSuccess());
|
||||
|
||||
@@ -284,7 +316,7 @@ public abstract class AbstractIT {
|
||||
};
|
||||
|
||||
PowerManagementService powerManagementServiceMock = new PowerManagementService() {
|
||||
@NotNull
|
||||
@NonNull
|
||||
@Override
|
||||
public BatteryStatus getBattery() {
|
||||
return new BatteryStatus();
|
||||
@@ -309,7 +341,7 @@ public abstract class AbstractIT {
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
account,
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
@@ -327,4 +359,26 @@ public abstract class AbstractIT {
|
||||
RemoteOperationResult result = newUpload.execute(client, getStorageManager());
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
}
|
||||
|
||||
protected void screenshot(View view) {
|
||||
Screenshot.snap(view).setName(createName()).record();
|
||||
}
|
||||
|
||||
protected void screenshot(Activity sut) {
|
||||
Screenshot.snapActivity(sut).setName(createName()).record();
|
||||
}
|
||||
|
||||
private String createName() {
|
||||
String name = TestNameDetector.getTestClass() + "_" + TestNameDetector.getTestName();
|
||||
|
||||
if (!DARK_MODE.isEmpty()) {
|
||||
name = name + "_" + DARK_MODE;
|
||||
}
|
||||
|
||||
if (!COLOR.isEmpty()) {
|
||||
name = name + "_" + COLOR;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.nextcloud.client.account.User;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl;
|
||||
import com.nextcloud.client.device.BatteryStatus;
|
||||
import com.nextcloud.client.device.PowerManagementService;
|
||||
import com.nextcloud.client.network.Connectivity;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.java.util.Optional;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.datamodel.UploadsStorageManager;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.files.services.FileUploader;
|
||||
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.e2ee.ToggleEncryptionRemoteOperation;
|
||||
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.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.operations.UploadFileOperation;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
|
||||
/**
|
||||
* Common base for all integration tests
|
||||
*/
|
||||
|
||||
public abstract class AbstractOnServerIT extends AbstractIT {
|
||||
@BeforeClass
|
||||
public static void beforeAll() {
|
||||
try {
|
||||
// clean up
|
||||
targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
AccountManager platformAccountManager = AccountManager.get(targetContext);
|
||||
|
||||
for (Account account : platformAccountManager.getAccounts()) {
|
||||
if (account.type.equalsIgnoreCase("nextcloud")) {
|
||||
platformAccountManager.removeAccountExplicitly(account);
|
||||
}
|
||||
}
|
||||
|
||||
Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments();
|
||||
|
||||
Uri baseUrl = Uri.parse(arguments.getString("TEST_SERVER_URL"));
|
||||
String loginName = arguments.getString("TEST_SERVER_USERNAME");
|
||||
String password = arguments.getString("TEST_SERVER_PASSWORD");
|
||||
|
||||
Account temp = new Account(loginName + "@" + baseUrl, MainApp.getAccountType(targetContext));
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
if (!accountManager.exists(temp)) {
|
||||
platformAccountManager.addAccountExplicitly(temp, password, null);
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_ACCOUNT_VERSION,
|
||||
Integer.toString(UserAccountManager.ACCOUNT_VERSION));
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_VERSION, "14.0.0.0");
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_OC_BASE_URL, baseUrl.toString());
|
||||
platformAccountManager.setUserData(temp, AccountUtils.Constants.KEY_USER_ID, loginName); // same as userId
|
||||
}
|
||||
|
||||
final UserAccountManager userAccountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
account = userAccountManager.getAccountByName(loginName + "@" + baseUrl);
|
||||
|
||||
if (account == null) {
|
||||
throw new ActivityNotFoundException();
|
||||
}
|
||||
|
||||
Optional<User> optionalUser = userAccountManager.getUser(account.name);
|
||||
user = optionalUser.orElseThrow(IllegalAccessError::new);
|
||||
|
||||
client = OwnCloudClientFactory.createOwnCloudClient(account, targetContext);
|
||||
|
||||
createDummyFiles();
|
||||
|
||||
waitForServer(client, baseUrl);
|
||||
|
||||
deleteAllFiles(); // makes sure that no file/folder is in root
|
||||
|
||||
} catch (OperationCanceledException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AuthenticatorException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (AccountUtils.AccountNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
deleteAllFiles();
|
||||
}
|
||||
|
||||
public static void deleteAllFiles() {
|
||||
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
|
||||
for (Object object : result.getData()) {
|
||||
RemoteFile remoteFile = (RemoteFile) object;
|
||||
|
||||
if (!remoteFile.getRemotePath().equals("/")) {
|
||||
if (remoteFile.isEncrypted()) {
|
||||
assertTrue(new ToggleEncryptionRemoteOperation(remoteFile.getLocalId(),
|
||||
remoteFile.getRemotePath(),
|
||||
false)
|
||||
.execute(client)
|
||||
.isSuccess());
|
||||
}
|
||||
|
||||
assertTrue(new RemoveFileRemoteOperation(remoteFile.getRemotePath())
|
||||
.execute(client)
|
||||
.isSuccess()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void waitForServer(OwnCloudClient client, Uri baseUrl) {
|
||||
GetMethod get = new GetMethod(baseUrl + "/status.php");
|
||||
|
||||
try {
|
||||
int i = 0;
|
||||
while (client.executeMethod(get) != HttpStatus.SC_OK && i < 3) {
|
||||
System.out.println("wait…");
|
||||
Thread.sleep(60 * 1000);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == 3) {
|
||||
Assert.fail("Server not ready!");
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void uploadOCUpload(OCUpload ocUpload) {
|
||||
uploadOCUpload(ocUpload, FileUploader.LOCAL_BEHAVIOUR_COPY);
|
||||
}
|
||||
|
||||
public void uploadOCUpload(OCUpload ocUpload, int localBehaviour) {
|
||||
ConnectivityService connectivityServiceMock = new ConnectivityService() {
|
||||
@Override
|
||||
public boolean isInternetWalled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connectivity getConnectivity() {
|
||||
return Connectivity.CONNECTED_WIFI;
|
||||
}
|
||||
};
|
||||
|
||||
PowerManagementService powerManagementServiceMock = new PowerManagementService() {
|
||||
@NonNull
|
||||
@Override
|
||||
public BatteryStatus getBattery() {
|
||||
return new BatteryStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPowerSavingExclusionAvailable() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
UserAccountManager accountManager = UserAccountManagerImpl.fromContext(targetContext);
|
||||
UploadsStorageManager uploadsStorageManager = new UploadsStorageManager(accountManager,
|
||||
targetContext.getContentResolver());
|
||||
|
||||
UploadFileOperation newUpload = new UploadFileOperation(
|
||||
uploadsStorageManager,
|
||||
connectivityServiceMock,
|
||||
powerManagementServiceMock,
|
||||
user,
|
||||
null,
|
||||
ocUpload,
|
||||
FileUploader.NameCollisionPolicy.DEFAULT,
|
||||
localBehaviour,
|
||||
targetContext,
|
||||
false,
|
||||
false
|
||||
);
|
||||
newUpload.addRenameUploadListener(() -> {
|
||||
// dummy
|
||||
});
|
||||
|
||||
newUpload.setRemoteFolderToBeCreated();
|
||||
|
||||
RemoteOperationResult result = newUpload.execute(client, getStorageManager());
|
||||
assertTrue(result.getLogMessage(), result.isSuccess());
|
||||
|
||||
OCFile parentFolder = getStorageManager()
|
||||
.getFileByEncryptedRemotePath(new File(ocUpload.getRemotePath()).getParent() + "/");
|
||||
String uploadedFileName = new File(ocUpload.getRemotePath()).getName();
|
||||
OCFile uploadedFile = getStorageManager().
|
||||
getFileByDecryptedRemotePath(parentFolder.getDecryptedRemotePath() + uploadedFileName);
|
||||
|
||||
assertNotNull(uploadedFile.getRemoteId());
|
||||
|
||||
if (localBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY ||
|
||||
localBehaviour == FileUploader.LOCAL_BEHAVIOUR_MOVE) {
|
||||
assertTrue(new File(uploadedFile.getStoragePath()).exists());
|
||||
}
|
||||
}
|
||||
|
||||
protected void refreshFolder(String path) {
|
||||
assertTrue(new RefreshFolderOperation(getStorageManager().getFileByEncryptedRemotePath(path),
|
||||
System.currentTimeMillis(),
|
||||
false,
|
||||
false,
|
||||
getStorageManager(),
|
||||
account,
|
||||
targetContext
|
||||
).execute(client).isSuccess());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Nextcloud Android client application
|
||||
*
|
||||
* @author Tobias Kaminsky
|
||||
* Copyright (C) 2020 Tobias Kaminsky
|
||||
* Copyright (C) 2020 Nextcloud GmbH
|
||||
* Copyright (C) 2020 Chris Narkiewicz <[email protected]>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.owncloud.android;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.OCUpload;
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||
import com.owncloud.android.operations.DownloadFileOperation;
|
||||
import com.owncloud.android.operations.RefreshFolderOperation;
|
||||
import com.owncloud.android.operations.RemoveFileOperation;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Tests related to file uploads
|
||||
*/
|
||||
|
||||
public class DownloadIT extends AbstractOnServerIT {
|
||||
private static final String FOLDER = "/testUpload/";
|
||||
|
||||
@After
|
||||
public void after() {
|
||||
RemoteOperationResult result = new RefreshFolderOperation(getStorageManager().getFileByPath("/"),
|
||||
System.currentTimeMillis() / 1000L,
|
||||
false,
|
||||
true,
|
||||
getStorageManager(),
|
||||
account,
|
||||
targetContext)
|
||||
.execute(client);
|
||||
|
||||
// cleanup only if folder exists
|
||||
if (result.isSuccess() && getStorageManager().getFileByDecryptedRemotePath(FOLDER) != null) {
|
||||
new RemoveFileOperation(getStorageManager().getFileByDecryptedRemotePath(FOLDER),
|
||||
false,
|
||||
account,
|
||||
false,
|
||||
targetContext)
|
||||
.execute(client, getStorageManager());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyDownload() {
|
||||
OCUpload ocUpload = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload);
|
||||
|
||||
OCUpload ocUpload2 = new OCUpload(FileStorageUtils.getTemporalPath(account.name) + "/nonEmpty.txt",
|
||||
FOLDER + "nonEmpty2.txt",
|
||||
account.name);
|
||||
|
||||
uploadOCUpload(ocUpload2);
|
||||
|
||||
refreshFolder("/");
|
||||
refreshFolder(FOLDER);
|
||||
|
||||
OCFile file1 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt");
|
||||
OCFile file2 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty2.txt");
|
||||
verifyDownload(file1, file2);
|
||||
|
||||
assertTrue(new DownloadFileOperation(account, file1, targetContext).execute(client).isSuccess());
|
||||
assertTrue(new DownloadFileOperation(account, file2, targetContext).execute(client).isSuccess());
|
||||
|
||||
refreshFolder(FOLDER);
|
||||
|
||||
file1 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty.txt");
|
||||
file2 = fileDataStorageManager.getFileByDecryptedRemotePath(FOLDER + "nonEmpty2.txt");
|
||||
|
||||
verifyDownload(file1, file2);
|
||||
}
|
||||
|
||||
private void verifyDownload(OCFile file1, OCFile file2) {
|
||||
assertNotNull(file1);
|
||||
assertNotNull(file2);
|
||||
assertNotSame(file1.getStoragePath(), file2.getStoragePath());
|
||||
|
||||
assertTrue(new File(file1.getStoragePath()).exists());
|
||||
assertTrue(new File(file2.getStoragePath()).exists());
|
||||
|
||||
// test against hardcoded path to make sure that it is correct
|
||||
assertEquals("/storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/" +
|
||||
Uri.encode(account.name, "@") + "/testUpload/nonEmpty.txt",
|
||||
file1.getStoragePath());
|
||||
assertEquals("/storage/emulated/0/Android/media/com.nextcloud.client/nextcloud/" +
|
||||
Uri.encode(account.name, "@") + "/testUpload/nonEmpty2.txt",
|
||||
file2.getStoragePath());
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import static org.junit.Assert.assertNull;
|
||||
* Tests related to file operations
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FileIT extends AbstractIT {
|
||||
public class FileIT extends AbstractOnServerIT {
|
||||
|
||||
@Test
|
||||
public void testCreateFolder() {
|
||||
@@ -27,7 +27,7 @@ public class FileIT extends AbstractIT {
|
||||
// folder does not exist yet
|
||||
assertNull(getStorageManager().getFileByPath(path));
|
||||
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, account, targetContext);
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, user, targetContext);
|
||||
RemoteOperationResult result = syncOp.execute(client, getStorageManager());
|
||||
|
||||
assertTrue(result.toString(), result.isSuccess());
|
||||
@@ -46,7 +46,7 @@ public class FileIT extends AbstractIT {
|
||||
// folder does not exist yet
|
||||
assertNull(getStorageManager().getFileByPath(path));
|
||||
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, account, targetContext);
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, user, targetContext);
|
||||
RemoteOperationResult result = syncOp.execute(client, getStorageManager());
|
||||
assertTrue(result.toString(), result.isSuccess());
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.logger.Logger;
|
||||
import com.nextcloud.client.network.ClientFactory;
|
||||
import com.nextcloud.client.network.ClientFactoryImpl;
|
||||
import com.nextcloud.client.network.ConnectivityService;
|
||||
import com.nextcloud.client.network.ConnectivityServiceImpl;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class MockedNetworkModule {
|
||||
|
||||
@Provides
|
||||
ConnectivityService connectivityService(ConnectivityManager connectivityManager,
|
||||
UserAccountManager accountManager,
|
||||
ClientFactory clientFactory,
|
||||
Logger logger) {
|
||||
return new ConnectivityServiceImpl(connectivityManager,
|
||||
accountManager,
|
||||
clientFactory,
|
||||
new ConnectivityServiceImpl.GetRequestBuilder(),
|
||||
logger);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ClientFactory clientFactory(Context context) {
|
||||
Log_OC.d("MOCK", "c");
|
||||
return new ClientFactoryImpl(context, new MockInterceptor());
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ConnectivityManager connectivityManager(Context context) {
|
||||
return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.owncloud.android.operations.CreateFolderOperation;
|
||||
import com.owncloud.android.operations.common.SyncOperation;
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||
import com.owncloud.android.ui.activity.SettingsActivity;
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -31,7 +32,6 @@ import static androidx.test.espresso.Espresso.onData;
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.Espresso.pressBack;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.action.ViewActions.swipeUp;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.core.AnyOf.anyOf;
|
||||
@@ -39,7 +39,7 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(JUnit4.class)
|
||||
public class ScreenshotsIT extends AbstractIT {
|
||||
public class ScreenshotsIT extends AbstractOnServerIT {
|
||||
@ClassRule
|
||||
public static final LocaleTestRule localeTestRule = new LocaleTestRule();
|
||||
|
||||
@@ -72,8 +72,8 @@ public class ScreenshotsIT extends AbstractIT {
|
||||
String path = "/Camera/";
|
||||
|
||||
// folder does not exist yet
|
||||
if (getStorageManager().getFileByPath(path) == null) {
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, account, targetContext);
|
||||
if (getStorageManager().getFileByEncryptedRemotePath(path) == null) {
|
||||
SyncOperation syncOp = new CreateFolderOperation(path, user, targetContext);
|
||||
RemoteOperationResult result = syncOp.execute(client, getStorageManager());
|
||||
|
||||
assertTrue(result.isSuccess());
|
||||
@@ -117,11 +117,7 @@ public class ScreenshotsIT extends AbstractIT {
|
||||
|
||||
@Test
|
||||
public void autoUploadScreenshot() {
|
||||
ActivityScenario.launch(FileDisplayActivity.class);
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
|
||||
onView(withId(R.id.nav_view)).perform(swipeUp());
|
||||
onView(anyOf(withText(R.string.drawer_synced_folders), withId(R.id.nav_synced_folders))).perform(click());
|
||||
ActivityScenario.launch(SyncedFoldersActivity.class);
|
||||
|
||||
Screengrab.screenshot("05_autoUpload");
|
||||
|
||||
|
||||