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 com
.owncloud
.android
.lib
.common
.accounts
.AccountUtils
; 
  22 import com
.owncloud
.android
.lib
.resources
.status
.OwnCloudVersion
; 
  24 import android
.test
.AndroidTestCase
; 
  27 public class AccountUtilsTest 
extends AndroidTestCase 
{ 
  29     public void testGetWebdavPathAndOCVersion() { 
  30         OwnCloudVersion ocv12 
= new OwnCloudVersion(0x010200); 
  31         OwnCloudVersion ocv12s 
= new OwnCloudVersion("1.2"); 
  32         OwnCloudVersion ocv22 
= new OwnCloudVersion(0x020200); 
  33         OwnCloudVersion ocv30 
= new OwnCloudVersion(0x030000); 
  34         OwnCloudVersion ocv33s 
= new OwnCloudVersion("3.3.3"); 
  35         OwnCloudVersion ocv45 
= new OwnCloudVersion(0x040500); 
  36         OwnCloudVersion ocv70 
= new OwnCloudVersion(0x070000); 
  38         assertTrue(AccountUtils
.getWebdavPath(ocv12
, false
, false
).equals("/webdav/owncloud.php")); 
  39         assertTrue(AccountUtils
.getWebdavPath(ocv12s
, false
, false
).equals("/webdav/owncloud.php")); 
  40         assertTrue(AccountUtils
.getWebdavPath(ocv22
, false
, false
).equals("/files/webdav.php")); 
  41         assertTrue(AccountUtils
.getWebdavPath(ocv30
,false
, false
).equals("/files/webdav.php")); 
  42         assertTrue(AccountUtils
.getWebdavPath(ocv33s
, false
, false
).equals("/files/webdav.php")); 
  43         assertTrue(AccountUtils
.getWebdavPath(ocv45
, false
, false
).equals("/remote.php/webdav")); 
  44         assertTrue(AccountUtils
.getWebdavPath(ocv70
, false
, false
).equals("/remote.php/webdav")); 
  45         assertNull(AccountUtils
.getWebdavPath(null
, false
, false
)); 
  46         assertTrue(AccountUtils
.getWebdavPath(ocv12
, true
, false
).equals("/remote.php/odav")); 
  47         assertTrue(AccountUtils
.getWebdavPath(ocv12s
, true
, false
).equals("/remote.php/odav")); 
  48         assertTrue(AccountUtils
.getWebdavPath(ocv22
, true
, false
).equals("/remote.php/odav")); 
  49         assertTrue(AccountUtils
.getWebdavPath(ocv30
, true
, false
).equals("/remote.php/odav")); 
  50         assertTrue(AccountUtils
.getWebdavPath(ocv33s
, true
, false
).equals("/remote.php/odav")); 
  51         assertTrue(AccountUtils
.getWebdavPath(ocv45
, true
, false
).equals("/remote.php/odav")); 
  52         assertTrue(AccountUtils
.getWebdavPath(ocv70
, true
, false
).equals("/remote.php/odav")); 
  54         OwnCloudVersion invalidVer 
= new OwnCloudVersion("a.b.c"); 
  55         assertFalse(invalidVer
.isVersionValid()); 
  57         assertTrue(ocv45
.toString().equals("4.5.0"));