Compare commits
574
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99632b39df | ||
|
|
7103b5590a | ||
|
|
06962348ca | ||
|
|
5e42f5bd7c | ||
|
|
55c5b59b6d | ||
|
|
8b0cc89b70 | ||
|
|
c574b2cadd | ||
|
|
e8d3cf5e81 | ||
|
|
7c242b30ce | ||
|
|
515ccbc761 | ||
|
|
d79c377641 | ||
|
|
d279a0d456 | ||
|
|
6b688c3630 | ||
|
|
96f9c3b2b4 | ||
|
|
aa666096b5 | ||
|
|
eea93d86d3 | ||
|
|
a2bd8158b8 | ||
|
|
33ff664286 | ||
|
|
3231ba4ab9 | ||
|
|
c10761ca50 | ||
|
|
3a6613fc5f | ||
|
|
1860c20f1b | ||
|
|
2ab9e32a3c | ||
|
|
4be4416e87 | ||
|
|
b576a1aaeb | ||
|
|
4ce5647043 | ||
|
|
3161b78355 | ||
|
|
5ca3632e95 | ||
|
|
39330bbd50 | ||
|
|
10fe08befc | ||
|
|
73de22c6db | ||
|
|
17b0ebf22b | ||
|
|
80df38f6b1 | ||
|
|
c46628b672 | ||
|
|
e6a4aa7e4e | ||
|
|
48f8701e8d | ||
|
|
2e06401721 | ||
|
|
703780cc7c | ||
|
|
95368df3ce | ||
|
|
136cbe9cca | ||
|
|
e246e964ff | ||
|
|
46b981ef77 | ||
|
|
57fbc9247c | ||
|
|
dfdd298f57 | ||
|
|
67272a315f | ||
|
|
7a534b1895 | ||
|
|
c78f63bf8e | ||
|
|
a960e728e3 | ||
|
|
4cdd8a0445 | ||
|
|
32bd9aedaa | ||
|
|
d2ca261db7 | ||
|
|
1c520ac522 | ||
|
|
66ab839cab | ||
|
|
1acae6201e | ||
|
|
c3fc1ea1f1 | ||
|
|
dfe4120af2 | ||
|
|
46e14d1895 | ||
|
|
73065f0895 | ||
|
|
0758e25ac4 | ||
|
|
ade6bccfde | ||
|
|
eb71854ef4 | ||
|
|
3159e7c10f | ||
|
|
cb919ef5b0 | ||
|
|
78638d7c16 | ||
|
|
74c9dc126d | ||
|
|
cb088eb263 | ||
|
|
26f0eef7d5 | ||
|
|
e96f5f8542 | ||
|
|
84e7c41820 | ||
|
|
6a884788f4 | ||
|
|
f653e87b8f | ||
|
|
683757716f | ||
|
|
082328e21f | ||
|
|
d94ca1fdea | ||
|
|
3b03877afc | ||
|
|
b7e3a2dd39 | ||
|
|
e6fda09681 | ||
|
|
530bcc017f | ||
|
|
006e12be74 | ||
|
|
b93b2702f5 | ||
|
|
0c1367dd50 | ||
|
|
447a7b7c01 | ||
|
|
184278cf5a | ||
|
|
3f5b20bcd4 | ||
|
|
dd3a64d3fe | ||
|
|
72c77a00e5 | ||
|
|
f0a3f675af | ||
|
|
d2c1af687b | ||
|
|
2af51844ae | ||
|
|
90b19aa338 | ||
|
|
bf5d0cb7ef | ||
|
|
3e9e6a18a5 | ||
|
|
1097d1e8ac | ||
|
|
f83f36d030 | ||
|
|
22c4b64fb4 | ||
|
|
77ecff2c84 | ||
|
|
673879f418 | ||
|
|
556607ed29 | ||
|
|
686ca7dc36 | ||
|
|
3e78385c9f | ||
|
|
bc1f5a23e6 | ||
|
|
33c5f6631d | ||
|
|
f11226c25a | ||
|
|
216402c20a | ||
|
|
70e1a0edde | ||
|
|
0a8a8ba9f0 | ||
|
|
62cf7c3ea6 | ||
|
|
b778488dd9 | ||
|
|
18c8f665d2 | ||
|
|
89b704d4fe | ||
|
|
ec57fec9b6 | ||
|
|
a1fc5d8519 | ||
|
|
1ba8b80528 | ||
|
|
a8f66d8621 | ||
|
|
bc2a009a07 | ||
|
|
b6402454eb | ||
|
|
e7acd2424b | ||
|
|
48280fbb4c | ||
|
|
613fe6d1a2 | ||
|
|
82d0d15077 | ||
|
|
7fe17f21f7 | ||
|
|
d5223059a6 | ||
|
|
c6885451b7 | ||
|
|
bd465ee07b | ||
|
|
51b322f9ed | ||
|
|
b0e656f563 | ||
|
|
385a89eb79 | ||
|
|
f269f11103 | ||
|
|
2b88c8f284 | ||
|
|
7114f33afc | ||
|
|
c89a7e2d3f | ||
|
|
e093d22a8d | ||
|
|
5dc9f3f940 | ||
|
|
a6fa939f03 | ||
|
|
dd0e339e21 | ||
|
|
050828f627 | ||
|
|
71391fe522 | ||
|
|
5b17836c5f | ||
|
|
6c0d88f38a | ||
|
|
307960e5ff | ||
|
|
a8a4424568 | ||
|
|
3479e47597 | ||
|
|
8b55b34533 | ||
|
|
b42af69446 | ||
|
|
3392060b0d | ||
|
|
ee658aa205 | ||
|
|
9291bebfe9 | ||
|
|
74e9900754 | ||
|
|
1e0db99c18 | ||
|
|
5c2549b9f4 | ||
|
|
fec57f4f31 | ||
|
|
26bb229a99 | ||
|
|
aa0af25774 | ||
|
|
ec0e916418 | ||
|
|
dd5139f480 | ||
|
|
6800d3811f | ||
|
|
b9058f7294 | ||
|
|
12f4c8700c | ||
|
|
f49594ba7e | ||
|
|
b5d9debea1 | ||
|
|
850be12094 | ||
|
|
d293e69d27 | ||
|
|
89436466c3 | ||
|
|
c73f0907a2 | ||
|
|
30909eeedd | ||
|
|
efccbba541 | ||
|
|
e5ca9f7872 | ||
|
|
1d7037b746 | ||
|
|
8777b76105 | ||
|
|
15afb8c184 | ||
|
|
043a763b96 | ||
|
|
078b3feaac | ||
|
|
0d88157c6d | ||
|
|
93fceaea1e | ||
|
|
e71e1e2507 | ||
|
|
68474b178b | ||
|
|
3b65421fc0 | ||
|
|
d9401c48ae | ||
|
|
e53e113cdf | ||
|
|
ff29bc460a | ||
|
|
c25d9a4d2b | ||
|
|
22c1eccaec | ||
|
|
a062b7e537 | ||
|
|
c7cd5c6233 | ||
|
|
f112697e51 | ||
|
|
2c2d4e8fb9 | ||
|
|
23000718f1 | ||
|
|
e968ed2d83 | ||
|
|
101eb9b48e | ||
|
|
9e3f651b5a | ||
|
|
d0775ec08a | ||
|
|
c33862010a | ||
|
|
7bba8f84eb | ||
|
|
cd6721430a | ||
|
|
8a58b2efcd | ||
|
|
7416f51109 | ||
|
|
87886024cb | ||
|
|
49c3be89ab | ||
|
|
f3d97558d4 | ||
|
|
fbaa242c51 | ||
|
|
6809763fe3 | ||
|
|
d5359f4f1b | ||
|
|
41fc243938 | ||
|
|
983635ca7b | ||
|
|
7605a32b4e | ||
|
|
0b421947fe | ||
|
|
98fb31d90f | ||
|
|
ad40517d30 | ||
|
|
7733a50c1c | ||
|
|
4eaf50249c | ||
|
|
0415db9648 | ||
|
|
48a3130ebe | ||
|
|
4effcf14b5 | ||
|
|
7e811f6b9b | ||
|
|
ae16c738eb | ||
|
|
f09e71e33c | ||
|
|
b82a9881fe | ||
|
|
2ef418808b | ||
|
|
d76ed5a769 | ||
|
|
c4ccea7f76 | ||
|
|
945ad6f843 | ||
|
|
f4bea54bfd | ||
|
|
f10666ff64 | ||
|
|
655b6010f4 | ||
|
|
e172e710ca | ||
|
|
163648e763 | ||
|
|
e3b0af9bd9 | ||
|
|
9eb5e4037f | ||
|
|
1df79b6a42 | ||
|
|
d499122e2e | ||
|
|
2a0b507ec0 | ||
|
|
646917b5fd | ||
|
|
ea06d34fbc | ||
|
|
0d51ff0c2e | ||
|
|
2da9010134 | ||
|
|
ffe2cc1edd | ||
|
|
5b544dc25a | ||
|
|
7463d33a5b | ||
|
|
f9c7d5e1d2 | ||
|
|
b595eed437 | ||
|
|
de99952964 | ||
|
|
4be340f073 | ||
|
|
75b9794e60 | ||
|
|
29d68adfdf | ||
|
|
e82bb019e5 | ||
|
|
32545d42f2 | ||
|
|
628b6147e9 | ||
|
|
da2aa8d861 | ||
|
|
17f396637c | ||
|
|
1307cdb0dc | ||
|
|
9db5b5bd71 | ||
|
|
4dc6faa9e2 | ||
|
|
5b1fe83ba4 | ||
|
|
c969a6014f | ||
|
|
d914618b32 | ||
|
|
9bbf716cc2 | ||
|
|
7d1231d40d | ||
|
|
ef243ebcf0 | ||
|
|
6f9d3256e5 | ||
|
|
10becaa76a | ||
|
|
4a3f2328e4 | ||
|
|
5d4af37768 | ||
|
|
5e297fbd89 | ||
|
|
35c1a573d0 | ||
|
|
2a50467d9e | ||
|
|
0ff3f91625 | ||
|
|
f127d5725a | ||
|
|
35b0d0e8b4 | ||
|
|
7f4c5e7199 | ||
|
|
444ca2eaaa | ||
|
|
7085312dbb | ||
|
|
0238cb71b3 | ||
|
|
b89a7dd409 | ||
|
|
2d89180eac | ||
|
|
d9e517dd09 | ||
|
|
b0656a6ed1 | ||
|
|
b65e86c141 | ||
|
|
ff139a7780 | ||
|
|
f1a886564f | ||
|
|
a31246bf95 | ||
|
|
68df0057f0 | ||
|
|
97d6a706f8 | ||
|
|
e692275bef | ||
|
|
2ef92184a9 | ||
|
|
b46969d845 | ||
|
|
51cd7c9260 | ||
|
|
c14c19d184 | ||
|
|
290bcf76aa | ||
|
|
3c6ff66f40 | ||
|
|
256c286093 | ||
|
|
159acc261f | ||
|
|
5b9245cc9b | ||
|
|
34eaa95dbf | ||
|
|
778c1bc5f0 | ||
|
|
544ca89580 | ||
|
|
c163f666c0 | ||
|
|
f3307dc43a | ||
|
|
0a9a8c1d70 | ||
|
|
de46d186dd | ||
|
|
eb2abbb493 | ||
|
|
6cba0320a1 | ||
|
|
e768ecd9ec | ||
|
|
e39653e688 | ||
|
|
058ba20a0c | ||
|
|
3fedca14df | ||
|
|
b73c881513 | ||
|
|
d112302b79 | ||
|
|
d078795157 | ||
|
|
036d1e47a6 | ||
|
|
4982894840 | ||
|
|
7d5acea1bb | ||
|
|
cb729dc1b9 | ||
|
|
e223453c30 | ||
|
|
4a876f0edc | ||
|
|
3d5bcbb3ea | ||
|
|
e470957819 | ||
|
|
4f9ca16075 | ||
|
|
1177e3b67d | ||
|
|
533c8a8deb | ||
|
|
32e6ada963 | ||
|
|
0cbad554b9 | ||
|
|
720d753202 | ||
|
|
eb3e5abe00 | ||
|
|
857cd674dd | ||
|
|
58ceea0462 | ||
|
|
a15986231e | ||
|
|
f1e59ec7e8 | ||
|
|
c609fe9340 | ||
|
|
1903257a2e | ||
|
|
4f922d7b94 | ||
|
|
65ef548743 | ||
|
|
8de1bbf74f | ||
|
|
8781a2363b | ||
|
|
5337d840a0 | ||
|
|
112508d03a | ||
|
|
eb328d6740 | ||
|
|
69f6d688a5 | ||
|
|
2afc7108c9 | ||
|
|
762d798a42 | ||
|
|
231353c95b | ||
|
|
a026eabb02 | ||
|
|
1d259c049b | ||
|
|
65a43377c0 | ||
|
|
df7546775c | ||
|
|
adb30bbf75 | ||
|
|
a952e7229b | ||
|
|
c04a70b064 | ||
|
|
0b87ea55c2 | ||
|
|
f4e1e9172b | ||
|
|
c80c60f69a | ||
|
|
b21d7a6458 | ||
|
|
1ed6bdd8ec | ||
|
|
10cc59efc1 | ||
|
|
a34df90502 | ||
|
|
d80668d375 | ||
|
|
4e16ee617d | ||
|
|
d09c2f84b5 | ||
|
|
8e69d8722e | ||
|
|
ca602666af | ||
|
|
54f68b589e | ||
|
|
156ebac1cf | ||
|
|
c3ddbe8971 | ||
|
|
0b94d26dfe | ||
|
|
c387abcd4a | ||
|
|
35255cd781 | ||
|
|
493d660686 | ||
|
|
6ae533c595 | ||
|
|
9098840a5b | ||
|
|
905ef229c8 | ||
|
|
dc86f03128 | ||
|
|
e5094f4155 | ||
|
|
5dfd9a018a | ||
|
|
80b1a9c04a | ||
|
|
7b3e948b4d | ||
|
|
48351df0f9 | ||
|
|
62838621ba | ||
|
|
75e59553ce | ||
|
|
77f3151550 | ||
|
|
1f92478c61 | ||
|
|
ac25f9b0a4 | ||
|
|
1107c08f3e | ||
|
|
54a07493c4 | ||
|
|
fdf77da0be | ||
|
|
cab8728fde | ||
|
|
a5ce31a4e7 | ||
|
|
e13343b3bc | ||
|
|
949251af93 | ||
|
|
1e87a96da3 | ||
|
|
90f5a1e196 | ||
|
|
8b9cb5fe29 | ||
|
|
68dd4044b2 | ||
|
|
c375e21cc0 | ||
|
|
2d6bf25c0d | ||
|
|
144d639528 | ||
|
|
d105cc148f | ||
|
|
d02b341c0a | ||
|
|
2757665a73 | ||
|
|
812f9717ac | ||
|
|
a73ebf8116 | ||
|
|
926a11a3b5 | ||
|
|
cd9ba70e58 | ||
|
|
fd784e9c01 | ||
|
|
e16bc82fee | ||
|
|
e7762e438e | ||
|
|
ac0e9780a6 | ||
|
|
f86b296822 | ||
|
|
4d3955d9d8 | ||
|
|
9a5ac00ecc | ||
|
|
022124ac10 | ||
|
|
375e534cc9 | ||
|
|
67d79594f7 | ||
|
|
7a35205951 | ||
|
|
8241e6f796 | ||
|
|
9333feedc8 | ||
|
|
ae15eb1a3f | ||
|
|
18d1a7751a | ||
|
|
bb3181d4d6 | ||
|
|
c079c0ad98 | ||
|
|
34f98b2a92 | ||
|
|
d8aef68648 | ||
|
|
ba6def86f2 | ||
|
|
67cdf5779e | ||
|
|
9ac81a4cfd | ||
|
|
d8b874bca7 | ||
|
|
c49412bd23 | ||
|
|
b0939f0b46 | ||
|
|
af85f82687 | ||
|
|
bccd3654e4 | ||
|
|
c9cfb0ff57 | ||
|
|
84ef075f62 | ||
|
|
012ee5279a | ||
|
|
3e6b2f7c5a | ||
|
|
3e7494b76d | ||
|
|
5dd572c676 | ||
|
|
a37a94a2eb | ||
|
|
8265b7737a | ||
|
|
c6818310c4 | ||
|
|
cbcc2d672f | ||
|
|
3127afa17e | ||
|
|
c1bf049abd | ||
|
|
3c7c60b6c8 | ||
|
|
407fc053a7 | ||
|
|
c14c11b8fc | ||
|
|
f6cbd48dad | ||
|
|
5ef90dbf70 | ||
|
|
db5fd624a4 | ||
|
|
f79fd6e6d7 | ||
|
|
4894bf4768 | ||
|
|
09651c2efd | ||
|
|
9e2428a981 | ||
|
|
835d668880 | ||
|
|
5d7c6f51fc | ||
|
|
47e2590bf5 | ||
|
|
9a0bf09208 | ||
|
|
c0d637d36e | ||
|
|
bf4393c6c1 | ||
|
|
7a96aa1b13 | ||
|
|
7bfa542110 | ||
|
|
f898140c2e | ||
|
|
cef991cace | ||
|
|
69e517e35e | ||
|
|
6fa7a316ca | ||
|
|
ff3dd36dcd | ||
|
|
028fdfedaa | ||
|
|
c02f880a10 | ||
|
|
04c83ead01 | ||
|
|
0830e68dd5 | ||
|
|
3bd4ce210e | ||
|
|
6b85e436df | ||
|
|
991302f5d1 | ||
|
|
5a049b75d7 | ||
|
|
c6b33f588e | ||
|
|
4b108f258c | ||
|
|
da64f1770f | ||
|
|
f292800286 | ||
|
|
d49532caaa | ||
|
|
a96d529012 | ||
|
|
128ac02c33 | ||
|
|
617185314c | ||
|
|
8cca3e1061 | ||
|
|
e439312a4c | ||
|
|
931fcdaeb5 | ||
|
|
5ca943484a | ||
|
|
77e08666c8 | ||
|
|
ff815e310f | ||
|
|
f7be02e79f | ||
|
|
31c37420a7 | ||
|
|
7d9256829c | ||
|
|
c8f83f87fe | ||
|
|
df14197b67 | ||
|
|
c889012358 | ||
|
|
7246e5b7b7 | ||
|
|
34b7eadc9a | ||
|
|
5770b93523 | ||
|
|
e64a017b8e | ||
|
|
43f838cfa1 | ||
|
|
90e9a4f88e | ||
|
|
7e49ba7444 | ||
|
|
56edf135b3 | ||
|
|
19222459c6 | ||
|
|
602db2e499 | ||
|
|
6c0bea1a75 | ||
|
|
17221fb8cd | ||
|
|
aa6624db1b | ||
|
|
f179b3cd91 | ||
|
|
4c89b09650 | ||
|
|
e3d22f07ab | ||
|
|
1c41ddaa29 | ||
|
|
9f507b3210 | ||
|
|
6088b9839f | ||
|
|
af19d396b1 | ||
|
|
cbd614cfb5 | ||
|
|
a611ea0876 | ||
|
|
53553fce05 | ||
|
|
bbb5fce979 | ||
|
|
468d9ad584 | ||
|
|
5ff6549ed2 | ||
|
|
5d2efc8ae3 | ||
|
|
974f01a299 | ||
|
|
00d57f2b68 | ||
|
|
d1c80d5470 | ||
|
|
2c066345d8 | ||
|
|
121b60a253 | ||
|
|
592e2ab152 | ||
|
|
43e626e726 | ||
|
|
3d6c006122 | ||
|
|
f2a09e45f6 | ||
|
|
7a5e28316a | ||
|
|
c15102b35c | ||
|
|
13746ab58e | ||
|
|
b4b9c70bad | ||
|
|
f35bb52da9 | ||
|
|
9914ea0d8b | ||
|
|
c02a49e558 | ||
|
|
4164553469 | ||
|
|
bc22506794 | ||
|
|
d4fe4e8881 | ||
|
|
476b94e946 | ||
|
|
2bc7de234c | ||
|
|
586264cecd | ||
|
|
641dafe934 | ||
|
|
70cf59f3e4 | ||
|
|
9676f0f044 | ||
|
|
35f5b93e85 | ||
|
|
006fc5a685 | ||
|
|
1613d064e9 | ||
|
|
35c30f23ba | ||
|
|
11d30a9440 | ||
|
|
4a5d23baf9 | ||
|
|
f7041bbb25 | ||
|
|
b5a3fdd8cc | ||
|
|
0c8291f979 | ||
|
|
04689b9548 | ||
|
|
243d7e4d36 | ||
|
|
60d3c3f9b8 | ||
|
|
29752e297f | ||
|
|
cde23750e5 | ||
|
|
bb5e54d0cd | ||
|
|
eeeb6db32a | ||
|
|
54b28f60a3 | ||
|
|
e99a4348ae | ||
|
|
7732562f0c | ||
|
|
ff1196e19b | ||
|
|
db1d454e9f | ||
|
|
e537ce27af | ||
|
|
5d0417cc82 | ||
|
|
9c3c15d5a8 | ||
|
|
96ad1c96f1 | ||
|
|
fe670b7baa | ||
|
|
04216c251e | ||
|
|
561d9862da | ||
|
|
288e961caf | ||
|
|
cbda93ee49 | ||
|
|
460320c201 |
No files matched your search
@@ -4,7 +4,7 @@ ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV ANDROID_HOME=/usr/lib/android-sdk
|
||||
|
||||
RUN apt-get update -y
|
||||
RUN apt-get install -y unzip wget openjdk-24-jdk vim
|
||||
RUN apt-get install -y unzip wget openjdk-17-jdk vim
|
||||
|
||||
RUN wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip -O /tmp/commandlinetools.zip
|
||||
RUN cd /tmp && unzip commandlinetools.zip
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ name: tests-stable
|
||||
|
||||
steps:
|
||||
- name: gplay
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:4
|
||||
image: ghcr.io/nextcloud/continuous-integration-android16:latest
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
@@ -74,7 +74,7 @@ name: tests-master
|
||||
|
||||
steps:
|
||||
- name: gplay
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:4
|
||||
image: ghcr.io/nextcloud/continuous-integration-android16:latest
|
||||
privileged: true
|
||||
environment:
|
||||
LOG_USERNAME:
|
||||
@@ -134,7 +134,7 @@ name: allScreenshots
|
||||
|
||||
steps:
|
||||
- name: runAllScreenshots
|
||||
image: ghcr.io/nextcloud/continuous-integration-android8:4
|
||||
image: ghcr.io/nextcloud/continuous-integration-android16:latest
|
||||
privileged: true
|
||||
environment:
|
||||
GIT_USERNAME:
|
||||
@@ -185,6 +185,6 @@ name: GIT_TOKEN
|
||||
data: XIoa9IYq+xQ+N5iln8dlpWv0jV6ROr7HuE24ioUr4uQ8m8SjyH0yognWYLYLqnbTKrFWlFZiEMQTH/sZiWjRFvV1iL0=
|
||||
---
|
||||
kind: signature
|
||||
hmac: b4568fe767026f67cca8c416c20cc522fd1d06941c836ca7eb4955682855d237
|
||||
hmac: d52e0df1af49c1b30e42a877655c6699914130adf3a3b881db46a70b90356c3a
|
||||
|
||||
...
|
||||
@@ -52,16 +52,16 @@ jobs:
|
||||
echo "repo=${{ github.event.pull_request.head.repo.full_name }}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
repository: ${{ steps.get-vars.outputs.repo }}
|
||||
ref: ${{ steps.get-vars.outputs.branch }}
|
||||
- name: Set up JDK 24
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 24
|
||||
java-version: 17
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt install python3-defusedxml
|
||||
|
||||
@@ -22,12 +22,12 @@ jobs:
|
||||
matrix:
|
||||
flavor: [ Generic, Gplay, Huawei ]
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: set up JDK 24
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 24
|
||||
java-version: 17
|
||||
- uses: gradle/actions/wrapper-validation@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
|
||||
- name: Build ${{ matrix.flavor }}
|
||||
run: |
|
||||
|
||||
@@ -22,11 +22,11 @@ jobs:
|
||||
matrix:
|
||||
task: [ detekt, spotlessKotlinCheck, lint ]
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: Set up JDK 24
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 24
|
||||
java-version: 17
|
||||
- name: Check ${{ matrix.task }}
|
||||
run: ./gradlew ${{ matrix.task }}
|
||||
@@ -34,7 +34,7 @@ jobs:
|
||||
language: [ 'java' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set Swap Space
|
||||
@@ -43,18 +43,18 @@ jobs:
|
||||
with:
|
||||
swap-size-gb: 10
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3
|
||||
uses: github/codeql-action/init@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Set up JDK 24
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 24
|
||||
java-version: 17
|
||||
- name: Assemble
|
||||
run: |
|
||||
mkdir -p "$HOME/.gradle"
|
||||
echo "org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError" > "$HOME/.gradle/gradle.properties"
|
||||
./gradlew assembleDebug
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3
|
||||
uses: github/codeql-action/analyze@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
|
||||
@@ -20,11 +20,11 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- name: Set up JDK 24
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 24
|
||||
java-version: 17
|
||||
- name: Detect SNAPSHOT
|
||||
run: scripts/analysis/detectWrongSettings.sh
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
blocklist=$(curl https://raw.githubusercontent.com/nextcloud/.github/master/non-community-usernames.txt | paste -s -d, -)
|
||||
echo "blocklist=$blocklist" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: nextcloud/pr-feedback-action@e397f3c7e655092b746e3610d121545530c6a90e # main
|
||||
- uses: nextcloud/pr-feedback-action@5227c55be184087d0aef6338bee210d8620b6297 # main
|
||||
with:
|
||||
feedback-message: |
|
||||
Hello there,
|
||||
|
||||
@@ -24,17 +24,17 @@ jobs:
|
||||
id: check-secrets
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: set up JDK 24
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
- name: set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 24
|
||||
java-version: 17
|
||||
|
||||
- name: Build QA
|
||||
if: ${{ steps.check-secrets.outputs.ok == 'true' }}
|
||||
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ jobs:
|
||||
runs-on: ubuntu-latest-low
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
@@ -42,6 +42,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3
|
||||
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -23,19 +23,19 @@ jobs:
|
||||
matrix:
|
||||
scheme: [ Light ]
|
||||
color: [ blue ]
|
||||
api-level: [ 27 ]
|
||||
api-level: [ 28 ]
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- name: Gradle cache
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
|
||||
- name: AVD cache
|
||||
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
|
||||
id: avd-cache
|
||||
with:
|
||||
path: |
|
||||
@@ -43,10 +43,10 @@ jobs:
|
||||
~/.android/adb*
|
||||
key: avd-${{ matrix.api-level }}
|
||||
|
||||
- uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
- uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 24
|
||||
java-version: 17
|
||||
|
||||
- name: Enable KVM group perms
|
||||
run: |
|
||||
@@ -56,7 +56,7 @@ jobs:
|
||||
|
||||
- name: create AVD and generate snapshot for caching
|
||||
if: steps.avd-cache.outputs.cache-hit != 'true'
|
||||
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
|
||||
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
@@ -87,7 +87,7 @@ jobs:
|
||||
- name: Run screenshot tests
|
||||
env:
|
||||
SHOT_TEST: "true"
|
||||
uses: reactivecircus/android-emulator-runner@1dcd0090116d15e7c562f8db72807de5e036a4ed # v2.34.0
|
||||
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b # v2.35.0
|
||||
with:
|
||||
api-level: ${{ matrix.api-level }}
|
||||
force-avd-creation: false
|
||||
@@ -102,7 +102,7 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "${{ matrix.color }}-${{ matrix.scheme }}" "Screenshot" ${{github.event.number}}
|
||||
- name: Archive Espresso results
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
name: Report-${{ matrix.color }}-${{ matrix.scheme }}
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@5f858e3efba33a5ca4407a664cc011ad407f2008 # v10.1.0
|
||||
- uses: actions/stale@997185467fa4f803885201cee163a9f38240193d # v10.1.1
|
||||
with:
|
||||
days-before-stale: 28
|
||||
days-before-close: 14
|
||||
|
||||
@@ -22,13 +22,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- name: Set up JDK 24
|
||||
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
|
||||
with:
|
||||
distribution: "temurin"
|
||||
java-version: 24
|
||||
java-version: 17
|
||||
|
||||
- name: Delete old comments
|
||||
env:
|
||||
@@ -49,7 +49,7 @@ jobs:
|
||||
run: scripts/uploadReport.sh "${{ secrets.LOG_USERNAME }}" "${{ secrets.LOG_PASSWORD }}" ${{github.event.number}} "test" "Unit" ${{github.event.number}}
|
||||
|
||||
- name: Upload coverage to codecov
|
||||
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
|
||||
uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
flags: unit
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
|
||||
- name: Upload jacoco artifacts
|
||||
if: ${{ failure() }}
|
||||
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/jacoco/jacocoTestGplayDebugUnitTestReport/html/
|
||||
Generated
+6
@@ -6,15 +6,19 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewMustBeTopLevelFunction" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewNeedsComposableAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="ComposePreviewNotSupportedInUnitTestFiles" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="GlancePreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
@@ -39,6 +43,7 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewDeviceShouldUseNewSpec" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewDimensionRespectsLimit" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
@@ -66,6 +71,7 @@
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewParameterProviderOnFirstParameter" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
<option name="previewFile" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="PreviewPickerAnnotation" enabled="true" level="ERROR" enabled_by_default="true">
|
||||
<option name="composableFile" value="true" />
|
||||
|
||||
+31
-32
@@ -1,40 +1,41 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
CFPropertyList (3.0.7)
|
||||
base64
|
||||
nkf
|
||||
rexml
|
||||
addressable (2.8.7)
|
||||
public_suffix (>= 2.0.2, < 7.0)
|
||||
CFPropertyList (3.0.8)
|
||||
abbrev (0.1.2)
|
||||
addressable (2.8.8)
|
||||
public_suffix (>= 2.0.2, < 8.0)
|
||||
artifactory (3.0.17)
|
||||
atomos (0.1.3)
|
||||
aws-eventstream (1.4.0)
|
||||
aws-partitions (1.1121.0)
|
||||
aws-sdk-core (3.226.1)
|
||||
aws-partitions (1.1201.0)
|
||||
aws-sdk-core (3.241.2)
|
||||
aws-eventstream (~> 1, >= 1.3.0)
|
||||
aws-partitions (~> 1, >= 1.992.0)
|
||||
aws-sigv4 (~> 1.9)
|
||||
base64
|
||||
bigdecimal
|
||||
jmespath (~> 1, >= 1.6.1)
|
||||
logger
|
||||
aws-sdk-kms (1.106.0)
|
||||
aws-sdk-core (~> 3, >= 3.225.0)
|
||||
aws-sdk-kms (1.119.0)
|
||||
aws-sdk-core (~> 3, >= 3.241.0)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sdk-s3 (1.191.0)
|
||||
aws-sdk-core (~> 3, >= 3.225.0)
|
||||
aws-sdk-s3 (1.210.1)
|
||||
aws-sdk-core (~> 3, >= 3.241.0)
|
||||
aws-sdk-kms (~> 1)
|
||||
aws-sigv4 (~> 1.5)
|
||||
aws-sigv4 (1.12.1)
|
||||
aws-eventstream (~> 1, >= 1.0.2)
|
||||
babosa (1.0.4)
|
||||
base64 (0.3.0)
|
||||
bigdecimal (3.3.1)
|
||||
cgi (0.4.2)
|
||||
claide (1.1.0)
|
||||
colored (1.2)
|
||||
colored2 (3.1.2)
|
||||
commander (4.6.0)
|
||||
highline (~> 2.0.0)
|
||||
csv (3.3.5)
|
||||
declarative (0.0.20)
|
||||
digest-crc (0.7.0)
|
||||
rake (>= 12.0.0, < 14.0.0)
|
||||
@@ -42,37 +43,34 @@ GEM
|
||||
dotenv (2.8.1)
|
||||
emoji_regex (3.2.3)
|
||||
excon (0.112.0)
|
||||
faraday (1.10.4)
|
||||
faraday (1.8.0)
|
||||
faraday-em_http (~> 1.0)
|
||||
faraday-em_synchrony (~> 1.0)
|
||||
faraday-excon (~> 1.1)
|
||||
faraday-httpclient (~> 1.0)
|
||||
faraday-multipart (~> 1.0)
|
||||
faraday-httpclient (~> 1.0.1)
|
||||
faraday-net_http (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.0)
|
||||
faraday-net_http_persistent (~> 1.1)
|
||||
faraday-patron (~> 1.0)
|
||||
faraday-rack (~> 1.0)
|
||||
faraday-retry (~> 1.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ruby2_keywords (>= 0.0.4)
|
||||
faraday-cookie_jar (0.0.7)
|
||||
faraday-cookie_jar (0.0.8)
|
||||
faraday (>= 0.8.0)
|
||||
http-cookie (~> 1.0.0)
|
||||
http-cookie (>= 1.0.0)
|
||||
faraday-em_http (1.0.0)
|
||||
faraday-em_synchrony (1.0.1)
|
||||
faraday-excon (1.1.0)
|
||||
faraday-httpclient (1.0.1)
|
||||
faraday-multipart (1.1.1)
|
||||
multipart-post (~> 2.0)
|
||||
faraday-net_http (1.0.2)
|
||||
faraday-net_http_persistent (1.2.0)
|
||||
faraday-patron (1.0.0)
|
||||
faraday-rack (1.0.0)
|
||||
faraday-retry (1.0.3)
|
||||
faraday_middleware (1.2.1)
|
||||
faraday (~> 1.0)
|
||||
fastimage (2.4.0)
|
||||
fastlane (2.228.0)
|
||||
fastlane (2.229.0)
|
||||
CFPropertyList (>= 2.3, < 4.0.0)
|
||||
abbrev (~> 0.1.2)
|
||||
addressable (>= 2.8, < 3.0.0)
|
||||
artifactory (~> 3.0)
|
||||
aws-sdk-s3 (~> 1.0)
|
||||
@@ -80,6 +78,7 @@ GEM
|
||||
bundler (>= 1.12.0, < 3.0.0)
|
||||
colored (~> 1.2)
|
||||
commander (~> 4.6)
|
||||
csv (~> 3.3)
|
||||
dotenv (>= 2.1.1, < 3.0.0)
|
||||
emoji_regex (>= 0.1, < 4.0)
|
||||
excon (>= 0.71.0, < 1.0.0)
|
||||
@@ -99,6 +98,7 @@ GEM
|
||||
jwt (>= 2.1.0, < 3)
|
||||
mini_magick (>= 4.9.4, < 5.0.0)
|
||||
multipart-post (>= 2.0.0, < 3.0.0)
|
||||
mutex_m (~> 0.3.0)
|
||||
naturally (~> 2.2)
|
||||
optparse (>= 0.1.1, < 1.0.0)
|
||||
plist (>= 3.1.0, < 4.0.0)
|
||||
@@ -160,37 +160,36 @@ GEM
|
||||
httpclient (2.9.0)
|
||||
mutex_m
|
||||
jmespath (1.6.2)
|
||||
json (2.12.2)
|
||||
jwt (2.10.1)
|
||||
json (2.18.0)
|
||||
jwt (2.10.2)
|
||||
base64
|
||||
logger (1.7.0)
|
||||
mini_magick (4.13.2)
|
||||
mini_mime (1.1.5)
|
||||
multi_json (1.15.0)
|
||||
multi_json (1.19.1)
|
||||
multipart-post (2.4.1)
|
||||
mutex_m (0.3.0)
|
||||
nanaimo (0.4.0)
|
||||
naturally (2.3.0)
|
||||
nkf (0.2.0)
|
||||
optparse (0.6.0)
|
||||
optparse (0.8.1)
|
||||
os (1.1.4)
|
||||
plist (3.7.2)
|
||||
public_suffix (6.0.2)
|
||||
rake (13.3.0)
|
||||
rake (13.3.1)
|
||||
representable (3.2.0)
|
||||
declarative (< 0.1.0)
|
||||
trailblazer-option (>= 0.1.1, < 0.2.0)
|
||||
uber (< 0.2.0)
|
||||
retriable (3.1.2)
|
||||
rexml (3.4.1)
|
||||
rexml (3.4.4)
|
||||
rouge (3.28.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.4.1)
|
||||
security (0.1.5)
|
||||
signet (0.20.0)
|
||||
signet (0.21.0)
|
||||
addressable (~> 2.8)
|
||||
faraday (>= 0.17.5, < 3.a)
|
||||
jwt (>= 1.5, < 3.0)
|
||||
jwt (>= 1.5, < 4.0)
|
||||
multi_json (~> 1.10)
|
||||
simctl (1.6.10)
|
||||
CFPropertyList
|
||||
|
||||
@@ -16,7 +16,7 @@ height="80">](https://f-droid.org/packages/com.nextcloud.client/)
|
||||
alt="Get it with Obtainium"
|
||||
height="80">](https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/%7B%22id%22%3A%22com.nextcloud.client%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2Fnextcloud%2Fandroid%22%2C%22author%22%3A%22nextcloud%22%2C%22name%22%3A%22Nextcloud%22%2C%22preferredApkIndex%22%3A0%2C%22additionalSettings%22%3A%22%7B%5C%22includePrereleases%5C%22%3Afalse%2C%5C%22fallbackToOlderReleases%5C%22%3Atrue%2C%5C%22filterReleaseTitlesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22filterReleaseNotesByRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22verifyLatestTag%5C%22%3Afalse%2C%5C%22sortMethodChoice%5C%22%3A%5C%22date%5C%22%2C%5C%22useLatestAssetDateAsReleaseDate%5C%22%3Afalse%2C%5C%22releaseTitleAsVersion%5C%22%3Afalse%2C%5C%22trackOnly%5C%22%3Afalse%2C%5C%22versionExtractionRegEx%5C%22%3A%5C%22%5C%22%2C%5C%22matchGroupToUse%5C%22%3A%5C%22%5C%22%2C%5C%22versionDetection%5C%22%3Atrue%2C%5C%22releaseDateAsVersion%5C%22%3Afalse%2C%5C%22useVersionCodeAsOSVersion%5C%22%3Afalse%2C%5C%22apkFilterRegEx%5C%22%3A%5C%22%5Enextcloud.*%5C%22%2C%5C%22invertAPKFilter%5C%22%3Afalse%2C%5C%22autoApkFilterByArch%5C%22%3Atrue%2C%5C%22appName%5C%22%3A%5C%22%5C%22%2C%5C%22appAuthor%5C%22%3A%5C%22%5C%22%2C%5C%22shizukuPretendToBeGooglePlay%5C%22%3Afalse%2C%5C%22allowInsecure%5C%22%3Afalse%2C%5C%22exemptFromBackgroundUpdates%5C%22%3Afalse%2C%5C%22skipUpdateNotifications%5C%22%3Afalse%2C%5C%22about%5C%22%3A%5C%22Nextcloud%20ist%20eine%20Cloudanwendung%2C%20die%20selbst%20gehostet%20werden%20kann.%5C%22%2C%5C%22refreshBeforeDownload%5C%22%3Atrue%7D%22%2C%22overrideSource%22%3Anull%7D)
|
||||
|
||||
Signing certificate fingerprint to [verify](https://developer.android.com/studio/command-line/apksigner#usage-verify) the APK:
|
||||
Signing certificate fingerprint to [verify](https://developer.android.com/studio/command-line/apksigner#usage-verify) the APK using the official Android documentation.
|
||||
- APK with "gplay" name, found [here](https://github.com/nextcloud/android/releases) or distributed via Google Play Store
|
||||
- APK with "nextcloud", found [here](https://github.com/nextcloud/android/releases)
|
||||
- not suitable for Fdroid downloads, as Fdroid is signing it on their own
|
||||
|
||||
+4
-4
@@ -30,13 +30,13 @@ SPDX-FileCopyrightText = "2015-2016 ownCloud Inc."
|
||||
SPDX-License-Identifier = "GPL-2.0-only"
|
||||
|
||||
[[annotations]]
|
||||
path = ["app/src/**/res/mipmap-**dpi/ic_launcher.png", "app/src/**/ic_launcher-web.png", "src/generic/fastlane/metadata/android/en-US/images/icon.png", "src/versionDev/fastlane/metadata/android/en-US/images/icon.png", "app/src/main/ic_launcher-web-round.png"]
|
||||
path = ["app/src/**/res/mipmap-**dpi/ic_launcher.png", "app/src/**/ic_launcher-web.png", "src/**/fastlane/metadata/en-US/images/*.png", "src/generic/fastlane/metadata/android/en-US/images/icon.png", "src/versionDev/fastlane/metadata/android/en-US/images/icon.png", "app/src/main/ic_launcher-web-round.png"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2017-2024 Nextcloud GmbH <https://nextcloud.com/trademarks/>"
|
||||
SPDX-FileCopyrightText = "2017-2025 Nextcloud GmbH <https://nextcloud.com/trademarks/>"
|
||||
SPDX-License-Identifier = "LicenseRef-NextcloudTrademarks"
|
||||
|
||||
[[annotations]]
|
||||
path = [".idea/**", "app/schemas/com.nextcloud.client.database.NextcloudDatabase/**.json", "app/screenshots/generic/debug/**.png", "app/src/main/res/values-**/strings.xml", "src/**/fastlane/metadata/android/**/**.txt", "src/versionDev/fastlane/metadata/android/**/changelogs/**.txt", "app/src/androidTest/assets/**", "app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker", "app/src/**/google-services.json", "app/src/main/res/drawable-**dpi/checker_16_16.png", "app/src/main/res/raw/encryption_key_words.txt", "app/src/main/resources/ical4j.properties", "app/src/main/res/drawable-**dpi/apk.png", "app/src/main/res/drawable-**dpi/fdroid.png", "app/src/main/res/drawable-**dpi/playstore.png", "app/src/main/res/drawable-**dpi/background.png", "app/src/main/res/drawable-**dpi/background_nc18.png"]
|
||||
path = [".idea/**", "app/schemas/com.nextcloud.client.database.NextcloudDatabase/**.json", "app/screenshots/generic/debug/**.png", "app/src/main/res/values-**/strings.xml", "src/**/fastlane/metadata/**/*.txt", "src/versionDev/fastlane/metadata/android/**/changelogs/**.txt", "app/src/androidTest/assets/**", "app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker", "app/src/**/google-services.json", "app/src/main/res/drawable-**dpi/checker_16_16.png", "app/src/main/res/raw/encryption_key_words.txt", "app/src/main/resources/ical4j.properties", "app/src/main/res/drawable-**dpi/apk.png", "app/src/main/res/drawable-**dpi/fdroid.png", "app/src/main/res/drawable-**dpi/playstore.png", "app/src/main/res/drawable-**dpi/background.png", "app/src/main/res/drawable-**dpi/background_nc18.png"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2016-2024 Nextcloud GmbH and Nextcloud contributors"
|
||||
SPDX-FileCopyrightText = "2016-2025 Nextcloud GmbH and Nextcloud contributors"
|
||||
SPDX-License-Identifier = "AGPL-3.0-or-later"
|
||||
@@ -63,7 +63,7 @@ configurations.configureEach {
|
||||
|
||||
// semantic versioning for version code
|
||||
val versionMajor = 3
|
||||
val versionMinor = 35
|
||||
val versionMinor = 36
|
||||
val versionPatch = 0
|
||||
val versionBuild = 0 // 0-50=Alpha / 51-98=RC / 90-99=stable
|
||||
|
||||
@@ -94,7 +94,7 @@ android {
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.nextcloud.client"
|
||||
minSdk = 27
|
||||
minSdk = 28
|
||||
targetSdk = 36
|
||||
compileSdk = 36
|
||||
|
||||
@@ -205,8 +205,8 @@ android {
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_24
|
||||
targetCompatibility = JavaVersion.VERSION_24
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
lint {
|
||||
@@ -247,7 +247,7 @@ kapt.useBuildCache = true
|
||||
|
||||
ksp.arg("room.schemaLocation", "$projectDir/schemas")
|
||||
|
||||
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_24)
|
||||
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
|
||||
|
||||
spotless.kotlin {
|
||||
target("**/*.kt")
|
||||
@@ -327,7 +327,7 @@ tasks.withType<JavaCompile>().configureEach {
|
||||
|
||||
tasks.withType<Test>().configureEach {
|
||||
// Run tests in parallel
|
||||
maxParallelForks = Runtime.getRuntime().availableProcessors().div(2)
|
||||
maxParallelForks = maxOf(1, Runtime.getRuntime().availableProcessors().div(2))
|
||||
|
||||
// increased logging for tests
|
||||
testLogging.events("passed", "skipped", "failed")
|
||||
@@ -355,6 +355,7 @@ dependencies {
|
||||
implementation(libs.compose.ui.graphics)
|
||||
implementation(libs.compose.material3)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
implementation(libs.foundation)
|
||||
debugImplementation(libs.compose.ui.tooling)
|
||||
// endregion
|
||||
|
||||
|
||||
@@ -116,12 +116,14 @@ BEGIN:VEVENT
|
||||
DTSTAMP:20210820T083606Z
|
||||
UID:[email protected]
|
||||
SUMMARY:Test event
|
||||
DESCRIPTION:
|
||||
DESCRIPTION:Test event
|
||||
|
||||
ORGANIZER:mailto:[email protected]
|
||||
LOCATION:
|
||||
STATUS:CONFIRMED
|
||||
DTSTART;TZID=Europe/Berlin:20210806T090000
|
||||
DTEND:20210806T080000Z
|
||||
DTEND;TZID=Europe/Berlin:20210806T100000
|
||||
|
||||
BEGIN:VALARM
|
||||
TRIGGER:-PT30M
|
||||
ACTION:DISPLAY
|
||||
|
||||
@@ -2,22 +2,6 @@ Java:
|
||||
|
||||
```java
|
||||
private String getAppProcessName() {
|
||||
String processName = "";
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||
ActivityManager manager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
final int ownPid = android.os.Process.myPid();
|
||||
final List<ActivityManager.RunningAppProcessInfo> processes = manager.getRunningAppProcesses();
|
||||
if (processes != null) {
|
||||
for (ActivityManager.RunningAppProcessInfo info : processes) {
|
||||
if (info.pid == ownPid) {
|
||||
processName = info.processName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
processName = Application.getProcessName();
|
||||
}
|
||||
return processName;
|
||||
}
|
||||
return Application.getProcessName();
|
||||
}
|
||||
```
|
||||
@@ -8,10 +8,8 @@
|
||||
package com.nextcloud.client
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
@@ -25,88 +23,72 @@ import com.owncloud.android.lib.resources.activities.model.RichObject
|
||||
import com.owncloud.android.lib.resources.activities.models.PreviewObject
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.ui.activities.ActivitiesActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
class ActivitiesActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.ActivitiesActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun openDrawer() {
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
sut.dismissSnackbar()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "openDrawer", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.dismissSnackbar()
|
||||
}
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
val screenShotName = createName("${testClassName}_openDrawer", "")
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
|
||||
onView(withId(R.id.drawer_layout)).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun loading() {
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.dismissSnackbar()
|
||||
sut.binding.emptyList.root.visibility = View.GONE
|
||||
sut.binding.swipeContainingList.visibility = View.GONE
|
||||
sut.binding.loadingContent.visibility = View.VISIBLE
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "loading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.dismissSnackbar()
|
||||
sut.binding.emptyList.root.visibility = View.GONE
|
||||
sut.binding.swipeContainingList.visibility = View.GONE
|
||||
sut.binding.loadingContent.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "loading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showActivities(mutableListOf(), nextcloudClient, -1)
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.showActivities(mutableListOf(), nextcloudClient, -1)
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@SuppressWarnings("MagicNumber")
|
||||
fun showActivities() {
|
||||
@@ -186,36 +168,35 @@ class ActivitiesActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showActivities(activities as List<Any>?, nextcloudClient, -1)
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "showActivities", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.showActivities(activities as List<Any>?, nextcloudClient, -1)
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showActivities", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<ActivitiesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.showEmptyContent("Error", "Error! Please try again later!")
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.showEmptyContent("Error", "Error! Please try again later!")
|
||||
sut.setProgressIndicatorState(false)
|
||||
sut.dismissSnackbar()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,15 @@
|
||||
*/
|
||||
package com.nextcloud.client
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.GrantStoragePermissionRule.Companion.grant
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.ui.activity.CommunityActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestRule
|
||||
@@ -29,30 +24,18 @@ import org.junit.rules.TestRule
|
||||
class CommunityActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.CommunityActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
var storagePermissionRule: TestRule = grant()
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<CommunityActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
package com.nextcloud.client
|
||||
|
||||
import android.Manifest
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.contrib.NavigationViewActions
|
||||
@@ -25,30 +23,18 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.fragment.EmptyListState
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.FileDisplayActivityScreenshotIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
companion object {
|
||||
@@ -56,31 +42,27 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
try {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.run {
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
resetScrolling(true)
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
}
|
||||
sut.run {
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
resetScrolling(true)
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
Log_OC.e(TAG, "Error caught at open $e")
|
||||
@@ -88,41 +70,35 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showMediaThenAllFiles() {
|
||||
try {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var activity: FileDisplayActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = sut.listOfFilesFragment
|
||||
Assert.assertNotNull(fragment)
|
||||
fragment!!.setFabEnabled(false)
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.nav_view))
|
||||
.perform(NavigationViewActions.navigateTo(R.id.nav_gallery))
|
||||
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
onView(ViewMatchers.withId(R.id.nav_view))
|
||||
.perform(NavigationViewActions.navigateTo(R.id.nav_all_files))
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
fragment.setFabEnabled(false)
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showMediaThenAllFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
activity = sut
|
||||
val fragment = sut.listOfFilesFragment
|
||||
Assert.assertNotNull(fragment)
|
||||
fragment!!.setFabEnabled(false)
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
}
|
||||
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
onView(ViewMatchers.withId(R.id.nav_view))
|
||||
.perform(NavigationViewActions.navigateTo(R.id.nav_gallery))
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
onView(ViewMatchers.withId(R.id.nav_view))
|
||||
.perform(NavigationViewActions.navigateTo(R.id.nav_all_files))
|
||||
|
||||
val fragment = activity!!.listOfFilesFragment
|
||||
fragment!!.setFabEnabled(false)
|
||||
fragment.setEmptyListMessage(EmptyListState.LOADING)
|
||||
fragment.isLoading = false
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showMediaThenAllFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
Log_OC.e(TAG, "Error caught at open $e")
|
||||
@@ -130,35 +106,31 @@ class FileDisplayActivityScreenshotIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun drawer() {
|
||||
try {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(ViewMatchers.withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
sut.run {
|
||||
hideInfoBox()
|
||||
resetScrolling(true)
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.run {
|
||||
hideInfoBox()
|
||||
resetScrolling(true)
|
||||
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
}
|
||||
listOfFilesFragment?.let {
|
||||
it.setFabEnabled(false)
|
||||
it.setEmptyListMessage(EmptyListState.LOADING)
|
||||
it.isLoading = false
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "drawer", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "drawer", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
} catch (e: SecurityException) {
|
||||
Log_OC.e(TAG, "Error caught at open $e")
|
||||
|
||||
@@ -8,45 +8,28 @@
|
||||
*/
|
||||
package com.nextcloud.client
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.client.onboarding.FirstRunActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class FirstRunActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.FirstRunActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<FirstRunActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,8 @@ package com.nextcloud.client
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Looper
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -23,11 +21,8 @@ import com.owncloud.android.datamodel.ArbitraryDataProviderImpl
|
||||
import com.owncloud.android.ui.activity.RequestCredentialsActivity
|
||||
import com.owncloud.android.ui.activity.SettingsActivity
|
||||
import com.owncloud.android.utils.EncryptionUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestRule
|
||||
@@ -36,53 +31,38 @@ import org.junit.rules.TestRule
|
||||
class SettingsActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.SettingsActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
var storagePermissionRule: TestRule = grant()
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showMnemonic_Error() {
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "showMnemonic_Error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
sut.handleMnemonicRequest(null)
|
||||
val screenShotName = createName(testClassName + "_" + "showMnemonic_Error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.handleMnemonicRequest(null)
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
@UiThread
|
||||
fun showMnemonic() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
@@ -96,14 +76,14 @@ class SettingsActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
sut.handleMnemonicRequest(intent)
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Looper.myLooper()?.quitSafely()
|
||||
Assert.assertTrue(true)
|
||||
}
|
||||
sut.handleMnemonicRequest(intent)
|
||||
}
|
||||
|
||||
Looper.myLooper()?.quitSafely()
|
||||
Assert.assertTrue(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,9 @@ package com.nextcloud.client
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Looper
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -24,46 +23,27 @@ import com.owncloud.android.datamodel.SyncedFolder
|
||||
import com.owncloud.android.datamodel.SyncedFolderDisplayItem
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity
|
||||
import com.owncloud.android.ui.dialog.SyncedFolderPreferencesDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SyncedFoldersActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.SyncedFoldersActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<SyncedFoldersActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.adapter.clear()
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.binding.emptyList.emptyListView, screenShotName)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
sut.adapter.clear()
|
||||
screenshotViaName(sut.binding.emptyList.emptyListView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testSyncedFolderDialog() {
|
||||
val item = SyncedFolderDisplayItem(
|
||||
@@ -86,26 +66,21 @@ class SyncedFoldersActivityIT : AbstractIT() {
|
||||
false,
|
||||
SyncedFolder.NOT_SCANNED_YET
|
||||
)
|
||||
val fragment = newInstance(item, 0)
|
||||
|
||||
val intent = Intent(targetContext, SyncedFoldersActivity::class.java)
|
||||
launchActivity<SyncedFoldersActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
fragment?.show(sut.supportFragmentManager, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "testSyncedFolderDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testSyncedFolderDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(fragment?.requireDialog()?.window?.decorView, screenShotName)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
val fragment = newInstance(item, 0)
|
||||
fragment!!.show(sut.supportFragmentManager, "")
|
||||
screenshot(fragment.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showPowerCheckDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -115,19 +90,15 @@ class SyncedFoldersActivityIT : AbstractIT() {
|
||||
val intent = Intent(targetContext, SyncedFoldersActivity::class.java)
|
||||
|
||||
launchActivity<SyncedFoldersActivity>(intent).use { scenario ->
|
||||
var dialog: AlertDialog? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val dialog = sut.buildPowerCheckDialog()
|
||||
sut.showPowerCheckDialog()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPowerCheckDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(dialog.window?.decorView, screenShotName)
|
||||
}
|
||||
dialog = sut.buildPowerCheckDialog()
|
||||
sut.showPowerCheckDialog()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPowerCheckDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(dialog!!.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2023 Álvaro Brey <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH
|
||||
* SPDX-FileCopyrightText: 2019 Tobias Kaminsky <[email protected]>
|
||||
@@ -9,23 +10,12 @@
|
||||
package com.nextcloud.client
|
||||
|
||||
import android.app.Application
|
||||
import android.app.Instrumentation
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.test.runner.AndroidJUnitRunner
|
||||
import com.github.tmurakami.dexopener.DexOpener
|
||||
import com.nextcloud.test.TestMainApp
|
||||
|
||||
class TestRunner : AndroidJUnitRunner() {
|
||||
@Throws(ClassNotFoundException::class, IllegalAccessException::class, InstantiationException::class)
|
||||
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application {
|
||||
/*
|
||||
* 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 Instrumentation.newApplication(TestMainApp::class.java, context)
|
||||
}
|
||||
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application =
|
||||
newApplication(TestMainApp::class.java, context)
|
||||
}
|
||||
@@ -8,10 +8,8 @@
|
||||
*/
|
||||
package com.nextcloud.client
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.DrawerActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
@@ -20,38 +18,23 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.ui.activity.UploadListActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class UploadListActivityActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.UploadListActivityActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun openDrawer() {
|
||||
launchActivity<UploadListActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "openDrawer", "")
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
val screenShotName = createName(testClassName + "_" + "openDrawer", "")
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-12
@@ -11,6 +11,7 @@ import com.nextcloud.client.assistant.repository.remote.AssistantRemoteRepositor
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -33,8 +34,10 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
return
|
||||
}
|
||||
|
||||
val result = sut?.getTaskTypes()
|
||||
assertTrue(result?.isNotEmpty() == true)
|
||||
runBlocking {
|
||||
val result = sut?.getTaskTypes()
|
||||
assertTrue(result?.isNotEmpty() == true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -45,8 +48,10 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
return
|
||||
}
|
||||
|
||||
val result = sut?.getTaskList("assistant")
|
||||
assertTrue(result?.isEmpty() == true || (result?.size ?: 0) > 0)
|
||||
runBlocking {
|
||||
val result = sut?.getTaskList("assistant")
|
||||
assertTrue(result?.isEmpty() == true || (result?.size ?: 0) > 0)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,8 +70,11 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
emptyMap(),
|
||||
emptyMap()
|
||||
)
|
||||
val result = sut?.createTask(input, taskType)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
|
||||
runBlocking {
|
||||
val result = sut?.createTask(input, taskType)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,14 +89,16 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
|
||||
|
||||
sleep(120)
|
||||
|
||||
val taskList = sut?.getTaskList("assistant")
|
||||
assertTrue(taskList != null)
|
||||
runBlocking {
|
||||
val taskList = sut?.getTaskList("assistant")
|
||||
assertTrue(taskList != null)
|
||||
|
||||
sleep(120)
|
||||
sleep(120)
|
||||
|
||||
assert((taskList?.size ?: 0) > 0)
|
||||
assert((taskList?.size ?: 0) > 0)
|
||||
|
||||
val result = sut?.deleteTask(taskList!!.first().id)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
val result = sut?.deleteTask(taskList!!.first().id)
|
||||
assertTrue(result?.isSuccess == true)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,63 +7,41 @@
|
||||
*/
|
||||
package com.nextcloud.client.etm
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class EtmActivityTest : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.client.etm.EtmActivityTest"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun overview() {
|
||||
launchActivity<EtmActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "overview", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "overview", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun accounts() {
|
||||
launchActivity<EtmActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.vm.onPageSelected(1)
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "accounts", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "accounts", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
sut.vm.onPageSelected(1)
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
package com.nextcloud.extensions
|
||||
import com.nextcloud.utils.extensions.isNotBlankAndEquals
|
||||
import com.nextcloud.utils.extensions.eTagChanged
|
||||
import junit.framework.TestCase.assertFalse
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Test
|
||||
@@ -17,160 +17,160 @@ class StringExtensionTests {
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreNull() {
|
||||
val str1: String? = null
|
||||
val str2: String? = null
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsNull() {
|
||||
val str1: String? = null
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsNull() {
|
||||
val str1 = "hello"
|
||||
val str2: String? = null
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreEmpty() {
|
||||
val str1 = ""
|
||||
val str2 = ""
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsEmpty() {
|
||||
val str1 = ""
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsEmpty() {
|
||||
val str1 = "hello"
|
||||
val str2 = ""
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreWhitespaceOnly() {
|
||||
val str1 = " "
|
||||
val str2 = " \t "
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenFirstStringIsWhitespaceOnly() {
|
||||
val str1 = " "
|
||||
val str2 = "hello"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenSecondStringIsWhitespaceOnly() {
|
||||
val str1 = "hello"
|
||||
val str2 = " "
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenStringsAreDifferentButBothValid() {
|
||||
val str1 = "hello"
|
||||
val str2 = "world"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenStringsHaveDifferentCase() {
|
||||
val str1 = "Hello"
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenMixedCaseStrings() {
|
||||
val str1 = "HeLLo WoRLd"
|
||||
val str2 = "hello world"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenUppercaseStrings() {
|
||||
val str1 = "HELLO"
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalAndValid() {
|
||||
val str1 = "hello"
|
||||
val str2 = "hello"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalWithSpaces() {
|
||||
val str1 = "hello world"
|
||||
val str2 = "hello world"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalSingleCharacter() {
|
||||
val str1 = "a"
|
||||
val str2 = "A"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothStringsAreIdenticalWithSpecialCharacters() {
|
||||
val str1 = "hello@world!123"
|
||||
val str2 = "HELLO@WORLD!123"
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneHasLeadingWhitespaceAndOtherDoesNot() {
|
||||
val str1 = " hello"
|
||||
val str2 = "HELLO"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneHasTrailingWhitespaceAndOtherDoesNot() {
|
||||
val str1 = "hello"
|
||||
val str2 = "HELLO "
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenBothHaveIdenticalWhitespacePaddingDifferentCase() {
|
||||
val str1 = " hello "
|
||||
val str2 = " HELLO "
|
||||
assertTrue(str1.isNotBlankAndEquals(str2))
|
||||
assertFalse(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenMixedWhitespaceCharacters() {
|
||||
val str1 = "\t"
|
||||
val str2 = "\n"
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneIsNullAndOtherIsEmpty() {
|
||||
val str1: String? = null
|
||||
val str2 = ""
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIsNotBlankAndEqualsWhenGivenOneIsNullAndOtherIsWhitespace() {
|
||||
val str1: String? = null
|
||||
val str2 = " "
|
||||
assertFalse(str1.isNotBlankAndEquals(str2))
|
||||
assertTrue(str1.eTagChanged(str2))
|
||||
}
|
||||
}
|
||||
@@ -11,10 +11,8 @@ package com.nextcloud.ui
|
||||
import android.graphics.BitmapFactory
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -22,58 +20,43 @@ import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class BitmapIT : AbstractIT() {
|
||||
private val testClassName = "com.nextcloud.ui.BitmapIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun roundBitmap() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val file = getFile("christine.jpg")
|
||||
val bitmap = BitmapFactory.decodeFile(file.absolutePath)
|
||||
val file = getFile("christine.jpg")
|
||||
val bitmap = BitmapFactory.decodeFile(file.absolutePath)
|
||||
|
||||
val imageView = ImageView(activity).apply {
|
||||
setImageBitmap(bitmap)
|
||||
}
|
||||
|
||||
val bitmap2 = BitmapFactory.decodeFile(file.absolutePath)
|
||||
val imageView2 = ImageView(activity).apply {
|
||||
setImageBitmap(BitmapUtils.roundBitmap(bitmap2))
|
||||
}
|
||||
|
||||
val linearLayout = LinearLayout(activity).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setBackgroundColor(context.getColor(R.color.grey_200))
|
||||
}
|
||||
linearLayout.addView(imageView, 200, 200)
|
||||
linearLayout.addView(imageView2, 200, 200)
|
||||
activity.addView(linearLayout)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "roundBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
val imageView = ImageView(activity).apply {
|
||||
setImageBitmap(bitmap)
|
||||
}
|
||||
|
||||
val bitmap2 = BitmapFactory.decodeFile(file.absolutePath)
|
||||
val imageView2 = ImageView(activity).apply {
|
||||
setImageBitmap(BitmapUtils.roundBitmap(bitmap2))
|
||||
}
|
||||
|
||||
val linearLayout = LinearLayout(activity).apply {
|
||||
orientation = LinearLayout.VERTICAL
|
||||
setBackgroundColor(context.getColor(R.color.grey_200))
|
||||
}
|
||||
linearLayout.addView(imageView, 200, 200)
|
||||
linearLayout.addView(imageView2, 200, 200)
|
||||
activity.addView(linearLayout)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "roundBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { activity ->
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,48 +8,43 @@
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import android.Manifest
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class SetOnlineStatusBottomSheetIT : AbstractIT() {
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun open() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
onView(withId(R.id.clearStatusAfterSpinner))
|
||||
.check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { activity ->
|
||||
val sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,60 +8,49 @@
|
||||
*/
|
||||
package com.nextcloud.ui
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import android.Manifest
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.users.ClearAt
|
||||
import com.owncloud.android.lib.resources.users.PredefinedStatus
|
||||
import com.owncloud.android.lib.resources.users.Status
|
||||
import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class SetStatusMessageBottomSheetIT : AbstractIT() {
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun open() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetStatusMessageBottomSheet(
|
||||
user,
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
val predefinedStatus: ArrayList<PredefinedStatus> = arrayListOf(
|
||||
PredefinedStatus("meeting", "📅", "In a meeting", ClearAt("period", "3600")),
|
||||
PredefinedStatus("commuting", "🚌", "Commuting", ClearAt("period", "1800")),
|
||||
PredefinedStatus("be-right-back", "⏳", "Be right back", ClearAt("period", "900")),
|
||||
PredefinedStatus("remote-work", "🏡", "Working remotely", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("sick-leave", "🤒", "Out sick", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("vacationing", "🌴", "Vacationing", null)
|
||||
)
|
||||
sut.setPredefinedStatus(predefinedStatus)
|
||||
EspressoIdlingResource.decrement()
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
scenario.onActivity { activity ->
|
||||
val sut = SetStatusMessageBottomSheet(
|
||||
user,
|
||||
Status(StatusType.DND, "Working hard…", "🤖", -1)
|
||||
)
|
||||
sut.show(activity.supportFragmentManager, "")
|
||||
val predefinedStatus: ArrayList<PredefinedStatus> = arrayListOf(
|
||||
PredefinedStatus("meeting", "📅", "In a meeting", ClearAt("period", "3600")),
|
||||
PredefinedStatus("commuting", "🚌", "Commuting", ClearAt("period", "1800")),
|
||||
PredefinedStatus("be-right-back", "⏳", "Be right back", ClearAt("period", "900")),
|
||||
PredefinedStatus("remote-work", "🏡", "Working remotely", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("sick-leave", "🤒", "Out sick", ClearAt("end-of", "day")),
|
||||
PredefinedStatus("vacationing", "🌴", "Vacationing", null)
|
||||
)
|
||||
sut.setPredefinedStatus(predefinedStatus)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
*/
|
||||
package com.nmc.android.ui
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
||||
@@ -18,60 +16,37 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class LauncherActivityIT : AbstractIT() {
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun testSplashScreenWithEmptyTitlesShouldHideTitles() {
|
||||
launchActivity<LauncherActivity>().use { scenario ->
|
||||
scenario.onActivity { _ ->
|
||||
onIdleSync {
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
onView(
|
||||
withId(R.id.splashScreenBold)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
onView(
|
||||
withId(R.id.splashScreenNormal)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
}
|
||||
}
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
onView(
|
||||
withId(R.id.splashScreenBold)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
onView(
|
||||
withId(R.id.splashScreenNormal)
|
||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun testSplashScreenWithTitlesShouldShowTitles() {
|
||||
launchActivity<LauncherActivity>().use { scenario ->
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
|
||||
scenario.onActivity {
|
||||
onIdleSync {
|
||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
it.setSplashTitles("Example", "Cloud")
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val onePercentArea = ViewMatchers.isDisplayingAtLeast(1)
|
||||
onView(withId(R.id.splashScreenBold)).check(matches(onePercentArea))
|
||||
onView(withId(R.id.splashScreenNormal)).check(matches(onePercentArea))
|
||||
}
|
||||
it.setSplashTitles("Example", "Cloud")
|
||||
}
|
||||
|
||||
val onePercentArea = ViewMatchers.isDisplayingAtLeast(1)
|
||||
onView(withId(R.id.splashScreenBold)).check(matches(onePercentArea))
|
||||
onView(withId(R.id.splashScreenNormal)).check(matches(onePercentArea))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ 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;
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
*/
|
||||
package com.owncloud.android
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import android.Manifest
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.action.ViewActions.scrollTo
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
@@ -19,17 +18,16 @@ import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.activity.SettingsActivity
|
||||
import com.owncloud.android.ui.activity.SyncedFoldersActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.ClassRule
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import tools.fastlane.screengrab.Screengrab
|
||||
import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy
|
||||
@@ -37,135 +35,91 @@ import tools.fastlane.screengrab.locale.LocaleTestRule
|
||||
|
||||
class ScreenshotsIT : AbstractIT() {
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun gridViewScreenshot() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withId(R.id.switch_grid_view_button)).perform(click())
|
||||
EspressoIdlingResource.decrement()
|
||||
launchActivity<FileDisplayActivity>().use {
|
||||
onView(withId(R.id.switch_grid_view_button)).perform(click())
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("01_gridView")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("01_gridView")
|
||||
|
||||
// Switch back
|
||||
onView(withId(R.id.switch_grid_view_button)).perform(click())
|
||||
// Switch back
|
||||
onView(withId(R.id.switch_grid_view_button)).perform(click())
|
||||
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun listViewScreenshot() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val path = "/Camera/"
|
||||
OCFile(path).apply {
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
onView(withId(R.id.list_root)).perform(click())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("02_listView")
|
||||
assertTrue(true)
|
||||
}
|
||||
launchActivity<FileDisplayActivity>().use {
|
||||
val path = "/Camera/"
|
||||
OCFile(path).apply {
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
onView(withId(R.id.list_root)).perform(click())
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("02_listView")
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun drawerScreenshot() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
EspressoIdlingResource.decrement()
|
||||
launchActivity<FileDisplayActivity>().use {
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open())
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("03_drawer")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("03_drawer")
|
||||
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close())
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
onView(withId(R.id.drawer_layout)).perform(DrawerActions.close())
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun multipleAccountsScreenshot() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withId(R.id.switch_account_button)).perform(click())
|
||||
EspressoIdlingResource.decrement()
|
||||
launchActivity<FileDisplayActivity>().use {
|
||||
onView(withId(R.id.switch_account_button)).perform(click())
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("04_accounts")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("04_accounts")
|
||||
|
||||
Espresso.pressBack()
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
Espresso.pressBack()
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun autoUploadScreenshot() {
|
||||
launchActivity<SyncedFoldersActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("05_autoUpload")
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
launchActivity<SyncedFoldersActivity>().use {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("05_autoUpload")
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun davdroidScreenshot() {
|
||||
launchActivity<SettingsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
onView(withText(R.string.prefs_category_more)).perform(scrollTo())
|
||||
EspressoIdlingResource.decrement()
|
||||
launchActivity<SettingsActivity>().use {
|
||||
onView(withText(R.string.prefs_category_more)).perform(scrollTo())
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("06_davdroid")
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
Screengrab.screenshot("06_davdroid")
|
||||
assertTrue(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ package com.owncloud.android.datamodel
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SdkSuppress
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -60,20 +58,4 @@ class ContentResolverHelperIT {
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
@SdkSuppress(maxSdkVersion = Build.VERSION_CODES.N_MR1)
|
||||
fun contentResolver_onAndroidBelow26_usesOldAPI() {
|
||||
ContentResolverHelper
|
||||
.queryResolver(resolver, URI, PROJECTION, SELECTION, null, SORT_COLUMN, SORT_DIRECTION, LIMIT)
|
||||
|
||||
verify(resolver).query(
|
||||
eq(URI),
|
||||
eq(PROJECTION),
|
||||
eq(SELECTION),
|
||||
eq(null),
|
||||
eq("$SORT_COLUMN $SORT_DIRECTION LIMIT $LIMIT"),
|
||||
eq(null)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.owncloud.android.extensions
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
|
||||
inline fun <reified T : Activity> AbstractIT.launchAndCapture(
|
||||
testClassName: String,
|
||||
actionName: String,
|
||||
intent: Intent? = null,
|
||||
crossinline before: (T) -> Unit
|
||||
) {
|
||||
launchActivity<T>(intent).use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
before(activity)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenshotName = createName(testClassName + "_" + actionName, "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenshotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.owncloud.android.providers
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.ContentUris
|
||||
import android.net.Uri
|
||||
import androidx.sqlite.db.SimpleSQLiteQuery
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import com.owncloud.android.db.ProviderMeta
|
||||
import io.mockk.Runs
|
||||
import io.mockk.every
|
||||
import io.mockk.just
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
class FileContentProviderTests {
|
||||
|
||||
private lateinit var provider: FileContentProvider
|
||||
private lateinit var db: SupportSQLiteDatabase
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
provider = FileContentProvider()
|
||||
db = mockk()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun insertNewFileShouldReturnNewId() {
|
||||
val values = ContentValues().apply {
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_PATH, "/path/to/file.txt")
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_ACCOUNT_OWNER, "[email protected]")
|
||||
}
|
||||
|
||||
// Mock insert to return new ID
|
||||
every { db.insert(any(), any(), any()) } returns 42L
|
||||
|
||||
val result: Uri = provider.upsertSingleFile(
|
||||
db,
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE,
|
||||
values
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
ContentUris.withAppendedId(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, 42),
|
||||
result
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateExistingFileShouldReturnSameId() {
|
||||
val values = ContentValues().apply {
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_PATH, "/path/to/file.txt")
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_ACCOUNT_OWNER, "[email protected]")
|
||||
}
|
||||
|
||||
// Simulate insert conflict
|
||||
every { db.insert(ProviderMeta.ProviderTableMeta.FILE_TABLE_NAME, any(), values) } returns -1L
|
||||
|
||||
// Simulate update returning 1 row affected
|
||||
every {
|
||||
db.update(
|
||||
ProviderMeta.ProviderTableMeta.FILE_TABLE_NAME,
|
||||
any(),
|
||||
values,
|
||||
any(),
|
||||
any()
|
||||
)
|
||||
} returns 1
|
||||
|
||||
// Mock cursor to return ID 99
|
||||
val cursor = mockk<android.database.Cursor>()
|
||||
every { cursor.moveToFirst() } returns true
|
||||
every { cursor.getLong(0) } returns 99L
|
||||
every { cursor.close() } just Runs
|
||||
|
||||
every { db.query(any<SimpleSQLiteQuery>()) } returns cursor
|
||||
|
||||
val result: Uri = provider.upsertSingleFile(
|
||||
db,
|
||||
ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE,
|
||||
values
|
||||
)
|
||||
|
||||
assertEquals(ContentUris.withAppendedId(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, 99), result)
|
||||
|
||||
cursor.close()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConcurrentUpserts() = runBlocking {
|
||||
val values = ContentValues().apply {
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_PATH, "/path/to/file.txt")
|
||||
put(ProviderMeta.ProviderTableMeta.FILE_ACCOUNT_OWNER, "[email protected]")
|
||||
}
|
||||
|
||||
// shared state to simulate race
|
||||
val inserted = mutableListOf<Long>()
|
||||
|
||||
// mock insert: fail first call, succeed second
|
||||
every { db.insert(any(), any(), any()) } answers {
|
||||
synchronized(inserted) {
|
||||
if (inserted.isEmpty()) {
|
||||
// first thread "fails" insert which means already existing file id will be returned
|
||||
inserted.add(-1L)
|
||||
-1L
|
||||
} else {
|
||||
// second thread "succeeds" it will update existing one
|
||||
inserted.add(42L)
|
||||
42L
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mock update only one row should be affected
|
||||
every { db.update(any(), any(), any(), any(), any()) } returns 1
|
||||
|
||||
// mock query existing file id will return 99
|
||||
val cursor = mockk<android.database.Cursor>()
|
||||
every { cursor.moveToFirst() } returns true
|
||||
every { cursor.getLong(0) } returns 99L
|
||||
every { cursor.close() } just Runs
|
||||
every { db.query(any<SimpleSQLiteQuery>()) } returns cursor
|
||||
|
||||
// launch two coroutines simulating concurrent threads
|
||||
val results = mutableListOf<Uri>()
|
||||
coroutineScope {
|
||||
val job1 =
|
||||
async {
|
||||
results.add(provider.upsertSingleFile(db, ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, values))
|
||||
}
|
||||
val job2 =
|
||||
async {
|
||||
results.add(provider.upsertSingleFile(db, ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, values))
|
||||
}
|
||||
awaitAll(job1, job2)
|
||||
}
|
||||
|
||||
// both URIs should be correct (one updated, one inserted)
|
||||
assertTrue(results.contains(ContentUris.withAppendedId(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, 99)))
|
||||
assertTrue(results.contains(ContentUris.withAppendedId(ProviderMeta.ProviderTableMeta.CONTENT_URI_FILE, 42)))
|
||||
|
||||
cursor.close()
|
||||
}
|
||||
}
|
||||
+3
-10
@@ -7,26 +7,19 @@
|
||||
*/
|
||||
package com.owncloud.android.providers
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractOnServerIT
|
||||
import org.junit.Test
|
||||
|
||||
class UsersAndGroupsSearchProviderIT : AbstractOnServerIT() {
|
||||
class UsersAndGroupsSearchProviderIT {
|
||||
@Test
|
||||
@UiThread
|
||||
fun searchUser() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
launchActivity<TestActivity>().use {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
+71
-87
@@ -9,7 +9,6 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
@@ -18,6 +17,7 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
import com.nextcloud.utils.extensions.getDecryptedPath
|
||||
import com.owncloud.android.AbstractIT
|
||||
@@ -25,6 +25,7 @@ import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.db.OCUpload
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Decision
|
||||
import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionMadeListener
|
||||
@@ -42,7 +43,6 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
private var returnCode = false
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun screenshotTextFiles() {
|
||||
val newFile = OCFile("/newFile.txt").apply {
|
||||
@@ -67,33 +67,33 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var dialog: ConflictsResolveDialog? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
dialog = newInstance(
|
||||
storageManager.getDecryptedPath(existingFile),
|
||||
targetContext,
|
||||
newFile,
|
||||
existingFile,
|
||||
UserAccountManagerImpl
|
||||
.fromContext(targetContext)
|
||||
.getUser()
|
||||
)
|
||||
dialog.showDialog(sut)
|
||||
}
|
||||
|
||||
val dialog = newInstance(
|
||||
storageManager.getDecryptedPath(existingFile),
|
||||
targetContext,
|
||||
newFile,
|
||||
existingFile,
|
||||
UserAccountManagerImpl
|
||||
.fromContext(targetContext)
|
||||
.getUser()
|
||||
)
|
||||
dialog.showDialog(sut)
|
||||
onView(withId(R.id.headline))
|
||||
.check(matches(isDisplayed()))
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "screenshotTextFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "screenshotTextFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(dialog.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(dialog!!.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun cancel() {
|
||||
val newUpload = OCUpload(
|
||||
FileStorageUtils.getSavePath(user.accountName) + "/nonEmpty.txt",
|
||||
@@ -126,24 +126,19 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
returnCode = false
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.CANCEL)
|
||||
returnCode = true
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withText("Cancel")).perform(ViewActions.click())
|
||||
TestCase.assertTrue(returnCode)
|
||||
returnCode = false
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.CANCEL)
|
||||
returnCode = true
|
||||
}
|
||||
}
|
||||
|
||||
onView(ViewMatchers.withText("Cancel")).perform(ViewActions.click())
|
||||
TestCase.assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun keepExisting() {
|
||||
returnCode = false
|
||||
@@ -180,30 +175,29 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var activity: ConflictsResolveActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_SERVER)
|
||||
returnCode = true
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.right_checkbox)).perform(ViewActions.click())
|
||||
val dialog = sut.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepExisting", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
activity = sut
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_SERVER)
|
||||
returnCode = true
|
||||
}
|
||||
}
|
||||
|
||||
onView(withId(R.id.right_checkbox)).perform(ViewActions.click())
|
||||
|
||||
val dialog = activity!!.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepExisting", "")
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun keepNew() {
|
||||
returnCode = false
|
||||
@@ -235,31 +229,26 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
intent.putExtra(ConflictsResolveActivity.EXTRA_CONFLICT_UPLOAD_ID, newUpload.uploadId)
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var activity: ConflictsResolveActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_LOCAL)
|
||||
returnCode = true
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
val dialog = sut.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepNew", "")
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
activity = sut
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_LOCAL)
|
||||
returnCode = true
|
||||
}
|
||||
}
|
||||
|
||||
onView(withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
val dialog = activity!!.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepNew", "")
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun keepBoth() {
|
||||
returnCode = false
|
||||
@@ -293,29 +282,24 @@ class ConflictsResolveActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<ConflictsResolveActivity>(intent).use { scenario ->
|
||||
var activity: ConflictsResolveActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_BOTH)
|
||||
returnCode = true
|
||||
}
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.right_checkbox)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
val dialog = sut.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepBoth", "")
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
activity = sut
|
||||
sut.listener = OnConflictDecisionMadeListener { decision: Decision? ->
|
||||
assertEquals(decision, Decision.KEEP_BOTH)
|
||||
returnCode = true
|
||||
}
|
||||
}
|
||||
|
||||
onView(withId(R.id.right_checkbox)).perform(ViewActions.click())
|
||||
onView(withId(R.id.left_checkbox)).perform(ViewActions.click())
|
||||
|
||||
val dialog = activity!!.supportFragmentManager.findFragmentByTag("conflictDialog") as DialogFragment?
|
||||
val screenShotName = createName(testClassName + "_" + "keepBoth", "")
|
||||
screenshotViaName(dialog?.requireDialog()?.window?.decorView, screenShotName)
|
||||
|
||||
onView(ViewMatchers.withText("OK")).perform(ViewActions.click())
|
||||
assertTrue(returnCode)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-27
@@ -8,37 +8,21 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class ContactsPreferenceActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.ContactsPreferenceActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun openVCF() {
|
||||
val file = getFile("vcard.vcf")
|
||||
@@ -53,27 +37,24 @@ class ContactsPreferenceActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<ContactsPreferenceActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "openVCF", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "openVCF", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun openContactsPreference() {
|
||||
launchActivity<ContactsPreferenceActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "openContactsPreference", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "openContactsPreference", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.Manifest
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.net.Uri
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.nextcloud.client.account.User
|
||||
import com.nextcloud.client.account.UserAccountManager
|
||||
import com.nextcloud.client.account.UserAccountManagerImpl
|
||||
@@ -26,7 +26,6 @@ import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.hamcrest.Matchers
|
||||
import org.junit.Assert
|
||||
import org.junit.BeforeClass
|
||||
@@ -39,32 +38,36 @@ class DrawerActivityIT : AbstractIT() {
|
||||
@JvmField
|
||||
val retryTestRule = RetryTestRule()
|
||||
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun switchAccountViaAccountList() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.setUser(user1)
|
||||
|
||||
Assert.assertEquals(account1, sut.user.get().toPlatformAccount())
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(
|
||||
Matchers.anyOf<View?>(
|
||||
ViewMatchers.withText(account2Name),
|
||||
ViewMatchers.withText(
|
||||
account2DisplayName
|
||||
)
|
||||
)
|
||||
).perform(ViewActions.click())
|
||||
Assert.assertEquals(account2, sut.user.get().toPlatformAccount())
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withText(account1?.name)).perform(ViewActions.click())
|
||||
}
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
}
|
||||
|
||||
Assert.assertEquals(account1, sut!!.user.get().toPlatformAccount())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(
|
||||
Matchers.anyOf(
|
||||
ViewMatchers.withText(account2Name),
|
||||
ViewMatchers.withText(
|
||||
account2DisplayName
|
||||
)
|
||||
)
|
||||
).perform(ViewActions.click())
|
||||
|
||||
Assert.assertEquals(account2, sut.user.get().toPlatformAccount())
|
||||
|
||||
onView(ViewMatchers.withId(R.id.switch_account_button)).perform(ViewActions.click())
|
||||
onView(ViewMatchers.withText(account1?.name)).perform(ViewActions.click())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+74
-114
@@ -10,10 +10,8 @@ package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -21,11 +19,8 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@@ -33,167 +28,133 @@ import org.junit.runner.RunWith
|
||||
class FolderPickerActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.FolderPickerActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun getActivityFile() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val origin = OCFile("/test/file.test").apply {
|
||||
remotePath = "/remotePath/test"
|
||||
}
|
||||
|
||||
// Act
|
||||
sut.file = origin
|
||||
val target = sut.file
|
||||
|
||||
// Assert
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
val origin = OCFile("/test/file.test").apply {
|
||||
remotePath = "/remotePath/test"
|
||||
}
|
||||
|
||||
var target: OCFile? = null
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.file = origin
|
||||
target = sut.file
|
||||
}
|
||||
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun getParentFolder_isNotRootFolder() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
// Arrange
|
||||
val origin = OCFile("/test/").apply {
|
||||
fileId = 1
|
||||
remotePath = "/test/"
|
||||
setStoragePath("/test/")
|
||||
setFolder()
|
||||
}
|
||||
|
||||
// Act
|
||||
sut.file = origin
|
||||
val target = sut.currentFolder
|
||||
|
||||
// Assert
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
val origin = OCFile("/test/").apply {
|
||||
fileId = 1
|
||||
remotePath = "/test/"
|
||||
setStoragePath("/test/")
|
||||
setFolder()
|
||||
}
|
||||
|
||||
var target: OCFile? = null
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.file = origin
|
||||
target = sut.currentFolder
|
||||
}
|
||||
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun getParentFolder_isRootFolder() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
// Arrange
|
||||
val origin = OCFile("/").apply {
|
||||
fileId = 1
|
||||
remotePath = "/"
|
||||
setStoragePath("/")
|
||||
setFolder()
|
||||
}
|
||||
|
||||
// Act
|
||||
sut.file = origin
|
||||
val target = sut.currentFolder
|
||||
|
||||
// Assert
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
val origin = OCFile("/").apply {
|
||||
fileId = 1
|
||||
remotePath = "/"
|
||||
setStoragePath("/")
|
||||
setFolder()
|
||||
}
|
||||
|
||||
var target: OCFile? = null
|
||||
scenario.onActivity { sut ->
|
||||
sut.file = origin
|
||||
target = sut.currentFolder
|
||||
}
|
||||
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Test
|
||||
@UiThread
|
||||
fun nullFile() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
var rootFolder: OCFile? = null
|
||||
var target: OCFile? = null
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
// Arrange
|
||||
val rootFolder = sut.storageManager.getFileByPath(OCFile.ROOT_PATH)
|
||||
|
||||
// Act
|
||||
sut.file = null
|
||||
val target = sut.currentFolder
|
||||
|
||||
// Assert
|
||||
assertEquals(rootFolder, target)
|
||||
}
|
||||
rootFolder = sut.storageManager.getFileByPath(OCFile.ROOT_PATH)
|
||||
sut.file = null
|
||||
target = sut.currentFolder
|
||||
}
|
||||
|
||||
assertEquals(rootFolder, target)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun getParentFolder() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
// Arrange
|
||||
val origin = OCFile("/test/file.test").apply {
|
||||
remotePath = "/test/file.test"
|
||||
}
|
||||
|
||||
val target = OCFile("/test/")
|
||||
|
||||
// Act
|
||||
sut.file = origin
|
||||
|
||||
// Assert
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
val origin = OCFile("/test/file.test").apply {
|
||||
remotePath = "/test/file.test"
|
||||
}
|
||||
|
||||
val target = OCFile("/test/")
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
sut.file = origin
|
||||
}
|
||||
|
||||
assertEquals(origin, target)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<FolderPickerActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val origin = OCFile("/test/file.txt")
|
||||
sut.file = origin
|
||||
sut.findViewById<View>(R.id.folder_picker_btn_copy).requestFocus()
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
val origin = OCFile("/test/file.txt")
|
||||
sut.file = origin
|
||||
sut.findViewById<View>(R.id.folder_picker_btn_copy).requestFocus()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testMoveOrCopy() {
|
||||
val intent = Intent(targetContext, FolderPickerActivity::class.java)
|
||||
launchActivity<FolderPickerActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "testMoveOrCopy", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "testMoveOrCopy", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testChooseLocationAction() {
|
||||
val intent = Intent(targetContext, FolderPickerActivity::class.java).apply {
|
||||
@@ -201,12 +162,11 @@ class FolderPickerActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<FolderPickerActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "testChooseLocationAction", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "testChooseLocationAction", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-45
@@ -8,81 +8,59 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.common.Quota
|
||||
import com.owncloud.android.lib.common.UserInfo
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class ManageAccountsActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.ManageAccountsActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<ManageAccountsActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun userInfoDetail() {
|
||||
launchActivity<ManageAccountsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val user = sut.accountManager.user
|
||||
val userInfo = UserInfo(
|
||||
"test",
|
||||
true,
|
||||
"Test User",
|
||||
"[email protected]",
|
||||
"+49 123 456",
|
||||
"Address 123, Berlin",
|
||||
"https://www.nextcloud.com",
|
||||
"https://twitter.com/Nextclouders",
|
||||
Quota(),
|
||||
ArrayList()
|
||||
)
|
||||
sut.showUser(user, userInfo)
|
||||
}
|
||||
|
||||
val user = sut.accountManager.user
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
val userInfo = UserInfo(
|
||||
"test",
|
||||
true,
|
||||
"Test User",
|
||||
"[email protected]",
|
||||
"+49 123 456",
|
||||
"Address 123, Berlin",
|
||||
"https://www.nextcloud.com",
|
||||
"https://twitter.com/Nextclouders",
|
||||
Quota(),
|
||||
ArrayList()
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
sut.showUser(user, userInfo)
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(getCurrentActivity(), screenShotName)
|
||||
}
|
||||
scenario.onActivity {
|
||||
screenshotViaName(getCurrentActivity(), screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-42
@@ -7,57 +7,40 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.resources.notifications.models.Action
|
||||
import com.owncloud.android.lib.resources.notifications.models.Notification
|
||||
import com.owncloud.android.lib.resources.notifications.models.RichObject
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
class NotificationsActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.NotificationsActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.populateList(ArrayList())
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.populateList(ArrayList())
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@SuppressWarnings("MagicNumber")
|
||||
fun showNotifications() {
|
||||
@@ -141,32 +124,31 @@ class NotificationsActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.populateList(notifications)
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "showNotifications", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.populateList(notifications)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotifications", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<NotificationsActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.setEmptyContent("Error", "Error! Please try again later!")
|
||||
EspressoIdlingResource.decrement()
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.setEmptyContent("Error", "Error! Please try again later!")
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,36 +9,20 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class PassCodeActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.PassCodeActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun check() {
|
||||
val intent = Intent(targetContext, PassCodeActivity::class.java).apply {
|
||||
@@ -47,22 +31,21 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<PassCodeActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.binding.txt0.clearFocus()
|
||||
Espresso.closeSoftKeyboard()
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.binding.txt0.clearFocus()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "check", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
Espresso.closeSoftKeyboard()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "check", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun request() {
|
||||
val intent = Intent(targetContext, PassCodeActivity::class.java).apply {
|
||||
@@ -71,22 +54,21 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<PassCodeActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.binding.txt0.clearFocus()
|
||||
Espresso.closeSoftKeyboard()
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.binding.txt0.clearFocus()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "request", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
Espresso.closeSoftKeyboard()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "request", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun delete() {
|
||||
val intent = Intent(targetContext, PassCodeActivity::class.java).apply {
|
||||
@@ -95,16 +77,16 @@ class PassCodeActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<PassCodeActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.binding.txt0.clearFocus()
|
||||
Espresso.closeSoftKeyboard()
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.binding.txt0.clearFocus()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "delete", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
Espresso.closeSoftKeyboard()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "delete", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-21
@@ -8,44 +8,27 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class ReceiveExternalFilesActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.ReceiveExternalFilesActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun open() {
|
||||
launchActivity<ReceiveExternalFilesActivity>().use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "open", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+53
-83
@@ -9,16 +9,13 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.GrantStoragePermissionRule.Companion.grant
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.FileStorageUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
@@ -47,46 +44,31 @@ class UploadFilesActivityIT : AbstractIT() {
|
||||
directories.forEach { it.deleteRecursively() }
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun noneSelected() {
|
||||
launchActivity<UploadFilesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
val screenShotName = createName(testClassName + "_" + "noneSelected", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "noneSelected", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.fileListFragment.binding?.listRoot, screenShotName)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut.fileListFragment.binding?.listRoot, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun localFolderPickerMode() {
|
||||
val intent = Intent(targetContext, UploadFilesActivity::class.java).apply {
|
||||
@@ -102,77 +84,65 @@ class UploadFilesActivityIT : AbstractIT() {
|
||||
|
||||
launchActivity<UploadFilesActivity>(intent).use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.fileListFragment.setFiles(
|
||||
directories
|
||||
)
|
||||
}
|
||||
|
||||
sut.fileListFragment.setFiles(
|
||||
directories
|
||||
)
|
||||
val screenShotName = createName(testClassName + "_" + "localFolderPickerMode", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "localFolderPickerMode", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun search() {
|
||||
launchActivity<UploadFilesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.fileListFragment.performSearch("1.txt", arrayListOf(), false)
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "search", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun selectAll() {
|
||||
launchActivity<UploadFilesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
sut.fileListFragment.setFiles(
|
||||
sut.fileListFragment.performSearch("1.txt", arrayListOf(), false)
|
||||
sut.fileListFragment.setFiles(
|
||||
directories +
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "search", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
fun selectAll() {
|
||||
launchActivity<UploadFilesActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
sut.fileListFragment.setFiles(
|
||||
listOf(
|
||||
File("1.txt"),
|
||||
File("2.pdf"),
|
||||
File("3.mp3")
|
||||
)
|
||||
)
|
||||
sut.fileListFragment.selectAllFiles(true)
|
||||
}
|
||||
|
||||
sut.fileListFragment.selectAllFiles(true)
|
||||
val screenShotName = createName(testClassName + "_" + "selectAll", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "selectAll", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.fileListFragment.binding?.listRoot, screenShotName)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut.fileListFragment.binding?.listRoot, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,36 +8,20 @@
|
||||
package com.owncloud.android.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.lib.common.UserInfo
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class UserInfoActivityIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.activity.UserInfoActivityIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun fullUserInfoDetail() {
|
||||
val intent = Intent(targetContext, UserInfoActivity::class.java).apply {
|
||||
@@ -59,12 +43,11 @@ class UserInfoActivityIT : AbstractIT() {
|
||||
}
|
||||
|
||||
launchActivity<UserInfoActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "fullUserInfoDetail", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "fullUserInfoDetail", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import android.Manifest
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.app.Dialog
|
||||
@@ -19,15 +20,14 @@ import android.view.ViewGroup
|
||||
import android.webkit.SslErrorHandler
|
||||
import android.widget.TextView
|
||||
import androidx.activity.result.contract.ActivityResultContract
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
@@ -38,6 +38,7 @@ import com.nextcloud.client.account.RegisteredUser
|
||||
import com.nextcloud.client.account.Server
|
||||
import com.nextcloud.client.device.DeviceInfo
|
||||
import com.nextcloud.client.documentscan.AppScanOptionalFeature
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment
|
||||
import com.nextcloud.ui.ChooseAccountDialogFragment.Companion.newInstance
|
||||
import com.nextcloud.ui.SetOnlineStatusBottomSheet
|
||||
import com.nextcloud.ui.fileactions.FileActionsBottomSheet.Companion.newInstance
|
||||
@@ -66,18 +67,16 @@ import com.owncloud.android.ui.dialog.LoadingDialog.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.RenameFileDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.SharePasswordDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.Companion.newInstanceForEmptySslError
|
||||
import com.owncloud.android.ui.dialog.StoragePermissionDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetActions
|
||||
import com.owncloud.android.ui.fragment.OCFileListBottomSheetDialog
|
||||
import com.owncloud.android.ui.fragment.ProfileBottomSheetDialog
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import com.owncloud.android.utils.theme.CapabilityUtils
|
||||
import com.owncloud.android.utils.theme.ViewThemeUtils
|
||||
import io.mockk.mockk
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.net.URI
|
||||
import java.util.function.Supplier
|
||||
@@ -87,15 +86,11 @@ class DialogFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.DialogFragmentIT"
|
||||
private val serverUrl = "https://nextcloud.localhost"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
@After
|
||||
fun quitLooperIfNeeded() {
|
||||
@@ -103,7 +98,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRenameFileDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -119,7 +113,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testLoadingDialog() {
|
||||
newInstance("Wait…").run {
|
||||
@@ -128,14 +121,13 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithOneAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.string.common_ok,
|
||||
R.drawable.ic_warning,
|
||||
-1,
|
||||
-1,
|
||||
-1
|
||||
@@ -145,14 +137,13 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithTwoAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.string.common_ok,
|
||||
R.drawable.ic_warning,
|
||||
R.string.common_cancel,
|
||||
-1,
|
||||
-1
|
||||
@@ -162,14 +153,13 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithThreeAction() {
|
||||
ConfirmationDialogFragment.newInstance(
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
R.string.filedetails_sync_file,
|
||||
R.string.common_ok,
|
||||
R.drawable.ic_warning,
|
||||
R.string.common_cancel,
|
||||
R.string.common_confirm,
|
||||
-1
|
||||
@@ -179,7 +169,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testConfirmationDialogWithThreeActionRTL() {
|
||||
enableRTL()
|
||||
@@ -187,7 +176,7 @@ class DialogFragmentIT : AbstractIT() {
|
||||
R.string.upload_list_empty_text_auto_upload,
|
||||
arrayOf(),
|
||||
-1,
|
||||
R.string.common_ok,
|
||||
R.drawable.ic_warning,
|
||||
R.string.common_cancel,
|
||||
R.string.common_confirm,
|
||||
-1
|
||||
@@ -198,7 +187,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFileDialog() {
|
||||
RemoveFilesDialogFragment.newInstance(OCFile("/Test.md")).run {
|
||||
@@ -207,7 +195,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFilesDialog() {
|
||||
val toDelete = ArrayList<OCFile>().apply {
|
||||
@@ -220,7 +207,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFolderDialog() {
|
||||
val dialog = RemoveFilesDialogFragment.newInstance(OCFile("/Folder/"))
|
||||
@@ -228,7 +214,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testRemoveFoldersDialog() {
|
||||
val toDelete = ArrayList<OCFile>()
|
||||
@@ -240,7 +225,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testNewFolderDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -251,7 +235,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testEnforcedPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -262,7 +245,6 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testOptionalPasswordDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -273,13 +255,13 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testAccountChooserDialog() {
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
ActivityScenario.launch<FileDisplayActivity>(intent).use { scenario ->
|
||||
var sut: ChooseAccountDialogFragment? = null
|
||||
|
||||
scenario.onActivity { activity: FileDisplayActivity ->
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val userAccountManager = activity.userAccountManager
|
||||
val accountManager = AccountManager.get(targetContext)
|
||||
@@ -322,73 +304,74 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
fileDataStorageManager.saveCapabilities(capability)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
sut = newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(URI.create(serverUrl), OwnCloudVersion.nextcloud_20)
|
||||
)
|
||||
)
|
||||
|
||||
try {
|
||||
onIdleSync {
|
||||
val sut = newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(URI.create(serverUrl), OwnCloudVersion.nextcloud_20)
|
||||
)
|
||||
)
|
||||
showDialog(activity, sut)
|
||||
sut.show(activity.supportFragmentManager, null)
|
||||
}
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.DND,
|
||||
"Busy fixing 🐛…",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "dnd")
|
||||
val dialogInstance = waitForDialog(sut!!) ?: throw IllegalStateException("Dialog was not created")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "online")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"Let's have some fun",
|
||||
"🎉",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "fun")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.OFFLINE, "", "", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "offline")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.AWAY, "Vacation", "🌴", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "away")
|
||||
}
|
||||
} catch (e: AccountUtils.AccountNotFoundException) {
|
||||
throw java.lang.RuntimeException(e)
|
||||
scenario.onActivity {
|
||||
val viewGroup = dialogInstance.window?.findViewById<ViewGroup>(android.R.id.content)
|
||||
if (viewGroup != null) {
|
||||
hideCursors(viewGroup)
|
||||
}
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.DND,
|
||||
"Busy fixing 🐛…",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "dnd")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"",
|
||||
"",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "online")
|
||||
|
||||
sut.setStatus(
|
||||
Status(
|
||||
StatusType.ONLINE,
|
||||
"Let's have some fun",
|
||||
"🎉",
|
||||
-1
|
||||
),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "fun")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.OFFLINE, "", "", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "offline")
|
||||
|
||||
sut.setStatus(
|
||||
Status(StatusType.AWAY, "Vacation", "🌴", -1),
|
||||
targetContext
|
||||
)
|
||||
screenshot(sut, "away")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Throws(AccountUtils.AccountNotFoundException::class)
|
||||
fun testAccountChooserDialogWithStatusDisabled() {
|
||||
@@ -404,44 +387,42 @@ class DialogFragmentIT : AbstractIT() {
|
||||
accountManager.setAuthToken(newAccount, AccountTypeUtils.getAuthTokenTypePass(newAccount.type), "password")
|
||||
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
var sut: ChooseAccountDialogFragment? = null
|
||||
scenario.onActivity { fda ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val userAccountManager = fda.userAccountManager
|
||||
val newUser = userAccountManager.getUser(newAccount.name).get()
|
||||
val fileDataStorageManager = FileDataStorageManager(
|
||||
newUser,
|
||||
targetContext.contentResolver
|
||||
)
|
||||
val userAccountManager = fda.userAccountManager
|
||||
val newUser = userAccountManager.getUser(newAccount.name).get()
|
||||
val fileDataStorageManager = FileDataStorageManager(
|
||||
newUser,
|
||||
targetContext.contentResolver
|
||||
)
|
||||
|
||||
val capability = OCCapability().apply {
|
||||
userStatus = CapabilityBooleanType.FALSE
|
||||
}
|
||||
|
||||
fileDataStorageManager.saveCapabilities(capability)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val sut =
|
||||
newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(
|
||||
URI.create(serverUrl),
|
||||
OwnCloudVersion.nextcloud_20
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
showDialog(fda, sut)
|
||||
val capability = OCCapability().apply {
|
||||
userStatus = CapabilityBooleanType.FALSE
|
||||
}
|
||||
|
||||
fileDataStorageManager.saveCapabilities(capability)
|
||||
|
||||
sut = newInstance(
|
||||
RegisteredUser(
|
||||
newAccount,
|
||||
OwnCloudAccount(newAccount, targetContext),
|
||||
Server(
|
||||
URI.create(serverUrl),
|
||||
OwnCloudVersion.nextcloud_20
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
sut.show(fda.supportFragmentManager, null)
|
||||
}
|
||||
|
||||
waitForDialog(sut!!) ?: throw IllegalStateException("Dialog was not created")
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -469,142 +450,128 @@ class DialogFragmentIT : AbstractIT() {
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
var sut: OCFileListBottomSheetDialog? = null
|
||||
scenario.onActivity { fda ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
var directEditing = DirectEditing()
|
||||
val creators = directEditing.creators.toMutableMap()
|
||||
val editors = directEditing.editors.toMutableMap()
|
||||
|
||||
// add direct editing info
|
||||
var directEditing = DirectEditing()
|
||||
val creators = directEditing.creators.toMutableMap()
|
||||
val editors = directEditing.editors.toMutableMap()
|
||||
creators["1"] = Creator(
|
||||
"1",
|
||||
"text",
|
||||
"text file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
|
||||
creators.put(
|
||||
"1",
|
||||
Creator(
|
||||
"1",
|
||||
"text",
|
||||
"text file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
)
|
||||
creators.put(
|
||||
"2",
|
||||
Creator(
|
||||
"2",
|
||||
"md",
|
||||
"markdown file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
)
|
||||
editors.put(
|
||||
"text",
|
||||
Editor(
|
||||
"1",
|
||||
"Text",
|
||||
ArrayList(mutableListOf(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN)),
|
||||
ArrayList(),
|
||||
false
|
||||
)
|
||||
)
|
||||
creators["2"] = Creator(
|
||||
"2",
|
||||
"md",
|
||||
"markdown file",
|
||||
".md",
|
||||
"application/octet-stream",
|
||||
false
|
||||
)
|
||||
|
||||
directEditing = DirectEditing(editors, creators)
|
||||
val json = Gson().toJson(directEditing)
|
||||
editors["text"] = Editor(
|
||||
"1",
|
||||
"Text",
|
||||
ArrayList(mutableListOf(MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN)),
|
||||
ArrayList(),
|
||||
false
|
||||
)
|
||||
|
||||
ArbitraryDataProviderImpl(targetContext).storeOrUpdateKeyValue(
|
||||
user.accountName,
|
||||
ArbitraryDataProvider.DIRECT_EDITING,
|
||||
json
|
||||
)
|
||||
directEditing = DirectEditing(editors, creators)
|
||||
val json = Gson().toJson(directEditing)
|
||||
|
||||
// activate templates
|
||||
val capability = fda.capabilities.apply {
|
||||
richDocuments = CapabilityBooleanType.TRUE
|
||||
richDocumentsDirectEditing = CapabilityBooleanType.TRUE
|
||||
richDocumentsTemplatesAvailable = CapabilityBooleanType.TRUE
|
||||
accountName = user.accountName
|
||||
}
|
||||
CapabilityUtils.updateCapability(capability)
|
||||
ArbitraryDataProviderImpl(targetContext).storeOrUpdateKeyValue(
|
||||
user.accountName,
|
||||
ArbitraryDataProvider.DIRECT_EDITING,
|
||||
json
|
||||
)
|
||||
|
||||
val appScanOptionalFeature: AppScanOptionalFeature = object : AppScanOptionalFeature() {
|
||||
override fun getScanContract(): ActivityResultContract<Unit, String?> =
|
||||
throw UnsupportedOperationException("Document scan is not available")
|
||||
}
|
||||
|
||||
val materialSchemesProvider = getMaterialSchemesProvider()
|
||||
val viewThemeUtils = ViewThemeUtils(
|
||||
materialSchemesProvider.getMaterialSchemesForCurrentUser(),
|
||||
ColorUtil(targetContext)
|
||||
)
|
||||
|
||||
val editorUtils = EditorUtils(ArbitraryDataProviderImpl(targetContext))
|
||||
|
||||
val sut = OCFileListBottomSheetDialog(
|
||||
fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile,
|
||||
fda.themeUtils,
|
||||
viewThemeUtils,
|
||||
editorUtils,
|
||||
appScanOptionalFeature
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
sut.show()
|
||||
sut.behavior.setState(BottomSheetBehavior.STATE_EXPANDED)
|
||||
val viewGroup = sut.window?.findViewById<ViewGroup>(android.R.id.content) ?: return@onIdleSync
|
||||
hideCursors(viewGroup)
|
||||
val screenShotName = createName(testClassName + "_" + "testBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.window?.decorView, screenShotName)
|
||||
val capability = fda.capabilities.apply {
|
||||
richDocuments = CapabilityBooleanType.TRUE
|
||||
richDocumentsDirectEditing = CapabilityBooleanType.TRUE
|
||||
richDocumentsTemplatesAvailable = CapabilityBooleanType.TRUE
|
||||
accountName = user.accountName
|
||||
}
|
||||
CapabilityUtils.updateCapability(capability)
|
||||
|
||||
val appScanOptionalFeature: AppScanOptionalFeature = object : AppScanOptionalFeature() {
|
||||
override fun getScanContract(): ActivityResultContract<Unit, String?> =
|
||||
throw UnsupportedOperationException("Document scan is not available")
|
||||
}
|
||||
|
||||
val materialSchemesProvider = getMaterialSchemesProvider()
|
||||
val viewThemeUtils = ViewThemeUtils(
|
||||
materialSchemesProvider.getMaterialSchemesForCurrentUser(),
|
||||
ColorUtil(targetContext)
|
||||
)
|
||||
|
||||
val editorUtils = EditorUtils(ArbitraryDataProviderImpl(targetContext))
|
||||
|
||||
sut = OCFileListBottomSheetDialog(
|
||||
fda,
|
||||
action,
|
||||
info,
|
||||
user,
|
||||
ocFile,
|
||||
fda.themeUtils,
|
||||
viewThemeUtils,
|
||||
editorUtils,
|
||||
appScanOptionalFeature
|
||||
)
|
||||
|
||||
sut.show()
|
||||
}
|
||||
|
||||
sut!!.behavior.setState(BottomSheetBehavior.STATE_EXPANDED)
|
||||
val viewGroup = sut.window?.findViewById<ViewGroup>(android.R.id.content) ?: return
|
||||
hideCursors(viewGroup)
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
screenshotViaName(sut.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testOnlineStatusBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
// show dialog
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
var sut: SetOnlineStatusBottomSheet? = null
|
||||
scenario.onActivity { fda ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Focus time", "\uD83E\uDD13", -1)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.show(fda.supportFragmentManager, "set_online_status")
|
||||
sut = SetOnlineStatusBottomSheet(
|
||||
Status(StatusType.DND, "Focus time", "\uD83E\uDD13", -1)
|
||||
)
|
||||
sut.show(fda.supportFragmentManager, "set_online_status")
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testOnlineStatusBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.view, screenShotName)
|
||||
}
|
||||
val screenShotName = createName(testClassName + "_" + "testOnlineStatusBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity {
|
||||
screenshotViaName(sut!!.view, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testProfileBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
// Fixed values for HoverCard
|
||||
val actions: MutableList<Action> = ArrayList()
|
||||
actions.add(
|
||||
Action(
|
||||
@@ -633,33 +600,30 @@ class DialogFragmentIT : AbstractIT() {
|
||||
)
|
||||
|
||||
val hoverCard = HoverCard("christine", "Christine Scott", actions)
|
||||
|
||||
// show dialog
|
||||
val intent = Intent(targetContext, FileDisplayActivity::class.java)
|
||||
|
||||
launchActivity<FileDisplayActivity>(intent).use { scenario ->
|
||||
var sut: ProfileBottomSheetDialog? = null
|
||||
scenario.onActivity { fda ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = ProfileBottomSheetDialog(
|
||||
fda,
|
||||
user,
|
||||
hoverCard,
|
||||
fda.viewThemeUtils
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
sut.show()
|
||||
sut = ProfileBottomSheetDialog(
|
||||
fda,
|
||||
user,
|
||||
hoverCard,
|
||||
fda.viewThemeUtils
|
||||
)
|
||||
sut.show()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "testProfileBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.window?.decorView, screenShotName)
|
||||
}
|
||||
val screenShotName = createName(testClassName + "_" + "testProfileBottomSheet", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity {
|
||||
screenshotViaName(sut!!.window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testSslUntrustedCertDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -677,20 +641,17 @@ class DialogFragmentIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testStoragePermissionDialog() {
|
||||
if (Looper.myLooper() == null) {
|
||||
Looper.prepare()
|
||||
}
|
||||
|
||||
newInstance(false).run {
|
||||
showDialog(this)
|
||||
}
|
||||
val dialog = StoragePermissionDialogFragment()
|
||||
showDialog(dialog)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun testFileActionsBottomSheet() {
|
||||
if (Looper.myLooper() == null) {
|
||||
@@ -709,34 +670,30 @@ class DialogFragmentIT : AbstractIT() {
|
||||
private fun showDialog(dialog: DialogFragment) {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
showDialog(sut, dialog)
|
||||
}
|
||||
dialog.show(sut.supportFragmentManager, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDialog(sut: FileDisplayActivity, dialog: DialogFragment) {
|
||||
dialog.show(sut.supportFragmentManager, null)
|
||||
onIdleSync {
|
||||
val dialogInstance = waitForDialog(dialog)
|
||||
?: throw IllegalStateException("Dialog was not created")
|
||||
val dialogInstance = waitForDialog(dialog) ?: throw IllegalStateException("Dialog was not created")
|
||||
|
||||
val viewGroup = dialogInstance.window?.findViewById<ViewGroup>(android.R.id.content) ?: return@onIdleSync
|
||||
hideCursors(viewGroup)
|
||||
scenario.onActivity {
|
||||
val viewGroup = dialogInstance.window?.findViewById<ViewGroup>(android.R.id.content)
|
||||
if (viewGroup != null) {
|
||||
hideCursors(viewGroup)
|
||||
}
|
||||
screenshot(dialogInstance.window?.decorView)
|
||||
}
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshot(dialogInstance.window?.decorView)
|
||||
}
|
||||
}
|
||||
|
||||
private fun waitForDialog(dialogFragment: DialogFragment, timeoutMs: Long = 5000): Dialog? {
|
||||
val start = System.currentTimeMillis()
|
||||
while (System.currentTimeMillis() - start < timeoutMs) {
|
||||
val dialog = dialogFragment.dialog
|
||||
if (dialog != null) return dialog
|
||||
Thread.sleep(100)
|
||||
if (dialogFragment.isAdded && dialogFragment.dialog != null) {
|
||||
return dialogFragment.dialog
|
||||
}
|
||||
Thread.sleep(50)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -8,12 +8,10 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -21,11 +19,8 @@ import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SendFilesDialogTest : AbstractIT() {
|
||||
@@ -53,38 +48,25 @@ class SendFilesDialogTest : AbstractIT() {
|
||||
)
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
private fun showDialog(files: Set<OCFile>, onComplete: (SendFilesDialog) -> Unit) {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
var dialog: SendFilesDialog? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val fm: FragmentManager = sut.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
|
||||
val dialog = SendFilesDialog.newInstance(files)
|
||||
dialog.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
onComplete(dialog)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
}
|
||||
val fm: FragmentManager = sut.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
dialog = SendFilesDialog.newInstance(files)
|
||||
dialog.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
fm.executePendingTransactions()
|
||||
}
|
||||
|
||||
onComplete(dialog!!)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialog() {
|
||||
showDialog(FILES_SAME_TYPE) { sut ->
|
||||
@@ -95,18 +77,15 @@ class SendFilesDialogTest : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialog_Screenshot() {
|
||||
showDialog(FILES_SAME_TYPE) { sut ->
|
||||
val screenShotName = createName(testClassName + "_" + "showDialog_Screenshot", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialogDifferentTypes() {
|
||||
showDialog(FILES_MIXED_TYPE) { sut ->
|
||||
@@ -117,7 +96,6 @@ class SendFilesDialogTest : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialogDifferentTypes_Screenshot() {
|
||||
showDialog(FILES_MIXED_TYPE) { sut ->
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
@@ -19,7 +18,6 @@ import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.Test
|
||||
|
||||
@@ -27,29 +25,26 @@ class SendShareDialogTest : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.SendShareDialogTest"
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDialog() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: SendShareDialog? = null
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fm: FragmentManager = activity.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
|
||||
val file = OCFile("/1.jpg").apply {
|
||||
mimeType = "image/jpg"
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val sut = SendShareDialog.newInstance(file, false, OCCapability())
|
||||
sut.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
val screenShotName = createName(testClassName + "_" + "showDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
val fm: FragmentManager = activity.supportFragmentManager
|
||||
val ft = fm.beginTransaction()
|
||||
ft.addToBackStack(null)
|
||||
fm.executePendingTransactions()
|
||||
val file = OCFile("/1.jpg").apply {
|
||||
mimeType = "image/jpg"
|
||||
}
|
||||
|
||||
sut = SendShareDialog.newInstance(file, false, OCCapability())
|
||||
sut.show(ft, "TAG_SEND_SHARE_DIALOG")
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDialog", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut!!.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
-55
@@ -8,93 +8,72 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.ui.dialog.setupEncryption.SetupEncryptionDialogFragment
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class SetupEncryptionDialogFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.SetupEncryptionDialogFragmentIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showMnemonic() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: SetupEncryptionDialogFragment? = null
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = SetupEncryptionDialogFragment.newInstance(user, 0)
|
||||
sut = SetupEncryptionDialogFragment.newInstance(user, 0)
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
val keyWords = arrayListOf(
|
||||
"ability",
|
||||
"able",
|
||||
"about",
|
||||
"above",
|
||||
"absent",
|
||||
"absorb",
|
||||
"abstract",
|
||||
"absurd",
|
||||
"abuse",
|
||||
"access",
|
||||
"accident",
|
||||
"account",
|
||||
"accuse"
|
||||
)
|
||||
sut.setMnemonic(keyWords)
|
||||
sut.showMnemonicInfo()
|
||||
}
|
||||
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
val screenShotName = createName(testClassName + "_" + "showMnemonic", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
val keyWords = arrayListOf(
|
||||
"ability",
|
||||
"able",
|
||||
"about",
|
||||
"above",
|
||||
"absent",
|
||||
"absorb",
|
||||
"abstract",
|
||||
"absurd",
|
||||
"abuse",
|
||||
"access",
|
||||
"accident",
|
||||
"account",
|
||||
"accuse"
|
||||
)
|
||||
sut.setMnemonic(keyWords)
|
||||
sut.showMnemonicInfo()
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showMnemonic", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
scenario.onActivity {
|
||||
screenshotViaName(sut!!.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var sut: SetupEncryptionDialogFragment? = null
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut = SetupEncryptionDialogFragment.newInstance(user, 0)
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
sut.errorSavingKeys()
|
||||
}
|
||||
|
||||
val sut = SetupEncryptionDialogFragment.newInstance(user, 0)
|
||||
sut.show(activity.supportFragmentManager, "1")
|
||||
sut.errorSavingKeys()
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
scenario.onActivity {
|
||||
screenshotViaName(sut!!.requireDialog().window?.decorView, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+27
-38
@@ -6,84 +6,73 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.dialog
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import android.Manifest
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragment.Companion.newInstance
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
class SyncFileNotEnoughSpaceDialogFragmentTest : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragmentTest"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@UiThread
|
||||
fun showNotEnoughSpaceDialogForFolder() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
val ocFile = OCFile("/Document/").apply {
|
||||
fileLength = 5000000
|
||||
setFolder()
|
||||
}
|
||||
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
newInstance(ocFile, 1000).apply {
|
||||
show(sut.supportFragmentManager, "1")
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFolder", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
newInstance(ocFile, 1000).apply {
|
||||
show(activity.supportFragmentManager, "1")
|
||||
}
|
||||
|
||||
sut = activity
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFolder", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@UiThread
|
||||
fun showNotEnoughSpaceDialogForFile() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
val ocFile = OCFile("/Video.mp4").apply {
|
||||
fileLength = 1000000
|
||||
}
|
||||
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
newInstance(ocFile, 2000).apply {
|
||||
show(sut.supportFragmentManager, "2")
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
newInstance(ocFile, 2000).apply {
|
||||
show(activity.supportFragmentManager, "2")
|
||||
}
|
||||
sut = activity
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showNotEnoughSpaceDialogForFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,12 @@
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.R
|
||||
@@ -23,171 +22,164 @@ import com.owncloud.android.lib.resources.users.StatusType
|
||||
import com.owncloud.android.ui.TextDrawable
|
||||
import com.owncloud.android.utils.BitmapUtils
|
||||
import com.owncloud.android.utils.DisplayUtils
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class AvatarIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.AvatarIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showAvatars() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = AvatarTestFragment()
|
||||
sut.addFragment(fragment)
|
||||
}
|
||||
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val fragment = AvatarTestFragment()
|
||||
onView(withId(R.id.avatar_list1))
|
||||
.check(matches(isDisplayed()))
|
||||
|
||||
sut.addFragment(fragment)
|
||||
fragment.run {
|
||||
addAvatar("Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Test Server Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Cormier Paulette", avatarRadius, width, targetContext)
|
||||
addAvatar("winston brent", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("[email protected]", avatarRadius, width, targetContext)
|
||||
}
|
||||
scenario.onActivity { sut ->
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val fragment = sut.supportFragmentManager.fragments.last() as AvatarTestFragment
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatars", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
fragment.run {
|
||||
addAvatar("Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Test Server Admin", avatarRadius, width, targetContext)
|
||||
addAvatar("Cormier Paulette", avatarRadius, width, targetContext)
|
||||
addAvatar("winston brent", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("Baker James Lorena", avatarRadius, width, targetContext)
|
||||
addAvatar("[email protected]", avatarRadius, width, targetContext)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatars", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showAvatarsWithStatus() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = AvatarTestFragment()
|
||||
sut.addFragment(fragment)
|
||||
}
|
||||
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
val fragment = AvatarTestFragment()
|
||||
onView(withId(R.id.avatar_list1))
|
||||
.check(matches(isDisplayed()))
|
||||
|
||||
val paulette = BitmapFactory.decodeFile(getFile("paulette.jpg").absolutePath)
|
||||
val christine = BitmapFactory.decodeFile(getFile("christine.jpg").absolutePath)
|
||||
val textBitmap = BitmapUtils.drawableToBitmap(TextDrawable.createNamedAvatar("Admin", avatarRadius))
|
||||
scenario.onActivity { sut ->
|
||||
val avatarRadius = targetContext.resources.getDimension(R.dimen.list_item_avatar_icon_radius)
|
||||
val width = DisplayUtils.convertDpToPixel(2 * avatarRadius, targetContext)
|
||||
|
||||
sut.addFragment(fragment)
|
||||
val paulette = BitmapFactory.decodeFile(getFile("paulette.jpg").absolutePath)
|
||||
val christine = BitmapFactory.decodeFile(getFile("christine.jpg").absolutePath)
|
||||
val textBitmap = BitmapUtils.drawableToBitmap(TextDrawable.createNamedAvatar("Admin", avatarRadius))
|
||||
val fragment = sut.supportFragmentManager.fragments.last() as AvatarTestFragment
|
||||
|
||||
fragment.run {
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.ONLINE, "😘", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "☁️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.DND, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.AWAY, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.OFFLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "😘", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "☁️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.DND, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.AWAY, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.OFFLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatarsWithStatus", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
fragment.run {
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.ONLINE, "😘", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "☁️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.ONLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.DND, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(christine, StatusType.AWAY, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(paulette, StatusType.OFFLINE, "", targetContext),
|
||||
width * 2,
|
||||
1,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "😘", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "☁️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "🌴️", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.ONLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.DND, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.AWAY, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
addBitmap(
|
||||
BitmapUtils.createAvatarWithStatus(textBitmap, StatusType.OFFLINE, "", targetContext),
|
||||
width,
|
||||
2,
|
||||
targetContext
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showAvatarsWithStatus", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
|
||||
scenario.onActivity { sut ->
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+68
-97
@@ -9,10 +9,8 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -25,10 +23,7 @@ import com.owncloud.android.lib.resources.activities.model.Activity
|
||||
import com.owncloud.android.lib.resources.activities.model.RichElement
|
||||
import com.owncloud.android.lib.resources.activities.model.RichObject
|
||||
import com.owncloud.android.lib.resources.activities.models.PreviewObject
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.util.GregorianCalendar
|
||||
@@ -36,16 +31,6 @@ import java.util.GregorianCalendar
|
||||
class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.FileDetailFragmentStaticServerIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
private var file: File = getFile("gps.jpg")
|
||||
private val oCFile: OCFile = OCFile("/").apply {
|
||||
storagePath = file.absolutePath
|
||||
@@ -54,67 +39,60 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showFileDetailActivitiesFragment() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.addFragment(FileDetailActivitiesFragment.newInstance(oCFile, user))
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailActivitiesFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
activity = sut
|
||||
sut.addFragment(FileDetailActivitiesFragment.newInstance(oCFile, user))
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailActivitiesFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showFileDetailSharingFragment() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.addFragment(FileDetailSharingFragment.newInstance(oCFile, user))
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailSharingFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
activity = sut
|
||||
sut.addFragment(FileDetailSharingFragment.newInstance(oCFile, user))
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailSharingFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showFileDetailDetailsFragment() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = ImageDetailFragment.newInstance(oCFile, user).apply {
|
||||
hideMap()
|
||||
}
|
||||
sut.addFragment(fragment)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailDetailsFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
activity = sut
|
||||
val fragment = ImageDetailFragment.newInstance(oCFile, user).apply {
|
||||
hideMap()
|
||||
}
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFileDetailDetailsFragment", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Suppress("MagicNumber")
|
||||
fun showDetailsActivities() {
|
||||
@@ -171,84 +149,77 @@ class FileDetailFragmentStaticServerIT : AbstractIT() {
|
||||
)
|
||||
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
fragment.fileDetailActivitiesFragment.populateList(activities as List<Any>?, true)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivities", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
activity = sut
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
fragment.fileDetailActivitiesFragment.populateList(activities as List<Any>?, true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivities", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDetailsActivitiesNone() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
fragment.fileDetailActivitiesFragment.populateList(emptyList(), true)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesNone", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
activity = sut
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
fragment.fileDetailActivitiesFragment.populateList(emptyList(), true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesNone", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDetailsActivitiesError() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
fragment.fileDetailActivitiesFragment.disableLoadingActivities()
|
||||
fragment.fileDetailActivitiesFragment.setErrorContent(
|
||||
targetContext.resources.getString(R.string.file_detail_activity_error)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesError", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
activity = sut
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 0)
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
fragment.fileDetailActivitiesFragment.disableLoadingActivities()
|
||||
fragment.fileDetailActivitiesFragment.setErrorContent(
|
||||
targetContext.resources.getString(R.string.file_detail_activity_error)
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsActivitiesError", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showDetailsSharing() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 1)
|
||||
sut.addFragment(fragment)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsSharing", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
activity = sut
|
||||
val fragment = FileDetailFragment.newInstance(oCFile, user, 1)
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showDetailsSharing", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
+523
-570
File diff suppressed because it is too large.
Load diff
@@ -12,10 +12,8 @@ import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Color
|
||||
import android.graphics.Paint
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -26,7 +24,6 @@ import com.owncloud.android.datamodel.ThumbnailsCacheManager
|
||||
import com.owncloud.android.datamodel.ThumbnailsCacheManager.PREFIX_RESIZED_IMAGE
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.files.model.ImageDimension
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertNotNull
|
||||
@@ -40,8 +37,6 @@ class GalleryFragmentIT : AbstractIT() {
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
|
||||
// initialise thumbnails cache on background thread
|
||||
@Suppress("DEPRECATION")
|
||||
ThumbnailsCacheManager.initDiskCacheAsync()
|
||||
@@ -49,51 +44,44 @@ class GalleryFragmentIT : AbstractIT() {
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
ThumbnailsCacheManager.clearCache()
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showEmpty() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showEmpty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showEmpty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showGallery() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
createImage(10000001, 700, 300)
|
||||
createImage(10000002, 500, 300)
|
||||
createImage(10000007, 300, 400)
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
createImage(10000001, 700, 300)
|
||||
createImage(10000002, 500, 300)
|
||||
createImage(10000007, 300, 400)
|
||||
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGallery", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
val sut = GalleryFragment()
|
||||
activity.addFragment(sut)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGallery", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+31
-55
@@ -8,91 +8,67 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.android.lib.resources.groupfolders.Groupfolder
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class GroupfolderListFragmentIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.GroupfolderListFragmentIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showGroupfolder() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val sut = GroupfolderListFragment()
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
|
||||
val sut = GroupfolderListFragment()
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.setAdapter(null)
|
||||
sut.setData(
|
||||
mapOf(
|
||||
Pair("2", Groupfolder(2, "/subfolder/group"))
|
||||
)
|
||||
sut.setAdapter(null)
|
||||
sut.setData(
|
||||
mapOf(
|
||||
Pair("2", Groupfolder(2, "/subfolder/group"))
|
||||
)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGroupfolder", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGroupfolder", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showGroupfolders() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val sut = GroupfolderListFragment()
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.setAdapter(null)
|
||||
sut.setData(
|
||||
mapOf(
|
||||
Pair("1", Groupfolder(1, "/test/")),
|
||||
Pair("2", Groupfolder(2, "/subfolder/group"))
|
||||
)
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val sut = GroupfolderListFragment()
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
sut.setAdapter(null)
|
||||
sut.setData(
|
||||
mapOf(
|
||||
Pair("1", Groupfolder(1, "/test/")),
|
||||
Pair("2", Groupfolder(2, "/subfolder/group"))
|
||||
)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGroupfolders", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showGroupfolders", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
+306
-343
@@ -9,10 +9,8 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -26,9 +24,7 @@ import com.owncloud.android.lib.resources.tags.Tag
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.MimeType
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TestRule
|
||||
@@ -36,84 +32,69 @@ import org.junit.rules.TestRule
|
||||
class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.fragment.OCFileListFragmentStaticServerIT"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
var storagePermissionRule: TestRule = grant()
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Suppress("MagicNumber")
|
||||
fun showFiles() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
OCFile("/1.png").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = "image/png"
|
||||
fileLength = 1024000
|
||||
modificationTimestamp = 1188206955000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/image.png").apply {
|
||||
remoteId = "00000002"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 3072000
|
||||
modificationTimestamp = 746443755000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
tags = listOf(Tag("", "Top secret", null))
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/live photo.png").apply {
|
||||
remoteId = "00000003"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 3072000
|
||||
modificationTimestamp = 746443755000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
setLivePhoto("/video.mov")
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/video.mp4").apply {
|
||||
remoteId = "00000004"
|
||||
mimeType = "video/mp4"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 12092000
|
||||
modificationTimestamp = 746143952000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
tags = listOf(Tag("", "Confidential", null), Tag("", "+5", null))
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(OCFileListFragment())
|
||||
|
||||
val fragment = (sut.fragment as OCFileListFragment)
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false, false)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
var sut: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
sut = testActivity
|
||||
OCFile("/1.png").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = "image/png"
|
||||
fileLength = 1024000
|
||||
modificationTimestamp = 1188206955000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/image.png").apply {
|
||||
remoteId = "00000002"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 3072000
|
||||
modificationTimestamp = 746443755000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
tags = listOf(Tag("", "Top secret", null))
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/live photo.png").apply {
|
||||
remoteId = "00000003"
|
||||
mimeType = "image/png"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 3072000
|
||||
modificationTimestamp = 746443755000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
setLivePhoto("/video.mov")
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/video.mp4").apply {
|
||||
remoteId = "00000004"
|
||||
mimeType = "video/mp4"
|
||||
isPreviewAvailable = false
|
||||
fileLength = 12092000
|
||||
modificationTimestamp = 746143952000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
tags = listOf(Tag("", "Confidential", null), Tag("", "+5", null))
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(OCFileListFragment())
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
val fragment = (sut.fragment as OCFileListFragment)
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,135 +102,131 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
* Use same values as {@link FileDetailSharingFragmentIT listSharesFileAllShareTypes }
|
||||
*/
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showSharedFiles() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
var sut: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
sut = testActivity
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
OCFile("/sharedToUser.jpg").apply {
|
||||
remoteId = "00000001"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Admin", "Server Admin", ShareType.USER))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToGroup.jpg").apply {
|
||||
remoteId = "00000002"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("group", "Group", ShareType.GROUP))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToEmail.jpg").apply {
|
||||
remoteId = "00000003"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees =
|
||||
listOf(
|
||||
ShareeUser("[email protected]", "[email protected]", ShareType.EMAIL)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/publicLink.jpg").apply {
|
||||
remoteId = "00000004"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToFederatedUser.jpg").apply {
|
||||
remoteId = "00000005"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser(
|
||||
"[email protected]",
|
||||
"[email protected] (remote)",
|
||||
ShareType.FEDERATED
|
||||
)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToPersonalCircle.jpg").apply {
|
||||
remoteId = "00000006"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("circle", "Circle (Personal circle)", ShareType.CIRCLE))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToUserRoom.jpg").apply {
|
||||
remoteId = "00000007"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Admin", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToGroupRoom.jpg").apply {
|
||||
remoteId = "00000008"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Meeting", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToUsers.jpg").apply {
|
||||
remoteId = "00000009"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser("Admin", "Server Admin", ShareType.USER),
|
||||
ShareeUser("User", "User", ShareType.USER),
|
||||
ShareeUser("Christine", "Christine Scott", ShareType.USER)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/notShared.jpg").apply {
|
||||
remoteId = "000000010"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/Foo%e2%80%aedm.exe").apply {
|
||||
remoteId = "000000011"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showSharedFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
OCFile("/sharedToUser.jpg").apply {
|
||||
remoteId = "00000001"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Admin", "Server Admin", ShareType.USER))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToGroup.jpg").apply {
|
||||
remoteId = "00000002"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("group", "Group", ShareType.GROUP))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToEmail.jpg").apply {
|
||||
remoteId = "00000003"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees =
|
||||
listOf(
|
||||
ShareeUser("[email protected]", "[email protected]", ShareType.EMAIL)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/publicLink.jpg").apply {
|
||||
remoteId = "00000004"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToFederatedUser.jpg").apply {
|
||||
remoteId = "00000005"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser(
|
||||
"[email protected]",
|
||||
"[email protected] (remote)",
|
||||
ShareType.FEDERATED
|
||||
)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToPersonalCircle.jpg").apply {
|
||||
remoteId = "00000006"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("circle", "Circle (Personal circle)", ShareType.CIRCLE))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToUserRoom.jpg").apply {
|
||||
remoteId = "00000007"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Admin", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToGroupRoom.jpg").apply {
|
||||
remoteId = "00000008"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(ShareeUser("Conversation", "Meeting", ShareType.ROOM))
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedToUsers.jpg").apply {
|
||||
remoteId = "00000009"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
isSharedWithSharee = true
|
||||
sharees = listOf(
|
||||
ShareeUser("Admin", "Server Admin", ShareType.USER),
|
||||
ShareeUser("User", "User", ShareType.USER),
|
||||
ShareeUser("Christine", "Christine Scott", ShareType.USER)
|
||||
)
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/notShared.jpg").apply {
|
||||
remoteId = "000000010"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/Foo%e2%80%aedm.exe").apply {
|
||||
remoteId = "000000011"
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
modificationTimestamp = 1000
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showSharedFiles", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,181 +234,167 @@ class OCFileListFragmentStaticServerIT : AbstractIT() {
|
||||
* Use same values as {@link FileDetailSharingFragmentIT listSharesFileAllShareTypes }
|
||||
*/
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showFolderTypes() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
var sut: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
sut = testActivity
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
OCFile("/normal/").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1624003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedViaLink/").apply {
|
||||
remoteId = "00000002"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1619003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/share/").apply {
|
||||
remoteId = "00000003"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isSharedWithSharee = true
|
||||
modificationTimestamp = 1619303571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/groupFolder/").apply {
|
||||
remoteId = "00000004"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1615003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
permissions += "M"
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/encrypted/").apply {
|
||||
remoteId = "00000005"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isEncrypted = true
|
||||
decryptedRemotePath = "/encrypted/"
|
||||
modificationTimestamp = 1614003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/locked/").apply {
|
||||
remoteId = "00000006"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isLocked = true
|
||||
decryptedRemotePath = "/locked/"
|
||||
modificationTimestamp = 1613003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/offlineOperation/").apply {
|
||||
mimeType = MimeType.DIRECTORY
|
||||
decryptedRemotePath = "/offlineOperation/"
|
||||
modificationTimestamp = System.currentTimeMillis()
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFolderTypes", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
OCFile("/normal/").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1624003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/sharedViaLink/").apply {
|
||||
remoteId = "00000002"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isSharedViaLink = true
|
||||
modificationTimestamp = 1619003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/share/").apply {
|
||||
remoteId = "00000003"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isSharedWithSharee = true
|
||||
modificationTimestamp = 1619303571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/groupFolder/").apply {
|
||||
remoteId = "00000004"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
modificationTimestamp = 1615003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
permissions += "M"
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/encrypted/").apply {
|
||||
remoteId = "00000005"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isEncrypted = true
|
||||
decryptedRemotePath = "/encrypted/"
|
||||
modificationTimestamp = 1614003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/locked/").apply {
|
||||
remoteId = "00000006"
|
||||
mimeType = MimeType.DIRECTORY
|
||||
isLocked = true
|
||||
decryptedRemotePath = "/locked/"
|
||||
modificationTimestamp = 1613003571000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
OCFile("/offlineOperation/").apply {
|
||||
mimeType = MimeType.DIRECTORY
|
||||
decryptedRemotePath = "/offlineOperation/"
|
||||
modificationTimestamp = System.currentTimeMillis()
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/").fileId
|
||||
sut.storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
val root = sut.storageManager.getFileByEncryptedRemotePath("/")
|
||||
fragment.listDirectory(root, false)
|
||||
fragment.adapter.setShowShareAvatar(true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showFolderTypes", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
@Suppress("MagicNumber")
|
||||
fun showRichWorkspace() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
var sut: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
sut = testActivity
|
||||
val fragment = OCFileListFragment()
|
||||
|
||||
val fragment = OCFileListFragment()
|
||||
val folder = OCFile("/test/")
|
||||
folder.setFolder()
|
||||
sut.storageManager.saveFile(folder)
|
||||
|
||||
val folder = OCFile("/test/")
|
||||
folder.setFolder()
|
||||
sut.storageManager.saveFile(folder)
|
||||
|
||||
val imageFile = OCFile("/test/image.png").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = "image/png"
|
||||
fileLength = 1024000
|
||||
modificationTimestamp = 1188206955000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/test/").fileId
|
||||
storagePath = getFile("java.md").absolutePath
|
||||
}
|
||||
|
||||
sut.storageManager.saveFile(imageFile)
|
||||
|
||||
sut.addFragment(fragment)
|
||||
val testFolder: OCFile = sut.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
testFolder.richWorkspace = getFile("java.md").readText()
|
||||
fragment.listDirectory(testFolder, false, false)
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showRichWorkspace", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
val imageFile = OCFile("/test/image.png").apply {
|
||||
remoteId = "00000001"
|
||||
mimeType = "image/png"
|
||||
fileLength = 1024000
|
||||
modificationTimestamp = 1188206955000
|
||||
parentId = sut.storageManager.getFileByEncryptedRemotePath("/test/").fileId
|
||||
storagePath = getFile("java.md").absolutePath
|
||||
}
|
||||
|
||||
sut.storageManager.saveFile(imageFile)
|
||||
|
||||
sut.addFragment(fragment)
|
||||
sut.supportFragmentManager.executePendingTransactions()
|
||||
val testFolder: OCFile = sut.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
testFolder.richWorkspace = getFile("java.md").readText()
|
||||
fragment.listDirectory(testFolder, false)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showRichWorkspace", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun shouldShowHeader() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = OCFileListFragment()
|
||||
val folder = OCFile("/test/").apply {
|
||||
remoteId = "000001"
|
||||
setFolder()
|
||||
}
|
||||
activity.storageManager.saveFile(folder)
|
||||
activity.addFragment(sut)
|
||||
val testFolder: OCFile = activity.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
EspressoIdlingResource.decrement()
|
||||
var activity: TestActivity? = null
|
||||
val sut = OCFileListFragment()
|
||||
|
||||
// richWorkspace is not set
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
testFolder.richWorkspace = " "
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
testFolder.richWorkspace = null
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
EspressoIdlingResource.decrement()
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
testFolder.richWorkspace = "1"
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.setCurrentDirectory(testFolder)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
Assert.assertTrue(sut.adapter.shouldShowHeader())
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val folder = OCFile("/test/").apply {
|
||||
remoteId = "000001"
|
||||
setFolder()
|
||||
}
|
||||
activity.storageManager.saveFile(folder)
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
}
|
||||
|
||||
val testFolder: OCFile = activity!!.storageManager.getFileByEncryptedRemotePath("/test/")
|
||||
|
||||
// richWorkspace is not set
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
testFolder.richWorkspace = " "
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
testFolder.richWorkspace = null
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.swapDirectory(user, testFolder, activity.storageManager, false, "")
|
||||
Assert.assertFalse(sut.adapter.shouldShowHeader())
|
||||
|
||||
EspressoIdlingResource.increment()
|
||||
testFolder.richWorkspace = "1"
|
||||
activity.storageManager.saveFile(testFolder)
|
||||
sut.adapter.setCurrentDirectory(testFolder)
|
||||
|
||||
Assert.assertTrue(sut.adapter.shouldShowHeader())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
@@ -21,8 +20,10 @@ import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.resources.shares.OCShare
|
||||
import com.owncloud.android.lib.resources.shares.ShareType
|
||||
import com.owncloud.android.ui.adapter.OCShareToOCFileConverter
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -46,7 +47,6 @@ internal class SharedListFragmentIT : AbstractIT() {
|
||||
var storagePermissionRule: TestRule = grant()
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showSharedFiles() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
@@ -165,14 +165,15 @@ internal class SharedListFragmentIT : AbstractIT() {
|
||||
|
||||
fragment.isLoading = false
|
||||
fragment.mEmptyListContainer?.visibility = View.GONE
|
||||
fragment.adapter.setData(
|
||||
shares,
|
||||
SearchType.SHARED_FILTER,
|
||||
storageManager,
|
||||
null,
|
||||
true
|
||||
)
|
||||
|
||||
val newList = runBlocking {
|
||||
OCShareToOCFileConverter
|
||||
.parseAndSaveShares(listOf(), shares, storageManager, user.accountName)
|
||||
}
|
||||
fragment.adapter.run {
|
||||
prepareForSearchData(storageManager, SearchType.SHARED_FILTER)
|
||||
updateAdapter(newList, null)
|
||||
}
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showSharedFiles", "")
|
||||
|
||||
+40
-64
@@ -8,10 +8,8 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
@@ -21,89 +19,67 @@ import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.lib.common.SearchResultEntry
|
||||
import com.owncloud.android.ui.unifiedsearch.UnifiedSearchSection
|
||||
import com.owncloud.android.ui.unifiedsearch.UnifiedSearchViewModel
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class UnifiedSearchFragmentIT : AbstractIT() {
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun showSearchResult() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.onSearchResultChanged(
|
||||
listOf(
|
||||
UnifiedSearchSection(
|
||||
providerID = "files",
|
||||
name = "Files",
|
||||
entries = listOf(
|
||||
SearchResultEntry(
|
||||
"thumbnailUrl",
|
||||
"Test",
|
||||
"in Files",
|
||||
"http://localhost/nc/index.php/apps/files/?dir=/Files&scrollto=Test",
|
||||
"icon",
|
||||
false
|
||||
)
|
||||
),
|
||||
hasMoreResults = false
|
||||
)
|
||||
scenario.onActivity { activity ->
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
sut.onSearchResultChanged(
|
||||
listOf(
|
||||
UnifiedSearchSection(
|
||||
providerID = "files",
|
||||
name = "Files",
|
||||
entries = listOf(
|
||||
SearchResultEntry(
|
||||
"thumbnailUrl",
|
||||
"Test",
|
||||
"in Files",
|
||||
"http://localhost/nc/index.php/apps/files/?dir=/Files&scrollto=Test",
|
||||
"icon",
|
||||
false
|
||||
)
|
||||
),
|
||||
hasMoreResults = false
|
||||
)
|
||||
)
|
||||
EspressoIdlingResource.decrement()
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
fun search() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
val testViewModel = UnifiedSearchViewModel(activity.application)
|
||||
testViewModel.setConnectivityService(activity.connectivityServiceMock)
|
||||
val localRepository = UnifiedSearchFakeRepository()
|
||||
testViewModel.setRepository(localRepository)
|
||||
val ocFile = OCFile("/folder/test1.txt").apply {
|
||||
storagePath = "/sdcard/1.txt"
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
File(ocFile.storagePath).createNewFile()
|
||||
activity.addFragment(sut)
|
||||
|
||||
sut.setViewModel(testViewModel)
|
||||
sut.vm.setQuery("test")
|
||||
sut.vm.initialQuery()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
val sut = UnifiedSearchFragment.newInstance(null, null, "/")
|
||||
val testViewModel = UnifiedSearchViewModel(activity.application)
|
||||
testViewModel.setConnectivityService(activity.connectivityServiceMock)
|
||||
val localRepository = UnifiedSearchFakeRepository()
|
||||
testViewModel.setRepository(localRepository)
|
||||
val ocFile = OCFile("/folder/test1.txt").apply {
|
||||
storagePath = "/sdcard/1.txt"
|
||||
storageManager.saveFile(this)
|
||||
}
|
||||
|
||||
File(ocFile.storagePath).createNewFile()
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
sut.setViewModel(testViewModel)
|
||||
sut.vm.setQuery("test")
|
||||
sut.vm.initialQuery()
|
||||
}
|
||||
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-21
@@ -9,18 +9,13 @@
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class PreviewBitmapScreenshotIT : AbstractIT() {
|
||||
@@ -30,18 +25,7 @@ class PreviewBitmapScreenshotIT : AbstractIT() {
|
||||
private const val PNG_FILE_ASSET = "imageFile.png"
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showBitmap() {
|
||||
val pngFile = getFile(PNG_FILE_ASSET)
|
||||
@@ -51,12 +35,10 @@ class PreviewBitmapScreenshotIT : AbstractIT() {
|
||||
)
|
||||
|
||||
launchActivity<PreviewBitmapActivity>(intent).use { scenario ->
|
||||
val screenShotName = createName(testClassName + "_" + "showBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
scenario.onActivity { sut ->
|
||||
onIdleSync {
|
||||
val screenShotName = createName(testClassName + "_" + "showBitmap", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+24
-38
@@ -6,84 +6,70 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.preview
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import android.Manifest
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.ui.activity.FileDisplayActivity
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.MimeTypeUtil
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.io.IOException
|
||||
|
||||
class PreviewTextFileFragmentTest : AbstractIT() {
|
||||
private val testClassName = "com.owncloud.android.ui.preview.PreviewTextFileFragmentTest"
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
@get:Rule
|
||||
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.POST_NOTIFICATIONS
|
||||
)
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@UiThread
|
||||
@Throws(IOException::class)
|
||||
fun displaySimpleTextFile() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val test = OCFile("/text.md").apply {
|
||||
mimeType = MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN
|
||||
storagePath = getDummyFile("nonEmpty.txt").absolutePath
|
||||
}
|
||||
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.startTextPreview(test, true)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "displaySimpleTextFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.startTextPreview(test, true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "displaySimpleTextFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenshotTest
|
||||
@UiThread
|
||||
@Throws(IOException::class)
|
||||
fun displayJavaSnippetFile() {
|
||||
launchActivity<FileDisplayActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
var sut: FileDisplayActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val test = OCFile("/java.md").apply {
|
||||
mimeType = MimeTypeUtil.MIMETYPE_TEXT_MARKDOWN
|
||||
storagePath = getFile("java.md").absolutePath
|
||||
}
|
||||
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.startTextPreview(test, true)
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "displayJavaSnippetFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.startTextPreview(test, true)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "displayJavaSnippetFile", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
+15
-33
@@ -8,20 +8,15 @@
|
||||
*/
|
||||
package com.owncloud.android.ui.preview.pdf
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.nextcloud.test.TestActivity
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.datamodel.OCFile
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class PreviewPdfFragmentScreenshotIT : AbstractIT() {
|
||||
@@ -31,40 +26,27 @@ class PreviewPdfFragmentScreenshotIT : AbstractIT() {
|
||||
private const val PDF_FILE_ASSET = "test.pdf"
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun showPdf() {
|
||||
launchActivity<TestActivity>().use { scenario ->
|
||||
scenario.onActivity { activity ->
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
val pdfFile = getFile(PDF_FILE_ASSET)
|
||||
val ocFile = OCFile("/test.pdf").apply {
|
||||
storagePath = pdfFile.absolutePath
|
||||
}
|
||||
|
||||
val sut = PreviewPdfFragment.newInstance(ocFile)
|
||||
activity.addFragment(sut)
|
||||
sut.dismissSnack()
|
||||
|
||||
EspressoIdlingResource.decrement()
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPdf", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
var activity: TestActivity? = null
|
||||
scenario.onActivity { testActivity ->
|
||||
activity = testActivity
|
||||
val pdfFile = getFile(PDF_FILE_ASSET)
|
||||
val ocFile = OCFile("/test.pdf").apply {
|
||||
storagePath = pdfFile.absolutePath
|
||||
}
|
||||
|
||||
val sut = PreviewPdfFragment.newInstance(ocFile)
|
||||
activity.addFragment(sut)
|
||||
activity.supportFragmentManager.executePendingTransactions()
|
||||
sut.dismissSnack()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "showPdf", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(activity, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,21 +10,15 @@ package com.owncloud.android.ui.trashbin
|
||||
import android.accounts.Account
|
||||
import android.accounts.AccountManager
|
||||
import android.content.Intent
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.test.core.app.launchActivity
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.IdlingRegistry
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isRoot
|
||||
import com.owncloud.android.utils.EspressoIdlingResource
|
||||
import com.owncloud.android.AbstractIT
|
||||
import com.owncloud.android.MainApp
|
||||
import com.owncloud.android.extensions.launchAndCapture
|
||||
import com.owncloud.android.lib.common.accounts.AccountUtils
|
||||
import com.owncloud.android.utils.ScreenshotTest
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
class TrashbinActivityIT : AbstractIT() {
|
||||
@@ -36,90 +30,106 @@ class TrashbinActivityIT : AbstractIT() {
|
||||
FILES
|
||||
}
|
||||
|
||||
@Before
|
||||
fun registerIdlingResource() {
|
||||
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@After
|
||||
fun unregisterIdlingResource() {
|
||||
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun error() {
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
scenario.onActivity { sut ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.ERROR)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
onIdleSync {
|
||||
EspressoIdlingResource.increment()
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "error", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun files() {
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "files", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
})
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.FILES)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "files", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun empty() {
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "empty", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { EspressoIdlingResource.decrement() },
|
||||
onError = { EspressoIdlingResource.decrement() }
|
||||
)
|
||||
})
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.loadFolder(
|
||||
onComplete = { },
|
||||
onError = { }
|
||||
)
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "empty", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun loading() {
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "loading", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showInitialLoading()
|
||||
})
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showInitialLoading()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "loading", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun normalUser() {
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "normalUser", before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
})
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "normalUser", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThread
|
||||
@ScreenshotTest
|
||||
fun differentUser() {
|
||||
val temp = Account("differentUser@https://nextcloud.localhost", MainApp.getAccountType(targetContext))
|
||||
@@ -134,10 +144,18 @@ class TrashbinActivityIT : AbstractIT() {
|
||||
putExtra(Intent.EXTRA_USER, "differentUser@https://nextcloud.localhost")
|
||||
}
|
||||
|
||||
launchAndCapture<TrashbinActivity>(testClassName, "differentUser", intent = intent, before = { sut ->
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
})
|
||||
launchActivity<TrashbinActivity>().use { scenario ->
|
||||
var sut: TrashbinActivity? = null
|
||||
scenario.onActivity { activity ->
|
||||
sut = activity
|
||||
val trashbinRepository = TrashbinLocalRepository(TestCase.EMPTY)
|
||||
sut.trashbinPresenter = TrashbinPresenter(trashbinRepository, sut)
|
||||
sut.showUser()
|
||||
}
|
||||
|
||||
val screenShotName = createName(testClassName + "_" + "differentUser", "")
|
||||
onView(isRoot()).check(matches(isDisplayed()))
|
||||
screenshotViaName(sut, screenShotName)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ import com.owncloud.android.datamodel.e2e.v1.decrypted.Encrypted;
|
||||
import com.owncloud.android.datamodel.e2e.v1.encrypted.EncryptedFolderMetadataFileV1;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.e2ee.CsrHelper;
|
||||
import com.owncloud.android.utils.crypto.CryptoHelper;
|
||||
import com.owncloud.android.utils.EncryptionUtils;
|
||||
import com.owncloud.android.utils.crypto.CryptoHelper;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
@@ -75,10 +75,10 @@ import static com.owncloud.android.utils.EncryptionUtils.serializeJSON;
|
||||
import static com.owncloud.android.utils.EncryptionUtils.verifySHA512;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class EncryptionTestIT extends AbstractIT {
|
||||
@Rule public RetryTestRule retryTestRule = new RetryTestRule();
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
android:installLocation="internalOnly"
|
||||
android:label="@string/app_name"
|
||||
android:manageSpaceActivity="com.owncloud.android.ui.activity.ManageSpaceActivity"
|
||||
android:memtagMode="async"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_launcher"
|
||||
@@ -302,9 +303,6 @@
|
||||
<receiver
|
||||
android:name="com.nextcloud.client.jobs.NotificationWork$NotificationReceiver"
|
||||
android:exported="false" />
|
||||
<receiver
|
||||
android:name="com.nextcloud.client.jobs.upload.FileUploadHelper$UploadNotificationActionReceiver"
|
||||
android:exported="false" />
|
||||
<receiver
|
||||
android:name="com.nextcloud.client.widget.DashboardWidgetProvider"
|
||||
android:exported="false">
|
||||
|
||||
@@ -95,7 +95,7 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
||||
|
||||
boolean setCurrentOwnCloudAccount(String accountName);
|
||||
|
||||
boolean setCurrentOwnCloudAccount(int hashCode);
|
||||
boolean setCurrentOwnCloudAccount(User user);
|
||||
|
||||
/**
|
||||
* Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
|
||||
|
||||
@@ -346,11 +346,11 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setCurrentOwnCloudAccount(int hashCode) {
|
||||
public boolean setCurrentOwnCloudAccount(User chosenUser) {
|
||||
boolean result = false;
|
||||
if (hashCode != 0) {
|
||||
if (chosenUser != null) {
|
||||
for (final User user : getAllUsers()) {
|
||||
if (hashCode == user.hashCode()) {
|
||||
if (chosenUser.nameEquals(user)) {
|
||||
SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
||||
appPrefs.putString(PREF_SELECT_OC_ACCOUNT, user.getAccountName());
|
||||
appPrefs.apply();
|
||||
|
||||
@@ -12,6 +12,7 @@ import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@@ -20,17 +21,18 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FabPosition
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.pulltorefresh.pullToRefresh
|
||||
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
|
||||
@@ -39,8 +41,10 @@ import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
@@ -51,10 +55,13 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.nextcloud.client.assistant.component.AddTaskAlertDialog
|
||||
import com.nextcloud.client.assistant.chat.ChatContent
|
||||
import com.nextcloud.client.assistant.conversation.ConversationScreen
|
||||
import com.nextcloud.client.assistant.conversation.ConversationViewModel
|
||||
import com.nextcloud.client.assistant.conversation.repository.MockConversationRemoteRepository
|
||||
import com.nextcloud.client.assistant.extensions.getInputTitle
|
||||
import com.nextcloud.client.assistant.model.AssistantScreenState
|
||||
import com.nextcloud.client.assistant.model.ScreenOverlayState
|
||||
import com.nextcloud.client.assistant.model.ScreenState
|
||||
import com.nextcloud.client.assistant.repository.local.MockAssistantLocalRepository
|
||||
import com.nextcloud.client.assistant.repository.remote.MockAssistantRemoteRepository
|
||||
import com.nextcloud.client.assistant.task.TaskView
|
||||
@@ -62,6 +69,7 @@ import com.nextcloud.client.assistant.taskTypes.TaskTypesRow
|
||||
import com.nextcloud.ui.composeActivity.ComposeActivity
|
||||
import com.nextcloud.ui.composeComponents.alertDialog.SimpleAlertDialog
|
||||
import com.nextcloud.ui.composeComponents.bottomSheet.MoreActionsBottomSheet
|
||||
import com.nextcloud.utils.extensions.getChat
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
@@ -69,15 +77,21 @@ import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
private const val CHAT_INPUT_DELAY = 100L
|
||||
private const val PULL_TO_REFRESH_DELAY = 1500L
|
||||
|
||||
@Suppress("LongMethod")
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun AssistantScreen(viewModel: AssistantViewModel, capability: OCCapability, activity: Activity) {
|
||||
fun AssistantScreen(
|
||||
viewModel: AssistantViewModel,
|
||||
conversationViewModel: ConversationViewModel,
|
||||
capability: OCCapability,
|
||||
activity: Activity
|
||||
) {
|
||||
val sessionId by viewModel.sessionId.collectAsState()
|
||||
val messageId by viewModel.snackbarMessageId.collectAsState()
|
||||
val screenOverlayState by viewModel.screenOverlayState.collectAsState()
|
||||
|
||||
val selectedTaskType by viewModel.selectedTaskType.collectAsState()
|
||||
val filteredTaskList by viewModel.filteredTaskList.collectAsState()
|
||||
val screenState by viewModel.screenState.collectAsState()
|
||||
@@ -85,6 +99,7 @@ fun AssistantScreen(viewModel: AssistantViewModel, capability: OCCapability, act
|
||||
val scope = rememberCoroutineScope()
|
||||
val pullRefreshState = rememberPullToRefreshState()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val pagerState = rememberPagerState(initialPage = 1, pageCount = { 2 })
|
||||
|
||||
LaunchedEffect(messageId) {
|
||||
messageId?.let {
|
||||
@@ -93,93 +108,201 @@ fun AssistantScreen(viewModel: AssistantViewModel, capability: OCCapability, act
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.startTaskListPolling()
|
||||
LaunchedEffect(sessionId) {
|
||||
viewModel.startPolling(sessionId)
|
||||
|
||||
sessionId?.let {
|
||||
viewModel.fetchChatMessages(it)
|
||||
}
|
||||
}
|
||||
|
||||
DisposableEffect(Unit) {
|
||||
onDispose {
|
||||
viewModel.stopTaskListPolling()
|
||||
viewModel.stopPolling()
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.pullToRefresh(
|
||||
false,
|
||||
pullRefreshState,
|
||||
onRefresh = {
|
||||
scope.launch {
|
||||
delay(PULL_TO_REFRESH_DELAY)
|
||||
viewModel.fetchTaskList()
|
||||
HorizontalPager(
|
||||
state = pagerState,
|
||||
userScrollEnabled = taskTypes.getChat() != null
|
||||
) { page ->
|
||||
when (page) {
|
||||
0 -> {
|
||||
ConversationScreen(viewModel = conversationViewModel, close = {
|
||||
scope.launch {
|
||||
pagerState.scrollToPage(1)
|
||||
}
|
||||
}, openChat = { newSessionId ->
|
||||
viewModel.initSessionId(newSessionId)
|
||||
taskTypes.getChat()?.let { chatTaskType ->
|
||||
viewModel.selectTaskType(chatTaskType)
|
||||
}
|
||||
scope.launch {
|
||||
pagerState.scrollToPage(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
1 -> {
|
||||
Scaffold(
|
||||
modifier = Modifier.pullToRefresh(
|
||||
false,
|
||||
pullRefreshState,
|
||||
onRefresh = {
|
||||
scope.launch {
|
||||
delay(PULL_TO_REFRESH_DELAY)
|
||||
|
||||
val newSessionId = sessionId
|
||||
if (newSessionId != null) {
|
||||
viewModel.fetchChatMessages(newSessionId)
|
||||
} else {
|
||||
viewModel.fetchTaskList()
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
topBar = {
|
||||
taskTypes?.let {
|
||||
TaskTypesRow(selectedTaskType, data = it, selectTaskType = { task ->
|
||||
viewModel.selectTaskType(task)
|
||||
}, navigateToConversationList = {
|
||||
scope.launch {
|
||||
pagerState.scrollToPage(0)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
bottomBar = {
|
||||
if (!taskTypes.isNullOrEmpty()) {
|
||||
ChatInputBar(
|
||||
sessionId,
|
||||
selectedTaskType,
|
||||
viewModel
|
||||
)
|
||||
}
|
||||
},
|
||||
snackbarHost = {
|
||||
SnackbarHost(snackbarHostState)
|
||||
}
|
||||
) { paddingValues ->
|
||||
when (screenState) {
|
||||
is AssistantScreenState.EmptyContent -> {
|
||||
val state = (screenState as AssistantScreenState.EmptyContent)
|
||||
EmptyContent(
|
||||
paddingValues,
|
||||
iconId = state.iconId,
|
||||
descriptionId = state.descriptionId,
|
||||
titleId = state.titleId
|
||||
)
|
||||
}
|
||||
|
||||
AssistantScreenState.TaskContent -> {
|
||||
TaskContent(
|
||||
paddingValues,
|
||||
filteredTaskList ?: listOf(),
|
||||
viewModel,
|
||||
capability
|
||||
)
|
||||
}
|
||||
|
||||
AssistantScreenState.ChatContent -> {
|
||||
ChatContent(
|
||||
viewModel = viewModel,
|
||||
modifier = Modifier.padding(paddingValues)
|
||||
)
|
||||
}
|
||||
|
||||
else -> EmptyContent(
|
||||
paddingValues,
|
||||
iconId = R.drawable.spinner_inner,
|
||||
titleId = null,
|
||||
descriptionId = R.string.common_loading
|
||||
)
|
||||
}
|
||||
|
||||
LinearProgressIndicator(
|
||||
progress = { pullRefreshState.distanceFraction },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
|
||||
OverlayState(screenOverlayState, activity, viewModel)
|
||||
}
|
||||
}
|
||||
),
|
||||
topBar = {
|
||||
taskTypes?.let {
|
||||
TaskTypesRow(selectedTaskType, data = it) { task ->
|
||||
viewModel.selectTaskType(task)
|
||||
}
|
||||
}
|
||||
},
|
||||
floatingActionButton = {
|
||||
if (!taskTypes.isNullOrEmpty()) {
|
||||
AddTaskButton(
|
||||
selectedTaskType,
|
||||
viewModel
|
||||
)
|
||||
}
|
||||
},
|
||||
floatingActionButtonPosition = FabPosition.EndOverlay,
|
||||
snackbarHost = {
|
||||
SnackbarHost(snackbarHostState)
|
||||
}
|
||||
) { paddingValues ->
|
||||
when (screenState) {
|
||||
is ScreenState.EmptyContent -> {
|
||||
val state = (screenState as ScreenState.EmptyContent)
|
||||
EmptyContent(
|
||||
paddingValues,
|
||||
state.iconId,
|
||||
state.descriptionId
|
||||
)
|
||||
}
|
||||
|
||||
ScreenState.Content -> {
|
||||
AssistantContent(
|
||||
paddingValues,
|
||||
filteredTaskList ?: listOf(),
|
||||
viewModel,
|
||||
capability
|
||||
)
|
||||
}
|
||||
|
||||
else -> EmptyContent(
|
||||
paddingValues,
|
||||
R.drawable.spinner_inner,
|
||||
R.string.assistant_screen_loading
|
||||
)
|
||||
}
|
||||
|
||||
LinearProgressIndicator(
|
||||
progress = { pullRefreshState.distanceFraction },
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
|
||||
OverlayState(screenOverlayState, activity, viewModel)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
private fun AddTaskButton(selectedTaskType: TaskTypeData?, viewModel: AssistantViewModel) {
|
||||
FloatingActionButton(
|
||||
onClick = {
|
||||
selectedTaskType?.let {
|
||||
val newState = ScreenOverlayState.AddTask(it, "")
|
||||
viewModel.updateTaskListScreenState(newState)
|
||||
private fun ChatInputBar(sessionId: Long?, selectedTaskType: TaskTypeData?, viewModel: AssistantViewModel) {
|
||||
val scope = rememberCoroutineScope()
|
||||
var text by remember { mutableStateOf("") }
|
||||
|
||||
Surface(
|
||||
tonalElevation = 3.dp,
|
||||
shadowElevation = 4.dp,
|
||||
color = MaterialTheme.colorScheme.surface
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.assistant_output_generation_warning_text),
|
||||
fontSize = 11.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
color = colorResource(R.color.text_color)
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = text,
|
||||
onValueChange = { text = it },
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(end = 8.dp),
|
||||
placeholder = { Text(selectedTaskType?.description ?: "") },
|
||||
singleLine = true
|
||||
)
|
||||
|
||||
IconButton(
|
||||
onClick = {
|
||||
if (text.isBlank()) {
|
||||
return@IconButton
|
||||
}
|
||||
|
||||
val taskType = selectedTaskType ?: return@IconButton
|
||||
if (taskType.isChat()) {
|
||||
if (sessionId != null) {
|
||||
viewModel.sendChatMessage(content = text, sessionId)
|
||||
} else {
|
||||
viewModel.createConversation(text)
|
||||
}
|
||||
} else {
|
||||
viewModel.createTask(input = text, taskType = taskType)
|
||||
}
|
||||
|
||||
scope.launch {
|
||||
delay(CHAT_INPUT_DELAY)
|
||||
text = ""
|
||||
}
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_send),
|
||||
contentDescription = "Send message",
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
) {
|
||||
Icon(Icons.Filled.Add, "Add Task Icon")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,42 +310,24 @@ private fun AddTaskButton(selectedTaskType: TaskTypeData?, viewModel: AssistantV
|
||||
@Composable
|
||||
private fun OverlayState(state: ScreenOverlayState?, activity: Activity, viewModel: AssistantViewModel) {
|
||||
when (state) {
|
||||
is ScreenOverlayState.AddTask -> {
|
||||
AddTaskAlertDialog(
|
||||
title = state.taskType.name,
|
||||
description = state.taskType.description,
|
||||
defaultInput = state.input,
|
||||
addTask = { input ->
|
||||
state.taskType.let { taskType ->
|
||||
viewModel.createTask(input = input, taskType = taskType)
|
||||
}
|
||||
},
|
||||
dismiss = {
|
||||
viewModel.updateTaskListScreenState(null)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
is ScreenOverlayState.DeleteTask -> {
|
||||
SimpleAlertDialog(
|
||||
title = stringResource(id = R.string.assistant_screen_delete_task_alert_dialog_title),
|
||||
description = stringResource(id = R.string.assistant_screen_delete_task_alert_dialog_description),
|
||||
dismiss = { viewModel.updateTaskListScreenState(null) },
|
||||
dismiss = { viewModel.updateScreenOverlayState(null) },
|
||||
onComplete = { viewModel.deleteTask(state.id) }
|
||||
)
|
||||
}
|
||||
|
||||
is ScreenOverlayState.TaskActions -> {
|
||||
val actions = state.getActions(activity, onEditCompleted = { addTask ->
|
||||
viewModel.updateTaskListScreenState(addTask)
|
||||
}, onDeleteCompleted = { deleteTask ->
|
||||
viewModel.updateTaskListScreenState(deleteTask)
|
||||
val actions = state.getActions(activity, onDeleteCompleted = { deleteTask ->
|
||||
viewModel.updateScreenOverlayState(deleteTask)
|
||||
})
|
||||
|
||||
MoreActionsBottomSheet(
|
||||
title = state.task.getInputTitle(),
|
||||
actions = actions,
|
||||
dismiss = { viewModel.updateTaskListScreenState(null) }
|
||||
dismiss = { viewModel.updateScreenOverlayState(null) }
|
||||
)
|
||||
}
|
||||
|
||||
@@ -231,7 +336,7 @@ private fun OverlayState(state: ScreenOverlayState?, activity: Activity, viewMod
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AssistantContent(
|
||||
private fun TaskContent(
|
||||
paddingValues: PaddingValues,
|
||||
taskList: List<Task>,
|
||||
viewModel: AssistantViewModel,
|
||||
@@ -251,7 +356,7 @@ private fun AssistantContent(
|
||||
capability,
|
||||
showTaskActions = {
|
||||
val newState = ScreenOverlayState.TaskActions(task)
|
||||
viewModel.updateTaskListScreenState(newState)
|
||||
viewModel.updateScreenOverlayState(newState)
|
||||
}
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
@@ -260,7 +365,7 @@ private fun AssistantContent(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EmptyContent(paddingValues: PaddingValues, iconId: Int?, descriptionId: Int) {
|
||||
private fun EmptyContent(paddingValues: PaddingValues, iconId: Int?, descriptionId: Int?, titleId: Int?) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
@@ -280,12 +385,24 @@ private fun EmptyContent(paddingValues: PaddingValues, iconId: Int?, description
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
|
||||
Text(
|
||||
text = stringResource(descriptionId),
|
||||
fontSize = 18.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
color = colorResource(R.color.text_color)
|
||||
)
|
||||
titleId?.let {
|
||||
Text(
|
||||
text = stringResource(titleId),
|
||||
style = MaterialTheme.typography.headlineSmall,
|
||||
textAlign = TextAlign.Center,
|
||||
color = colorResource(R.color.text_color)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
|
||||
descriptionId?.let {
|
||||
Text(
|
||||
text = stringResource(descriptionId),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
color = colorResource(R.color.text_color)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +413,8 @@ private fun AssistantScreenPreview() {
|
||||
MaterialTheme(
|
||||
content = {
|
||||
AssistantScreen(
|
||||
viewModel = getMockViewModel(false),
|
||||
conversationViewModel = getMockConversationViewModel(),
|
||||
viewModel = getMockAssistantViewModel(false),
|
||||
activity = ComposeActivity(),
|
||||
capability = OCCapability().apply {
|
||||
versionMayor = 30
|
||||
@@ -313,7 +431,8 @@ private fun AssistantEmptyScreenPreview() {
|
||||
MaterialTheme(
|
||||
content = {
|
||||
AssistantScreen(
|
||||
viewModel = getMockViewModel(true),
|
||||
conversationViewModel = getMockConversationViewModel(),
|
||||
viewModel = getMockAssistantViewModel(true),
|
||||
activity = ComposeActivity(),
|
||||
capability = OCCapability().apply {
|
||||
versionMayor = 30
|
||||
@@ -323,12 +442,20 @@ private fun AssistantEmptyScreenPreview() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun getMockViewModel(giveEmptyTasks: Boolean): AssistantViewModel {
|
||||
private fun getMockConversationViewModel(): ConversationViewModel {
|
||||
val mockRemoteRepository = MockConversationRemoteRepository()
|
||||
return ConversationViewModel(
|
||||
remoteRepository = mockRemoteRepository
|
||||
)
|
||||
}
|
||||
|
||||
private fun getMockAssistantViewModel(giveEmptyTasks: Boolean): AssistantViewModel {
|
||||
val mockLocalRepository = MockAssistantLocalRepository()
|
||||
val mockRemoteRepository = MockAssistantRemoteRepository(giveEmptyTasks)
|
||||
return AssistantViewModel(
|
||||
accountName = "test:localhost",
|
||||
remoteRepository = mockRemoteRepository,
|
||||
localRepository = mockLocalRepository
|
||||
localRepository = mockLocalRepository,
|
||||
sessionIdArg = null
|
||||
)
|
||||
}
|
||||
@@ -9,12 +9,16 @@ package com.nextcloud.client.assistant
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.nextcloud.client.assistant.model.AssistantScreenState
|
||||
import com.nextcloud.client.assistant.model.ScreenOverlayState
|
||||
import com.nextcloud.client.assistant.model.ScreenState
|
||||
import com.nextcloud.client.assistant.repository.local.AssistantLocalRepository
|
||||
import com.nextcloud.client.assistant.repository.remote.AssistantRemoteRepository
|
||||
import com.nextcloud.utils.TimeConstants.MILLIS_PER_SECOND
|
||||
import com.nextcloud.utils.extensions.isHuman
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessage
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessageRequest
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -22,27 +26,33 @@ import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
class AssistantViewModel(
|
||||
private val accountName: String,
|
||||
private val remoteRepository: AssistantRemoteRepository,
|
||||
private val localRepository: AssistantLocalRepository
|
||||
private val localRepository: AssistantLocalRepository,
|
||||
sessionIdArg: Long?
|
||||
) : ViewModel() {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "AssistantViewModel"
|
||||
private const val TASK_LIST_POLLING_INTERVAL_MS = 15_000L
|
||||
private const val POLLING_INTERVAL_MS = 15_000L
|
||||
}
|
||||
|
||||
private val _screenState = MutableStateFlow<ScreenState?>(null)
|
||||
val screenState: StateFlow<ScreenState?> = _screenState
|
||||
private val _screenState = MutableStateFlow<AssistantScreenState?>(null)
|
||||
val screenState: StateFlow<AssistantScreenState?> = _screenState
|
||||
|
||||
private val _screenOverlayState = MutableStateFlow<ScreenOverlayState?>(null)
|
||||
val screenOverlayState: StateFlow<ScreenOverlayState?> = _screenOverlayState
|
||||
|
||||
private val _sessionId = MutableStateFlow(sessionIdArg)
|
||||
val sessionId: StateFlow<Long?> = _sessionId
|
||||
|
||||
private val _snackbarMessageId = MutableStateFlow<Int?>(null)
|
||||
val snackbarMessageId: StateFlow<Int?> = _snackbarMessageId
|
||||
|
||||
@@ -57,36 +67,59 @@ class AssistantViewModel(
|
||||
private val _filteredTaskList = MutableStateFlow<List<Task>?>(null)
|
||||
val filteredTaskList: StateFlow<List<Task>?> = _filteredTaskList
|
||||
|
||||
private var taskPollingJob: Job? = null
|
||||
private val _chatMessages = MutableStateFlow<List<ChatMessage>>(listOf())
|
||||
val chatMessages: StateFlow<List<ChatMessage>> = _chatMessages
|
||||
|
||||
private val _isAssistantAnswering = MutableStateFlow(false)
|
||||
val isAssistantAnswering: StateFlow<Boolean> = _isAssistantAnswering
|
||||
|
||||
private var pollingJob: Job? = null
|
||||
private var currentChatTaskId: String? = null
|
||||
|
||||
init {
|
||||
observeScreenState()
|
||||
fetchTaskTypes()
|
||||
}
|
||||
|
||||
// region task polling
|
||||
fun startTaskListPolling() {
|
||||
stopTaskListPolling()
|
||||
fun startPolling(sessionId: Long?) {
|
||||
stopPolling()
|
||||
|
||||
taskPollingJob = viewModelScope.launch(Dispatchers.IO) {
|
||||
pollingJob = viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
while (isActive) {
|
||||
Log_OC.d(TAG, "Polling task list...")
|
||||
fetchTaskListSuspending()
|
||||
delay(TASK_LIST_POLLING_INTERVAL_MS)
|
||||
delay(POLLING_INTERVAL_MS)
|
||||
|
||||
val taskType = _selectedTaskType.value ?: continue
|
||||
|
||||
if (taskType.isChat() && sessionId != null) {
|
||||
Log_OC.d(TAG, "Polling chat messages, sessionId: $sessionId")
|
||||
|
||||
if (currentChatTaskId == null) {
|
||||
remoteRepository.generateSession(sessionId.toString())?.let {
|
||||
currentChatTaskId = it.taskId.toString()
|
||||
}
|
||||
}
|
||||
|
||||
fetchNewChatMessage(sessionId)
|
||||
} else if (!taskType.isChat()) {
|
||||
Log_OC.d(TAG, "Polling task list")
|
||||
pollTaskList()
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
Log_OC.d(TAG, "Polling coroutine cancelled")
|
||||
Log_OC.d(TAG, "Polling cancelled, sessionId: $sessionId")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun stopTaskListPolling() {
|
||||
taskPollingJob?.cancel()
|
||||
taskPollingJob = null
|
||||
fun stopPolling() {
|
||||
pollingJob?.cancel()
|
||||
pollingJob = null
|
||||
}
|
||||
// endregion
|
||||
|
||||
private suspend fun fetchTaskListSuspending() {
|
||||
private suspend fun pollTaskList() {
|
||||
val cachedTasks = localRepository.getCachedTasks(accountName)
|
||||
if (cachedTasks.isNotEmpty()) {
|
||||
_filteredTaskList.value = cachedTasks.sortedByDescending { it.id }
|
||||
@@ -101,107 +134,171 @@ class AssistantViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
fun createTask(input: String, taskType: TaskTypeData) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val result = remoteRepository.createTask(input, taskType)
|
||||
fun fetchNewChatMessage(sessionId: Long) = viewModelScope.launch(Dispatchers.IO) {
|
||||
val taskId = currentChatTaskId ?: return@launch
|
||||
val newMessage = remoteRepository.checkGeneration(taskId, sessionId.toString()) ?: return@launch
|
||||
|
||||
val messageId = if (result.isSuccess) {
|
||||
R.string.assistant_screen_task_create_success_message
|
||||
} else {
|
||||
R.string.assistant_screen_task_create_fail_message
|
||||
_chatMessages.update { current ->
|
||||
val messageExists = current.any {
|
||||
it.id == newMessage.id ||
|
||||
(it.timestamp == newMessage.timestamp && it.content == newMessage.content)
|
||||
}
|
||||
|
||||
updateSnackbarMessage(messageId)
|
||||
if (messageExists) {
|
||||
current
|
||||
} else {
|
||||
if (!newMessage.isHuman()) {
|
||||
_isAssistantAnswering.update {
|
||||
false
|
||||
}
|
||||
}
|
||||
current + newMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delay(2000L)
|
||||
private fun observeScreenState() {
|
||||
viewModelScope.launch {
|
||||
combine(
|
||||
_selectedTaskType,
|
||||
_chatMessages,
|
||||
_filteredTaskList
|
||||
) { selectedTask, chats, tasks ->
|
||||
val isChat = selectedTask?.isChat() == true
|
||||
|
||||
when {
|
||||
selectedTask == null -> AssistantScreenState.Loading
|
||||
isChat && chats.isEmpty() -> AssistantScreenState.emptyChatList()
|
||||
isChat -> AssistantScreenState.ChatContent
|
||||
!isChat && (tasks == null || tasks.isEmpty()) -> AssistantScreenState.emptyTaskList()
|
||||
else -> AssistantScreenState.TaskContent
|
||||
}
|
||||
}.collect { newState ->
|
||||
_screenState.value = newState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// region chat
|
||||
fun sendChatMessage(content: String, sessionId: Long) = viewModelScope.launch(Dispatchers.IO) {
|
||||
val request = ChatMessageRequest(
|
||||
sessionId = sessionId.toString(),
|
||||
role = "human",
|
||||
content = content,
|
||||
timestamp = System.currentTimeMillis() / MILLIS_PER_SECOND,
|
||||
firstHumanMessage = _chatMessages.value.isEmpty()
|
||||
)
|
||||
|
||||
remoteRepository.sendChatMessage(request)?.let { newMessage ->
|
||||
_chatMessages.update { messages ->
|
||||
messages + newMessage
|
||||
}
|
||||
_isAssistantAnswering.update {
|
||||
true
|
||||
}
|
||||
} ?: updateSnackbarMessage(R.string.assistant_screen_chat_create_error)
|
||||
}
|
||||
|
||||
fun fetchChatMessages(sessionId: Long) = viewModelScope.launch(Dispatchers.IO) {
|
||||
remoteRepository.fetchChatMessages(sessionId)?.let { messageList ->
|
||||
_chatMessages.update {
|
||||
messageList
|
||||
}
|
||||
} ?: updateSnackbarMessage(R.string.assistant_screen_chat_fetch_error)
|
||||
}
|
||||
|
||||
fun createConversation(title: String) = viewModelScope.launch(Dispatchers.IO) {
|
||||
remoteRepository.createConversation(title)?.let { result ->
|
||||
initSessionId(result.session.id)
|
||||
sendChatMessage(title, result.session.id)
|
||||
}
|
||||
}
|
||||
|
||||
fun initSessionId(value: Long) {
|
||||
Log_OC.d(TAG, "session id updated: $value")
|
||||
currentChatTaskId = null
|
||||
_sessionId.update { value }
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region task
|
||||
fun createTask(input: String, taskType: TaskTypeData) = viewModelScope.launch(Dispatchers.IO) {
|
||||
val result = remoteRepository.createTask(input, taskType)
|
||||
val message = if (result.isSuccess) {
|
||||
R.string.assistant_screen_task_create_success_message
|
||||
} else {
|
||||
R.string.assistant_screen_task_create_fail_message
|
||||
}
|
||||
|
||||
updateSnackbarMessage(message)
|
||||
delay(MILLIS_PER_SECOND * 2L)
|
||||
fetchTaskList()
|
||||
}
|
||||
|
||||
fun selectTaskType(task: TaskTypeData) {
|
||||
Log_OC.d(TAG, "Task type changed: ${task.name}, session id: ${_sessionId.value}")
|
||||
updateTaskType(task)
|
||||
|
||||
val sessionId = _sessionId.value ?: return
|
||||
if (task.isChat()) {
|
||||
if (_chatMessages.value.isEmpty()) {
|
||||
fetchChatMessages(sessionId)
|
||||
} else {
|
||||
fetchNewChatMessage(sessionId)
|
||||
}
|
||||
} else {
|
||||
fetchTaskList()
|
||||
}
|
||||
}
|
||||
|
||||
fun selectTaskType(task: TaskTypeData) {
|
||||
_selectedTaskType.update {
|
||||
task
|
||||
private fun fetchTaskTypes() = viewModelScope.launch(Dispatchers.IO) {
|
||||
val result = remoteRepository.getTaskTypes()
|
||||
if (result.isNullOrEmpty()) {
|
||||
_screenState.value = AssistantScreenState.emptyTaskTypes()
|
||||
return@launch
|
||||
}
|
||||
|
||||
fetchTaskList()
|
||||
}
|
||||
|
||||
private fun fetchTaskTypes() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val taskTypesResult = remoteRepository.getTaskTypes()
|
||||
if (taskTypesResult == null || taskTypesResult.isEmpty()) {
|
||||
_screenState.update {
|
||||
ScreenState.emptyTaskTypes()
|
||||
}
|
||||
return@launch
|
||||
}
|
||||
|
||||
_taskTypes.update {
|
||||
taskTypesResult
|
||||
}
|
||||
|
||||
selectTaskType(taskTypesResult.first())
|
||||
_taskTypes.update {
|
||||
result
|
||||
}
|
||||
selectTaskType(result.first())
|
||||
}
|
||||
|
||||
fun fetchTaskList() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
// Try cached data first
|
||||
val cachedTasks = localRepository.getCachedTasks(accountName)
|
||||
if (cachedTasks.isNotEmpty()) {
|
||||
_filteredTaskList.update {
|
||||
cachedTasks.sortedByDescending { it.id }
|
||||
}
|
||||
updateTaskListScreenState()
|
||||
}
|
||||
fun fetchTaskList() = viewModelScope.launch(Dispatchers.IO) {
|
||||
val cached = localRepository.getCachedTasks(accountName)
|
||||
if (cached.isNotEmpty()) {
|
||||
_filteredTaskList.value = cached.sortedByDescending { it.id }
|
||||
}
|
||||
|
||||
val taskType = _selectedTaskType.value?.id ?: return@launch
|
||||
val result = remoteRepository.getTaskList(taskType)
|
||||
if (result != null) {
|
||||
_selectedTaskType.value?.id?.let { typeId ->
|
||||
remoteRepository.getTaskList(typeId)?.let { result ->
|
||||
taskList = result
|
||||
_filteredTaskList.update {
|
||||
taskList?.sortedByDescending { task ->
|
||||
task.id
|
||||
}
|
||||
}
|
||||
|
||||
_filteredTaskList.value = result.sortedByDescending { it.id }
|
||||
localRepository.cacheTasks(result, accountName)
|
||||
updateSnackbarMessage(null)
|
||||
} else {
|
||||
updateSnackbarMessage(R.string.assistant_screen_task_list_error_state_message)
|
||||
}
|
||||
|
||||
updateTaskListScreenState()
|
||||
} ?: updateSnackbarMessage(R.string.assistant_screen_task_list_error_state_message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTaskListScreenState() {
|
||||
_screenState.update {
|
||||
if (_filteredTaskList.value?.isEmpty() == true) {
|
||||
ScreenState.emptyTaskList()
|
||||
} else {
|
||||
ScreenState.Content
|
||||
}
|
||||
fun deleteTask(id: Long) = viewModelScope.launch(Dispatchers.IO) {
|
||||
val result = remoteRepository.deleteTask(id)
|
||||
val message = if (result.isSuccess) {
|
||||
R.string.assistant_screen_task_delete_success_message
|
||||
} else {
|
||||
R.string.assistant_screen_task_delete_fail_message
|
||||
}
|
||||
|
||||
updateSnackbarMessage(message)
|
||||
if (result.isSuccess) {
|
||||
removeTaskFromList(id)
|
||||
localRepository.deleteTask(id, accountName)
|
||||
}
|
||||
}
|
||||
// endregion
|
||||
|
||||
fun deleteTask(id: Long) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val result = remoteRepository.deleteTask(id)
|
||||
|
||||
val messageId = if (result.isSuccess) {
|
||||
R.string.assistant_screen_task_delete_success_message
|
||||
} else {
|
||||
R.string.assistant_screen_task_delete_fail_message
|
||||
}
|
||||
|
||||
updateSnackbarMessage(messageId)
|
||||
|
||||
if (result.isSuccess) {
|
||||
removeTaskFromList(id)
|
||||
localRepository.deleteTask(id, accountName)
|
||||
}
|
||||
private fun updateTaskType(value: TaskTypeData) {
|
||||
_selectedTaskType.update {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +308,7 @@ class AssistantViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
fun updateTaskListScreenState(value: ScreenOverlayState?) {
|
||||
fun updateScreenOverlayState(value: ScreenOverlayState?) {
|
||||
_screenOverlayState.update {
|
||||
value
|
||||
}
|
||||
|
||||
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
@file:Suppress("TopLevelPropertyNaming", "MagicNumber")
|
||||
|
||||
package com.nextcloud.client.assistant.chat
|
||||
|
||||
import androidx.compose.animation.core.LinearEasing
|
||||
import androidx.compose.animation.core.RepeatMode
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.infiniteRepeatable
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.defaultMinSize
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.draw.scale
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.nextcloud.client.assistant.AssistantViewModel
|
||||
import com.nextcloud.utils.TimeConstants
|
||||
import com.nextcloud.utils.extensions.isHuman
|
||||
import com.nextcloud.utils.extensions.time
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessage
|
||||
import java.time.Instant
|
||||
|
||||
private val MIN_CHAT_HEIGHT = 60.dp
|
||||
private val CHAT_BUBBLE_CORNER_RADIUS = 8.dp
|
||||
private val ASSISTANT_ICON_SIZE = 40.dp
|
||||
|
||||
@Composable
|
||||
fun ChatContent(viewModel: AssistantViewModel, modifier: Modifier = Modifier) {
|
||||
val chatMessages by viewModel.chatMessages.collectAsState()
|
||||
val isAssistantAnswering by viewModel.isAssistantAnswering.collectAsState()
|
||||
val listState = rememberLazyListState()
|
||||
|
||||
LaunchedEffect(chatMessages) {
|
||||
listState.animateScrollToItem(listState.layoutInfo.totalItemsCount)
|
||||
}
|
||||
|
||||
LazyColumn(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.padding(horizontal = 12.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.Bottom,
|
||||
reverseLayout = false,
|
||||
state = listState
|
||||
) {
|
||||
items(chatMessages, key = { it.id }) { message ->
|
||||
if (message.isHuman()) {
|
||||
UserMessageItem(message)
|
||||
} else {
|
||||
AssistantMessageItem(message)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
|
||||
if (isAssistantAnswering) {
|
||||
item {
|
||||
AssistantTypingIndicator()
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AssistantTypingIndicator() {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(vertical = 12.dp)
|
||||
.fillMaxWidth(),
|
||||
contentAlignment = Alignment.CenterStart
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.Bottom
|
||||
) {
|
||||
AnimatedAssistantIcon()
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(start = 8.dp, end = 16.dp)
|
||||
.defaultMinSize(minHeight = MIN_CHAT_HEIGHT)
|
||||
.clip(
|
||||
RoundedCornerShape(
|
||||
topEnd = CHAT_BUBBLE_CORNER_RADIUS,
|
||||
topStart = CHAT_BUBBLE_CORNER_RADIUS,
|
||||
bottomEnd = CHAT_BUBBLE_CORNER_RADIUS
|
||||
)
|
||||
)
|
||||
.background(color = colorResource(R.color.white))
|
||||
) {
|
||||
TypingAnimation()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AnimatedAssistantIcon() {
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "assistant_icon_animation")
|
||||
val scale by infiniteTransition.animateFloat(
|
||||
initialValue = 1f,
|
||||
targetValue = 1.1f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(TimeConstants.MILLIS_PER_SECOND, easing = LinearEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
),
|
||||
label = "scale_animation"
|
||||
)
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(ASSISTANT_ICON_SIZE)
|
||||
.clip(CircleShape)
|
||||
.background(Color.White),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_assistant),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
.scale(scale)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TypingAnimation() {
|
||||
val infiniteTransition = rememberInfiniteTransition(label = "typing_animation")
|
||||
|
||||
val alpha by infiniteTransition.animateFloat(
|
||||
initialValue = 0.3f,
|
||||
targetValue = 1f,
|
||||
animationSpec = infiniteRepeatable(
|
||||
animation = tween(600, easing = LinearEasing),
|
||||
repeatMode = RepeatMode.Reverse
|
||||
),
|
||||
label = "typing_alpha"
|
||||
)
|
||||
|
||||
Column(
|
||||
modifier = Modifier.padding(8.dp),
|
||||
horizontalAlignment = Alignment.Start
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.assistant_thinking),
|
||||
style = TextStyle(
|
||||
color = colorResource(R.color.text_color).copy(alpha = alpha),
|
||||
fontSize = 16.sp
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AssistantMessageItem(message: ChatMessage) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(vertical = 12.dp)
|
||||
.fillMaxWidth(),
|
||||
contentAlignment = Alignment.CenterStart
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.Bottom
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(ASSISTANT_ICON_SIZE)
|
||||
.clip(CircleShape)
|
||||
.background(Color.White),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_assistant),
|
||||
contentDescription = null,
|
||||
contentScale = ContentScale.Crop,
|
||||
alignment = Alignment.Center
|
||||
)
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(start = 8.dp, end = 16.dp)
|
||||
.defaultMinSize(minHeight = MIN_CHAT_HEIGHT)
|
||||
.clip(
|
||||
RoundedCornerShape(
|
||||
topEnd = CHAT_BUBBLE_CORNER_RADIUS,
|
||||
topStart = CHAT_BUBBLE_CORNER_RADIUS,
|
||||
bottomEnd = CHAT_BUBBLE_CORNER_RADIUS
|
||||
)
|
||||
)
|
||||
.background(
|
||||
color = colorResource(R.color.white)
|
||||
)
|
||||
) {
|
||||
MessageTextItem(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun UserMessageItem(message: ChatMessage) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(vertical = 12.dp)
|
||||
.fillMaxWidth(),
|
||||
contentAlignment = Alignment.CenterEnd
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.Bottom
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.padding(start = 16.dp, end = 8.dp)
|
||||
.defaultMinSize(minHeight = MIN_CHAT_HEIGHT)
|
||||
.clip(
|
||||
RoundedCornerShape(
|
||||
topEnd = CHAT_BUBBLE_CORNER_RADIUS,
|
||||
topStart = CHAT_BUBBLE_CORNER_RADIUS,
|
||||
bottomStart = CHAT_BUBBLE_CORNER_RADIUS
|
||||
)
|
||||
)
|
||||
.background(color = colorResource(R.color.white))
|
||||
) {
|
||||
MessageTextItem(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MessageTextItem(message: ChatMessage) {
|
||||
Column(
|
||||
modifier = Modifier.padding(8.dp),
|
||||
horizontalAlignment = Alignment.Start
|
||||
) {
|
||||
Text(
|
||||
text = message.content,
|
||||
style = TextStyle(
|
||||
color = colorResource(R.color.text_color),
|
||||
fontSize = 16.sp
|
||||
)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
Text(
|
||||
text = message.time(),
|
||||
style = TextStyle(
|
||||
color = colorResource(R.color.text_color),
|
||||
fontSize = 12.sp
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
private fun MessageTextItemPreview() {
|
||||
val mockMessages = listOf(
|
||||
ChatMessage(
|
||||
id = 1,
|
||||
sessionId = 101,
|
||||
role = "human",
|
||||
content = "Hey, how are you?",
|
||||
timestamp = Instant.now().epochSecond,
|
||||
ocpTaskId = null,
|
||||
sources = "",
|
||||
attachments = emptyList()
|
||||
),
|
||||
ChatMessage(
|
||||
id = 2,
|
||||
sessionId = 101,
|
||||
role = "assistant",
|
||||
content = "I'm good! Here’s a message from yesterday.",
|
||||
timestamp = Instant.now().minusSeconds(86_400).epochSecond, // 1 day ago
|
||||
ocpTaskId = null,
|
||||
sources = "",
|
||||
attachments = emptyList()
|
||||
),
|
||||
ChatMessage(
|
||||
id = 3,
|
||||
sessionId = 101,
|
||||
role = "human",
|
||||
content = "And an older one from last week.",
|
||||
timestamp = Instant.now().minusSeconds(7 * 86_400).epochSecond, // 7 days ago
|
||||
ocpTaskId = null,
|
||||
sources = "",
|
||||
attachments = emptyList()
|
||||
)
|
||||
)
|
||||
|
||||
Column(modifier = Modifier.padding(16.dp)) {
|
||||
mockMessages.forEach { message ->
|
||||
MessageTextItem(message = message)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
|
||||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
|
||||
*/
|
||||
package com.nextcloud.client.assistant.component
|
||||
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.nextcloud.ui.composeComponents.alertDialog.SimpleAlertDialog
|
||||
import com.owncloud.android.R
|
||||
|
||||
@Composable
|
||||
fun AddTaskAlertDialog(
|
||||
title: String,
|
||||
description: String?,
|
||||
defaultInput: String = "",
|
||||
addTask: (String) -> Unit,
|
||||
dismiss: () -> Unit
|
||||
) {
|
||||
var input by remember {
|
||||
mutableStateOf(defaultInput)
|
||||
}
|
||||
|
||||
SimpleAlertDialog(
|
||||
title = title,
|
||||
description = description ?: "",
|
||||
dismiss = { dismiss() },
|
||||
onComplete = {
|
||||
addTask(input)
|
||||
},
|
||||
content = {
|
||||
TextField(
|
||||
placeholder = {
|
||||
Text(
|
||||
text = stringResource(
|
||||
id = R.string.assistant_screen_create_task_alert_dialog_input_field_placeholder
|
||||
)
|
||||
)
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
||||
value = input,
|
||||
onValueChange = {
|
||||
input = it
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview
|
||||
private fun AddTaskAlertDialogPreview() {
|
||||
AddTaskAlertDialog(title = "Title", description = "Description", addTask = { }, dismiss = {})
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
@file:Suppress("TopLevelPropertyNaming", "MagicNumber")
|
||||
|
||||
package com.nextcloud.client.assistant.conversation
|
||||
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FabPosition
|
||||
import androidx.compose.material3.FloatingActionButton
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableLongStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.nextcloud.client.assistant.conversation.model.ConversationScreenState
|
||||
import com.nextcloud.ui.composeComponents.bottomSheet.MoreActionsBottomSheet
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.Conversation
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
fun ConversationScreen(viewModel: ConversationViewModel, close: () -> Unit, openChat: (Long) -> Unit) {
|
||||
val screenState by viewModel.screenState.collectAsState()
|
||||
val errorMessageId by viewModel.errorMessageId.collectAsState()
|
||||
val conversations by viewModel.conversations.collectAsState()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val errorString = errorMessageId?.let { stringResource(it) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.fetchConversations()
|
||||
}
|
||||
|
||||
LaunchedEffect(errorString) {
|
||||
errorString?.let {
|
||||
snackbarHostState.showSnackbar(it)
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
||||
IconButton(
|
||||
onClick = {
|
||||
close()
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.AutoMirrored.Outlined.ArrowBack,
|
||||
contentDescription = "go back to assistant page"
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.width(8.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.conversation_screen_title),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.headlineSmall
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
}
|
||||
},
|
||||
snackbarHost = {
|
||||
SnackbarHost(snackbarHostState)
|
||||
},
|
||||
floatingActionButton = {
|
||||
FloatingActionButton(onClick = {
|
||||
viewModel.createConversation(null, onResult = {
|
||||
openChat(it)
|
||||
})
|
||||
}) {
|
||||
Icon(Icons.Filled.Add, "Floating action button.")
|
||||
}
|
||||
},
|
||||
floatingActionButtonPosition = FabPosition.EndOverlay
|
||||
) { innerPadding ->
|
||||
when (screenState) {
|
||||
is ConversationScreenState.Loading -> {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
}
|
||||
}
|
||||
|
||||
is ConversationScreenState.EmptyContent -> {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(innerPadding),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
stringResource(R.string.conversation_screen_empty_content_title),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.headlineSmall
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
ConversationList(
|
||||
viewModel = viewModel,
|
||||
conversations = conversations,
|
||||
modifier = Modifier.padding(innerPadding),
|
||||
openChat = openChat
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ConversationList(
|
||||
viewModel: ConversationViewModel,
|
||||
conversations: List<Conversation>,
|
||||
modifier: Modifier = Modifier,
|
||||
openChat: (Long) -> Unit
|
||||
) {
|
||||
var selectedConversationId by remember { mutableLongStateOf(-1L) }
|
||||
|
||||
LazyColumn(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.padding(16.dp),
|
||||
verticalArrangement = Arrangement.Bottom
|
||||
) {
|
||||
items(conversations) { conversation ->
|
||||
ConversationListItem(
|
||||
conversation = conversation,
|
||||
onClick = {
|
||||
openChat(conversation.id)
|
||||
},
|
||||
onLongPressed = {
|
||||
selectedConversationId = conversation.id
|
||||
}
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedConversationId != -1L) {
|
||||
val currentId = selectedConversationId
|
||||
|
||||
val bottomSheetAction = listOf(
|
||||
Triple(
|
||||
R.drawable.ic_delete,
|
||||
R.string.conversation_screen_delete_button_title
|
||||
) {
|
||||
val sessionId: String = currentId.toString()
|
||||
viewModel.deleteConversation(sessionId)
|
||||
selectedConversationId = -1L
|
||||
}
|
||||
)
|
||||
|
||||
MoreActionsBottomSheet(
|
||||
actions = bottomSheetAction,
|
||||
dismiss = { selectedConversationId = -1L }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ConversationListItem(conversation: Conversation, onClick: () -> Unit, onLongPressed: () -> Unit) {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.combinedClickable(
|
||||
onClick = onClick,
|
||||
onLongClick = onLongPressed
|
||||
)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Text(
|
||||
text = conversation.titleRepresentation(),
|
||||
style = MaterialTheme.typography.bodyLarge.copy(fontSize = 16.sp),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
color = colorResource(R.color.text_color),
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun ConversationListPreview() {
|
||||
Column {
|
||||
ConversationListItem(Conversation(1L, "User1", "Who is Al Pacino?", 1762847286L, "", null), {
|
||||
}, {
|
||||
})
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
ConversationListItem(Conversation(2L, "User1", "What is JetpackCompose?", 1761847286L, "", null), {
|
||||
}, {
|
||||
})
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.assistant.conversation
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.nextcloud.client.assistant.conversation.model.ConversationScreenState
|
||||
import com.nextcloud.client.assistant.conversation.repository.ConversationRemoteRepository
|
||||
import com.nextcloud.utils.TimeConstants.MILLIS_PER_SECOND
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.common.utils.Log_OC
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.Conversation
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ConversationViewModel(private val remoteRepository: ConversationRemoteRepository) : ViewModel() {
|
||||
private val _errorMessageId = MutableStateFlow<Int?>(null)
|
||||
val errorMessageId: StateFlow<Int?> = _errorMessageId
|
||||
|
||||
private val _screenState = MutableStateFlow<ConversationScreenState?>(null)
|
||||
val screenState: StateFlow<ConversationScreenState?> = _screenState
|
||||
|
||||
private val _conversations = MutableStateFlow<List<Conversation>>(listOf())
|
||||
val conversations: StateFlow<List<Conversation>> = _conversations.asStateFlow()
|
||||
|
||||
fun fetchConversations() {
|
||||
_screenState.update {
|
||||
ConversationScreenState.Loading
|
||||
}
|
||||
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val conversations = remoteRepository.fetchConversationList()
|
||||
if (conversations != null) {
|
||||
if (conversations.isEmpty()) {
|
||||
_screenState.update {
|
||||
ConversationScreenState.emptyConversationList()
|
||||
}
|
||||
} else {
|
||||
_screenState.update {
|
||||
null
|
||||
}
|
||||
_conversations.update {
|
||||
conversations
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_screenState.update {
|
||||
null
|
||||
}
|
||||
_errorMessageId.update {
|
||||
R.string.conversation_screen_fetch_error_title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun createConversation(title: String?, onResult: (Long) -> Unit) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val timestamp = System.currentTimeMillis().div(MILLIS_PER_SECOND)
|
||||
val newConversation = remoteRepository.createConversation(title, timestamp)
|
||||
if (newConversation != null) {
|
||||
_conversations.update {
|
||||
listOf(newConversation.session) + it
|
||||
}
|
||||
onResult(newConversation.session.id)
|
||||
} else {
|
||||
_errorMessageId.update {
|
||||
R.string.conversation_screen_create_error_title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteConversation(sessionId: String) {
|
||||
Log_OC.d("", "BBBB: $sessionId")
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val success = remoteRepository.deleteConversation(sessionId)
|
||||
if (success) {
|
||||
val updatedList = _conversations.value.filterNot { it.id == sessionId.toLong() }
|
||||
_conversations.update {
|
||||
updatedList
|
||||
}
|
||||
} else {
|
||||
_errorMessageId.update {
|
||||
R.string.conversation_screen_delete_error_title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.assistant.conversation.model
|
||||
|
||||
import com.owncloud.android.R
|
||||
|
||||
sealed class ConversationScreenState {
|
||||
data object Loading : ConversationScreenState()
|
||||
|
||||
data class EmptyContent(val descriptionId: Int) : ConversationScreenState()
|
||||
|
||||
companion object {
|
||||
fun emptyConversationList(): ConversationScreenState = EmptyContent(
|
||||
descriptionId = R.string.conversation_screen_empty_conversation_list_title
|
||||
)
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.assistant.conversation.repository
|
||||
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.Conversation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.CreateConversation
|
||||
|
||||
interface ConversationRemoteRepository {
|
||||
suspend fun fetchConversationList(): List<Conversation>?
|
||||
suspend fun createConversation(title: String?, timestamp: Long): CreateConversation?
|
||||
suspend fun deleteConversation(sessionId: String): Boolean
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.assistant.conversation.repository
|
||||
|
||||
import com.nextcloud.common.NextcloudClient
|
||||
import com.owncloud.android.lib.resources.assistant.chat.CreateConversationRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.DeleteConversationRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.GetConversationListRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.Conversation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.CreateConversation
|
||||
|
||||
class ConversationRemoteRepositoryImpl(private val client: NextcloudClient) : ConversationRemoteRepository {
|
||||
override suspend fun fetchConversationList(): List<Conversation>? {
|
||||
val result = GetConversationListRemoteOperation().execute(client)
|
||||
return if (result.isSuccess) {
|
||||
result.resultData
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun createConversation(title: String?, timestamp: Long): CreateConversation? {
|
||||
val result = CreateConversationRemoteOperation(title, timestamp).execute(client)
|
||||
return if (result.isSuccess) {
|
||||
result.resultData
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun deleteConversation(sessionId: String): Boolean {
|
||||
val result = DeleteConversationRemoteOperation(sessionId).execute(client)
|
||||
return result.isSuccess
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.assistant.conversation.repository
|
||||
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.Conversation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.CreateConversation
|
||||
|
||||
class MockConversationRemoteRepository : ConversationRemoteRepository {
|
||||
override suspend fun fetchConversationList(): List<Conversation>? = null
|
||||
|
||||
override suspend fun createConversation(title: String?, timestamp: Long): CreateConversation? = null
|
||||
|
||||
override suspend fun deleteConversation(sessionId: String): Boolean = true
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.assistant.model
|
||||
|
||||
import com.owncloud.android.R
|
||||
|
||||
sealed class AssistantScreenState {
|
||||
data object Loading : AssistantScreenState()
|
||||
|
||||
data object TaskContent : AssistantScreenState()
|
||||
|
||||
data object ChatContent : AssistantScreenState()
|
||||
|
||||
data class EmptyContent(val iconId: Int?, val titleId: Int?, val descriptionId: Int?) : AssistantScreenState()
|
||||
|
||||
companion object {
|
||||
fun emptyTaskTypes(): AssistantScreenState = EmptyContent(
|
||||
titleId = null,
|
||||
descriptionId = R.string.assistant_screen_task_list_empty_warning,
|
||||
iconId = null
|
||||
)
|
||||
|
||||
fun emptyChatList(): AssistantScreenState = EmptyContent(
|
||||
iconId = R.drawable.ic_assistant,
|
||||
titleId = R.string.assistant_screen_empty_content_title,
|
||||
descriptionId = R.string.assistant_screen_empty_content_description
|
||||
)
|
||||
|
||||
fun emptyTaskList(): AssistantScreenState = EmptyContent(
|
||||
iconId = R.drawable.ic_assistant,
|
||||
titleId = R.string.assistant_screen_empty_content_title,
|
||||
descriptionId = null
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,16 @@
|
||||
package com.nextcloud.client.assistant.model
|
||||
|
||||
import android.app.Activity
|
||||
import com.nextcloud.client.assistant.extensions.getInput
|
||||
import com.nextcloud.client.assistant.extensions.getInputAndOutput
|
||||
import com.nextcloud.utils.extensions.showShareIntent
|
||||
import com.owncloud.android.R
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
import com.owncloud.android.utils.ClipboardUtil
|
||||
|
||||
sealed class ScreenOverlayState {
|
||||
data class DeleteTask(val id: Long) : ScreenOverlayState()
|
||||
data class AddTask(val taskType: TaskTypeData, val input: String) : ScreenOverlayState()
|
||||
data class TaskActions(val task: Task) : ScreenOverlayState() {
|
||||
private fun getInputAndOutput(): String = task.getInputAndOutput()
|
||||
private fun getInput(): String? = task.getInput()
|
||||
|
||||
private fun getCopyToClipboardAction(activity: Activity): Triple<Int, Int, () -> Unit> = Triple(
|
||||
R.drawable.ic_content_copy,
|
||||
@@ -37,22 +33,6 @@ sealed class ScreenOverlayState {
|
||||
activity.showShareIntent(getInputAndOutput())
|
||||
}
|
||||
|
||||
private fun getEditAction(activity: Activity, onComplete: (AddTask) -> Unit): Triple<Int, Int, () -> Unit> =
|
||||
Triple(
|
||||
R.drawable.ic_edit,
|
||||
R.string.action_edit
|
||||
) {
|
||||
val taskType = TaskTypeData(
|
||||
task.type,
|
||||
activity.getString(R.string.assistant_screen_add_task_alert_dialog_title),
|
||||
null,
|
||||
emptyMap(),
|
||||
emptyMap()
|
||||
)
|
||||
val newState = AddTask(taskType, getInput() ?: "")
|
||||
onComplete(newState)
|
||||
}
|
||||
|
||||
private fun getDeleteAction(onComplete: (DeleteTask) -> Unit): Triple<Int, Int, () -> Unit> = Triple(
|
||||
R.drawable.ic_delete,
|
||||
R.string.assistant_screen_task_more_actions_bottom_sheet_delete_action
|
||||
@@ -63,14 +43,10 @@ sealed class ScreenOverlayState {
|
||||
|
||||
fun getActions(
|
||||
activity: Activity,
|
||||
onEditCompleted: (AddTask) -> Unit,
|
||||
onDeleteCompleted: (DeleteTask) -> Unit
|
||||
): List<Triple<Int, Int, () -> Unit>> = listOf(
|
||||
getShareAction(activity),
|
||||
getCopyToClipboardAction(activity),
|
||||
getEditAction(activity, onComplete = {
|
||||
onEditCompleted(it)
|
||||
}),
|
||||
getDeleteAction(onComplete = {
|
||||
onDeleteCompleted(it)
|
||||
})
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.assistant.model
|
||||
|
||||
import com.owncloud.android.R
|
||||
|
||||
sealed class ScreenState {
|
||||
data object Loading : ScreenState()
|
||||
|
||||
data object Content : ScreenState()
|
||||
|
||||
data class EmptyContent(val iconId: Int?, val descriptionId: Int) : ScreenState()
|
||||
|
||||
companion object {
|
||||
fun emptyTaskTypes(): ScreenState = EmptyContent(
|
||||
descriptionId = R.string.assistant_screen_task_list_empty_warning,
|
||||
iconId = null
|
||||
)
|
||||
|
||||
fun emptyTaskList(): ScreenState = EmptyContent(
|
||||
descriptionId = R.string.assistant_screen_create_a_new_task_from_bottom_right_text,
|
||||
iconId = null
|
||||
)
|
||||
}
|
||||
}
|
||||
+21
-4
@@ -8,15 +8,32 @@
|
||||
package com.nextcloud.client.assistant.repository.remote
|
||||
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessage
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessageRequest
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.CreateConversation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.Session
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.SessionTask
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
|
||||
interface AssistantRemoteRepository {
|
||||
fun getTaskTypes(): List<TaskTypeData>?
|
||||
suspend fun getTaskTypes(): List<TaskTypeData>?
|
||||
|
||||
fun createTask(input: String, taskType: TaskTypeData): RemoteOperationResult<Void>
|
||||
suspend fun createTask(input: String, taskType: TaskTypeData): RemoteOperationResult<Void>
|
||||
|
||||
fun getTaskList(taskType: String): List<Task>?
|
||||
suspend fun getTaskList(taskType: String): List<Task>?
|
||||
|
||||
fun deleteTask(id: Long): RemoteOperationResult<Void>
|
||||
suspend fun deleteTask(id: Long): RemoteOperationResult<Void>
|
||||
|
||||
suspend fun fetchChatMessages(id: Long): List<ChatMessage>?
|
||||
|
||||
suspend fun sendChatMessage(request: ChatMessageRequest): ChatMessage?
|
||||
|
||||
suspend fun createConversation(title: String): CreateConversation?
|
||||
|
||||
suspend fun checkSession(sessionId: String): Session?
|
||||
|
||||
suspend fun generateSession(sessionId: String): SessionTask?
|
||||
|
||||
suspend fun checkGeneration(taskId: String, sessionId: String): ChatMessage?
|
||||
}
|
||||
+74
-27
@@ -7,8 +7,20 @@
|
||||
package com.nextcloud.client.assistant.repository.remote
|
||||
|
||||
import com.nextcloud.common.NextcloudClient
|
||||
import com.nextcloud.utils.TimeConstants
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode
|
||||
import com.owncloud.android.lib.resources.assistant.chat.CheckGenerationRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.CheckSessionRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.CreateConversationRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.CreateMessageRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.GenerateSessionRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.GetMessagesRemoteOperation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessage
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessageRequest
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.CreateConversation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.Session
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.SessionTask
|
||||
import com.owncloud.android.lib.resources.assistant.v1.CreateTaskRemoteOperationV1
|
||||
import com.owncloud.android.lib.resources.assistant.v1.DeleteTaskRemoteOperationV1
|
||||
import com.owncloud.android.lib.resources.assistant.v1.GetTaskListRemoteOperationV1
|
||||
@@ -22,59 +34,94 @@ import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
import com.owncloud.android.lib.resources.status.NextcloudVersion
|
||||
import com.owncloud.android.lib.resources.status.OCCapability
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class AssistantRemoteRepositoryImpl(private val client: NextcloudClient, capability: OCCapability) :
|
||||
AssistantRemoteRepository {
|
||||
|
||||
private val supportsV2 = capability.version.isNewerOrEqual(NextcloudVersion.nextcloud_30)
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun getTaskTypes(): List<TaskTypeData>? {
|
||||
override suspend fun getTaskTypes(): List<TaskTypeData>? = withContext(Dispatchers.IO) {
|
||||
if (supportsV2) {
|
||||
val result = GetTaskTypesRemoteOperationV2().execute(client)
|
||||
if (result.isSuccess) {
|
||||
return result.resultData
|
||||
return@withContext result.resultData
|
||||
}
|
||||
} else {
|
||||
val result = GetTaskTypesRemoteOperationV1().execute(client)
|
||||
if (result.isSuccess) {
|
||||
return result.resultData.toV2()
|
||||
return@withContext result.resultData.toV2()
|
||||
}
|
||||
}
|
||||
return@withContext null
|
||||
}
|
||||
|
||||
override suspend fun createTask(input: String, taskType: TaskTypeData): RemoteOperationResult<Void> =
|
||||
withContext(Dispatchers.IO) {
|
||||
if (supportsV2) {
|
||||
CreateTaskRemoteOperationV2(input, taskType).execute(client)
|
||||
} else {
|
||||
if (taskType.id.isNullOrEmpty()) {
|
||||
RemoteOperationResult<Void>(ResultCode.CANCELLED)
|
||||
} else {
|
||||
CreateTaskRemoteOperationV1(input, taskType.id!!).execute(client)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
override fun createTask(input: String, taskType: TaskTypeData): RemoteOperationResult<Void> = if (supportsV2) {
|
||||
CreateTaskRemoteOperationV2(input, taskType).execute(client)
|
||||
} else {
|
||||
if (taskType.id.isNullOrEmpty()) {
|
||||
RemoteOperationResult<Void>(ResultCode.CANCELLED)
|
||||
} else {
|
||||
CreateTaskRemoteOperationV1(input, taskType.id!!).execute(client)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun getTaskList(taskType: String): List<Task>? {
|
||||
override suspend fun getTaskList(taskType: String): List<Task>? = withContext(Dispatchers.IO) {
|
||||
if (supportsV2) {
|
||||
val result = GetTaskListRemoteOperationV2(taskType).execute(client)
|
||||
if (result.isSuccess) {
|
||||
return result.resultData.tasks.filter { it.appId == "assistant" }
|
||||
return@withContext result.resultData.tasks.filter { it.appId == "assistant" }
|
||||
}
|
||||
} else {
|
||||
val result = GetTaskListRemoteOperationV1("assistant").execute(client)
|
||||
if (result.isSuccess) {
|
||||
return result.resultData.toV2().tasks.filter { it.type == taskType }
|
||||
return@withContext result.resultData.toV2().tasks.filter { it.type == taskType }
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
return@withContext null
|
||||
}
|
||||
|
||||
override fun deleteTask(id: Long): RemoteOperationResult<Void> = if (supportsV2) {
|
||||
DeleteTaskRemoteOperationV2(id).execute(client)
|
||||
} else {
|
||||
DeleteTaskRemoteOperationV1(id).execute(client)
|
||||
override suspend fun deleteTask(id: Long): RemoteOperationResult<Void> = withContext(Dispatchers.IO) {
|
||||
if (supportsV2) {
|
||||
DeleteTaskRemoteOperationV2(id).execute(client)
|
||||
} else {
|
||||
DeleteTaskRemoteOperationV1(id).execute(client)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun fetchChatMessages(id: Long): List<ChatMessage>? = withContext(Dispatchers.IO) {
|
||||
val result = GetMessagesRemoteOperation(id.toString()).execute(client)
|
||||
if (result.isSuccess) result.resultData else null
|
||||
}
|
||||
|
||||
override suspend fun sendChatMessage(request: ChatMessageRequest): ChatMessage? = withContext(Dispatchers.IO) {
|
||||
val result = CreateMessageRemoteOperation(request).execute(client)
|
||||
if (result.isSuccess) result.resultData else null
|
||||
}
|
||||
|
||||
override suspend fun createConversation(title: String): CreateConversation? = withContext(Dispatchers.IO) {
|
||||
val timestamp = System.currentTimeMillis().div(TimeConstants.MILLIS_PER_SECOND)
|
||||
val result = CreateConversationRemoteOperation(title, timestamp).execute(client)
|
||||
if (result.isSuccess) result.resultData else null
|
||||
}
|
||||
|
||||
override suspend fun checkSession(sessionId: String): Session? = withContext(Dispatchers.IO) {
|
||||
val result = CheckSessionRemoteOperation(sessionId).execute(client)
|
||||
if (result.isSuccess) result.resultData else null
|
||||
}
|
||||
|
||||
override suspend fun generateSession(sessionId: String): SessionTask? = withContext(Dispatchers.IO) {
|
||||
val result = GenerateSessionRemoteOperation(sessionId).execute(client)
|
||||
if (result.isSuccess) result.resultData else null
|
||||
}
|
||||
|
||||
override suspend fun checkGeneration(taskId: String, sessionId: String): ChatMessage? =
|
||||
withContext(Dispatchers.IO) {
|
||||
val result = CheckGenerationRemoteOperation(taskId, sessionId).execute(client)
|
||||
if (result.isSuccess) result.resultData else null
|
||||
}
|
||||
}
|
||||
+16
-4
@@ -8,6 +8,11 @@ package com.nextcloud.client.assistant.repository.remote
|
||||
|
||||
import com.nextcloud.utils.extensions.getRandomString
|
||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessage
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.ChatMessageRequest
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.CreateConversation
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.Session
|
||||
import com.owncloud.android.lib.resources.assistant.chat.model.SessionTask
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Shape
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.Task
|
||||
import com.owncloud.android.lib.resources.assistant.v2.model.TaskInput
|
||||
@@ -16,7 +21,7 @@ import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
|
||||
@Suppress("MagicNumber")
|
||||
class MockAssistantRemoteRepository(private val giveEmptyTasks: Boolean = false) : AssistantRemoteRepository {
|
||||
override fun getTaskTypes(): List<TaskTypeData> = listOf(
|
||||
override suspend fun getTaskTypes(): List<TaskTypeData> = listOf(
|
||||
TaskTypeData(
|
||||
id = "core:text2text",
|
||||
name = "Free text to text prompt",
|
||||
@@ -38,10 +43,10 @@ class MockAssistantRemoteRepository(private val giveEmptyTasks: Boolean = false)
|
||||
)
|
||||
)
|
||||
|
||||
override fun createTask(input: String, taskType: TaskTypeData): RemoteOperationResult<Void> =
|
||||
override suspend fun createTask(input: String, taskType: TaskTypeData): RemoteOperationResult<Void> =
|
||||
RemoteOperationResult<Void>(RemoteOperationResult.ResultCode.OK)
|
||||
|
||||
override fun getTaskList(taskType: String): List<Task> = if (giveEmptyTasks) {
|
||||
override suspend fun getTaskList(taskType: String): List<Task> = if (giveEmptyTasks) {
|
||||
listOf()
|
||||
} else {
|
||||
listOf(
|
||||
@@ -62,6 +67,13 @@ class MockAssistantRemoteRepository(private val giveEmptyTasks: Boolean = false)
|
||||
)
|
||||
}
|
||||
|
||||
override fun deleteTask(id: Long): RemoteOperationResult<Void> =
|
||||
override suspend fun deleteTask(id: Long): RemoteOperationResult<Void> =
|
||||
RemoteOperationResult<Void>(RemoteOperationResult.ResultCode.OK)
|
||||
override suspend fun fetchChatMessages(id: Long): List<ChatMessage> = emptyList()
|
||||
override suspend fun sendChatMessage(request: ChatMessageRequest): ChatMessage? = null
|
||||
override suspend fun createConversation(title: String): CreateConversation? = null
|
||||
override suspend fun checkSession(sessionId: String): Session? = null
|
||||
override suspend fun generateSession(sessionId: String): SessionTask? = null
|
||||
|
||||
override suspend fun checkGeneration(taskId: String, sessionId: String): ChatMessage? = null
|
||||
}
|
||||
+6
-2
@@ -21,6 +21,7 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
@@ -39,6 +40,7 @@ import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
@@ -104,9 +106,11 @@ fun TaskDetailBottomSheet(task: Task, showTaskActions: () -> Unit, dismiss: () -
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.assistant_generation_warning),
|
||||
modifier = Modifier.widthIn(max = 300.dp),
|
||||
text = stringResource(R.string.assistant_output_generation_warning_text),
|
||||
color = colorResource(R.color.text_color),
|
||||
fontSize = 12.sp
|
||||
fontSize = 11.sp,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,13 @@
|
||||
package com.nextcloud.client.assistant.taskTypes
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.PrimaryScrollableTabRow
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.TabRowDefaults
|
||||
@@ -15,6 +22,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.owncloud.android.R
|
||||
@@ -22,22 +30,48 @@ import com.owncloud.android.lib.resources.assistant.v2.model.TaskTypeData
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
@Composable
|
||||
fun TaskTypesRow(selectedTaskType: TaskTypeData?, data: List<TaskTypeData>, selectTaskType: (TaskTypeData) -> Unit) {
|
||||
fun TaskTypesRow(
|
||||
selectedTaskType: TaskTypeData?,
|
||||
data: List<TaskTypeData>,
|
||||
selectTaskType: (TaskTypeData) -> Unit,
|
||||
navigateToConversationList: () -> Unit
|
||||
) {
|
||||
if (data.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val selectedTabIndex = data.indexOfFirst { it.id == selectedTaskType?.id }.takeIf { it >= 0 } ?: 0
|
||||
|
||||
PrimaryScrollableTabRow(
|
||||
selectedTabIndex = selectedTabIndex,
|
||||
edgePadding = 0.dp,
|
||||
containerColor = colorResource(R.color.actionbar_color),
|
||||
indicator = {
|
||||
TabRowDefaults.SecondaryIndicator(
|
||||
Modifier.tabIndicatorOffset(selectedTabIndex),
|
||||
color = colorResource(R.color.primary)
|
||||
)
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier.background(color = colorResource(R.color.actionbar_color)),
|
||||
horizontalArrangement = Arrangement.Center
|
||||
) {
|
||||
data.forEach { taskType ->
|
||||
if (taskType.name.isNotEmpty()) {
|
||||
if (data.any { it.isChat() }) {
|
||||
Spacer(modifier = Modifier.width(11.dp))
|
||||
|
||||
IconButton(
|
||||
onClick = { navigateToConversationList() }
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(id = R.drawable.ic_history_back_arrow),
|
||||
contentDescription = "open conversation list button",
|
||||
tint = colorResource(R.color.text_color)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
PrimaryScrollableTabRow(
|
||||
selectedTabIndex = selectedTabIndex,
|
||||
edgePadding = 0.dp,
|
||||
containerColor = colorResource(R.color.actionbar_color),
|
||||
indicator = {
|
||||
TabRowDefaults.SecondaryIndicator(
|
||||
Modifier.tabIndicatorOffset(selectedTabIndex),
|
||||
color = colorResource(R.color.primary)
|
||||
)
|
||||
}
|
||||
) {
|
||||
data.forEach { taskType ->
|
||||
Tab(
|
||||
selected = selectedTaskType?.id == taskType.id,
|
||||
onClick = { selectTaskType(taskType) },
|
||||
@@ -61,5 +95,7 @@ private fun TaskTypesRowPreview() {
|
||||
TaskTypeData("4", "Summarize", "", emptyMap(), emptyMap())
|
||||
)
|
||||
|
||||
TaskTypesRow(selectedTaskType, taskTypes) { }
|
||||
TaskTypesRow(selectedTaskType, taskTypes, {
|
||||
}, {
|
||||
})
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.nextcloud.client.database.dao.FileDao
|
||||
import com.nextcloud.client.database.dao.FileSystemDao
|
||||
import com.nextcloud.client.database.dao.OfflineOperationDao
|
||||
import com.nextcloud.client.database.dao.RecommendedFileDao
|
||||
import com.nextcloud.client.database.dao.ShareDao
|
||||
import com.nextcloud.client.database.dao.SyncedFolderDao
|
||||
import com.nextcloud.client.database.dao.UploadDao
|
||||
import com.nextcloud.client.database.entity.ArbitraryDataEntity
|
||||
@@ -106,6 +107,7 @@ abstract class NextcloudDatabase : RoomDatabase() {
|
||||
abstract fun fileSystemDao(): FileSystemDao
|
||||
abstract fun syncedFolderDao(): SyncedFolderDao
|
||||
abstract fun assistantDao(): AssistantDao
|
||||
abstract fun shareDao(): ShareDao
|
||||
|
||||
companion object {
|
||||
const val FIRST_ROOM_DB_VERSION = 65
|
||||
|
||||
@@ -38,9 +38,15 @@ interface FileDao {
|
||||
@Query("SELECT * FROM filelist WHERE remote_id = :remoteId AND file_owner = :fileOwner LIMIT 1")
|
||||
fun getFileByRemoteId(remoteId: String, fileOwner: String): FileEntity?
|
||||
|
||||
@Query("SELECT * FROM filelist WHERE remote_id = :remoteId LIMIT 1")
|
||||
suspend fun getFileByRemoteId(remoteId: String): FileEntity?
|
||||
|
||||
@Query("SELECT * FROM filelist WHERE parent = :parentId ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}")
|
||||
fun getFolderContent(parentId: Long): List<FileEntity>
|
||||
|
||||
@Query("SELECT * FROM filelist WHERE parent = :parentId ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}")
|
||||
suspend fun getFolderContentSuspended(parentId: Long): List<FileEntity>
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM filelist WHERE modified >= :startDate" +
|
||||
" AND modified < :endDate" +
|
||||
@@ -73,7 +79,7 @@ interface FileDao {
|
||||
AND file_owner = :accountName
|
||||
AND is_encrypted = 0
|
||||
AND (content_type = :dirType OR content_type = :webdavType)
|
||||
ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}
|
||||
ORDER BY ${ProviderTableMeta._ID} ASC
|
||||
"""
|
||||
)
|
||||
fun getNonEncryptedSubfolders(
|
||||
@@ -93,7 +99,7 @@ interface FileDao {
|
||||
ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}
|
||||
"""
|
||||
)
|
||||
fun getSubfiles(
|
||||
suspend fun getSubfiles(
|
||||
parentId: Long,
|
||||
accountName: String,
|
||||
dirType: String = MimeType.DIRECTORY,
|
||||
@@ -111,4 +117,33 @@ interface FileDao {
|
||||
"""
|
||||
)
|
||||
fun searchFilesInFolder(parentId: Long, fileOwner: String, query: String): List<FileEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
FROM filelist
|
||||
WHERE file_owner = :accountName
|
||||
AND (
|
||||
share_by_link = 1
|
||||
OR shared_via_users = 1
|
||||
OR permissions LIKE '%S%'
|
||||
)
|
||||
ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}
|
||||
"""
|
||||
)
|
||||
suspend fun getSharedFiles(accountName: String): List<FileEntity>
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
FROM filelist
|
||||
WHERE file_owner = :fileOwner
|
||||
AND favorite = 1
|
||||
ORDER BY ${ProviderTableMeta.FILE_DEFAULT_SORT_ORDER}
|
||||
"""
|
||||
)
|
||||
suspend fun getFavoriteFiles(fileOwner: String): List<FileEntity>
|
||||
|
||||
@Query("SELECT remote_id FROM filelist WHERE file_owner = :accountName AND remote_id IS NOT NULL")
|
||||
fun getAllRemoteIds(accountName: String): List<String>
|
||||
}
|
||||
@@ -8,12 +8,26 @@
|
||||
package com.nextcloud.client.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.nextcloud.client.database.entity.FilesystemEntity
|
||||
import com.owncloud.android.db.ProviderMeta
|
||||
|
||||
@Dao
|
||||
interface FileSystemDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertOrReplace(filesystemEntity: FilesystemEntity)
|
||||
|
||||
@Query(
|
||||
"""
|
||||
DELETE FROM ${ProviderMeta.ProviderTableMeta.FILESYSTEM_TABLE_NAME}
|
||||
WHERE ${ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_LOCAL_PATH} = :localPath
|
||||
AND ${ProviderMeta.ProviderTableMeta._ID} = :id
|
||||
"""
|
||||
)
|
||||
suspend fun deleteByLocalPathAndId(localPath: String, id: Int)
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
@@ -37,4 +51,15 @@ interface FileSystemDao {
|
||||
"""
|
||||
)
|
||||
suspend fun markFileAsUploaded(localPath: String, syncedFolderId: String)
|
||||
|
||||
@Query(
|
||||
"""
|
||||
SELECT *
|
||||
FROM ${ProviderMeta.ProviderTableMeta.FILESYSTEM_TABLE_NAME}
|
||||
WHERE ${ProviderMeta.ProviderTableMeta.FILESYSTEM_FILE_LOCAL_PATH} = :localPath
|
||||
AND ${ProviderMeta.ProviderTableMeta.FILESYSTEM_SYNCED_FOLDER_ID} = :syncedFolderId
|
||||
LIMIT 1
|
||||
"""
|
||||
)
|
||||
fun getFileByPathAndFolder(localPath: String, syncedFolderId: String): FilesystemEntity?
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Nextcloud - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Alper Ozturk <[email protected]>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.client.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import com.nextcloud.client.database.entity.ShareEntity
|
||||
|
||||
@Dao
|
||||
interface ShareDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertAll(shares: List<ShareEntity>)
|
||||
|
||||
@Query("DELETE FROM ocshares WHERE owner_share = :accountName")
|
||||
suspend fun clearSharesForAccount(accountName: String)
|
||||
}
|
||||
@@ -41,7 +41,7 @@ interface UploadDao {
|
||||
"WHERE ${ProviderTableMeta.UPLOADS_ACCOUNT_NAME} = :accountName " +
|
||||
"AND ${ProviderTableMeta.UPLOADS_REMOTE_PATH} = :remotePath"
|
||||
)
|
||||
fun deleteByAccountAndRemotePath(accountName: String, remotePath: String)
|
||||
fun deleteByAccountAndRemotePath(remotePath: String, accountName: String)
|
||||
|
||||
@Query(
|
||||
"SELECT * FROM " + ProviderTableMeta.UPLOADS_TABLE_NAME +
|
||||
|
||||
@@ -10,7 +10,6 @@ import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.owncloud.android.R
|
||||
@@ -49,10 +48,9 @@ class ShowErrorActivity : AppCompatActivity() {
|
||||
private fun createErrorTitle() = String.format(getString(R.string.error_crash_title), getString(R.string.app_name))
|
||||
|
||||
private fun reportIssue() {
|
||||
ClipboardUtil.copyToClipboard(this, binding.textViewError.text.toString(), false)
|
||||
ClipboardUtil.copyToClipboard(this, binding.textViewError.text.toString(), true)
|
||||
val issueLink = getString(R.string.report_issue_link)
|
||||
DisplayUtils.startLinkIntent(this, issueLink)
|
||||
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
@@ -179,7 +179,8 @@ class BackgroundJobFactory @Inject constructor(
|
||||
powerManagementService = powerManagementService,
|
||||
syncedFolderProvider = syncedFolderProvider,
|
||||
backgroundJobManager = backgroundJobManager.get(),
|
||||
repository = FileSystemRepository(dao = database.fileSystemDao())
|
||||
repository = FileSystemRepository(dao = database.fileSystemDao(), context),
|
||||
viewThemeUtils = viewThemeUtils.get()
|
||||
)
|
||||
|
||||
private fun createOfflineSyncWork(context: Context, params: WorkerParameters): OfflineSyncWork = OfflineSyncWork(
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.work.ListenableWorker
|
||||
import androidx.work.NetworkType
|
||||
import androidx.work.OneTimeWorkRequest
|
||||
import androidx.work.Operation
|
||||
import androidx.work.OutOfQuotaPolicy
|
||||
import androidx.work.PeriodicWorkRequest
|
||||
import androidx.work.WorkInfo
|
||||
import androidx.work.WorkManager
|
||||
@@ -681,6 +682,7 @@ internal class BackgroundJobManagerImpl(
|
||||
.addTag(tag)
|
||||
.setInputData(dataBuilder.build())
|
||||
.setConstraints(constraints)
|
||||
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
|
||||
.build()
|
||||
}
|
||||
|
||||
@@ -728,6 +730,7 @@ internal class BackgroundJobManagerImpl(
|
||||
val request = oneTimeRequestBuilder(FileDownloadWorker::class, JOB_FILES_DOWNLOAD, user)
|
||||
.addTag(tag)
|
||||
.setInputData(data)
|
||||
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
|
||||
.build()
|
||||
|
||||
// Since for each file new FileDownloadWorker going to be scheduled,
|
||||
@@ -839,6 +842,7 @@ internal class BackgroundJobManagerImpl(
|
||||
.addTag(JOB_DOWNLOAD_FOLDER)
|
||||
.setInputData(data)
|
||||
.setConstraints(constraints)
|
||||
.setExpedited(OutOfQuotaPolicy.RUN_AS_NON_EXPEDITED_WORK_REQUEST)
|
||||
.build()
|
||||
|
||||
workManager.enqueueUniqueWork(JOB_DOWNLOAD_FOLDER, ExistingWorkPolicy.APPEND_OR_REPLACE, request)
|
||||
|
||||
Loaded 100 of 656 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user