OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ios/web/net/request_group_util.h" | 5 #include "ios/web/net/request_group_util.h" |
6 | 6 |
7 #include <Foundation/Foundation.h> | 7 #include <Foundation/Foundation.h> |
| 8 #include <stddef.h> |
8 | 9 |
9 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 // Checks that all newly generated groupID are unique and that there are no | 13 // Checks that all newly generated groupID are unique and that there are no |
13 // duplicates. | 14 // duplicates. |
14 TEST(RequestGroupUtilTest, RequestGroupID) { | 15 TEST(RequestGroupUtilTest, RequestGroupID) { |
15 base::scoped_nsobject<NSMutableSet> set([[NSMutableSet alloc] init]); | 16 base::scoped_nsobject<NSMutableSet> set([[NSMutableSet alloc] init]); |
16 const size_t kGenerated = 2000; | 17 const size_t kGenerated = 2000; |
17 for (size_t i = 0; i < kGenerated; ++i) | 18 for (size_t i = 0; i < kGenerated; ++i) |
18 [set addObject:web::GenerateNewRequestGroupID()]; | 19 [set addObject:web::GenerateNewRequestGroupID()]; |
19 EXPECT_EQ(kGenerated, [set count]); | 20 EXPECT_EQ(kGenerated, [set count]); |
20 } | 21 } |
21 | 22 |
22 // Tests that the ExtractRequestGroupIDFromUserAgent function behaves as | 23 // Tests that the ExtractRequestGroupIDFromUserAgent function behaves as |
23 // intended. | 24 // intended. |
24 TEST(RequestGroupUtilTest, ExtractRequestGroupIDFromUserAgent) { | 25 TEST(RequestGroupUtilTest, ExtractRequestGroupIDFromUserAgent) { |
25 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(nil)); | 26 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(nil)); |
26 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent( | 27 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent( |
27 @"Lynx/2.8.1pre.9 libwww-FM/2.14")); | 28 @"Lynx/2.8.1pre.9 libwww-FM/2.14")); |
28 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(@" ")); | 29 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(@" ")); |
29 EXPECT_TRUE([web::ExtractRequestGroupIDFromUserAgent(@"Mozilla/3.04 (WinNT)") | 30 EXPECT_TRUE([web::ExtractRequestGroupIDFromUserAgent(@"Mozilla/3.04 (WinNT)") |
30 isEqualToString:@"WinNT"]); | 31 isEqualToString:@"WinNT"]); |
31 } | 32 } |
OLD | NEW |