| 1 |
package android.databinding.testapp; |
| 2 |
|
| 3 |
import android.databinding.testapp.databinding.MultiThreadLayoutBinding; |
| 4 |
import android.test.UiThreadTest; |
| 5 |
|
| 6 |
import java.util.concurrent.CountDownLatch; |
| 7 |
|
| 8 |
public class MultiThreadTest extends BaseDataBinderTest<MultiThreadLayoutBinding> { |
| 9 |
public MultiThreadTest() { |
| 10 |
super(MultiThreadLayoutBinding.class); |
| 11 |
} |
| 12 |
|
| 13 |
public void testSetOnBackgroundThread() throws Throwable { |
| 14 |
initBinder(); |
| 15 |
mBinder.setText("a"); |
| 16 |
assertEquals("a", mBinder.getText()); |
| 17 |
Thread.sleep(500); |
| 18 |
runTestOnUiThread(new Runnable() { |
| 19 |
@Override |
| 20 |
public void run() { |
| 21 |
assertEquals("a", mBinder.myTextView.getText().toString()); |
| 22 |
} |
| 23 |
}); |
| 24 |
mBinder.setText("b"); |
| 25 |
Thread.sleep(500); |
| 26 |
assertEquals("b", mBinder.getText()); |
| 27 |
runTestOnUiThread(new Runnable() { |
| 28 |
@Override |
| 29 |
public void run() { |
| 30 |
assertEquals("b", mBinder.myTextView.getText().toString()); |
| 31 |
} |
| 32 |
}); |
| 33 |
} |
| 34 |
} |