• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.os.cts;
17 
18 import java.io.File;
19 
20 import junit.framework.TestCase;
21 import android.os.Environment;
22 import android.os.StatFs;
23 
24 public class StatFsTest extends TestCase {
testStatFs()25     public void testStatFs() {
26         File path = Environment.getDataDirectory();
27         StatFs stat = new StatFs(path.getPath());
28 
29         assertTrue(stat.getBlockSize() > 0);
30         assertTrue(stat.getBlockCount() > 0);
31         assertTrue(stat.getFreeBlocks() >= stat.getAvailableBlocks());
32         assertTrue(stat.getAvailableBlocks() > 0);
33 
34         assertTrue(stat.getBlockSizeLong() > 0);
35         assertTrue(stat.getBlockCountLong() > 0);
36         assertTrue(stat.getFreeBlocksLong() >= stat.getAvailableBlocksLong());
37         assertTrue(stat.getAvailableBlocksLong() > 0);
38 
39         assertTrue(stat.getFreeBytes() > 0);
40         assertTrue(stat.getAvailableBytes() > 0);
41         assertTrue(stat.getTotalBytes() > 0);
42 
43         path = Environment.getRootDirectory();
44         stat.restat(path.getPath());
45 
46         assertTrue(stat.getBlockSize() > 0);
47         assertTrue(stat.getBlockCount() > 0);
48         assertTrue(stat.getFreeBlocks() >= stat.getAvailableBlocks());
49         assertTrue(stat.getAvailableBlocks() > 0);
50 
51         assertTrue(stat.getBlockSizeLong() > 0);
52         assertTrue(stat.getBlockCountLong() > 0);
53         assertTrue(stat.getFreeBlocksLong() >= stat.getAvailableBlocksLong());
54         assertTrue(stat.getAvailableBlocksLong() > 0);
55 
56         assertTrue(stat.getFreeBytes() > 0);
57         assertTrue(stat.getAvailableBytes() > 0);
58         assertTrue(stat.getTotalBytes() > 0);
59     }
60 }
61