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

Unified Diff: ios/web/net/request_group_util_unittest.mm

Issue 988383002: Upstream various ios/web utilities and helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web-public-upstreaming
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/web/net/request_group_util_unittest.mm
diff --git a/ios/web/net/request_group_util_unittest.mm b/ios/web/net/request_group_util_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..b21e30e58133bd3e80d111454912a3a3cdb553f4
--- /dev/null
+++ b/ios/web/net/request_group_util_unittest.mm
@@ -0,0 +1,31 @@
+// 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/web/net/request_group_util.h"
+
+#include <Foundation/Foundation.h>
+
+#include "base/mac/scoped_nsobject.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// Checks that all newly generated groupID are unique and that there are no
+// duplicates.
+TEST(RequestGroupUtilTest, RequestGroupID) {
+ base::scoped_nsobject<NSMutableSet> set([[NSMutableSet alloc] init]);
+ const size_t kGenerated = 2000;
+ for (size_t i = 0; i < kGenerated; ++i)
+ [set addObject:web::GenerateNewRequestGroupID()];
+ EXPECT_EQ(kGenerated, [set count]);
+}
+
+// Tests that the ExtractRequestGroupIDFromUserAgent function behaves as
+// intended.
+TEST(RequestGroupUtilTest, ExtractRequestGroupIDFromUserAgent) {
+ EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(nil));
+ EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(
+ @"Lynx/2.8.1pre.9 libwww-FM/2.14"));
+ EXPECT_FALSE(web::ExtractRequestGroupIDFromUserAgent(@" "));
+ EXPECT_TRUE([web::ExtractRequestGroupIDFromUserAgent(@"Mozilla/3.04 (WinNT)")
+ isEqualToString:@"WinNT"]);
+}

Powered by Google App Engine
This is Rietveld 408576698