From: David A. Velasco Date: Tue, 12 Nov 2013 13:55:21 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/refactor_remote_operation_to_create_folder'... X-Git-Tag: oc-android-1.5.5~123^2~15 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/0421d5353debd21f8e19187475bf9650d207bfce?hp=a8f70cf823b9994b65776c7c3ff1463e5a105525 Merge remote-tracking branch 'origin/refactor_remote_operation_to_create_folder' into refactor_remote_operation_to_create_folder --- diff --git a/oc_framework-test-project/.classpath b/oc_framework-test-project/.classpath new file mode 100644 index 00000000..d3d9f2d8 --- /dev/null +++ b/oc_framework-test-project/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/oc_framework-test-project/.project b/oc_framework-test-project/.project new file mode 100644 index 00000000..8c7df640 --- /dev/null +++ b/oc_framework-test-project/.project @@ -0,0 +1,33 @@ + + + oc_framework-test-project + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/oc_framework-test-project/.settings/org.eclipse.jdt.core.prefs b/oc_framework-test-project/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..b080d2dd --- /dev/null +++ b/oc_framework-test-project/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/oc_framework-test-project/AndroidManifest.xml b/oc_framework-test-project/AndroidManifest.xml new file mode 100644 index 00000000..d4d5316a --- /dev/null +++ b/oc_framework-test-project/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/oc_framework-test-project/ic_launcher-web.png b/oc_framework-test-project/ic_launcher-web.png new file mode 100644 index 00000000..a18cbb48 Binary files /dev/null and b/oc_framework-test-project/ic_launcher-web.png differ diff --git a/oc_framework-test-project/libs/android-support-v4.jar b/oc_framework-test-project/libs/android-support-v4.jar new file mode 100644 index 00000000..9056828a Binary files /dev/null and b/oc_framework-test-project/libs/android-support-v4.jar differ diff --git a/oc_framework-test-project/oc_framework-test-test/.classpath b/oc_framework-test-project/oc_framework-test-test/.classpath new file mode 100644 index 00000000..dce56855 --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/oc_framework-test-project/oc_framework-test-test/.project b/oc_framework-test-project/oc_framework-test-test/.project new file mode 100644 index 00000000..c490827b --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/.project @@ -0,0 +1,34 @@ + + + oc_framework-test + + + oc_framework-test-project + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + diff --git a/oc_framework-test-project/oc_framework-test-test/.settings/org.eclipse.jdt.core.prefs b/oc_framework-test-project/oc_framework-test-test/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..b080d2dd --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/oc_framework-test-project/oc_framework-test-test/AndroidManifest.xml b/oc_framework-test-project/oc_framework-test-test/AndroidManifest.xml new file mode 100644 index 00000000..294f271b --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/AndroidManifest.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/oc_framework-test-project/oc_framework-test-test/project.properties b/oc_framework-test-project/oc_framework-test-test/project.properties new file mode 100644 index 00000000..4ab12569 --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-19 diff --git a/oc_framework-test-project/oc_framework-test-test/res/drawable-hdpi/ic_launcher.png b/oc_framework-test-project/oc_framework-test-test/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..96a442e5 Binary files /dev/null and b/oc_framework-test-project/oc_framework-test-test/res/drawable-hdpi/ic_launcher.png differ diff --git a/oc_framework-test-project/oc_framework-test-test/res/drawable-ldpi/ic_launcher.png b/oc_framework-test-project/oc_framework-test-test/res/drawable-ldpi/ic_launcher.png new file mode 100644 index 00000000..99238729 Binary files /dev/null and b/oc_framework-test-project/oc_framework-test-test/res/drawable-ldpi/ic_launcher.png differ diff --git a/oc_framework-test-project/oc_framework-test-test/res/drawable-mdpi/ic_launcher.png b/oc_framework-test-project/oc_framework-test-test/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..359047df Binary files /dev/null and b/oc_framework-test-project/oc_framework-test-test/res/drawable-mdpi/ic_launcher.png differ diff --git a/oc_framework-test-project/oc_framework-test-test/res/drawable-xhdpi/ic_launcher.png b/oc_framework-test-project/oc_framework-test-test/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..71c6d760 Binary files /dev/null and b/oc_framework-test-project/oc_framework-test-test/res/drawable-xhdpi/ic_launcher.png differ diff --git a/oc_framework-test-project/oc_framework-test-test/res/values/strings.xml b/oc_framework-test-project/oc_framework-test-test/res/values/strings.xml new file mode 100644 index 00000000..657f31dd --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/res/values/strings.xml @@ -0,0 +1,6 @@ + + + + Oc_framework-testTest + + diff --git a/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java new file mode 100644 index 00000000..34b8f324 --- /dev/null +++ b/oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java @@ -0,0 +1,51 @@ +package com.owncloud.android.oc_framework_test_project.test; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework_test_project.TestActivity; + +import android.test.ActivityInstrumentationTestCase2; +import android.util.Log; + +public class CreateFolderTest extends ActivityInstrumentationTestCase2 { + + private TestActivity mActivity; + private String mCurrentDate; + + public CreateFolderTest() { + super(TestActivity.class); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); + mCurrentDate = sdf.format(new Date()); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + public void testCreateFolder() { + + String remotePath = "/testCreateFolder" + mCurrentDate; + boolean createFullPath = true; + + RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath); + Log.d("test CreateFolder", "-----------------------" + result.getCode().name()); + Log.d("test CreateFolder", "-----------------------" + result.getLogMessage()); + assertTrue(result.isSuccess()); + } + + public void testCreateFolderSpecialCharacters() { + String remotePath = "/test^^SpecialCharacters" + mCurrentDate; + boolean createFullPath = true; + + RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath); + assertFalse(result.isSuccess()); + } + + +} diff --git a/oc_framework-test-project/project.properties b/oc_framework-test-project/project.properties new file mode 100644 index 00000000..153d36b6 --- /dev/null +++ b/oc_framework-test-project/project.properties @@ -0,0 +1,15 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-19 +android.library.reference.1=../oc_framework diff --git a/oc_framework-test-project/res/drawable-hdpi/ic_launcher.png b/oc_framework-test-project/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 00000000..288b6655 Binary files /dev/null and b/oc_framework-test-project/res/drawable-hdpi/ic_launcher.png differ diff --git a/oc_framework-test-project/res/drawable-mdpi/ic_launcher.png b/oc_framework-test-project/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 00000000..6ae570b4 Binary files /dev/null and b/oc_framework-test-project/res/drawable-mdpi/ic_launcher.png differ diff --git a/oc_framework-test-project/res/drawable-xhdpi/ic_launcher.png b/oc_framework-test-project/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 00000000..d4fb7cd9 Binary files /dev/null and b/oc_framework-test-project/res/drawable-xhdpi/ic_launcher.png differ diff --git a/oc_framework-test-project/res/drawable-xxhdpi/ic_launcher.png b/oc_framework-test-project/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 00000000..85a60815 Binary files /dev/null and b/oc_framework-test-project/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/oc_framework-test-project/res/layout/activity_test.xml b/oc_framework-test-project/res/layout/activity_test.xml new file mode 100644 index 00000000..42c4fbda --- /dev/null +++ b/oc_framework-test-project/res/layout/activity_test.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/oc_framework-test-project/res/menu/test.xml b/oc_framework-test-project/res/menu/test.xml new file mode 100644 index 00000000..c0020282 --- /dev/null +++ b/oc_framework-test-project/res/menu/test.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/oc_framework-test-project/res/values-sw600dp/dimens.xml b/oc_framework-test-project/res/values-sw600dp/dimens.xml new file mode 100644 index 00000000..44f01db7 --- /dev/null +++ b/oc_framework-test-project/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/oc_framework-test-project/res/values-sw720dp-land/dimens.xml b/oc_framework-test-project/res/values-sw720dp-land/dimens.xml new file mode 100644 index 00000000..61e3fa8f --- /dev/null +++ b/oc_framework-test-project/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ + + + + 128dp + + diff --git a/oc_framework-test-project/res/values-v11/styles.xml b/oc_framework-test-project/res/values-v11/styles.xml new file mode 100644 index 00000000..3c02242a --- /dev/null +++ b/oc_framework-test-project/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/oc_framework-test-project/res/values-v14/styles.xml b/oc_framework-test-project/res/values-v14/styles.xml new file mode 100644 index 00000000..a91fd037 --- /dev/null +++ b/oc_framework-test-project/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/oc_framework-test-project/res/values/dimens.xml b/oc_framework-test-project/res/values/dimens.xml new file mode 100644 index 00000000..55c1e590 --- /dev/null +++ b/oc_framework-test-project/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + diff --git a/oc_framework-test-project/res/values/strings.xml b/oc_framework-test-project/res/values/strings.xml new file mode 100644 index 00000000..e50b40df --- /dev/null +++ b/oc_framework-test-project/res/values/strings.xml @@ -0,0 +1,8 @@ + + + + oc_framework-test-project + Settings + Hello world! + + diff --git a/oc_framework-test-project/res/values/styles.xml b/oc_framework-test-project/res/values/styles.xml new file mode 100644 index 00000000..6ce89c7b --- /dev/null +++ b/oc_framework-test-project/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java new file mode 100644 index 00000000..057e3455 --- /dev/null +++ b/oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java @@ -0,0 +1,102 @@ +package com.owncloud.android.oc_framework_test_project; + +import java.io.IOException; + +import com.owncloud.android.oc_framework.authentication.AccountUtils.AccountNotFoundException; +import com.owncloud.android.oc_framework.network.OwnCloudClientUtils; +import com.owncloud.android.oc_framework.network.webdav.WebdavClient; +import com.owncloud.android.oc_framework.operations.RemoteOperationResult; +import com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation; + +import android.os.Bundle; +import android.accounts.Account; +import android.accounts.AccountManager; +import android.accounts.AuthenticatorException; +import android.accounts.OperationCanceledException; +import android.app.Activity; +import android.util.Log; +import android.view.Menu; + +/** + * Activity to test OC framework + * @author masensio + * + */ +public class TestActivity extends Activity { + + private static final String TAG = "TestActivity"; + + private Account mAccount = null; + private WebdavClient mClient; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_test); + + String accountHost = "beta.owncloud.com"; + String accountUser = "masensio"; + String accountName = accountUser + "@"+ accountHost; + String accountPass = "masensio"; + String accountType = "owncloud"; + String authorities = "org.owncloud"; + + AccountManager am = AccountManager.get(this); + + Account[] ocAccounts = am.getAccountsByType(accountType); + for (Account ac : ocAccounts) { + if (ac.name.equals(accountName)) { + mAccount = ac; + break; + } + } + + if (mAccount == null) { + mAccount = new Account(accountName, accountType); + am.addAccountExplicitly(mAccount, accountPass, null); + am.setUserData(mAccount, "oc_version", "5.0.14"); + am.setUserData(mAccount, "oc_base_url", "http://beta.owncloud.com/owncloud"); + } else { + Log.d(TAG, "oc_version --->"+ am.getUserData(mAccount, "oc_version") ); + Log.d(TAG, "oc_base_url --->"+ am.getUserData(mAccount, "oc_base_url") ); + } + + + try { + mClient = OwnCloudClientUtils.createOwnCloudClient(mAccount, this.getApplicationContext(), authorities); + } catch (OperationCanceledException e) { + Log.e(TAG, "Error while trying to access to " + mAccount.name, e); + e.printStackTrace(); + } catch (AuthenticatorException e) { + Log.e(TAG, "Error while trying to access to " + mAccount.name, e); + e.printStackTrace(); + } catch (AccountNotFoundException e) { + Log.e(TAG, "Error while trying to access to " + mAccount.name, e); + e.printStackTrace(); + } catch (IOException e) { + Log.e(TAG, "Error while trying to access to " + mAccount.name, e); + e.printStackTrace(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.test, menu); + return true; + } + + /** + * Access to the library method to Create a Folder + * @param remotePath + * @param createFullPath + * @return + */ + public RemoteOperationResult createFolder(String remotePath, boolean createFullPath) { + + CreateRemoteFolderOperation createOperation = new CreateRemoteFolderOperation(remotePath, createFullPath); + RemoteOperationResult result = createOperation.execute(mClient); + + return result; + } +} diff --git a/tests/.classpath b/tests/.classpath index 2731f9c5..3ac9c4d6 100644 --- a/tests/.classpath +++ b/tests/.classpath @@ -4,6 +4,8 @@ - + + + diff --git a/tests/src/com/owncloud/android/test/AccountUtilsTest.java b/tests/src/com/owncloud/android/test/AccountUtilsTest.java index 51030a55..44a2b60a 100644 --- a/tests/src/com/owncloud/android/test/AccountUtilsTest.java +++ b/tests/src/com/owncloud/android/test/AccountUtilsTest.java @@ -34,21 +34,21 @@ public class AccountUtilsTest extends AndroidTestCase { OwnCloudVersion ocv45 = new OwnCloudVersion(0x040500); OwnCloudVersion ocv70 = new OwnCloudVersion(0x070000); - assertTrue(AccountUtils.getWebdavPath(ocv12, false).equals("/webdav/owncloud.php")); - assertTrue(AccountUtils.getWebdavPath(ocv12s, false).equals("/webdav/owncloud.php")); - assertTrue(AccountUtils.getWebdavPath(ocv22, false).equals("/files/webdav.php")); - assertTrue(AccountUtils.getWebdavPath(ocv30,false).equals("/files/webdav.php")); - assertTrue(AccountUtils.getWebdavPath(ocv33s, false).equals("/files/webdav.php")); - assertTrue(AccountUtils.getWebdavPath(ocv45, false).equals("/remote.php/webdav")); - assertTrue(AccountUtils.getWebdavPath(ocv70, false).equals("/remote.php/webdav")); - assertNull(AccountUtils.getWebdavPath(null, false)); - assertTrue(AccountUtils.getWebdavPath(ocv12, true).equals("/remote.php/odav")); - assertTrue(AccountUtils.getWebdavPath(ocv12s, true).equals("/remote.php/odav")); - assertTrue(AccountUtils.getWebdavPath(ocv22, true).equals("/remote.php/odav")); - assertTrue(AccountUtils.getWebdavPath(ocv30, true).equals("/remote.php/odav")); - assertTrue(AccountUtils.getWebdavPath(ocv33s, true).equals("/remote.php/odav")); - assertTrue(AccountUtils.getWebdavPath(ocv45, true).equals("/remote.php/odav")); - assertTrue(AccountUtils.getWebdavPath(ocv70, true).equals("/remote.php/odav")); + assertTrue(AccountUtils.getWebdavPath(ocv12, false, false).equals("/webdav/owncloud.php")); + assertTrue(AccountUtils.getWebdavPath(ocv12s, false, false).equals("/webdav/owncloud.php")); + assertTrue(AccountUtils.getWebdavPath(ocv22, false, false).equals("/files/webdav.php")); + assertTrue(AccountUtils.getWebdavPath(ocv30, false, false).equals("/files/webdav.php")); + assertTrue(AccountUtils.getWebdavPath(ocv33s, false, false).equals("/files/webdav.php")); + assertTrue(AccountUtils.getWebdavPath(ocv45, false, false).equals("/remote.php/webdav")); + assertTrue(AccountUtils.getWebdavPath(ocv70, false, false).equals("/remote.php/webdav")); + assertNull(AccountUtils.getWebdavPath(null, false, false)); + assertTrue(AccountUtils.getWebdavPath(ocv12, true, false).equals("/remote.php/odav")); + assertTrue(AccountUtils.getWebdavPath(ocv12s, true, false).equals("/remote.php/odav")); + assertTrue(AccountUtils.getWebdavPath(ocv22, true, false).equals("/remote.php/odav")); + assertTrue(AccountUtils.getWebdavPath(ocv30, true, false).equals("/remote.php/odav")); + assertTrue(AccountUtils.getWebdavPath(ocv33s, true, false).equals("/remote.php/odav")); + assertTrue(AccountUtils.getWebdavPath(ocv45, true, false).equals("/remote.php/odav")); + assertTrue(AccountUtils.getWebdavPath(ocv70, true, false).equals("/remote.php/odav")); OwnCloudVersion invalidVer = new OwnCloudVersion("a.b.c"); assertFalse(invalidVer.isVersionValid());