| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "headless/test/headless_browser_test.h" | 5 #include "headless/test/headless_browser_test.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 RunTestOnMainThread(); | 92 RunTestOnMainThread(); |
| 93 TearDownOnMainThread(); | 93 TearDownOnMainThread(); |
| 94 | 94 |
| 95 for (content::RenderProcessHost::iterator i( | 95 for (content::RenderProcessHost::iterator i( |
| 96 content::RenderProcessHost::AllHostsIterator()); | 96 content::RenderProcessHost::AllHostsIterator()); |
| 97 !i.IsAtEnd(); i.Advance()) { | 97 !i.IsAtEnd(); i.Advance()) { |
| 98 i.GetCurrentValue()->FastShutdownIfPossible(); | 98 i.GetCurrentValue()->FastShutdownIfPossible(); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 void HeadlessBrowserTest::SetBrowserOptions( | 102 void HeadlessBrowserTest::SetBrowserOptions(HeadlessBrowser::Options options) { |
| 103 const HeadlessBrowser::Options& options) { | |
| 104 HeadlessContentMainDelegate::GetInstance()->browser()->SetOptionsForTesting( | 103 HeadlessContentMainDelegate::GetInstance()->browser()->SetOptionsForTesting( |
| 105 options); | 104 std::move(options)); |
| 106 } | 105 } |
| 107 | 106 |
| 108 HeadlessBrowser* HeadlessBrowserTest::browser() const { | 107 HeadlessBrowser* HeadlessBrowserTest::browser() const { |
| 109 return HeadlessContentMainDelegate::GetInstance()->browser(); | 108 return HeadlessContentMainDelegate::GetInstance()->browser(); |
| 110 } | 109 } |
| 111 | 110 |
| 112 bool HeadlessBrowserTest::WaitForLoad(HeadlessWebContents* web_contents) { | 111 bool HeadlessBrowserTest::WaitForLoad(HeadlessWebContents* web_contents) { |
| 113 WaitForLoadObserver observer(this, web_contents); | 112 WaitForLoadObserver observer(this, web_contents); |
| 114 RunAsynchronousTest(); | 113 RunAsynchronousTest(); |
| 115 return observer.navigation_succeeded(); | 114 return observer.navigation_succeeded(); |
| 116 } | 115 } |
| 117 | 116 |
| 118 void HeadlessBrowserTest::RunAsynchronousTest() { | 117 void HeadlessBrowserTest::RunAsynchronousTest() { |
| 119 base::MessageLoop::ScopedNestableTaskAllower nestable_allower( | 118 base::MessageLoop::ScopedNestableTaskAllower nestable_allower( |
| 120 base::MessageLoop::current()); | 119 base::MessageLoop::current()); |
| 121 EXPECT_FALSE(run_loop_); | 120 EXPECT_FALSE(run_loop_); |
| 122 run_loop_ = base::WrapUnique(new base::RunLoop()); | 121 run_loop_ = base::WrapUnique(new base::RunLoop()); |
| 123 run_loop_->Run(); | 122 run_loop_->Run(); |
| 124 run_loop_ = nullptr; | 123 run_loop_ = nullptr; |
| 125 } | 124 } |
| 126 | 125 |
| 127 void HeadlessBrowserTest::FinishAsynchronousTest() { | 126 void HeadlessBrowserTest::FinishAsynchronousTest() { |
| 128 run_loop_->Quit(); | 127 run_loop_->Quit(); |
| 129 } | 128 } |
| 130 | 129 |
| 131 } // namespace headless | 130 } // namespace headless |
| OLD | NEW |