1 /* ownCloud Android client application
2 * Copyright (C) 2012 Bartek Przybylski
3 * Copyright (C) 2012-2013 ownCloud Inc.
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.
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.
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/>.
19 package com
.owncloud
.android
.test
;
21 import android
.test
.AndroidTestCase
;
23 import com
.owncloud
.android
.oc_framework
.accounts
.AccountUtils
;
24 import com
.owncloud
.android
.oc_framework
.utils
.OwnCloudVersion
;
26 public class AccountUtilsTest
extends AndroidTestCase
{
28 public void testGetWebdavPathAndOCVersion() {
29 OwnCloudVersion ocv12
= new OwnCloudVersion(0x010200);
30 OwnCloudVersion ocv12s
= new OwnCloudVersion("1.2");
31 OwnCloudVersion ocv22
= new OwnCloudVersion(0x020200);
32 OwnCloudVersion ocv30
= new OwnCloudVersion(0x030000);
33 OwnCloudVersion ocv33s
= new OwnCloudVersion("3.3.3");
34 OwnCloudVersion ocv45
= new OwnCloudVersion(0x040500);
35 OwnCloudVersion ocv70
= new OwnCloudVersion(0x070000);
37 assertTrue(AccountUtils
.getWebdavPath(ocv12
, false
, false
).equals("/webdav/owncloud.php"));
38 assertTrue(AccountUtils
.getWebdavPath(ocv12s
, false
, false
).equals("/webdav/owncloud.php"));
39 assertTrue(AccountUtils
.getWebdavPath(ocv22
, false
, false
).equals("/files/webdav.php"));
40 assertTrue(AccountUtils
.getWebdavPath(ocv30
,false
, false
).equals("/files/webdav.php"));
41 assertTrue(AccountUtils
.getWebdavPath(ocv33s
, false
, false
).equals("/files/webdav.php"));
42 assertTrue(AccountUtils
.getWebdavPath(ocv45
, false
, false
).equals("/remote.php/webdav"));
43 assertTrue(AccountUtils
.getWebdavPath(ocv70
, false
, false
).equals("/remote.php/webdav"));
44 assertNull(AccountUtils
.getWebdavPath(null
, false
, false
));
45 assertTrue(AccountUtils
.getWebdavPath(ocv12
, true
, false
).equals("/remote.php/odav"));
46 assertTrue(AccountUtils
.getWebdavPath(ocv12s
, true
, false
).equals("/remote.php/odav"));
47 assertTrue(AccountUtils
.getWebdavPath(ocv22
, true
, false
).equals("/remote.php/odav"));
48 assertTrue(AccountUtils
.getWebdavPath(ocv30
, true
, false
).equals("/remote.php/odav"));
49 assertTrue(AccountUtils
.getWebdavPath(ocv33s
, true
, false
).equals("/remote.php/odav"));
50 assertTrue(AccountUtils
.getWebdavPath(ocv45
, true
, false
).equals("/remote.php/odav"));
51 assertTrue(AccountUtils
.getWebdavPath(ocv70
, true
, false
).equals("/remote.php/odav"));
53 OwnCloudVersion invalidVer
= new OwnCloudVersion("a.b.c");
54 assertFalse(invalidVer
.isVersionValid());
56 assertTrue(ocv45
.toString().equals("4.5.0"));