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

Unified Diff: headless/test/headless_browser_test.cc

Issue 1674263002: headless: Initial headless embedder API implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix shutdown memory leak. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698