OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 11 matching lines...) Expand all Loading... |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 package org.webrtc; | 27 package org.webrtc; |
28 | 28 |
29 import static org.webrtc.NetworkMonitorAutoDetect.ConnectionType; | 29 import static org.webrtc.NetworkMonitorAutoDetect.ConnectionType; |
30 import static org.webrtc.NetworkMonitorAutoDetect.ConnectivityManagerDelegate; | 30 import static org.webrtc.NetworkMonitorAutoDetect.ConnectivityManagerDelegate; |
31 import static org.webrtc.NetworkMonitorAutoDetect.INVALID_NET_ID; | 31 import static org.webrtc.NetworkMonitorAutoDetect.INVALID_NET_ID; |
| 32 import static org.webrtc.NetworkMonitorAutoDetect.NetworkInformation; |
32 import static org.webrtc.NetworkMonitorAutoDetect.NetworkState; | 33 import static org.webrtc.NetworkMonitorAutoDetect.NetworkState; |
33 | 34 |
34 import android.annotation.SuppressLint; | 35 import android.annotation.SuppressLint; |
35 import android.content.Context; | 36 import android.content.Context; |
36 import android.content.Intent; | 37 import android.content.Intent; |
37 import android.net.ConnectivityManager; | 38 import android.net.ConnectivityManager; |
38 import android.net.Network; | 39 import android.net.Network; |
39 import android.net.wifi.WifiManager; | 40 import android.net.wifi.WifiManager; |
40 import android.os.Build; | 41 import android.os.Build; |
41 import android.os.Handler; | 42 import android.os.Handler; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 this.wifiSSID = wifiSSID; | 132 this.wifiSSID = wifiSSID; |
132 } | 133 } |
133 } | 134 } |
134 | 135 |
135 // A dummy NetworkMonitorAutoDetect.Observer. | 136 // A dummy NetworkMonitorAutoDetect.Observer. |
136 private static class TestNetworkMonitorAutoDetectObserver | 137 private static class TestNetworkMonitorAutoDetectObserver |
137 implements NetworkMonitorAutoDetect.Observer { | 138 implements NetworkMonitorAutoDetect.Observer { |
138 | 139 |
139 @Override | 140 @Override |
140 public void onConnectionTypeChanged(ConnectionType newConnectionType) {} | 141 public void onConnectionTypeChanged(ConnectionType newConnectionType) {} |
| 142 |
| 143 @Override |
| 144 public void onNetworkConnect(NetworkInformation networkInfo) {} |
141 } | 145 } |
142 | 146 |
143 private static final Object lock = new Object(); | 147 private static final Object lock = new Object(); |
144 private static Handler uiThreadHandler = null; | 148 private static Handler uiThreadHandler = null; |
145 | 149 |
146 private NetworkMonitorAutoDetect receiver; | 150 private NetworkMonitorAutoDetect receiver; |
147 private MockConnectivityManagerDelegate connectivityDelegate; | 151 private MockConnectivityManagerDelegate connectivityDelegate; |
148 private MockWifiManagerDelegate wifiDelegate; | 152 private MockWifiManagerDelegate wifiDelegate; |
149 | 153 |
150 private static Handler getUiThreadHandler() { | 154 private static Handler getUiThreadHandler() { |
(...skipping 20 matching lines...) Expand all Loading... |
171 receiver.setConnectivityManagerDelegateForTests(connectivityDelegate); | 175 receiver.setConnectivityManagerDelegateForTests(connectivityDelegate); |
172 | 176 |
173 wifiDelegate = new MockWifiManagerDelegate(); | 177 wifiDelegate = new MockWifiManagerDelegate(); |
174 receiver.setWifiManagerDelegateForTests(wifiDelegate); | 178 receiver.setWifiManagerDelegateForTests(wifiDelegate); |
175 wifiDelegate.setWifiSSID("foo"); | 179 wifiDelegate.setWifiSSID("foo"); |
176 } | 180 } |
177 | 181 |
178 private NetworkMonitorAutoDetect.ConnectionType getCurrentConnectionType() { | 182 private NetworkMonitorAutoDetect.ConnectionType getCurrentConnectionType() { |
179 final NetworkMonitorAutoDetect.NetworkState networkState = | 183 final NetworkMonitorAutoDetect.NetworkState networkState = |
180 receiver.getCurrentNetworkState(); | 184 receiver.getCurrentNetworkState(); |
181 return receiver.getCurrentConnectionType(networkState); | 185 return receiver.getConnectionType(networkState); |
182 } | 186 } |
183 | 187 |
184 @Override | 188 @Override |
185 protected void setUp() throws Exception { | 189 protected void setUp() throws Exception { |
186 super.setUp(); | 190 super.setUp(); |
187 getUiThreadHandler().post(new Runnable() { | 191 getUiThreadHandler().post(new Runnable() { |
188 public void run() { | 192 public void run() { |
189 createTestMonitor(); | 193 createTestMonitor(); |
190 } | 194 } |
191 }); | 195 }); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 */ | 283 */ |
280 @UiThreadTest | 284 @UiThreadTest |
281 @SmallTest | 285 @SmallTest |
282 public void testQueryableAPIsDoNotCrash() { | 286 public void testQueryableAPIsDoNotCrash() { |
283 NetworkMonitorAutoDetect.Observer observer = new TestNetworkMonitorAutoDetec
tObserver(); | 287 NetworkMonitorAutoDetect.Observer observer = new TestNetworkMonitorAutoDetec
tObserver(); |
284 NetworkMonitorAutoDetect ncn = | 288 NetworkMonitorAutoDetect ncn = |
285 new NetworkMonitorAutoDetect(observer, getInstrumentation().getTargetCon
text()); | 289 new NetworkMonitorAutoDetect(observer, getInstrumentation().getTargetCon
text()); |
286 ncn.getDefaultNetId(); | 290 ncn.getDefaultNetId(); |
287 } | 291 } |
288 } | 292 } |
OLD | NEW |