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

Unified Diff: ios/net/nsurlrequest_util_unittest.mm

Issue 994823004: [iOS] Upstream //ios/net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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: ios/net/nsurlrequest_util_unittest.mm
diff --git a/ios/net/nsurlrequest_util_unittest.mm b/ios/net/nsurlrequest_util_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..01bd2f74646a73fd66e157e248cdb5fd92d60aca
--- /dev/null
+++ b/ios/net/nsurlrequest_util_unittest.mm
@@ -0,0 +1,47 @@
+// Copyright 2014 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.
+
+#include "ios/net/nsurlrequest_util.h"
+
+#include "base/mac/scoped_nsobject.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+// Tests that FormatUrlRequestForLogging outputs the string in the form:
+// request:<url> request.mainDocURL:<mainDocumentURL>.
+TEST(NSURLRequestUtilTest, FormatUrlRequestForLogging) {
+ base::scoped_nsobject<NSMutableURLRequest> request(
+ [[NSMutableURLRequest alloc] init]);
+ request.get().URL = [NSURL URLWithString:@"http://www.google.com"];
+ request.get().mainDocumentURL =
+ [NSURL URLWithString:@"http://www.google1.com"];
+ std::string actualString, expectedString;
+
+ actualString = net::FormatUrlRequestForLogging(request);
+ expectedString = "request: http://www.google.com"
+ " request.mainDocURL: http://www.google1.com";
+ EXPECT_EQ(expectedString, actualString);
+
+ request.get().URL = nil;
+ request.get().mainDocumentURL =
+ [NSURL URLWithString:@"http://www.google1.com"];
+ actualString = net::FormatUrlRequestForLogging(request);
+ expectedString = "request: [nil] request.mainDocURL: http://www.google1.com";
+ EXPECT_EQ(expectedString, actualString);
+
+ request.get().URL = [NSURL URLWithString:@"http://www.google.com"];
+ request.get().mainDocumentURL = nil;
+ actualString = net::FormatUrlRequestForLogging(request);
+ expectedString = "request: http://www.google.com request.mainDocURL: [nil]";
+ EXPECT_EQ(expectedString, actualString);
+
+ request.get().URL = nil;
+ request.get().mainDocumentURL = nil;
+ actualString = net::FormatUrlRequestForLogging(request);
+ expectedString = "request: [nil] request.mainDocURL: [nil]";
+ EXPECT_EQ(expectedString, actualString);
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698