Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
io.flutter.util.PathUtilsTest Class Reference

Public Member Functions

void canGetFilesDir ()
 
void canOnlyGetFilesPathWhenDiskFullAndFilesDirNotCreated ()
 
void canGetFlutterDataDir ()
 
void canOnlyGetFlutterDataPathWhenDiskFullAndFlutterDataDirNotCreated ()
 
void canGetCacheDir ()
 
void canOnlyGetCachePathWhenDiskFullAndCacheDirNotCreated ()
 

Detailed Description

Definition at line 23 of file PathUtilsTest.java.

Member Function Documentation

◆ canGetCacheDir()

void io.flutter.util.PathUtilsTest.canGetCacheDir ( )
inline

Definition at line 67 of file PathUtilsTest.java.

67 {
68 Context context = mock(Context.class);
69 when(context.getCacheDir()).thenReturn(new File(APP_DATA_PATH + "/cache"));
70 if (Build.VERSION.SDK_INT >= API_LEVELS.API_21) {
71 when(context.getCodeCacheDir()).thenReturn(new File(APP_DATA_PATH + "/code_cache"));
72 }
73 assertTrue(PathUtils.getCacheDirectory(context).startsWith(APP_DATA_PATH));
74 }
def Build(configs, env, options)
Definition: build.py:232

◆ canGetFilesDir()

void io.flutter.util.PathUtilsTest.canGetFilesDir ( )
inline

Definition at line 28 of file PathUtilsTest.java.

28 {
29 Context context = mock(Context.class);
30 when(context.getFilesDir()).thenReturn(new File(APP_DATA_PATH + "/files"));
31 assertEquals(PathUtils.getFilesDir(context), APP_DATA_PATH + "/files");
32 }

◆ canGetFlutterDataDir()

void io.flutter.util.PathUtilsTest.canGetFlutterDataDir ( )
inline

Definition at line 47 of file PathUtilsTest.java.

47 {
48 Context context = mock(Context.class);
49 when(context.getDir("flutter", Context.MODE_PRIVATE))
50 .thenReturn(new File(APP_DATA_PATH + "/app_flutter"));
51 assertEquals(PathUtils.getDataDirectory(context), APP_DATA_PATH + "/app_flutter");
52 }

◆ canOnlyGetCachePathWhenDiskFullAndCacheDirNotCreated()

void io.flutter.util.PathUtilsTest.canOnlyGetCachePathWhenDiskFullAndCacheDirNotCreated ( )
inline

Definition at line 77 of file PathUtilsTest.java.

77 {
78 Context context = mock(Context.class);
79 when(context.getCacheDir()).thenReturn(null);
80 if (Build.VERSION.SDK_INT >= API_LEVELS.API_21) {
81 when(context.getCodeCacheDir()).thenReturn(null);
82 }
83 if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) {
84 when(context.getDataDir()).thenReturn(new File(APP_DATA_PATH));
85 } else {
86 when(context.getApplicationInfo().dataDir).thenReturn(APP_DATA_PATH);
87 }
88 assertEquals(PathUtils.getCacheDirectory(context), APP_DATA_PATH + "/cache");
89 }

◆ canOnlyGetFilesPathWhenDiskFullAndFilesDirNotCreated()

void io.flutter.util.PathUtilsTest.canOnlyGetFilesPathWhenDiskFullAndFilesDirNotCreated ( )
inline

Definition at line 35 of file PathUtilsTest.java.

35 {
36 Context context = mock(Context.class);
37 when(context.getFilesDir()).thenReturn(null);
38 if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) {
39 when(context.getDataDir()).thenReturn(new File(APP_DATA_PATH));
40 } else {
41 when(context.getApplicationInfo().dataDir).thenReturn(APP_DATA_PATH);
42 }
43 assertEquals(PathUtils.getFilesDir(context), APP_DATA_PATH + "/files");
44 }

◆ canOnlyGetFlutterDataPathWhenDiskFullAndFlutterDataDirNotCreated()

void io.flutter.util.PathUtilsTest.canOnlyGetFlutterDataPathWhenDiskFullAndFlutterDataDirNotCreated ( )
inline

Definition at line 55 of file PathUtilsTest.java.

55 {
56 Context context = mock(Context.class);
57 when(context.getDir("flutter", Context.MODE_PRIVATE)).thenReturn(null);
58 if (Build.VERSION.SDK_INT >= API_LEVELS.API_24) {
59 when(context.getDataDir()).thenReturn(new File(APP_DATA_PATH));
60 } else {
61 when(context.getApplicationInfo().dataDir).thenReturn(APP_DATA_PATH);
62 }
63 assertEquals(PathUtils.getDataDirectory(context), APP_DATA_PATH + "/app_flutter");
64 }

The documentation for this class was generated from the following file: