Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/blimp_engine_config.h" | |
| 16 #include "blimp/engine/app/switches.h" | |
| 17 #include "content/public/browser/browser_thread.h" | |
| 18 #include "content/public/browser/render_process_host.h" | |
| 19 #include "content/public/common/url_constants.h" | |
| 20 #include "ui/gl/gl_switches.h" | |
| 21 | |
| 22 namespace blimp { | |
| 23 | |
| 24 BlimpBrowserTest::BlimpBrowserTest() { | |
| 25 base::FilePath test_data(FILE_PATH_LITERAL("blimp/engine/test/data")); | |
|
Kevin M
2016/05/02 21:32:39
Path should be a const char* kConstant
haibinlu
2016/05/03 19:32:43
Done.
| |
| 26 CreateTestServer(test_data); | |
| 27 } | |
| 28 | |
| 29 BlimpBrowserTest::~BlimpBrowserTest() {} | |
| 30 | |
| 31 void BlimpBrowserTest::SetUp() { | |
| 32 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 33 SetUpCommandLine(command_line); | |
| 34 BrowserTestBase::SetUp(); | |
| 35 } | |
| 36 | |
| 37 void BlimpBrowserTest::SetUpOnMainThread() {} | |
| 38 | |
| 39 void BlimpBrowserTest::TearDownOnMainThread() { | |
| 40 content::BrowserThread::GetMessageLoopProxyForThread( | |
| 41 content::BrowserThread::UI) | |
| 42 ->PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | |
| 43 } | |
| 44 | |
| 45 void BlimpBrowserTest::SetUpCommandLine(base::CommandLine* command_line) { | |
| 46 command_line->AppendSwitchASCII(::switches::kVModule, "blimp*=2"); | |
| 47 command_line->AppendSwitchASCII(blimp::switches::kEnginePort, "25567"); | |
|
Brian Goldman
2016/05/02 16:48:58
Is this port guaranteed available on the environme
haibinlu
2016/05/02 18:36:27
It should be. we have been using static port test
Kevin M
2016/05/02 21:32:39
I think this introduces a flakiness risk for the w
haibinlu
2016/05/03 19:32:43
ah, my bad. both tcp_transport_unittest and tcp_se
| |
| 48 | |
| 49 // Engine switches | |
|
Kevin M
2016/05/02 21:32:39
I don't think the engine and client should be sha
haibinlu
2016/05/03 19:32:43
what is the alternative way to provide these args?
| |
| 50 blimp::engine::SetUpCommandLine(command_line); | |
| 51 command_line->AppendSwitchASCII(blimp::engine::kClientToken, | |
| 52 blimp::client::kDummyClientToken); | |
| 53 | |
| 54 // Client switches | |
| 55 // Client's AssignmentSource uses engine IP&port from command line and | |
| 56 // defaults to TCP client. | |
| 57 command_line->AppendSwitchASCII(blimp::switches::kEngineIP, "127.0.0.1"); | |
| 58 command_line->AppendSwitchASCII(blimp::switches::kEngineTransport, "tcp"); | |
| 59 } | |
| 60 | |
| 61 void BlimpBrowserTest::RunTestOnMainThreadLoop() { | |
| 62 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 63 | |
| 64 // Pump startup related events. | |
| 65 base::MessageLoop::current()->RunUntilIdle(); | |
| 66 | |
| 67 SetUpOnMainThread(); | |
| 68 RunTestOnMainThread(); | |
| 69 TearDownOnMainThread(); | |
| 70 | |
| 71 for (content::RenderProcessHost::iterator i( | |
| 72 content::RenderProcessHost::AllHostsIterator()); | |
| 73 !i.IsAtEnd(); i.Advance()) { | |
| 74 i.GetCurrentValue()->FastShutdownIfPossible(); | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 void BlimpBrowserTest::RunAsynchronousTest() { | |
| 79 base::MessageLoop::ScopedNestableTaskAllower nestable_allower( | |
| 80 base::MessageLoop::current()); | |
| 81 EXPECT_FALSE(run_loop_); | |
| 82 run_loop_ = base::WrapUnique(new base::RunLoop()); | |
| 83 run_loop_->Run(); | |
| 84 run_loop_ = nullptr; | |
| 85 } | |
| 86 | |
| 87 void BlimpBrowserTest::FinishAsynchronousTest() { | |
| 88 run_loop_->Quit(); | |
| 89 } | |
| 90 | |
| 91 } // namespace blimp | |
| OLD | NEW |