| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.physicalweb; | 5 package org.chromium.chrome.browser.physicalweb; |
| 6 | 6 |
| 7 import static org.junit.Assert.assertEquals; | 7 import static org.junit.Assert.assertEquals; |
| 8 import static org.junit.Assert.assertFalse; | 8 import static org.junit.Assert.assertFalse; |
| 9 import static org.junit.Assert.assertTrue; | 9 import static org.junit.Assert.assertTrue; |
| 10 import static org.mockito.Mockito.mock; | 10 import static org.mockito.Mockito.mock; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 private static final String ACCEPT_LANGUAGES = "en-US,en"; | 39 private static final String ACCEPT_LANGUAGES = "en-US,en"; |
| 40 PwsClientImpl mPwsClientImpl; | 40 PwsClientImpl mPwsClientImpl; |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * Robolectric shadow to mock out calls to {@link Resources#getString}. | 43 * Robolectric shadow to mock out calls to {@link Resources#getString}. |
| 44 */ | 44 */ |
| 45 @Implements(Resources.class) | 45 @Implements(Resources.class) |
| 46 public static class AcceptLanguageShadowResources extends ShadowResources { | 46 public static class AcceptLanguageShadowResources extends ShadowResources { |
| 47 public static final Resources sResources = mock(Resources.class); | 47 public static final Resources sResources = mock(Resources.class); |
| 48 | 48 |
| 49 @Override | |
| 50 @Implementation | 49 @Implementation |
| 51 public CharSequence getText(int id) { | 50 public CharSequence getText(int id) { |
| 52 return sResources.getText(id); | 51 return sResources.getText(id); |
| 53 } | 52 } |
| 54 } | 53 } |
| 55 | 54 |
| 56 @Before | 55 @Before |
| 57 public void setUp() throws Exception { | 56 public void setUp() throws Exception { |
| 58 ContextUtils.initApplicationContextForTests(RuntimeEnvironment.applicati
on); | 57 ContextUtils.initApplicationContextForTests(RuntimeEnvironment.applicati
on); |
| 59 mPwsClientImpl = new PwsClientImpl(); | 58 mPwsClientImpl = new PwsClientImpl(); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // Should insert q-values for each item except the first which implicitl
y has q=1.0. | 188 // Should insert q-values for each item except the first which implicitl
y has q=1.0. |
| 190 String acceptLanguage = PwsClientImpl.generateAcceptLanguageHeader(langu
ageList); | 189 String acceptLanguage = PwsClientImpl.generateAcceptLanguageHeader(langu
ageList); |
| 191 assertEquals("en-US,en-GB;q=0.8,en;q=0.6,jp-JP;q=0.4,jp;q=0.2", acceptLa
nguage); | 190 assertEquals("en-US,en-GB;q=0.8,en;q=0.6,jp-JP;q=0.4,jp;q=0.2", acceptLa
nguage); |
| 192 | 191 |
| 193 // When there are six or more items, the q-value should not go below 0.2
. | 192 // When there are six or more items, the q-value should not go below 0.2
. |
| 194 languageList = "mas,es,en,jp,ch,fr"; | 193 languageList = "mas,es,en,jp,ch,fr"; |
| 195 acceptLanguage = PwsClientImpl.generateAcceptLanguageHeader(languageList
); | 194 acceptLanguage = PwsClientImpl.generateAcceptLanguageHeader(languageList
); |
| 196 assertEquals("mas,es;q=0.8,en;q=0.6,jp;q=0.4,ch;q=0.2,fr;q=0.2", acceptL
anguage); | 195 assertEquals("mas,es;q=0.8,en;q=0.6,jp;q=0.4,ch;q=0.2,fr;q=0.2", acceptL
anguage); |
| 197 } | 196 } |
| 198 } | 197 } |
| OLD | NEW |