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 "headless/test/headless_browser_test.h" |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/message_loop/message_loop.h" |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "content/public/browser/render_process_host.h" |
| 11 #include "headless/lib/browser/headless_browser_impl.h" |
| 12 #include "headless/lib/headless_content_main_delegate.h" |
| 13 |
| 14 namespace headless { |
| 15 |
| 16 HeadlessBrowserTest::HeadlessBrowserTest() { |
| 17 base::FilePath headless_test_data(FILE_PATH_LITERAL("headless/test/data")); |
| 18 CreateTestServer(headless_test_data); |
| 19 } |
| 20 |
| 21 HeadlessBrowserTest::~HeadlessBrowserTest() {} |
| 22 |
| 23 void HeadlessBrowserTest::SetUpOnMainThread() {} |
| 24 |
| 25 void HeadlessBrowserTest::TearDownOnMainThread() { |
| 26 browser()->Shutdown(); |
| 27 } |
| 28 |
| 29 void HeadlessBrowserTest::RunTestOnMainThreadLoop() { |
| 30 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 31 |
| 32 // Pump startup related events. |
| 33 base::MessageLoop::current()->RunUntilIdle(); |
| 34 |
| 35 SetUpOnMainThread(); |
| 36 RunTestOnMainThread(); |
| 37 TearDownOnMainThread(); |
| 38 |
| 39 for (content::RenderProcessHost::iterator i( |
| 40 content::RenderProcessHost::AllHostsIterator()); |
| 41 !i.IsAtEnd(); i.Advance()) { |
| 42 i.GetCurrentValue()->FastShutdownIfPossible(); |
| 43 } |
| 44 } |
| 45 |
| 46 HeadlessBrowser* HeadlessBrowserTest::browser() const { |
| 47 return HeadlessContentMainDelegate::GetInstance()->browser(); |
| 48 } |
| 49 |
| 50 } // namespace headless |
OLD | NEW |