public void testCancelDecoding() {
   DecodeThread t = new DecodeThread();
   mBitmapManager.cancelThreadDecoding(t);
   try {
     t.start();
     t.join();
   } catch (InterruptedException ex) {
   } finally {
     assertNull(t.getBitmap());
   }
 }
  public void testCanThreadDecoding() {
    Thread t = new DecodeThread();

    // By default all threads can decode.
    assertTrue(mBitmapManager.canThreadDecoding(t));

    // Disallow thread t to decode.
    mBitmapManager.cancelThreadDecoding(t);
    assertFalse(mBitmapManager.canThreadDecoding(t));

    // Allow thread t to decode again.
    mBitmapManager.allowThreadDecoding(t);
    assertTrue(mBitmapManager.canThreadDecoding(t));
  }
  public void testThreadDecoding() {
    DecodeThread t1 = new DecodeThread();
    DecodeThread t2 = new DecodeThread();
    mBitmapManager.allowThreadDecoding(t1);
    mBitmapManager.cancelThreadDecoding(t2);
    t1.start();
    t2.start();

    try {
      t1.join();
      t2.join();
    } catch (InterruptedException ex) {
    } finally {
      assertTrue(mBitmapManager.canThreadDecoding(t1));
      assertNotNull(t1.getBitmap());
      assertFalse(mBitmapManager.canThreadDecoding(t2));
      assertNull(t2.getBitmap());
    }
  }