/** Initialization needed for tests. Mainly used by content browsertests. */
  public void initChromiumBrowserProcessForTests() {
    ResourceExtractor resourceExtractor = ResourceExtractor.get(mContext);
    resourceExtractor.startExtractingResources();
    resourceExtractor.waitForCompletion();

    // Having a single renderer should be sufficient for tests. We can't have more than
    // MAX_RENDERERS_LIMIT.
    nativeSetCommandLineFlags(1 /* maxRenderers */, null);
  }
  @VisibleForTesting
  void prepareToStartBrowserProcess(int maxRendererProcesses) throws ProcessInitException {
    Log.i(TAG, "Initializing chromium process, renderers=" + maxRendererProcesses);

    // Normally Main.java will have kicked this off asynchronously for Chrome. But other
    // ContentView apps like tests also need them so we make sure we've extracted resources
    // here. We can still make it a little async (wait until the library is loaded).
    ResourceExtractor resourceExtractor = ResourceExtractor.get(mContext);
    resourceExtractor.startExtractingResources();

    // Normally Main.java will have already loaded the library asynchronously, we only need
    // to load it here if we arrived via another flow, e.g. bookmark access & sync setup.
    LibraryLoader.ensureInitialized(mContext);

    // TODO(yfriedman): Remove dependency on a command line flag for this.
    DeviceUtils.addDeviceSpecificUserAgentSwitch(mContext);

    Context appContext = mContext.getApplicationContext();
    // Now we really need to have the resources ready.
    resourceExtractor.waitForCompletion();

    nativeSetCommandLineFlags(maxRendererProcesses, nativeIsPluginEnabled() ? getPlugins() : null);
    ContentMain.initApplicationContext(appContext);
  }