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

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

Issue 2146643002: [Cronet] Integrate CrNet functionality into Cronet on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Andrei's comments. Created 4 years, 4 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
Index: components/cronet/ios/test/cronet_bidirectional_stream_test.mm
diff --git a/components/cronet/ios/test/cronet_bidirectional_stream_test.mm b/components/cronet/ios/test/cronet_bidirectional_stream_test.mm
index 8348fe72aac61068088031f967b17809d5e1cca9..53c74c15c6104c5d3a994485f4285e69448e6012 100644
--- a/components/cronet/ios/test/cronet_bidirectional_stream_test.mm
+++ b/components/cronet/ios/test/cronet_bidirectional_stream_test.mm
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import <Foundation/Foundation.h>
#include <stdint.h>
#include <list>
#include <map>
@@ -15,8 +14,9 @@
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/synchronization/waitable_event.h"
+#import "components/cronet/ios/Cronet.h"
+#import "components/cronet/ios/Cronet+TestSupport.h"
#include "components/cronet/ios/cronet_c_for_grpc.h"
-#include "components/cronet/ios/cronet_environment.h"
#include "components/cronet/ios/test/quic_test_server.h"
#include "net/base/mac/url_conversions.h"
#include "net/base/net_errors.h"
@@ -38,59 +38,47 @@ const cronet_bidirectional_stream_header_array kTestHeadersArray = {
namespace cronet {
+void StartCronetIfNecessary() {
+ static bool initialized = false;
+ if (!initialized) {
+ initialized = true;
+ [Cronet setPartialUserAgent:@"CronetTest/1.0.0.0"];
+ [Cronet setHttp2Enabled:true];
+ [Cronet setQuicEnabled:true];
+ [Cronet setSslKeyLogFileName:@"SSLKEYLOGFILE"];
+
+ net::MockCertVerifier* mock_cert_verifier = new net::MockCertVerifier();
+ mock_cert_verifier->set_default_result(net::OK);
+ [Cronet setMockCertVerifierForTesting:mock_cert_verifier];
+ [Cronet
+ setHostResolverRulesForTesting:@"MAP test.example.com 127.0.0.1,"
+ "MAP notfound.example.com ~NOTFOUND"];
+ [Cronet addQuicHint:@"test.example.com"
+ port:cronet::kTestServerPort
+ altPort:cronet::kTestServerPort];
+ [Cronet start];
+ }
+}
+
class CronetBidirectionalStreamTest : public ::testing::TestWithParam<bool> {
protected:
CronetBidirectionalStreamTest() {}
~CronetBidirectionalStreamTest() override {}
void SetUp() override {
- static bool initialized = false;
- if (!initialized) {
- initialized = true;
- // Hack to work around issues with SetUp being called multiple times
- // during the test, and QuicTestServer not shutting down / restarting
- // gracefully.
- CronetEnvironment::Initialize();
- cronet_environment_ = new CronetEnvironment("CronetTest/1.0.0.0");
- cronet_environment_->set_http2_enabled(true);
- cronet_environment_->set_quic_enabled(true);
- cronet_environment_->set_ssl_key_log_file_name("SSLKEYLOGFILE");
-
- std::unique_ptr<net::MockCertVerifier> mock_cert_verifier(
- new net::MockCertVerifier());
- mock_cert_verifier->set_default_result(net::OK);
-
- cronet_environment_->set_cert_verifier(std::move(mock_cert_verifier));
- cronet_environment_->set_host_resolver_rules(
- "MAP test.example.com 127.0.0.1,"
- "MAP notfound.example.com ~NOTFOUND");
- cronet_environment_->AddQuicHint(kTestServerDomain, kTestServerPort,
- kTestServerPort);
-
- cronet_environment_->Start();
-
- cronet_engine_.obj = cronet_environment_;
- }
-
+ StartCronetIfNecessary();
StartQuicTestServer();
- cronet_environment_->StartNetLog("cronet_netlog.json", true);
+ [Cronet startNetLogToFile:@"cronet_netlog.json" logBytes:YES];
}
void TearDown() override {
ShutdownQuicTestServer();
- cronet_environment_->StopNetLog();
+ [Cronet stopNetLog];
}
- cronet_engine* engine() { return &cronet_engine_; }
-
- private:
- static CronetEnvironment* cronet_environment_;
- static cronet_engine cronet_engine_;
+ cronet_engine* engine() { return [Cronet getGlobalEngine]; }
};
-CronetEnvironment* CronetBidirectionalStreamTest::cronet_environment_ = nullptr;
-cronet_engine CronetBidirectionalStreamTest::cronet_engine_ = {0};
-
class TestBidirectionalStreamCallback {
public:
enum ResponseStep {

Powered by Google App Engine
This is Rietveld 408576698