Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ repositories {
}
dependencies {
...
compile 'com.github.nextcloud:android-library:-SNAPSHOT'
implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
}
```

### As a git submodule
Expand Down
30 changes: 20 additions & 10 deletions library/src/androidTest/java/com/owncloud/android/FileIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.net.Uri;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
Expand All @@ -37,16 +41,15 @@
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.shares.ShareeUser;
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation;
import com.owncloud.android.lib.resources.status.NextcloudVersion;
import com.owncloud.android.lib.resources.status.OCCapability;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
* Tests related to file operations
*/
Expand Down Expand Up @@ -169,14 +172,21 @@ public void testShareToGroupSharees() {

ShareeUser sharee = new ShareeUser("users", "", ShareType.GROUP);

// only on NC26+
OCCapability ocCapability = (OCCapability) new GetCapabilitiesRemoteOperation()
.execute(nextcloudClient).getSingleData();
if (ocCapability.getVersion().isNewerOrEqual(NextcloudVersion.nextcloud_26)) {
sharee.setDisplayName("users");
}

// share folder
assertTrue(new CreateShareRemoteOperation(path,
ShareType.GROUP,
"users",
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());
ShareType.GROUP,
"users",
false,
"",
OCShare.NO_PERMISSION)
.execute(client).isSuccess());

// verify
RemoteOperationResult result = new ReadFolderRemoteOperation("/").execute(client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class ShareeUser(val userId: String?, val displayName: String?, val shareType: ShareType?) : Parcelable
data class ShareeUser(val userId: String?, var displayName: String?, val shareType: ShareType?) :
Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ class NextcloudVersion : OwnCloudVersion {

@JvmField
val nextcloud_22 = NextcloudVersion(0x16000000) // 22.0

@JvmField
val nextcloud_23 = NextcloudVersion(0x17000000) // 23.0

@JvmField
val nextcloud_24 = NextcloudVersion(0x18000000) // 24.0

@JvmField
val nextcloud_25 = NextcloudVersion(0x19000000) // 25.0

@JvmField
val nextcloud_26 = NextcloudVersion(0x1A000000) // 25.0
}

constructor(string: String) : super(string)
Expand Down
14 changes: 11 additions & 3 deletions sample_client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repositories {
}

android {
compileSdkVersion 31
compileSdkVersion 33

lintOptions {
abortOnError false
Expand All @@ -33,12 +33,20 @@ android {
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 33

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}

dependencies {
implementation project(path: ':library')
implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
implementation "commons-httpclient:commons-httpclient:3.1@jar"
// remove after entire switch to lib v2
implementation "org.jacoco:org.jacoco.agent:$jacoco_version:runtime"
implementation 'androidx.test:monitor:1.6.0'
androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:monitor:1.6.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test:runner:1.5.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2022 Tobias Kaminsky
* Copyright (C) 2022 Nextcloud GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

package com.owncloud.android.lib.sampleclient;

import static org.junit.Assert.assertEquals;

import android.content.Context;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.owncloud.android.lib.sampleclient", appContext.getPackageName());
}
}