| Index: blimp/engine/testing/app/test_blimp_browser_main_parts.cc
|
| diff --git a/blimp/engine/testing/app/test_blimp_browser_main_parts.cc b/blimp/engine/testing/app/test_blimp_browser_main_parts.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..b1de2ff734ddc39016496e89946b8a4665e49992
|
| --- /dev/null
|
| +++ b/blimp/engine/testing/app/test_blimp_browser_main_parts.cc
|
| @@ -0,0 +1,66 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "blimp/engine/testing/app/test_blimp_browser_main_parts.h"
|
| +
|
| +#include "blimp/engine/app/blimp_engine_config.h"
|
| +#include "blimp/engine/testing/app/blimp_url_rewriter.h"
|
| +#include "blimp/engine/testing/session/test_blimp_engine_session.h"
|
| +#include "content/public/browser/browser_url_handler.h"
|
| +#include "net/log/net_log.h"
|
| +#include "net/test/embedded_test_server/embedded_test_server.h"
|
| +
|
| +namespace blimp {
|
| +namespace engine {
|
| +
|
| +const base::FilePath::CharType kBlimpTestRoot[] = FILE_PATH_LITERAL("");
|
| +
|
| +TestBlimpBrowserMainParts::TestBlimpBrowserMainParts(
|
| + const content::MainFunctionParams& parameters)
|
| + : BlimpBrowserMainParts(parameters){}
|
| +
|
| +void TestBlimpBrowserMainParts::PreEarlyInitialization() {
|
| + // Fetch the engine config from the command line, and crash if invalid. Allow
|
| + // IO operations even though this is not in the FILE thread as this is
|
| + // necessary for Blimp startup and occurs before any user interaction.
|
| + const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
|
| + base::ThreadRestrictions::ScopedAllowIO allow_io;
|
| + engine_config_ = BlimpEngineConfig::Create(*cmd_line);
|
| + CHECK(engine_config_);
|
| +}
|
| +
|
| +void TestBlimpBrowserMainParts::PreMainMessageLoopRun() {
|
| + blimp::engine::test::g_ets_instance =
|
| + base::MakeUnique<net::EmbeddedTestServer>();
|
| + blimp::engine::test::g_ets_instance->ServeFilesFromSourceDirectory(
|
| + base::FilePath(kBlimpTestRoot));
|
| + DCHECK(blimp::engine::test::g_ets_instance->Start());
|
| +
|
| + content::BrowserURLHandler::GetInstance()->AddHandlerPair(
|
| + &blimp::engine::test::HandleBlimpTestURL,
|
| + content::BrowserURLHandler::null_handler());
|
| +
|
| + net_log_ = base::MakeUnique<net::NetLog>();
|
| +
|
| + std::unique_ptr<SettingsManager> settings_manager_ =
|
| + base::MakeUnique<SettingsManager>();
|
| + std::unique_ptr<BlimpBrowserContext> browser_context =
|
| + base::MakeUnique<BlimpBrowserContext>(false, net_log_.get());
|
| + std::unique_ptr<BlimpEngineSession> engine_session_ =
|
| + base::MakeUnique<TestBlimpEngineSession>(
|
| + std::move(browser_context), net_log_.get(), engine_config_.get(),
|
| + settings_manager_.get());
|
| + engine_session_->Initialize();
|
| +
|
| + SetSettingsManagerForTesting(std::move(settings_manager_));
|
| + SetEngineSessionForTesting(std::move(engine_session_));
|
| +}
|
| +
|
| +void TestBlimpBrowserMainParts::PostMainMessageLoopRun() {
|
| + BlimpBrowserMainParts::PostMainMessageLoopRun();
|
| + DCHECK(blimp::engine::test::g_ets_instance->ShutdownAndWaitUntilComplete());
|
| +}
|
| +
|
| +} // namespace engine
|
| +} // namespace blimp
|
|
|