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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 builder.setLibraryLoader(loader).setLibraryName("cronet_tests"); | 1119 builder.setLibraryLoader(loader).setLibraryName("cronet_tests"); |
1120 try { | 1120 try { |
1121 // ensureInitialized() calls native code to check the version right
after library load | 1121 // ensureInitialized() calls native code to check the version right
after library load |
1122 // and will error with the message below if library loading was skip
ped | 1122 // and will error with the message below if library loading was skip
ped |
1123 CronetLibraryLoader.ensureInitialized(getContext(), builder); | 1123 CronetLibraryLoader.ensureInitialized(getContext(), builder); |
1124 fail("Native library should not be loaded"); | 1124 fail("Native library should not be loaded"); |
1125 } catch (UnsatisfiedLinkError e) { | 1125 } catch (UnsatisfiedLinkError e) { |
1126 assertTrue(loader.wasCalled()); | 1126 assertTrue(loader.wasCalled()); |
1127 } | 1127 } |
1128 } | 1128 } |
1129 | |
1130 // Creates a CronetEngine on another thread and then one on the main thread.
This shouldn't | |
1131 // crash. | |
1132 @SmallTest | |
1133 @Feature({"Cronet"}) | |
1134 public void testThreadedStartup() throws Exception { | |
1135 final ConditionVariable otherThreadDone = new ConditionVariable(); | |
1136 final ConditionVariable uiThreadDone = new ConditionVariable(); | |
1137 new Handler(Looper.getMainLooper()).post(new Runnable() { | |
1138 public void run() { | |
1139 final CronetEngine.Builder builder = | |
1140 new CronetEngine.Builder(getContext()).setLibraryName("c
ronet_tests"); | |
1141 new Thread() { | |
1142 public void run() { | |
1143 CronetEngine cronetEngine = builder.build(); | |
1144 otherThreadDone.open(); | |
1145 cronetEngine.shutdown(); | |
1146 } | |
1147 }.start(); | |
1148 otherThreadDone.block(); | |
1149 builder.build().shutdown(); | |
1150 uiThreadDone.open(); | |
1151 } | |
1152 }); | |
1153 assertTrue(uiThreadDone.block(1000)); | |
1154 } | |
1155 } | 1129 } |
OLD | NEW |