OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ios/net/nsurlrequest_util.h" |
| 6 |
| 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace { |
| 11 |
| 12 // Tests that FormatUrlRequestForLogging outputs the string in the form: |
| 13 // request:<url> request.mainDocURL:<mainDocumentURL>. |
| 14 TEST(NSURLRequestUtilTest, FormatUrlRequestForLogging) { |
| 15 base::scoped_nsobject<NSMutableURLRequest> request( |
| 16 [[NSMutableURLRequest alloc] init]); |
| 17 request.get().URL = [NSURL URLWithString:@"http://www.google.com"]; |
| 18 request.get().mainDocumentURL = |
| 19 [NSURL URLWithString:@"http://www.google1.com"]; |
| 20 std::string actualString, expectedString; |
| 21 |
| 22 actualString = net::FormatUrlRequestForLogging(request); |
| 23 expectedString = "request: http://www.google.com" |
| 24 " request.mainDocURL: http://www.google1.com"; |
| 25 EXPECT_EQ(expectedString, actualString); |
| 26 |
| 27 request.get().URL = nil; |
| 28 request.get().mainDocumentURL = |
| 29 [NSURL URLWithString:@"http://www.google1.com"]; |
| 30 actualString = net::FormatUrlRequestForLogging(request); |
| 31 expectedString = "request: [nil] request.mainDocURL: http://www.google1.com"; |
| 32 EXPECT_EQ(expectedString, actualString); |
| 33 |
| 34 request.get().URL = [NSURL URLWithString:@"http://www.google.com"]; |
| 35 request.get().mainDocumentURL = nil; |
| 36 actualString = net::FormatUrlRequestForLogging(request); |
| 37 expectedString = "request: http://www.google.com request.mainDocURL: [nil]"; |
| 38 EXPECT_EQ(expectedString, actualString); |
| 39 |
| 40 request.get().URL = nil; |
| 41 request.get().mainDocumentURL = nil; |
| 42 actualString = net::FormatUrlRequestForLogging(request); |
| 43 expectedString = "request: [nil] request.mainDocURL: [nil]"; |
| 44 EXPECT_EQ(expectedString, actualString); |
| 45 } |
| 46 |
| 47 } // namespace |
OLD | NEW |