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/web/net/request_group_util.h"
7 #include <Foundation/Foundation.h>
9 #include "base/mac/scoped_nsobject.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 // Checks that all newly generated groupID are unique and that there are no
14 TEST(RequestGroupUtilTest, RequestGroupID) {
15 base::scoped_nsobject<NSMutableSet> set([[NSMutableSet alloc] init]);
16 const size_t kGenerated = 2000;
17 for (size_t i = 0; i < kGenerated; ++i)
18 [set addObject:web::GenerateNewRequestGroupID()];
19 EXPECT_EQ(kGenerated, [set count]);
22 // Tests that the ExtractRequestGroupIDFromUserAgent function behaves as
24 TEST(RequestGroupUtilTest, ExtractRequestGroupIDFromUserAgent) {
25 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(nil));
26 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(
27 @"Lynx/2.8.1pre.9 libwww-FM/2.14"));
28 EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(@" "));
29 EXPECT_TRUE([web::ExtractRequestGroupIDFromUserAgent(@"Mozilla/3.04 (WinNT)")
30 isEqualToString:@"WinNT"]);