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