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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "base/bind.h"
6 #include "base/run_loop.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/utility_process_host.h"
10 #include "content/public/browser/utility_process_host_client.h"
11 #include "content/public/common/service_registry.h"
12 #include "content/public/test/content_browser_test.h"
13 #include "content/public/test/content_browser_test_utils.h"
14 #include "content/public/test/test_mojo_service.mojom.h"
15
16 namespace content {
17
18 class UtilityProcessHostImplBrowserTest : public ContentBrowserTest {
19 public:
20 void RunUtilityProcess() {
21 base::RunLoop run_loop;
22 done_closure_ = run_loop.QuitClosure();
23 BrowserThread::PostTask(
24 BrowserThread::IO, FROM_HERE,
25 base::Bind(
26 &UtilityProcessHostImplBrowserTest::RunUtilityProcessOnIOThread,
27 base::Unretained(this)));
28 run_loop.Run();
29 }
30
31 protected:
32 void RunUtilityProcessOnIOThread() {
33 UtilityProcessHost* host = UtilityProcessHost::Create(nullptr, nullptr);
34 host->SetName(base::ASCIIToUTF16("TestProcess"));
35 EXPECT_TRUE(host->Start());
36
37 ServiceRegistry* service_registry = host->GetServiceRegistry();
38 service_registry->ConnectToRemoteService(mojo::GetProxy(&service_));
39 service_->DoSomething(base::Bind(
40 &UtilityProcessHostImplBrowserTest::OnSomething,
41 base::Unretained(this)));
42 }
43
44 void OnSomething() {
45 service_.reset();
46 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, done_closure_);
47 }
48
49 mojom::TestMojoServicePtr service_;
50 base::Closure done_closure_;
51 };
52
53 IN_PROC_BROWSER_TEST_F(UtilityProcessHostImplBrowserTest, LaunchProcess) {
54 RunUtilityProcess();
55 }
56
57 } // namespace content
OLDNEW
« 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