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

Unified Diff: content/browser/utility_process_mojo_client_browsertest.cc

Issue 2645683006: UtilityProcessMojoClientBrowserTest: add enum for run options (Closed)
Patch Set: Created 3 years, 11 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/utility_process_mojo_client_browsertest.cc
diff --git a/content/browser/utility_process_mojo_client_browsertest.cc b/content/browser/utility_process_mojo_client_browsertest.cc
index 6ac13b5d5314d41080575a34c51fa54c8ca9ab41..edc89a18621c6f0527f4f579e8fa34230b6956ae 100644
--- a/content/browser/utility_process_mojo_client_browsertest.cc
+++ b/content/browser/utility_process_mojo_client_browsertest.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/public/browser/utility_process_mojo_client.h"
-
#include <memory>
#include "base/bind.h"
@@ -11,6 +9,7 @@
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
+#include "content/public/browser/utility_process_mojo_client.h"
Noel Gordon 2017/01/23 02:38:57 In off-line chat, we checked the style guide about
#include "content/public/common/content_switches.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/test_service.mojom.h"
@@ -20,23 +19,25 @@ namespace content {
// Test fixture used to make different Mojo calls to the utility process.
class UtilityProcessMojoClientBrowserTest : public ContentBrowserTest {
public:
- void StartMojoService(bool disable_sandbox, bool run_elevated = false) {
+ enum RunOption {
+ SANDBOXED, UNSANDBOXED, ELEVATED
+ };
+
+ void StartMojoService(RunOption option = SANDBOXED) {
mojo_client_.reset(new UtilityProcessMojoClient<mojom::TestService>(
- base::ASCIIToUTF16("TestMojoProcess")));
+ base::ASCIIToUTF16("TestUtilityProcessMojoClient")));
mojo_client_->set_error_callback(
base::Bind(&UtilityProcessMojoClientBrowserTest::OnConnectionError,
base::Unretained(this)));
// This test case needs to have the sandbox disabled.
- if (disable_sandbox)
+ if (option == UNSANDBOXED)
mojo_client_->set_disable_sandbox();
#if defined(OS_WIN)
- // This test case needs utility process privilege elevation.
- if (run_elevated) {
- CHECK(disable_sandbox);
+ // This test case needs utility process UAC privilege elevation.
+ if (option == ELEVATED)
mojo_client_->set_run_elevated();
- }
#endif // defined(OS_WIN)
mojo_client_->Start();
@@ -79,7 +80,7 @@ IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, CallService) {
base::RunLoop run_loop;
done_closure_ = run_loop.QuitClosure();
- StartMojoService(false);
+ StartMojoService();
mojo_client_->service()->DoSomething(
base::Bind(&UtilityProcessMojoClientBrowserTest::OnResponseReceived,
@@ -96,7 +97,7 @@ IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, ConnectionError) {
base::RunLoop run_loop;
done_closure_ = run_loop.QuitClosure();
- StartMojoService(false);
+ StartMojoService();
mojo_client_->service()->DoTerminateProcess(
base::Bind(&UtilityProcessMojoClientBrowserTest::OnResponseReceived,
@@ -114,7 +115,7 @@ IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, SandboxFailure) {
base::RunLoop run_loop;
done_closure_ = run_loop.QuitClosure();
- StartMojoService(false);
+ StartMojoService();
mojo_client_->service()->CreateFolder(
base::Bind(&UtilityProcessMojoClientBrowserTest::OnCreateFolderFinished,
@@ -133,7 +134,7 @@ IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, SandboxSuccess) {
base::RunLoop run_loop;
done_closure_ = run_loop.QuitClosure();
- StartMojoService(true);
+ StartMojoService(UNSANDBOXED);
mojo_client_->service()->CreateFolder(
base::Bind(&UtilityProcessMojoClientBrowserTest::OnCreateFolderFinished,
@@ -154,8 +155,7 @@ IN_PROC_BROWSER_TEST_F(UtilityProcessMojoClientBrowserTest, ElevatedSuccess) {
base::RunLoop run_loop;
done_closure_ = run_loop.QuitClosure();
- bool elevated_utility_process = true;
- StartMojoService(true, elevated_utility_process);
+ StartMojoService(ELEVATED);
mojo_client_->service()->CreateFolder(
base::Bind(&UtilityProcessMojoClientBrowserTest::OnCreateFolderFinished,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698