5package io.flutter.util;
7import static io.flutter.Build.API_LEVELS;
8import static org.junit.Assert.assertEquals;
9import static org.junit.Assert.assertTrue;
10import static org.mockito.Mockito.mock;
11import static org.mockito.Mockito.when;
17import org.junit.runner.RunWith;
18import org.robolectric.RobolectricTestRunner;
19import org.robolectric.annotation.Config;
22@RunWith(RobolectricTestRunner.class)
25 private static final String APP_DATA_PATH =
"/data/data/package_name";
29 Context context = mock(Context.class);
30 when(context.getFilesDir()).thenReturn(
new File(APP_DATA_PATH +
"/files"));
36 Context context = mock(Context.class);
37 when(context.getFilesDir()).thenReturn(
null);
39 when(context.getDataDir()).thenReturn(
new File(APP_DATA_PATH));
41 when(context.getApplicationInfo().dataDir).thenReturn(APP_DATA_PATH);
48 Context context = mock(Context.class);
49 when(context.getDir(
"flutter", Context.MODE_PRIVATE))
50 .thenReturn(
new File(APP_DATA_PATH +
"/app_flutter"));
56 Context context = mock(Context.class);
57 when(context.getDir(
"flutter", Context.MODE_PRIVATE)).thenReturn(
null);
59 when(context.getDataDir()).thenReturn(
new File(APP_DATA_PATH));
61 when(context.getApplicationInfo().dataDir).thenReturn(APP_DATA_PATH);
68 Context context = mock(Context.class);
69 when(context.getCacheDir()).thenReturn(
new File(APP_DATA_PATH +
"/cache"));
71 when(context.getCodeCacheDir()).thenReturn(
new File(APP_DATA_PATH +
"/code_cache"));
78 Context context = mock(Context.class);
79 when(context.getCacheDir()).thenReturn(
null);
81 when(context.getCodeCacheDir()).thenReturn(
null);
84 when(context.getDataDir()).thenReturn(
new File(APP_DATA_PATH));
86 when(context.getApplicationInfo().dataDir).thenReturn(APP_DATA_PATH);
void canOnlyGetFilesPathWhenDiskFullAndFilesDirNotCreated()
void canOnlyGetCachePathWhenDiskFullAndCacheDirNotCreated()
void canGetFlutterDataDir()
void canOnlyGetFlutterDataPathWhenDiskFullAndFlutterDataDirNotCreated()
static String getDataDirectory(@NonNull Context applicationContext)
static String getCacheDirectory(@NonNull Context applicationContext)
static String getFilesDir(@NonNull Context applicationContext)
def Build(configs, env, options)