OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.net; | 5 package org.chromium.net; |
6 | 6 |
7 import static org.chromium.base.CollectionUtil.newHashSet; | 7 import static org.chromium.base.CollectionUtil.newHashSet; |
8 | 8 |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.ContextWrapper; | 10 import android.content.ContextWrapper; |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1118 builder.setLibraryLoader(loader).setLibraryName("cronet_tests"); | 1118 builder.setLibraryLoader(loader).setLibraryName("cronet_tests"); |
1119 try { | 1119 try { |
1120 // ensureInitialized() calls native code to check the version right after library load | 1120 // ensureInitialized() calls native code to check the version right after library load |
1121 // and will error with the message below if library loading was skip ped | 1121 // and will error with the message below if library loading was skip ped |
1122 CronetLibraryLoader.ensureInitialized(getContext(), builder); | 1122 CronetLibraryLoader.ensureInitialized(getContext(), builder); |
1123 fail("Native library should not be loaded"); | 1123 fail("Native library should not be loaded"); |
1124 } catch (UnsatisfiedLinkError e) { | 1124 } catch (UnsatisfiedLinkError e) { |
1125 assertTrue(loader.wasCalled()); | 1125 assertTrue(loader.wasCalled()); |
1126 } | 1126 } |
1127 } | 1127 } |
1128 | |
1129 // Creates a CronetEngine on another thread and then one on the main thread. This shouldn't | |
1130 // crash. | |
1131 @SmallTest | |
1132 @Feature({"Cronet"}) | |
1133 public void testThreadedStartup() throws Exception { | |
1134 final ConditionVariable otherThreadDone = new ConditionVariable(); | |
1135 final ConditionVariable uiThreadDone = new ConditionVariable(); | |
1136 new Handler(Looper.getMainLooper()).post(new Runnable() { | |
1137 public void run() { | |
1138 final CronetEngine.Builder builder = | |
1139 new CronetEngine.Builder(getContext()).setLibraryName("c ronet_tests"); | |
1140 new Thread() { | |
1141 public void run() { | |
1142 CronetEngine cronetEngine = builder.build(); | |
mef
2016/04/27 18:48:15
Can we create and start a new request here, before
pauljensen
2016/04/27 19:04:24
We could do lots of things here. I think our othe
mef
2016/04/27 19:50:00
Acknowledged.
| |
1143 otherThreadDone.open(); | |
1144 cronetEngine.shutdown(); | |
1145 } | |
1146 }.start(); | |
1147 otherThreadDone.block(); | |
mef
2016/04/27 18:48:15
OTOH I can see Paul's point that this will deadloc
| |
1148 builder.build().shutdown(); | |
1149 uiThreadDone.open(); | |
1150 } | |
1151 }); | |
1152 assertTrue(uiThreadDone.block(1000)); | |
1153 } | |
1128 } | 1154 } |
OLD | NEW |