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


Java PathUtils类代码示例

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


PathUtils类属于org.chromium.base包,在下文中一共展示了PathUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: preInflationStartup

import org.chromium.base.PathUtils; //导入依赖的package包/类
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    ChromeWebApkHost.init();

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:ChromeBrowserInitializer.java

示例7: cleanupPersistentData

import org.chromium.base.PathUtils; //导入依赖的package包/类
/**
 * Remove on-disk thumbnails that are no longer needed.
 * @param modelSelector The selector that answers whether a tab is currently present.
 */
public void cleanupPersistentData(TabModelSelector modelSelector) {
    if (mNativeTabContentManager == 0) return;
    File[] files = PathUtils.getThumbnailCacheDirectory(mContext).listFiles();
    if (files == null) return;

    for (File file : files) {
        try {
            int id = Integer.parseInt(file.getName());
            if (TabModelUtils.getTabById(modelSelector.getModel(false), id) == null
                    && TabModelUtils.getTabById(modelSelector.getModel(true), id) == null) {
                nativeRemoveTabThumbnail(mNativeTabContentManager, id);
            }
        } catch (NumberFormatException expected) {
            // This is an unknown file name, we'll leave it there.
        }
    }
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:22,代码来源:TabContentManager.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: onCreate

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this);
    mConfig = getIntent().getData();
    // Execute benchmarks on another thread to avoid networking on main thread.
    new BenchmarkTask().execute();
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:9,代码来源:CronetPerfTestActivity.java

示例13: doInBackground

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
    if (mDestroyed) return null;

    mTabFileNames = getOrCreateStateDirectory().list();
    String thumbnailDirectory = PathUtils.getThumbnailCacheDirectory();
    mThumbnailFileNames = new File(thumbnailDirectory).list();

    mOtherTabIds = new SparseBooleanArray();
    getTabsFromOtherStateFiles(mOtherTabIds);
    return null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:TabbedModeTabPersistencePolicy.java

示例14: shouldRequestFileAccess

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
public boolean shouldRequestFileAccess(String url, Tab tab) {
    // If the tab is null, then do not attempt to prompt for access.
    if (tab == null) return false;

    // If the url points inside of Chromium's data directory, no permissions are necessary.
    // This is required to prevent permission prompt when uses wants to access offline pages.
    if (url.startsWith("file://" + PathUtils.getDataDirectory())) {
        return false;
    }

    return !tab.getWindowAndroid().hasPermission(permission.WRITE_EXTERNAL_STORAGE)
            && tab.getWindowAndroid().canRequestPermission(permission.WRITE_EXTERNAL_STORAGE);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:ExternalNavigationDelegateImpl.java

示例15: initializeLibraryDependencies

import org.chromium.base.PathUtils; //导入依赖的package包/类
@Override
protected void initializeLibraryDependencies() {
    // The ResourceExtractor is only needed by the browser process, but this will have no
    // impact on the renderer process construction.
    ResourceBundle.initializeLocalePaks(this, R.array.locale_paks);
    if (!BuildInfo.hasLanguageApkSplits(this)) {
        ResourceExtractor.setResourcesToExtract(ResourceBundle.getActiveLocaleResources());
    }
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, this);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:11,代码来源:ChromeApplication.java


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