| Index: components/cronet/ios/test/cronet_http_test.mm
|
| diff --git a/components/cronet/ios/test/cronet_http_test.mm b/components/cronet/ios/test/cronet_http_test.mm
|
| index 4b3e7465b530f5373aab28c06d654fde0e48ebf8..89e64a2422d9b01f83fcc0154ca2b68784ad1062 100644
|
| --- a/components/cronet/ios/test/cronet_http_test.mm
|
| +++ b/components/cronet/ios/test/cronet_http_test.mm
|
| @@ -10,8 +10,9 @@
|
| #include "base/logging.h"
|
| #include "base/mac/scoped_nsobject.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| -#include "components/cronet/ios/test/quic_test_server.h"
|
| +#include "components/cronet/ios/test/start_cronet.h"
|
| #include "components/cronet/ios/test/test_server.h"
|
| +#include "components/grpc_support/test/quic_test_server.h"
|
| #include "net/base/mac/url_conversions.h"
|
| #include "net/base/net_errors.h"
|
| #include "net/cert/mock_cert_verifier.h"
|
| @@ -112,16 +113,16 @@ namespace cronet {
|
| static const int64_t ns_in_second = 1000000000LL;
|
| const char kUserAgent[] = "CronetTest/1.0.0.0";
|
|
|
| -// TODO(mef): Create common header file to declare this.
|
| -void StartCronetIfNecessary();
|
| -
|
| class HttpTest : public ::testing::Test {
|
| protected:
|
| HttpTest() {}
|
| ~HttpTest() override {}
|
|
|
| void SetUp() override {
|
| - StartCronetIfNecessary();
|
| + grpc_support::StartQuicTestServer();
|
| + TestServer::Start();
|
| +
|
| + StartCronetIfNecessary(grpc_support::GetQuicTestServerPort());
|
| NSURLSessionConfiguration* config =
|
| [NSURLSessionConfiguration ephemeralSessionConfiguration];
|
| [Cronet installIntoSessionConfiguration:config];
|
| @@ -132,12 +133,10 @@ class HttpTest : public ::testing::Test {
|
| // Take a reference to the session and store it so it doesn't get
|
| // deallocated until this object does.
|
| session_.reset([session retain]);
|
| - StartQuicTestServer();
|
| - TestServer::Start();
|
| }
|
|
|
| void TearDown() override {
|
| - ShutdownQuicTestServer();
|
| + grpc_support::ShutdownQuicTestServer();
|
| TestServer::Shutdown();
|
| }
|
|
|
| @@ -155,21 +154,23 @@ class HttpTest : public ::testing::Test {
|
| };
|
|
|
| TEST_F(HttpTest, NSURLSessionReceivesData) {
|
| - NSURL* url = net::NSURLWithGURL(GURL(kTestServerUrl));
|
| + NSURL* url = net::NSURLWithGURL(GURL(grpc_support::kTestServerUrl));
|
| NSURLSessionDataTask* task = [session_ dataTaskWithURL:url];
|
| StartDataTaskAndWaitForCompletion(task);
|
| EXPECT_EQ(nil, [delegate_ error]);
|
| - EXPECT_STREQ(kHelloBodyValue, [[delegate_ responseBody] UTF8String]);
|
| + EXPECT_STREQ(grpc_support::kHelloBodyValue,
|
| + base::SysNSStringToUTF8([delegate_ responseBody]).c_str());
|
| }
|
|
|
| TEST_F(HttpTest, GetGlobalMetricsDeltas) {
|
| NSData* delta1 = [Cronet getGlobalMetricsDeltas];
|
|
|
| - NSURL* url = net::NSURLWithGURL(GURL(kTestServerUrl));
|
| + NSURL* url = net::NSURLWithGURL(GURL(grpc_support::kTestServerUrl));
|
| NSURLSessionDataTask* task = [session_ dataTaskWithURL:url];
|
| StartDataTaskAndWaitForCompletion(task);
|
| EXPECT_EQ(nil, [delegate_ error]);
|
| - EXPECT_STREQ(kHelloBodyValue, [[delegate_ responseBody] UTF8String]);
|
| + EXPECT_STREQ(grpc_support::kHelloBodyValue,
|
| + base::SysNSStringToUTF8([delegate_ responseBody]).c_str());
|
|
|
| NSData* delta2 = [Cronet getGlobalMetricsDeltas];
|
| EXPECT_FALSE([delta2 isEqualToData:delta1]);
|
|
|