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

Unified Diff: content/browser/utility_process_host_impl_browsertest.cc

Issue 1965683002: Add a browser test for UtilityProcessHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops Created 4 years, 7 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
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/utility_process_host_impl_browsertest.cc
diff --git a/content/browser/utility_process_host_impl_browsertest.cc b/content/browser/utility_process_host_impl_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f152367257fa0a2d7b4e08f7ee440b00b2735c00
--- /dev/null
+++ b/content/browser/utility_process_host_impl_browsertest.cc
@@ -0,0 +1,57 @@
+// 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 "base/bind.h"
+#include "base/run_loop.h"
+#include "base/strings/utf_string_conversions.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/utility_process_host.h"
+#include "content/public/browser/utility_process_host_client.h"
+#include "content/public/common/service_registry.h"
+#include "content/public/test/content_browser_test.h"
+#include "content/public/test/content_browser_test_utils.h"
+#include "content/public/test/test_mojo_service.mojom.h"
+
+namespace content {
+
+class UtilityProcessHostImplBrowserTest : public ContentBrowserTest {
+ public:
+ void RunUtilityProcess() {
+ base::RunLoop run_loop;
+ done_closure_ = run_loop.QuitClosure();
+ BrowserThread::PostTask(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(
+ &UtilityProcessHostImplBrowserTest::RunUtilityProcessOnIOThread,
+ base::Unretained(this)));
+ run_loop.Run();
+ }
+
+ protected:
+ void RunUtilityProcessOnIOThread() {
+ UtilityProcessHost* host = UtilityProcessHost::Create(nullptr, nullptr);
+ host->SetName(base::ASCIIToUTF16("TestProcess"));
+ EXPECT_TRUE(host->Start());
+
+ ServiceRegistry* service_registry = host->GetServiceRegistry();
+ service_registry->ConnectToRemoteService(mojo::GetProxy(&service_));
+ service_->DoSomething(base::Bind(
+ &UtilityProcessHostImplBrowserTest::OnSomething,
+ base::Unretained(this)));
+ }
+
+ void OnSomething() {
+ service_.reset();
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, done_closure_);
+ }
+
+ mojom::TestMojoServicePtr service_;
+ base::Closure done_closure_;
+};
+
+IN_PROC_BROWSER_TEST_F(UtilityProcessHostImplBrowserTest, LaunchProcess) {
+ RunUtilityProcess();
+}
+
+} // namespace content
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698