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

Side by Side Diff: blimp/test/blimp_browser_test.cc

Issue 1929723002: [Blimp] Adds blimp engine browser test framework and LoadUrl test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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/test/blimp_browser_test.h"
6
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
10 #include "base/memory/ptr_util.h"
11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
13 #include "blimp/client/app/blimp_client_switches.h"
14 #include "blimp/client/session/assignment_source.h"
15 #include "blimp/engine/app/switches.h"
16 #include "cc/base/switches.h"
17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/render_process_host.h"
19 #include "content/public/common/content_switches.h"
20 #include "content/public/common/url_constants.h"
21 #include "ui/gl/gl_switches.h"
22
23 namespace blimp {
24
25 BlimpBrowserTest::BlimpBrowserTest() {
26 base::FilePath test_data(FILE_PATH_LITERAL("blimp/engine/test/data"));
27 CreateTestServer(test_data);
28 }
29
30 BlimpBrowserTest::~BlimpBrowserTest() {}
31
32 void BlimpBrowserTest::SetUp() {
33 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
34 SetUpCommandLine(command_line);
35 BrowserTestBase::SetUp();
36 }
37
38 void BlimpBrowserTest::SetUpOnMainThread() {}
39
40 void BlimpBrowserTest::TearDownOnMainThread() {
41 content::BrowserThread::GetMessageLoopProxyForThread(
42 content::BrowserThread::UI)
43 ->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
44 }
45
46 void BlimpBrowserTest::SetUpCommandLine(base::CommandLine* command_line) {
47 command_line->AppendSwitchASCII(::switches::kVModule, "blimp*=2");
48 command_line->AppendSwitchASCII(blimp::switches::kEnginePort, "25567");
49
50 // Engine switches
51 command_line->AppendSwitch(::switches::kDisableGpu);
52 command_line->AppendSwitch(::switches::kUseRemoteCompositing);
nyquist 2016/04/29 21:30:54 Could you file a bug that we should move these to
haibinlu 2016/04/29 22:43:13 pull engine command line config out of blimp/engin
53 command_line->AppendSwitch(cc::switches::kDisableCachedPictureRaster);
54 command_line->AppendSwitchASCII(::switches::kUseGL, "osmesa");
55 command_line->AppendSwitch(
56 "disable-remote-fonts"); // switches::kDisableRemoteFonts is not visible.
57 command_line->AppendSwitchASCII(blimp::engine::kClientToken,
58 blimp::client::kDummyClientToken);
59
60 // Client switches
61 // Client's AssignmentSource uses engine IP&port from command line and
62 // defaults to TCP client.
63 command_line->AppendSwitchASCII(blimp::switches::kEngineIP, "127.0.0.1");
64 command_line->AppendSwitchASCII(blimp::switches::kEngineTransport, "tcp");
65 }
66
67 void BlimpBrowserTest::RunTestOnMainThreadLoop() {
68 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
69
70 // Pump startup related events.
71 base::MessageLoop::current()->RunUntilIdle();
72
73 SetUpOnMainThread();
74 RunTestOnMainThread();
75 TearDownOnMainThread();
76
77 for (content::RenderProcessHost::iterator i(
78 content::RenderProcessHost::AllHostsIterator());
79 !i.IsAtEnd(); i.Advance()) {
80 i.GetCurrentValue()->FastShutdownIfPossible();
81 }
82 }
83
84 void BlimpBrowserTest::RunAsynchronousTest() {
85 base::MessageLoop::ScopedNestableTaskAllower nestable_allower(
86 base::MessageLoop::current());
87 EXPECT_FALSE(run_loop_);
88 run_loop_ = base::WrapUnique(new base::RunLoop());
89 run_loop_->Run();
90 run_loop_ = nullptr;
91 }
92
93 void BlimpBrowserTest::FinishAsynchronousTest() {
94 run_loop_->Quit();
95 }
96
97 } // namespace blimp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698