Chromium Code Reviews| Index: headless/test/headless_browser_test.cc |
| diff --git a/headless/test/headless_browser_test.cc b/headless/test/headless_browser_test.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4cb85dd51f77c99e6fa53c2a6a71f70d94a6f589 |
| --- /dev/null |
| +++ b/headless/test/headless_browser_test.cc |
| @@ -0,0 +1,47 @@ |
| +// 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 "headless/test/headless_browser_test.h" |
| + |
| +#include "base/files/file_path.h" |
| +#include "base/message_loop/message_loop.h" |
| +#include "content/public/browser/render_process_host.h" |
| +#include "headless/lib/browser/headless_browser_impl.h" |
| +#include "headless/lib/headless_content_main_delegate.h" |
| + |
| +namespace headless { |
| + |
| +HeadlessBrowserTest::HeadlessBrowserTest() { |
| + base::FilePath headless_test_data(FILE_PATH_LITERAL("headless/test/data")); |
| + CreateTestServer(headless_test_data); |
| +} |
| + |
| +HeadlessBrowserTest::~HeadlessBrowserTest() {} |
| + |
| +void HeadlessBrowserTest::SetUpOnMainThread() {} |
| + |
| +void HeadlessBrowserTest::TearDownOnMainThread() { |
| + browser()->Shutdown(); |
| +} |
| + |
| +void HeadlessBrowserTest::RunTestOnMainThreadLoop() { |
| + // Pump startup related events. |
| + base::MessageLoopForUI::current()->RunUntilIdle(); |
|
Ryan Sleevi
2016/02/25 22:04:37
Does this need to be as base::MessageLoopForUI::cu
Sami
2016/02/26 18:49:16
I only used MessageLoopForUI for the side-effect D
|
| + |
| + SetUpOnMainThread(); |
| + RunTestOnMainThread(); |
| + TearDownOnMainThread(); |
| + |
| + for (content::RenderProcessHost::iterator i( |
| + content::RenderProcessHost::AllHostsIterator()); |
| + !i.IsAtEnd(); i.Advance()) { |
| + i.GetCurrentValue()->FastShutdownIfPossible(); |
| + } |
| +} |
| + |
| +HeadlessBrowser* HeadlessBrowserTest::browser() const { |
| + return HeadlessContentMainDelegate::GetInstance()->browser(); |
| +} |
| + |
| +} // namespace headless |