Last active
December 20, 2015 12:39
-
-
Save bastoche/6133227 to your computer and use it in GitHub Desktop.
Test case reproducing a crash on a few Android devices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
import junit.framework.TestCase; | |
import org.apache.http.impl.client.DefaultHttpClient; | |
public final class HttpClientTest extends TestCase { | |
// won't pass on T-Mobile MyTouch Q | |
public void testInstanciateAsynchronously() { | |
Thread thread = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
new DefaultHttpClient(); | |
} | |
}); | |
thread.start(); | |
boolean result = false; | |
try { | |
thread.join(); | |
result = true; | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
assertTrue(result); | |
} | |
// will always pass | |
public void testInstanciateSynchronouslyThenAsynchronously() { | |
new DefaultHttpClient(); | |
Thread thread = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
new DefaultHttpClient(); | |
} | |
}); | |
thread.start(); | |
boolean result = false; | |
try { | |
thread.join(); | |
result = true; | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
assertTrue(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment