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

Side by Side 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, 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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.
4
5 // These tests are somewhat dependent on the exact contents of the
6 // accept languages table generated at build-time.
7
8 #import <Cronet/Cronet.h>
9 #import <Foundation/Foundation.h>
10
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 @interface Cronet (ExposedForTesting)
14 + (NSString*)getAcceptLanguagesFromPreferredLanguages:
15 (NSArray<NSString*>*)languages;
16 @end
17
18 namespace cronet {
19
20 #define EXPECT_NSEQ(a, b) EXPECT_TRUE([(a) isEqual:(b)])
21
22 TEST(AcceptLangTest, Region) {
23 NSString* acceptLangs =
24 [Cronet getAcceptLanguagesFromPreferredLanguages:@[ @"en-GB" ]];
25
26 EXPECT_NSEQ(acceptLangs, @"en-GB,en-US,en");
27 }
28
29 TEST(AcceptLangTest, Lang) {
30 NSString* acceptLangs =
31 [Cronet getAcceptLanguagesFromPreferredLanguages:@[ @"ja-JP" ]];
32
33 EXPECT_NSEQ(acceptLangs, @"ja,en-US,en");
34 }
35
36 TEST(AcceptLangTest, Default) {
37 NSString* acceptLangs =
38 [Cronet getAcceptLanguagesFromPreferredLanguages:@[ @"lol-LOL" ]];
39
40 EXPECT_NSEQ(acceptLangs, @"en-US,en");
41 }
42
43 TEST(AcceptLangTest, Append) {
44 NSString* acceptLangs =
45 [Cronet getAcceptLanguagesFromPreferredLanguages:@[ @"ja-JP", @"en-GB" ]];
46
47 EXPECT_NSEQ(acceptLangs, @"ja,en-US,en,en-GB");
48 }
49
50 TEST(AcceptLangTest, NoDefaultAppend) {
51 NSString* acceptLangs = [Cronet
52 getAcceptLanguagesFromPreferredLanguages:@[ @"en-GB", @"lol-LOL" ]];
53
54 NSLog(@"%@", acceptLangs);
55 EXPECT_NSEQ(acceptLangs, @"en-GB,en-US,en");
56 }
57 }
OLDNEW
« 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