Chromium Code Reviews| 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..847874ec16381401b66a385940dc159f39c6eccc |
| --- /dev/null |
| +++ b/components/cronet/ios/test/cronet_acceptlang_test.mm |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
|
mef
2017/02/06 16:21:05
nit: 2017
lilyhoughton
2017/02/06 17:54:55
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import <Cronet/Cronet.h> |
| +#import <Foundation/Foundation.h> |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +@interface Cronet (ExposedForTesting) |
| ++ (NSString*)getAcceptLanguagesFromNSLocale:(NSLocale*)locale; |
| +@end |
| + |
| +namespace cronet { |
| + |
| +#define EXPECT_NSEQ(a, b) EXPECT_TRUE([(a) isEqual:(b)]) |
| + |
| +TEST(AcceptLangTest, Region) { |
| + NSString* acceptLangs = [Cronet |
| + getAcceptLanguagesFromNSLocale:[NSLocale |
| + localeWithLocaleIdentifier:@"en-GB"]]; |
| + |
| + EXPECT_NSEQ(acceptLangs, @"en-GB,en-US,en"); |
| +} |
| + |
| +TEST(AcceptLangTest, Lang) { |
| + NSString* acceptLangs = [Cronet |
| + getAcceptLanguagesFromNSLocale:[NSLocale |
| + localeWithLocaleIdentifier:@"ja-JP"]]; |
|
mef
2017/02/06 16:21:05
did you mean to specify just 'ja'?
lilyhoughton
2017/02/06 17:54:55
No, this is testing the behavior that if a languag
mef
2017/02/16 19:20:29
Acknowledged.
|
| + |
| + EXPECT_NSEQ(acceptLangs, @"ja,en-US,en"); |
| +} |
| + |
| +TEST(AcceptLangTest, Default) { |
| + NSString* acceptLangs = |
| + [Cronet getAcceptLanguagesFromNSLocale: |
| + [NSLocale localeWithLocaleIdentifier:@"lol-LOL"]]; |
| + |
| + EXPECT_NSEQ(acceptLangs, @"en-US,en"); |
| +} |
| +} |