当前位置: 首页>>代码示例>>Java>>正文


Java PathUtils.getDataDirectory方法代码示例

本文整理汇总了Java中org.chromium.base.PathUtils.getDataDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java PathUtils.getDataDirectory方法的具体用法?Java PathUtils.getDataDirectory怎么用?Java PathUtils.getDataDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.chromium.base.PathUtils的用法示例。


在下文中一共展示了PathUtils.getDataDirectory方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNetLogAfterShutdown

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
public void testNetLogAfterShutdown() throws Exception {
    mTestFramework = startCronetTestFramework();
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder = new UrlRequest.Builder(
            mUrl, callback, callback.getExecutor(), mTestFramework.mCronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    mTestFramework.mCronetEngine.shutdown();

    File directory = new File(PathUtils.getDataDirectory(getContext()));
    File file = File.createTempFile("cronet", "json", directory);
    try {
        mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
        fail("Should throw an exception.");
    } catch (Exception e) {
        assertEquals("Engine is shut down.", e.getMessage());
    }
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:25,代码来源:CronetUrlRequestContextTest.java

示例2: testNetLogStartMultipleTimes

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
public void testNetLogStartMultipleTimes() throws Exception {
    mTestFramework = startCronetTestFramework();
    File directory = new File(PathUtils.getDataDirectory(getContext()));
    File file = File.createTempFile("cronet", "json", directory);
    // Start NetLog multiple times.
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder = new UrlRequest.Builder(
            mUrl, callback, callback.getExecutor(), mTestFramework.mCronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    mTestFramework.mCronetEngine.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:25,代码来源:CronetUrlRequestContextTest.java

示例3: testNetLogStopMultipleTimes

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
public void testNetLogStopMultipleTimes() throws Exception {
    mTestFramework = startCronetTestFramework();
    File directory = new File(PathUtils.getDataDirectory(getContext()));
    File file = File.createTempFile("cronet", "json", directory);
    mTestFramework.mCronetEngine.startNetLogToFile(file.getPath(), false);
    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder = new UrlRequest.Builder(
            mUrl, callback, callback.getExecutor(), mTestFramework.mCronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    // Stop NetLog multiple times.
    mTestFramework.mCronetEngine.stopNetLog();
    mTestFramework.mCronetEngine.stopNetLog();
    mTestFramework.mCronetEngine.stopNetLog();
    mTestFramework.mCronetEngine.stopNetLog();
    mTestFramework.mCronetEngine.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:26,代码来源:CronetUrlRequestContextTest.java

示例4: testNetLogWithBytes

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
public void testNetLogWithBytes() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file = File.createTempFile("cronet", "json", directory);
    CronetEngine cronetEngine = new CronetUrlRequestContext(
            new CronetEngine.Builder(context).setLibraryName("cronet_tests"));
    // Start NetLog with logAll as true.
    cronetEngine.startNetLogToFile(file.getPath(), true);
    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder =
            new UrlRequest.Builder(mUrl, callback, callback.getExecutor(), cronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    cronetEngine.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertTrue(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:25,代码来源:CronetUrlRequestContextTest.java

示例5: install

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
/**
 * Installs test files that are included in {@code path}.
 * @params context Application context
 * @params path
 */
private static void install(Context context, String path) throws IOException {
    AssetManager assetManager = context.getAssets();
    String files[] = assetManager.list(path);
    Log.i(TAG, "Loading " + path + " ...");
    String root = PathUtils.getDataDirectory(context);
    if (files.length == 0) {
        // The path is a file, so copy the file now.
        copyTestFile(context, path, root + "/" + path);
    } else {
        // The path is a directory, so recursively handle its files, since
        // the directory can contain subdirectories.
        String fullPath = root + "/" + path;
        File dir = new File(fullPath);
        if (!dir.exists()) {
            Log.i(TAG, "Creating directory " + fullPath + " ...");
            if (!dir.mkdir()) {
                throw new IOException("Directory not created.");
            }
        }
        for (int i = 0; i < files.length; i++) {
            install(context, path + "/" + files[i]);
        }
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:30,代码来源:TestFilesInstaller.java

示例6: testNetLog

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet // No netlogs for pure java impl
public void testNetLog() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file = File.createTempFile("cronet", "json", directory);
    CronetEngine cronetEngine = new CronetUrlRequestContext(
            new CronetEngine.Builder(context).setLibraryName("cronet_tests"));
    // Start NetLog immediately after the request context is created to make
    // sure that the call won't crash the app even when the native request
    // context is not fully initialized. See crbug.com/470196.
    cronetEngine.startNetLogToFile(file.getPath(), false);

    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder =
            new UrlRequest.Builder(mUrl, callback, callback.getExecutor(), cronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    cronetEngine.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:28,代码来源:CronetUrlRequestContextTest.java

示例7: testNoStopNetLog

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet // No netlogs for pure java impl
// Tests that if stopNetLog is not explicity called, CronetEngine.shutdown()
// will take care of it. crbug.com/623701.
public void testNoStopNetLog() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file = File.createTempFile("cronet", "json", directory);
    CronetEngine cronetEngine = new CronetUrlRequestContext(
            new CronetEngine.Builder(context).setLibraryName("cronet_tests"));
    cronetEngine.startNetLogToFile(file.getPath(), false);

    // Start a request.
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder urlRequestBuilder =
            new UrlRequest.Builder(mUrl, callback, callback.getExecutor(), cronetEngine);
    urlRequestBuilder.build().start();
    callback.blockForDone();
    // Shut down the engine without calling stopNetLog.
    cronetEngine.shutdown();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertFalse(hasBytesInNetLog(file));
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:28,代码来源:CronetUrlRequestContextTest.java

示例8: testNetLog

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet // No NetLog from HttpURLConnection
public void testNetLog() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file = File.createTempFile("cronet", "json", directory);
    HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
            context,
            new UrlRequestContextConfig().setLibraryName("cronet_tests"));
    // Start NetLog immediately after the request context is created to make
    // sure that the call won't crash the app even when the native request
    // context is not fully initialized. See crbug.com/470196.
    factory.startNetLogToFile(file.getPath(), false);
    // Starts a request.
    HashMap<String, String> headers = new HashMap<String, String>();
    TestHttpUrlRequestListener listener = new TestHttpUrlRequestListener();
    HttpUrlRequest request = factory.createRequest(
            mUrl, HttpUrlRequest.REQUEST_PRIORITY_MEDIUM, headers, listener);
    request.start();
    listener.blockForComplete();
    factory.stopNetLog();
    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:28,代码来源:CronetUrlTest.java

示例9: testSetSSLKeyLogFile

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
public void testSetSSLKeyLogFile() throws Exception {
    String url = Http2TestServer.getEchoMethodUrl();
    File dir = new File(PathUtils.getDataDirectory(getContext()));
    File file = File.createTempFile("ssl_key_log_file", "", dir);

    JSONObject experimentalOptions = new JSONObject().put("ssl_key_log_file", file.getPath());
    mBuilder.setExperimentalOptions(experimentalOptions.toString());
    mTestFramework = new CronetTestFramework(null, null, getContext(), mBuilder);

    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder builder = new UrlRequest.Builder(
            url, callback, callback.getExecutor(), mTestFramework.mCronetEngine);
    UrlRequest urlRequest = builder.build();
    urlRequest.start();
    callback.blockForDone();
    assertEquals(200, callback.mResponseInfo.getHttpStatusCode());
    assertEquals("GET", callback.mResponseAsString);

    assertTrue(file.exists());
    assertTrue(file.length() != 0);
    BufferedReader logReader = new BufferedReader(new FileReader(file));
    boolean validFile = false;
    try {
        String logLine;
        while ((logLine = logReader.readLine()) != null) {
            if (logLine.contains("CLIENT_RANDOM")) {
                validFile = true;
                break;
            }
        }
    } finally {
        logReader.close();
    }
    assertTrue(validFile);
    assertTrue(file.delete());
    assertTrue(!file.exists());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:41,代码来源:ExperimentalOptionsTest.java

示例10: onCreate

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    /* Copying the www folder to the data folder at the start of the application */
    String dataDirectoryPath = PathUtils.getDataDirectory(this);
    File f = new File(dataDirectoryPath);
    try {
        AssetManager assetManager = getAssets();
        InputStream is = assetManager.open("www.zip");
        if (!f.exists()) {
            f.mkdirs();
        }
        File targetFile = new File(f.getAbsolutePath() + "/" + "www.zip");
        OutputStream io = new FileOutputStream(targetFile);
        copyFile(is, io);

        unzipFile(targetFile.getAbsolutePath(), f.getAbsolutePath() + "/");

    } catch (IOException e) {
        e.printStackTrace();
    }

    String startupUrl = Uri.fromFile(new File(f.getAbsolutePath() + "/www/index.html")).toString();
    this.setStartupUrl(startupUrl);

    super.onCreate(savedInstanceState);


    /**
     * This line when used crashes the app with Exception
     * java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams
     * cannot be cast to android.widget.FrameLayout$LayoutParams
     * I have no idea why this happens until now
     */
    //this.loadUrl("http://google.com");

}
 
开发者ID:R4md4c,项目名称:cordova-android-chromium,代码行数:37,代码来源:MainActivity.java

示例11: testNetLogContainEventsFromAllLiveEngines

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
// Tests that NetLog contains events emitted by all live CronetEngines.
public void testNetLogContainEventsFromAllLiveEngines() throws Exception {
    Context context = getContext();
    File directory = new File(PathUtils.getDataDirectory(context));
    File file1 = File.createTempFile("cronet1", "json", directory);
    File file2 = File.createTempFile("cronet2", "json", directory);
    CronetEngine cronetEngine1 = new CronetUrlRequestContext(
            new CronetEngine.Builder(context).setLibraryName("cronet_tests"));
    CronetEngine cronetEngine2 = new CronetUrlRequestContext(
            new CronetEngine.Builder(context).setLibraryName("cronet_tests"));

    cronetEngine1.startNetLogToFile(file1.getPath(), false);
    cronetEngine2.startNetLogToFile(file2.getPath(), false);

    // Warm CronetEngine and make sure both CronetUrlRequestContexts are
    // initialized before testing the logs.
    makeRequestAndCheckStatus(cronetEngine1, mUrl, 200);
    makeRequestAndCheckStatus(cronetEngine2, mUrl, 200);

    // Use cronetEngine1 to make a request to mUrl404.
    makeRequestAndCheckStatus(cronetEngine1, mUrl404, 404);

    // Use cronetEngine2 to make a request to mUrl500.
    makeRequestAndCheckStatus(cronetEngine2, mUrl500, 500);

    cronetEngine1.stopNetLog();
    cronetEngine2.stopNetLog();
    assertTrue(file1.exists());
    assertTrue(file2.exists());
    // Make sure both files contain the two requests made separately using
    // different engines.
    assertTrue(containsStringInNetLog(file1, mUrl404));
    assertTrue(containsStringInNetLog(file1, mUrl500));
    assertTrue(containsStringInNetLog(file2, mUrl404));
    assertTrue(containsStringInNetLog(file2, mUrl500));
    assertTrue(file1.delete());
    assertTrue(file2.delete());
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:42,代码来源:CronetUrlRequestContextTest.java

示例12: getInstalledPath

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
/**
 * Returns the installed path of the test files.
 */
public static String getInstalledPath(Context context) {
    return PathUtils.getDataDirectory(context) + "/" + TEST_FILE_ASSET_PATH;
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:7,代码来源:TestFilesInstaller.java

示例13: getOutputDirFromContext

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
public static File getOutputDirFromContext(Context context) {
    return new File(PathUtils.getDataDirectory(context.getApplicationContext()), "paks");
}
 
开发者ID:openresearch,项目名称:android-chromium-view,代码行数:4,代码来源:ResourceExtractor.java

示例14: getTestStorageDirectory

import org.chromium.base.PathUtils; //导入方法依赖的package包/类
/**
 * Returns the path for the test storage (http cache, QUIC server info).
 * NOTE: Does not ensure it exists; tests should use {@link #getTestStorage}.
 */
private static String getTestStorageDirectory(Context context) {
    return PathUtils.getDataDirectory(context) + "/test_storage";
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:8,代码来源:CronetTestFramework.java


注:本文中的org.chromium.base.PathUtils.getDataDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。