| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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.components.variations.firstrun; | 5 package org.chromium.components.variations.firstrun; |
| 6 | 6 |
| 7 import static org.hamcrest.CoreMatchers.equalTo; | 7 import static org.hamcrest.CoreMatchers.equalTo; |
| 8 import static org.junit.Assert.assertFalse; | 8 import static org.junit.Assert.assertFalse; |
| 9 import static org.junit.Assert.assertThat; | 9 import static org.junit.Assert.assertThat; |
| 10 import static org.junit.Assert.assertTrue; | 10 import static org.junit.Assert.assertTrue; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 /** | 109 /** |
| 110 * Test method for {@link VariationsSeedFetcher#fetchSeed()} with a bad respo
nse | 110 * Test method for {@link VariationsSeedFetcher#fetchSeed()} with a bad respo
nse |
| 111 */ | 111 */ |
| 112 @Test | 112 @Test |
| 113 public void testFetchSeed_badResponse() throws IOException { | 113 public void testFetchSeed_badResponse() throws IOException { |
| 114 when(mConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_NO
T_FOUND); | 114 when(mConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_NO
T_FOUND); |
| 115 | 115 |
| 116 mFetcher.fetchSeed(""); | 116 mFetcher.fetchSeed(""); |
| 117 | 117 |
| 118 assertTrue(mPrefs.getBoolean(VariationsSeedFetcher.VARIATIONS_INITIALIZE
D_PREF, false)); | 118 assertTrue(mPrefs.getBoolean(VariationsSeedFetcher.VARIATIONS_INITIALIZE
D_PREF, false)); |
| 119 assertFalse(VariationsSeedBridge.hasJavaPref(ContextUtils.getApplication
Context())); | 119 assertFalse(VariationsSeedBridge.hasJavaPref()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * Test method for {@link VariationsSeedFetcher#fetchSeed()} with an exceptio
n when connecting | 123 * Test method for {@link VariationsSeedFetcher#fetchSeed()} with an exceptio
n when connecting |
| 124 */ | 124 */ |
| 125 @Test | 125 @Test |
| 126 public void testFetchSeed_IOException() throws IOException { | 126 public void testFetchSeed_IOException() throws IOException { |
| 127 doThrow(new IOException()).when(mConnection).connect(); | 127 doThrow(new IOException()).when(mConnection).connect(); |
| 128 | 128 |
| 129 mFetcher.fetchSeed(""); | 129 mFetcher.fetchSeed(""); |
| 130 | 130 |
| 131 assertTrue(mPrefs.getBoolean(VariationsSeedFetcher.VARIATIONS_INITIALIZE
D_PREF, false)); | 131 assertTrue(mPrefs.getBoolean(VariationsSeedFetcher.VARIATIONS_INITIALIZE
D_PREF, false)); |
| 132 assertFalse(VariationsSeedBridge.hasJavaPref(ContextUtils.getApplication
Context())); | 132 assertFalse(VariationsSeedBridge.hasJavaPref()); |
| 133 } | 133 } |
| 134 } | 134 } |
| OLD | NEW |