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

Unified Diff: components/cronet/ios/test/cronet_acceptlang_test.mm

Issue 2665703002: [cronet] Make getAcceptLanguages index a static table instead of the application bundle. (Closed)
Patch Set: move accept_languages header generation script to more appropriate location Created 3 years, 10 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
« no previous file with comments | « components/cronet/ios/test/BUILD.gn ('k') | components/cronet/ios/test/start_cronet.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/ios/test/cronet_acceptlang_test.mm
diff --git a/components/cronet/ios/test/cronet_acceptlang_test.mm b/components/cronet/ios/test/cronet_acceptlang_test.mm
new file mode 100644
index 0000000000000000000000000000000000000000..d19ace698c618ad36633f5853bc29bde4e946a61
--- /dev/null
+++ b/components/cronet/ios/test/cronet_acceptlang_test.mm
@@ -0,0 +1,57 @@
+// Copyright 2017 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.
+
+// These tests are somewhat dependent on the exact contents of the
+// accept languages table generated at build-time.
+
+#import <Cronet/Cronet.h>
+#import <Foundation/Foundation.h>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+@interface Cronet (ExposedForTesting)
++ (NSString*)getAcceptLanguagesFromPreferredLanguages:
+ (NSArray<NSString*>*)languages;
+@end
+
+namespace cronet {
+
+#define EXPECT_NSEQ(a, b) EXPECT_TRUE([(a) isEqual:(b)])
+
+TEST(AcceptLangTest, Region) {
+ NSString* acceptLangs =
+ [Cronet getAcceptLanguagesFromPreferredLanguages:@[ @"en-GB" ]];
+
+ EXPECT_NSEQ(acceptLangs, @"en-GB,en-US,en");
+}
+
+TEST(AcceptLangTest, Lang) {
+ NSString* acceptLangs =
+ [Cronet getAcceptLanguagesFromPreferredLanguages:@[ @"ja-JP" ]];
+
+ EXPECT_NSEQ(acceptLangs, @"ja,en-US,en");
+}
+
+TEST(AcceptLangTest, Default) {
+ NSString* acceptLangs =
+ [Cronet getAcceptLanguagesFromPreferredLanguages:@[ @"lol-LOL" ]];
+
+ EXPECT_NSEQ(acceptLangs, @"en-US,en");
+}
+
+TEST(AcceptLangTest, Append) {
+ NSString* acceptLangs =
+ [Cronet getAcceptLanguagesFromPreferredLanguages:@[ @"ja-JP", @"en-GB" ]];
+
+ EXPECT_NSEQ(acceptLangs, @"ja,en-US,en,en-GB");
+}
+
+TEST(AcceptLangTest, NoDefaultAppend) {
+ NSString* acceptLangs = [Cronet
+ getAcceptLanguagesFromPreferredLanguages:@[ @"en-GB", @"lol-LOL" ]];
+
+ NSLog(@"%@", acceptLangs);
+ EXPECT_NSEQ(acceptLangs, @"en-GB,en-US,en");
+}
+}
« no previous file with comments | « components/cronet/ios/test/BUILD.gn ('k') | components/cronet/ios/test/start_cronet.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698