AccountUtilsTest.java 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* ownCloud Android client application
  2. * Copyright (C) 2012 Bartek Przybylski
  3. * Copyright (C) 2012-2013 ownCloud Inc.
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2,
  7. * as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. */
  18. package com.owncloud.android.test;
  19. import android.test.AndroidTestCase;
  20. import com.owncloud.android.authentication.AccountUtils;
  21. import com.owncloud.android.utils.OwnCloudVersion;
  22. public class AccountUtilsTest extends AndroidTestCase {
  23. public void testGetWebdavPathAndOCVersion() {
  24. OwnCloudVersion ocv12 = new OwnCloudVersion(0x010200);
  25. OwnCloudVersion ocv12s = new OwnCloudVersion("1.2");
  26. OwnCloudVersion ocv22 = new OwnCloudVersion(0x020200);
  27. OwnCloudVersion ocv30 = new OwnCloudVersion(0x030000);
  28. OwnCloudVersion ocv33s = new OwnCloudVersion("3.3.3");
  29. OwnCloudVersion ocv45 = new OwnCloudVersion(0x040500);
  30. OwnCloudVersion ocv70 = new OwnCloudVersion(0x070000);
  31. assertTrue(AccountUtils.getWebdavPath(ocv12, false).equals("/webdav/owncloud.php"));
  32. assertTrue(AccountUtils.getWebdavPath(ocv12s, false).equals("/webdav/owncloud.php"));
  33. assertTrue(AccountUtils.getWebdavPath(ocv22, false).equals("/files/webdav.php"));
  34. assertTrue(AccountUtils.getWebdavPath(ocv30,false).equals("/files/webdav.php"));
  35. assertTrue(AccountUtils.getWebdavPath(ocv33s, false).equals("/files/webdav.php"));
  36. assertTrue(AccountUtils.getWebdavPath(ocv45, false).equals("/remote.php/webdav"));
  37. assertTrue(AccountUtils.getWebdavPath(ocv70, false).equals("/remote.php/webdav"));
  38. assertNull(AccountUtils.getWebdavPath(null, false));
  39. assertTrue(AccountUtils.getWebdavPath(ocv12, true).equals("/remote.php/odav"));
  40. assertTrue(AccountUtils.getWebdavPath(ocv12s, true).equals("/remote.php/odav"));
  41. assertTrue(AccountUtils.getWebdavPath(ocv22, true).equals("/remote.php/odav"));
  42. assertTrue(AccountUtils.getWebdavPath(ocv30, true).equals("/remote.php/odav"));
  43. assertTrue(AccountUtils.getWebdavPath(ocv33s, true).equals("/remote.php/odav"));
  44. assertTrue(AccountUtils.getWebdavPath(ocv45, true).equals("/remote.php/odav"));
  45. assertTrue(AccountUtils.getWebdavPath(ocv70, true).equals("/remote.php/odav"));
  46. OwnCloudVersion invalidVer = new OwnCloudVersion("a.b.c");
  47. assertFalse(invalidVer.isVersionValid());
  48. assertTrue(ocv45.toString().equals("4.5.0"));
  49. }
  50. }