| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.feedback; | 5 package org.chromium.chrome.browser.feedback; |
| 6 | 6 |
| 7 import android.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
| 8 import android.test.suitebuilder.annotation.SmallTest; | 8 import android.test.suitebuilder.annotation.SmallTest; |
| 9 | 9 |
| 10 import org.chromium.base.ThreadUtils; | 10 import org.chromium.base.ThreadUtils; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 import java.util.concurrent.atomic.AtomicReference; | 24 import java.util.concurrent.atomic.AtomicReference; |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Tests for {@link ConnectivityTask}. | 27 * Tests for {@link ConnectivityTask}. |
| 28 */ | 28 */ |
| 29 public class ConnectivityTaskTest extends ConnectivityCheckerTestBase { | 29 public class ConnectivityTaskTest extends ConnectivityCheckerTestBase { |
| 30 private static final int RESULT_CHECK_INTERVAL_MS = 10; | 30 private static final int RESULT_CHECK_INTERVAL_MS = 10; |
| 31 | 31 |
| 32 @MediumTest | 32 @MediumTest |
| 33 @Feature({"Feedback"}) | 33 @Feature({"Feedback"}) |
| 34 public void testNormalCaseShouldWork() throws InterruptedException { | 34 public void testNormalCaseShouldWork() { |
| 35 final ConnectivityTask task = ThreadUtils.runOnUiThreadBlockingNoExcepti
on( | 35 final ConnectivityTask task = ThreadUtils.runOnUiThreadBlockingNoExcepti
on( |
| 36 new Callable<ConnectivityTask>() { | 36 new Callable<ConnectivityTask>() { |
| 37 @Override | 37 @Override |
| 38 public ConnectivityTask call() { | 38 public ConnectivityTask call() { |
| 39 // Intentionally make HTTPS-connection fail which should
result in | 39 // Intentionally make HTTPS-connection fail which should
result in |
| 40 // NOT_CONNECTED. | 40 // NOT_CONNECTED. |
| 41 ConnectivityChecker.overrideUrlsForTest(mGenerate204Url,
mGenerate404Url); | 41 ConnectivityChecker.overrideUrlsForTest(mGenerate204Url,
mGenerate404Url); |
| 42 return ConnectivityTask.create(Profile.getLastUsedProfil
e(), TIMEOUT_MS, | 42 return ConnectivityTask.create(Profile.getLastUsedProfil
e(), TIMEOUT_MS, |
| 43 null); | 43 null); |
| 44 } | 44 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } | 137 } |
| 138 FeedbackData feedback = feedbackRef.get(); | 138 FeedbackData feedback = feedbackRef.get(); |
| 139 // In the case of a timeout when using callbacks, the result will be TIM
EOUT instead | 139 // In the case of a timeout when using callbacks, the result will be TIM
EOUT instead |
| 140 // of UNKNOWN. | 140 // of UNKNOWN. |
| 141 verifyConnections(feedback, ConnectivityCheckResult.TIMEOUT); | 141 verifyConnections(feedback, ConnectivityCheckResult.TIMEOUT); |
| 142 assertEquals("The timeout value is wrong.", checkTimeoutMs, feedback.get
TimeoutMs()); | 142 assertEquals("The timeout value is wrong.", checkTimeoutMs, feedback.get
TimeoutMs()); |
| 143 } | 143 } |
| 144 | 144 |
| 145 @MediumTest | 145 @MediumTest |
| 146 @Feature({"Feedback"}) | 146 @Feature({"Feedback"}) |
| 147 public void testTwoTimeoutsShouldFillInTheRest() throws InterruptedException
{ | 147 public void testTwoTimeoutsShouldFillInTheRest() { |
| 148 final ConnectivityTask task = ThreadUtils.runOnUiThreadBlockingNoExcepti
on( | 148 final ConnectivityTask task = ThreadUtils.runOnUiThreadBlockingNoExcepti
on( |
| 149 new Callable<ConnectivityTask>() { | 149 new Callable<ConnectivityTask>() { |
| 150 @Override | 150 @Override |
| 151 public ConnectivityTask call() { | 151 public ConnectivityTask call() { |
| 152 // Intentionally make HTTPS connections slow which shoul
d result in | 152 // Intentionally make HTTPS connections slow which shoul
d result in |
| 153 // UNKNOWN. | 153 // UNKNOWN. |
| 154 ConnectivityChecker.overrideUrlsForTest(mGenerate204Url, | 154 ConnectivityChecker.overrideUrlsForTest(mGenerate204Url, |
| 155 mGenerateSlowUrl); | 155 mGenerateSlowUrl); |
| 156 return ConnectivityTask.create(Profile.getLastUsedProfil
e(), TIMEOUT_MS, | 156 return ConnectivityTask.create(Profile.getLastUsedProfil
e(), TIMEOUT_MS, |
| 157 null); | 157 null); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 final FeedbackData result = ThreadUtils.runOnUiThreadBlockingNoException
( | 205 final FeedbackData result = ThreadUtils.runOnUiThreadBlockingNoException
( |
| 206 new Callable<FeedbackData>() { | 206 new Callable<FeedbackData>() { |
| 207 @Override | 207 @Override |
| 208 public FeedbackData call() { | 208 public FeedbackData call() { |
| 209 return task.get(); | 209 return task.get(); |
| 210 } | 210 } |
| 211 }); | 211 }); |
| 212 return result; | 212 return result; |
| 213 } | 213 } |
| 214 } | 214 } |
| OLD | NEW |