Commit 475d9807 authored by Misha Efimov's avatar Misha Efimov Committed by Commit Bot

[Cronet] Move cronet::TestServer from cronet/ios/test to cronet/test.

- Make it available for native tests.
- Fix lint warnings.

Bug: 786559
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ib8d704d63e7eaebdc92134fc595f3f3c7a1cb79e
Reviewed-on: https://chromium-review.googlesource.com/899522Reviewed-by: default avatarAndrei Kapishnikov <kapishnikov@chromium.org>
Commit-Queue: Misha Efimov <mef@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534087}
parent 477b5b9f
...@@ -21,8 +21,6 @@ test("cronet_test") { ...@@ -21,8 +21,6 @@ test("cronet_test") {
"get_stream_engine.mm", "get_stream_engine.mm",
"start_cronet.h", "start_cronet.h",
"start_cronet.mm", "start_cronet.mm",
"test_server.cc",
"test_server.h",
] ]
deps = [ deps = [
...@@ -30,6 +28,7 @@ test("cronet_test") { ...@@ -30,6 +28,7 @@ test("cronet_test") {
"//base:i18n", "//base:i18n",
"//components/cronet/ios:cronet_framework+link", "//components/cronet/ios:cronet_framework+link",
"//components/cronet/native:cronet_native_tests", "//components/cronet/native:cronet_native_tests",
"//components/cronet/test:test_support",
"//components/grpc_support:bidirectional_stream_unittest", "//components/grpc_support:bidirectional_stream_unittest",
"//components/grpc_support/test:quic_test_server", "//components/grpc_support/test:quic_test_server",
"//net", "//net",
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "components/cronet/ios/test/cronet_test_base.h" #include "components/cronet/ios/test/cronet_test_base.h"
#include "components/cronet/ios/test/start_cronet.h" #include "components/cronet/ios/test/start_cronet.h"
#include "components/cronet/ios/test/test_server.h" #include "components/cronet/test/test_server.h"
#include "components/grpc_support/test/quic_test_server.h" #include "components/grpc_support/test/quic_test_server.h"
#include "net/base/mac/url_conversions.h" #include "net/base/mac/url_conversions.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "components/cronet/ios/test/cronet_test_base.h" #include "components/cronet/ios/test/cronet_test_base.h"
#include "components/cronet/ios/test/start_cronet.h" #include "components/cronet/ios/test/start_cronet.h"
#include "components/cronet/ios/test/test_server.h" #include "components/cronet/test/test_server.h"
#include "components/grpc_support/test/quic_test_server.h" #include "components/grpc_support/test/quic_test_server.h"
#import "net/base/mac/url_conversions.h" #import "net/base/mac/url_conversions.h"
#include "testing/gtest_mac.h" #include "testing/gtest_mac.h"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "components/cronet/ios/test/cronet_test_base.h" #include "components/cronet/ios/test/cronet_test_base.h"
#include "components/cronet/ios/test/test_server.h" #include "components/cronet/test/test_server.h"
#include "components/grpc_support/test/quic_test_server.h" #include "components/grpc_support/test/quic_test_server.h"
#include "net/base/mac/url_conversions.h" #include "net/base/mac/url_conversions.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/path_service.h" #include "base/path_service.h"
#include "components/cronet/ios/test/cronet_test_base.h" #include "components/cronet/ios/test/cronet_test_base.h"
#include "components/cronet/ios/test/start_cronet.h" #include "components/cronet/ios/test/start_cronet.h"
#include "components/cronet/ios/test/test_server.h" #include "components/cronet/test/test_server.h"
#include "components/grpc_support/test/quic_test_server.h" #include "components/grpc_support/test/quic_test_server.h"
#include "net/base/mac/url_conversions.h" #include "net/base/mac/url_conversions.h"
#include "testing/gtest_mac.h" #include "testing/gtest_mac.h"
......
...@@ -89,6 +89,7 @@ source_set("cronet_native_tests") { ...@@ -89,6 +89,7 @@ source_set("cronet_native_tests") {
":cronet_native_testutil", ":cronet_native_testutil",
"//base", "//base",
"//base/test:test_support", "//base/test:test_support",
"//components/cronet/test:test_support",
"//net:test_support", "//net:test_support",
"//testing/gtest", "//testing/gtest",
] ]
......
# Copyright 2018 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.
import("//testing/test.gni")
# Test support for Cronet common implementation.
source_set("test_support") {
testonly = true
deps = [
"//net:test_support",
]
sources = [
"test_server.cc",
"test_server.h",
]
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "components/cronet/ios/test/test_server.h" #include "components/cronet/test/test_server.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
...@@ -155,7 +155,8 @@ bool TestServer::Start() { ...@@ -155,7 +155,8 @@ bool TestServer::Start() {
DCHECK(!g_test_server.get()); DCHECK(!g_test_server.get());
g_test_server = std::make_unique<net::EmbeddedTestServer>( g_test_server = std::make_unique<net::EmbeddedTestServer>(
net::EmbeddedTestServer::TYPE_HTTP); net::EmbeddedTestServer::TYPE_HTTP);
g_test_server->RegisterRequestHandler(base::Bind(&CronetTestRequestHandler)); g_test_server->RegisterRequestHandler(
base::BindRepeating(&CronetTestRequestHandler));
CHECK(g_test_server->Start()); CHECK(g_test_server->Start());
return true; return true;
} }
...@@ -190,7 +191,7 @@ std::string TestServer::EchoRequestBodyURL() { ...@@ -190,7 +191,7 @@ std::string TestServer::EchoRequestBodyURL() {
return g_test_server->GetURL(kEchoRequestBodyPath).spec(); return g_test_server->GetURL(kEchoRequestBodyPath).spec();
} }
std::string TestServer::PrepareBigDataURL(long data_size) { std::string TestServer::PrepareBigDataURL(size_t data_size) {
DCHECK(g_test_server); DCHECK(g_test_server);
DCHECK(g_big_data_body.Get().empty()); DCHECK(g_big_data_body.Get().empty());
// Response line with headers. // Response line with headers.
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_CRONET_IOS_TEST_TEST_SERVER_H_ #ifndef COMPONENTS_CRONET_TEST_TEST_SERVER_H_
#define COMPONENTS_CRONET_IOS_TEST_TEST_SERVER_H_ #define COMPONENTS_CRONET_TEST_TEST_SERVER_H_
#include <string> #include <string>
...@@ -30,11 +30,11 @@ class TestServer { ...@@ -30,11 +30,11 @@ class TestServer {
static std::string EchoRequestBodyURL(); static std::string EchoRequestBodyURL();
// Prepares response and returns URL which respond with |data_size| of bytes // Prepares response and returns URL which respond with |data_size| of bytes
// in response body. // in response body.
static std::string PrepareBigDataURL(long data_size); static std::string PrepareBigDataURL(size_t data_size);
// Releases response created by PrepareBigDataURL(). // Releases response created by PrepareBigDataURL().
static void ReleaseBigDataURL(); static void ReleaseBigDataURL();
}; };
} // namespace cronet } // namespace cronet
#endif // COMPONENTS_CRONET_IOS_TEST_TEST_SERVER_H_ #endif // COMPONENTS_CRONET_TEST_TEST_SERVER_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment