[BackgroundSyncManager] Rename BackgroundSyncRegistration.name to tag
[chromium-blink-merge.git] / ios / net / nsurlrequest_util_unittest.mm
blob01bd2f74646a73fd66e157e248cdb5fd92d60aca
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.
5 #include "ios/net/nsurlrequest_util.h"
7 #include "base/mac/scoped_nsobject.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace {
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;
22   actualString = net::FormatUrlRequestForLogging(request);
23   expectedString = "request: http://www.google.com"
24                    " request.mainDocURL: http://www.google1.com";
25   EXPECT_EQ(expectedString, actualString);
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);
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);
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);
47 }  // namespace