| Index: blimp/engine/browser_tests/blimp_browser_test.cc
|
| diff --git a/blimp/engine/browser_tests/blimp_browser_test.cc b/blimp/engine/browser_tests/blimp_browser_test.cc
|
| index 5440666b78bc7c6c17ce1aafb9586ddbde53d46c..f132fc3df236931270d44cec228497a3612d7187 100644
|
| --- a/blimp/engine/browser_tests/blimp_browser_test.cc
|
| +++ b/blimp/engine/browser_tests/blimp_browser_test.cc
|
| @@ -15,6 +15,7 @@
|
| #include "base/run_loop.h"
|
| #include "blimp/client/core/session/assignment_source.h"
|
| #include "blimp/client/core/switches/blimp_client_switches.h"
|
| +#include "blimp/common/public/session/assignment_options.h"
|
| #include "blimp/common/switches.h"
|
| #include "blimp/engine/app/blimp_browser_main_parts.h"
|
| #include "blimp/engine/app/blimp_content_browser_client.h"
|
| @@ -35,14 +36,24 @@ const char kClientAuthToken[] = "MyVoiceIsMyPassport";
|
| } // namespace
|
|
|
| BlimpBrowserTest::BlimpBrowserTest()
|
| - : engine_port_(0),
|
| - completion_event_(base::WaitableEvent::ResetPolicy::MANUAL,
|
| + : completion_event_(base::WaitableEvent::ResetPolicy::MANUAL,
|
| base::WaitableEvent::InitialState::NOT_SIGNALED) {
|
| CreateTestServer(base::FilePath(FILE_PATH_LITERAL(kTestDataFilePath)));
|
| }
|
|
|
| BlimpBrowserTest::~BlimpBrowserTest() {}
|
|
|
| +extern bool UsesGrpc();
|
| +
|
| +// Lets the same set of browser_tests run with different protocols.
|
| +client::Assignment::TransportProtocol GetAssignmentProtocol() {
|
| + if (UsesGrpc()) {
|
| + return client::Assignment::TransportProtocol::GRPC;
|
| + } else {
|
| + return client::Assignment::TransportProtocol::TCP;
|
| + }
|
| +}
|
| +
|
| void BlimpBrowserTest::RunUntilCompletion() {
|
| while (!completion_event_.IsSignaled()) {
|
| content::RunAllPendingInMessageLoop(content::BrowserThread::IO);
|
| @@ -77,9 +88,8 @@ engine::BlimpEngineSession* BlimpBrowserTest::GetEngineSession() {
|
| client::Assignment BlimpBrowserTest::GetAssignment() {
|
| client::Assignment assignment;
|
| assignment.client_auth_token = kClientAuthToken;
|
| - assignment.engine_endpoint =
|
| - net::IPEndPoint(net::IPAddress::IPv4Localhost(), engine_port_);
|
| - assignment.transport_protocol = client::Assignment::TransportProtocol::TCP;
|
| + assignment.assignment_options = assignment_options_;
|
| + assignment.transport_protocol = GetAssignmentProtocol();
|
| return assignment;
|
| }
|
|
|
| @@ -93,7 +103,19 @@ void BlimpBrowserTest::SetUpCommandLine(base::CommandLine* command_line) {
|
| command_line->AppendSwitchASCII(blimp::engine::kEnginePort, "0");
|
| }
|
|
|
| - // TODO(perumaal): Switch to gRPC when it's ready. See crbug.com/659279.
|
| + switch (GetAssignmentProtocol()) {
|
| + case client::Assignment::TransportProtocol::TCP:
|
| + command_line->AppendSwitchASCII(blimp::engine::kEngineTransport,
|
| + blimp::engine::kTcpTransport);
|
| + break;
|
| + case client::Assignment::TransportProtocol::GRPC:
|
| + command_line->AppendSwitchASCII(blimp::engine::kEngineTransport,
|
| + blimp::engine::kGrpcTransport);
|
| + break;
|
| + default:
|
| + LOG(FATAL) << "Unknown transport type: "
|
| + << static_cast<int>(GetAssignmentProtocol());
|
| + }
|
|
|
| base::FilePath src_root;
|
| PathService::Get(base::DIR_SOURCE_ROOT, &src_root);
|
| @@ -103,8 +125,8 @@ void BlimpBrowserTest::SetUpCommandLine(base::CommandLine* command_line) {
|
|
|
| void BlimpBrowserTest::SetUpOnMainThread() {
|
| // Get the connection's port number across the IO/UI thread boundary.
|
| - GetEngineSession()->GetEnginePortForTesting(base::Bind(
|
| - &BlimpBrowserTest::OnGetEnginePortCompletion, base::Unretained(this)));
|
| + GetEngineSession()->GetAssignmentOptions(base::Bind(
|
| + &BlimpBrowserTest::OnGetEngineSetupCompletion, base::Unretained(this)));
|
|
|
| RunUntilCompletion();
|
| }
|
| @@ -128,8 +150,9 @@ void BlimpBrowserTest::RunTestOnMainThreadLoop() {
|
| }
|
| }
|
|
|
| -void BlimpBrowserTest::OnGetEnginePortCompletion(uint16_t port) {
|
| - engine_port_ = port;
|
| +void BlimpBrowserTest::OnGetEngineSetupCompletion(
|
| + AssignmentOptions assignment_options) {
|
| + assignment_options_ = assignment_options;
|
| SignalCompletion();
|
| }
|
|
|
|
|