Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: blimp/engine/testing/app/test_blimp_browser_main_parts.cc

Issue 2572563006: [Blimp] Refactor Blimp test engine with embedded test server and URL rewriting (Closed)
Patch Set: nit change Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/engine/testing/app/test_blimp_browser_main_parts.h"
6
7 #include "blimp/engine/app/blimp_engine_config.h"
8 #include "blimp/engine/testing/app/blimp_url_rewriter.h"
9 #include "blimp/engine/testing/session/test_blimp_engine_session.h"
10 #include "content/public/browser/browser_url_handler.h"
11 #include "net/log/net_log.h"
12 #include "net/test/embedded_test_server/embedded_test_server.h"
13
14 namespace blimp {
15 namespace engine {
16
17 const base::FilePath::CharType kBlimpTestRoot[] = FILE_PATH_LITERAL("");
18
19 TestBlimpBrowserMainParts::TestBlimpBrowserMainParts(
20 const content::MainFunctionParams& parameters)
21 : BlimpBrowserMainParts(parameters){}
22
23 void TestBlimpBrowserMainParts::PreEarlyInitialization() {
24 // Fetch the engine config from the command line, and crash if invalid. Allow
25 // IO operations even though this is not in the FILE thread as this is
26 // necessary for Blimp startup and occurs before any user interaction.
27 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
28 base::ThreadRestrictions::ScopedAllowIO allow_io;
29 engine_config_ = BlimpEngineConfig::Create(*cmd_line);
30 CHECK(engine_config_);
31 }
32
33 void TestBlimpBrowserMainParts::PreMainMessageLoopRun() {
34 blimp::engine::test::g_ets_instance =
35 base::MakeUnique<net::EmbeddedTestServer>();
36 blimp::engine::test::g_ets_instance->ServeFilesFromSourceDirectory(
37 base::FilePath(kBlimpTestRoot));
38 DCHECK(blimp::engine::test::g_ets_instance->Start());
39
40 content::BrowserURLHandler::GetInstance()->AddHandlerPair(
41 &blimp::engine::test::HandleBlimpTestURL,
42 content::BrowserURLHandler::null_handler());
43
44 net_log_ = base::MakeUnique<net::NetLog>();
45
46 std::unique_ptr<SettingsManager> settings_manager_ =
47 base::MakeUnique<SettingsManager>();
48 std::unique_ptr<BlimpBrowserContext> browser_context =
49 base::MakeUnique<BlimpBrowserContext>(false, net_log_.get());
50 std::unique_ptr<BlimpEngineSession> engine_session_ =
51 base::MakeUnique<TestBlimpEngineSession>(
52 std::move(browser_context), net_log_.get(), engine_config_.get(),
53 settings_manager_.get());
54 engine_session_->Initialize();
55
56 SetSettingsManagerForTesting(std::move(settings_manager_));
57 SetEngineSessionForTesting(std::move(engine_session_));
58 }
59
60 void TestBlimpBrowserMainParts::PostMainMessageLoopRun() {
61 BlimpBrowserMainParts::PostMainMessageLoopRun();
62 DCHECK(blimp::engine::test::g_ets_instance->ShutdownAndWaitUntilComplete());
63 }
64
65 } // namespace engine
66 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/testing/app/test_blimp_browser_main_parts.h ('k') | blimp/engine/testing/app/test_blimp_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698