| 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.offlinepages; | 5 package org.chromium.chrome.browser.offlinepages; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Environment; | 8 import android.os.Environment; |
| 9 import android.test.suitebuilder.annotation.SmallTest; | 9 import android.test.suitebuilder.annotation.SmallTest; |
| 10 | 10 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 String offlinePageUrl = offlinePage.getOfflineUrl(); | 166 String offlinePageUrl = offlinePage.getOfflineUrl(); |
| 167 loadUrl(offlinePageUrl); | 167 loadUrl(offlinePageUrl); |
| 168 Log.d(TAG, "Calling showOfflineSnackbarIfNecessary from test"); | 168 Log.d(TAG, "Calling showOfflineSnackbarIfNecessary from test"); |
| 169 | 169 |
| 170 // Act. This needs to be called from the UI thread. | 170 // Act. This needs to be called from the UI thread. |
| 171 Log.d(TAG, "before connecting NCN online state " + NetworkChangeNotifier
.isOnline()); | 171 Log.d(TAG, "before connecting NCN online state " + NetworkChangeNotifier
.isOnline()); |
| 172 ThreadUtils.runOnUiThread(new Runnable() { | 172 ThreadUtils.runOnUiThread(new Runnable() { |
| 173 @Override | 173 @Override |
| 174 public void run() { | 174 public void run() { |
| 175 Log.d(TAG, "Showing offline snackbar from UI thread"); | 175 Log.d(TAG, "Showing offline snackbar from UI thread"); |
| 176 OfflinePageUtils.showOfflineSnackbarIfNecessary( | 176 OfflinePageUtils.showOfflineSnackbarIfNecessary(getActivity().ge
tBaseContext(), |
| 177 getActivity(), getActivity().getActivityTab(), mockSnack
barController); | 177 getActivity().getSnackbarManager(), getActivity().getAct
ivityTab(), |
| 178 mockSnackbarController); |
| 178 | 179 |
| 179 // Pretend that we went online, this should cause the snackbar t
o show. | 180 // Pretend that we went online, this should cause the snackbar t
o show. |
| 180 // This call will set the isConnected call to return true. | 181 // This call will set the isConnected call to return true. |
| 181 NetworkChangeNotifier.forceConnectivityState(true); | 182 NetworkChangeNotifier.forceConnectivityState(true); |
| 182 // This call will make an event get sent with connection type CO
NNECTION_WIFI. | 183 // This call will make an event get sent with connection type CO
NNECTION_WIFI. |
| 183 NetworkChangeNotifier.fakeNetworkConnected(0, ConnectionType.CON
NECTION_WIFI); | 184 NetworkChangeNotifier.fakeNetworkConnected(0, ConnectionType.CON
NECTION_WIFI); |
| 184 } | 185 } |
| 185 }); | 186 }); |
| 186 | 187 |
| 187 // Wait for the snackbar to be dismissed before we check its values. Th
e snackbar is on a | 188 // Wait for the snackbar to be dismissed before we check its values. Th
e snackbar is on a |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 result.add(item); | 232 result.add(item); |
| 232 } | 233 } |
| 233 | 234 |
| 234 semaphore.release(); | 235 semaphore.release(); |
| 235 } | 236 } |
| 236 }); | 237 }); |
| 237 assertTrue(semaphore.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS)); | 238 assertTrue(semaphore.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS)); |
| 238 return result; | 239 return result; |
| 239 } | 240 } |
| 240 } | 241 } |
| OLD | NEW |