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

Unified Diff: components/cronet/ios/test/cronet_http_test.mm

Issue 2492703002: Third try at landing gRPC refactoring. Previous issue failed on the waterfall (Closed)
Patch Set: Change DCHECK Created 4 years, 1 month 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
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]);
« no previous file with comments | « components/cronet/ios/test/cronet_bidirectional_stream_test.mm ('k') | components/cronet/ios/test/cronet_test_runner.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698