gt:                 for (int i = 0; i < 50; i++) {
context: package com.mediatek.ngin3d.tests;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.res.Resources;
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.os.Environment;
  import android.os.SystemClock;
  import android.util.Log;
  import com.mediatek.ngin3d.BitmapFont;
  import com.mediatek.ngin3d.BitmapText;
  import com.mediatek.ngin3d.Container;
  import com.mediatek.ngin3d.Empty;
  import com.mediatek.ngin3d.Glo3D;
  import com.mediatek.ngin3d.Image;
  import com.mediatek.ngin3d.Point;
  import com.mediatek.ngin3d.Rotation;
  import com.mediatek.ngin3d.Scale;
  import com.mediatek.ngin3d.Stage;
  import com.mediatek.ngin3d.Text;
  import com.mediatek.ngin3d.animation.AnimationGroup;
  import com.mediatek.ngin3d.animation.PropertyAnimation;
  import com.mediatek.ngin3d.presentation.PresentationEngine;
  import org.w3c.dom.Document;
  import org.w3c.dom.NodeList;
  import org.xml.sax.SAXException;
  
  import javax.xml.parsers.DocumentBuilder;
  import javax.xml.parsers.DocumentBuilderFactory;
  import javax.xml.parsers.ParserConfigurationException;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.concurrent.Callable;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.FutureTask;
  
  import static org.hamcrest.MatcherAssert.assertThat;
  import static org.hamcrest.Matchers.greaterThanOrEqualTo;
  import static org.hamcrest.Matchers.is;
  import static org.hamcrest.Matchers.lessThanOrEqualTo;
  
  public class Ngin3dTestCaseProvider {
      private static final String TAG = "Ngin3dTestCaseProvider";
      // Test criteria
      public static long ENGINE_INITIALIZATION_TIME_CRITERIA = 0;
      public static long IMAGE_LOADING_FROM_RESOURCE_TIME_CRITERIA = 0;
      public static long IMAGE_LOADING_FROM_ASSET_TIME_CRITERIA = 0;
      public static long IMAGE_LOADING_FROM_BITMAP_TIME_CRITERIA = 0;
      public static long IMAGE_LOADING_FROM_FILE_TIME_CRITERIA = 0;
      public static long SYSTEM_TEXT_CONTENT_UPDATE_TIME_CRITERIA = 0;
      public static long BITMAP_FONT_TEXT_CONTENT_UPDATE_TIME_CRITERIA = 0;
      public static long RENDER_50_ACTORS_TIME_CRITERIA = 0;
      public static long RENDER_100_ACTORS_TIME_CRITERIA = 0;
      public static long START_50_ANIMATIONS_TIME_CRITERIA = 0;
      public static long START_100_ANIMATIONS_TIME_CRITERIA = 0;
      public static long SCREEN_SHOT_TIME_CRITERIA = 0;
      public static long RENDER_25_LANDSCAPES_FPS_CRITERIA = 0;
  
      /**
       * Causes the current thread to sleep for a specified period.
       *
       * @param ms Sleep time in milliseconds
       */
      private static void sleep(int ms) {
          try {
              Thread.sleep(ms);
          } catch (InterruptedException ie) {
              // Do nothing
          }
      }
  
      public static FutureTask<Boolean> getEngineInitialTask(
          final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
  
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  engine.uninitialize();
                  Log.v(TAG, "Start engine initialize");
                  long t1 = SystemClock.uptimeMillis();
                  engine.initialize(480, 800);
                  long t2 = SystemClock.uptimeMillis() - t1;
                  Log.v(TAG, "Engine initialize costs: " + t2);
  
                  writePerformanceData(activity, "ngin3d.initialize-time.txt", t2);
                  assertThat(t2, is(lessThanOrEqualTo(ENGINE_INITIALIZATION_TIME_CRITERIA)));
                  return true;
              }
          });
      }
  
      public static FutureTask<Boolean> getImageLoadingFromResourceTask(
          final PresentationEngine engine, final Resources resources) throws ExecutionException, InterruptedException {
          return getImageLoadingFromResourceTask(engine, null, resources);
      }
  
      public static FutureTask<Boolean> getImageLoadingFromResourceTask(
          final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
          return getImageLoadingFromResourceTask(engine, activity, activity.getResources());
      }
  
      private static FutureTask<Boolean> getImageLoadingFromResourceTask(
          final PresentationEngine engine, final Activity activity,
          final Resources resources) throws ExecutionException, InterruptedException {
  
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  Log.v(TAG, "Start loading images from png resource png");
  
                  long png1 = SystemClock.uptimeMillis();
                  Image image = Image.createFromResource(resources, R.drawable.earthpng);
                  image.realize(engine);
                  long png2 = SystemClock.uptimeMillis() - png1;
                  Log.v(TAG, "Loading images from png resource costs: " + png2);
                  writePerformanceData(activity, "ngin3d.image_loading_from_png_resource-time.txt", png2);
                  assertThat(png2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_RESOURCE_TIME_CRITERIA)));
  
                  Log.v(TAG, "Start loading images from jpg resource");
                  long jpg1 = SystemClock.uptimeMillis();
                  image = Image.createFromResource(resources, R.drawable.earthjpg);
                  image.realize(engine);
                  long jpg2 = SystemClock.uptimeMillis() - jpg1;
                  Log.v(TAG, "Loading images from jpg resource costs: " + jpg2);
                  writePerformanceData(activity, "ngin3d.image_loading_from_jpg_resource-time.txt", jpg2);
                  assertThat(jpg2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_RESOURCE_TIME_CRITERIA)));
  
                  Log.v(TAG, "Start loading images from bmp resource");
                  long bmp1 = SystemClock.uptimeMillis();
                  image = Image.createFromResource(resources, R.drawable.earthbmp);
                  image.realize(engine);
                  long bmp2 = SystemClock.uptimeMillis() - bmp1;
                  Log.v(TAG, "Loading images from bmp resource costs: " + bmp2);
                  writePerformanceData(activity, "ngin3d.image_loading_from_bmp_resource-time.txt", bmp2);
                  assertThat(bmp2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_RESOURCE_TIME_CRITERIA)));
  
                  Log.v(TAG, "Start loading images from pvr resource");
                  long pvr1 = SystemClock.uptimeMillis();
                  image = Image.createFromResource(resources, R.raw.media3d_altas);
                  image.realize(engine);
                  long pvr2 = SystemClock.uptimeMillis() - pvr1;
                  Log.v(TAG, "Loading images from pvr resource costs: " + pvr2);
                  writePerformanceData(activity, "ngin3d.image_loading_from_pvr_resource-time.txt", pvr2);
                  assertThat(pvr2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_RESOURCE_TIME_CRITERIA)));
  
                  return true;
              }
          });
  
      }
  
      public static FutureTask<Boolean> getImageLoadingFromAssetTask(
          final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
  
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  Log.v(TAG, "Start loading images from png asset");
                  long png1 = SystemClock.uptimeMillis();
                  Image image = Image.createFromAsset("earth.png");
                  image.realize(engine);
                  long png2 = SystemClock.uptimeMillis() - png1;
                  Log.v(TAG, "Loading images from png asset costs: " + png2);
                  writePerformanceData(activity, "ngin3d.image_loading_from_jpg_asset-time.txt", png2);
                  assertThat(png2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_ASSET_TIME_CRITERIA)));
  
                  Log.v(TAG, "Start loading images from jpg asset");
                  long jpg1 = SystemClock.uptimeMillis();
                  image = Image.createFromAsset("earth.jpg");
                  image.realize(engine);
                  long jpg2 = SystemClock.uptimeMillis() - jpg1;
                  Log.v(TAG, "Loading images from jpg asset costs: " + jpg2);
                  writePerformanceData(activity, "ngin3d.image_loading_from_jpg_asset-time.txt", jpg2);
                  assertThat(jpg2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_ASSET_TIME_CRITERIA)));
  
                  Log.v(TAG, "Start loading images from bmp asset");
                  long bmp1 = SystemClock.uptimeMillis();
                  image = Image.createFromAsset("earth.bmp");
                  image.realize(engine);
                  long bmp2 = SystemClock.uptimeMillis() - bmp1;
                  Log.v(TAG, "Loading images from bmp asset costs: " + bmp2);
                  writePerformanceData(activity, "ngin3d.image_loading_from_bmp_asset-time.txt", bmp2);
                  assertThat(bmp2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_ASSET_TIME_CRITERIA)));
  
                  Log.v(TAG, "Start loading images from pvr asset");
                  long pvr1 = SystemClock.uptimeMillis();
                  image = Image.createFromAsset("media3d_altas.pvr");
                  image.realize(engine);
                  long pvr2 = SystemClock.uptimeMillis() - pvr1;
                  Log.v(TAG, "Loading images from pvr asset costs: " + pvr2);
                  writePerformanceData(activity, "ngin3d.image_loading_from_pvr_asset-time.txt", pvr2);
                  assertThat(pvr2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_ASSET_TIME_CRITERIA)));
                  return true;
              }
          });
      }
  
      public static FutureTask<Boolean> getImageLoadingFromBitmapTask(
          final PresentationEngine engine, final Resources resources) throws ExecutionException, InterruptedException {
          return getImageLoadingFromBitmapTask(engine, null, resources);
      }
  
      public static FutureTask<Boolean> getImageLoadingFromBitmapTask(
          final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
          return getImageLoadingFromBitmapTask(engine, activity, activity.getResources());
      }
  
      private static FutureTask<Boolean> getImageLoadingFromBitmapTask(
          final PresentationEngine engine, final Activity activity, final Resources resources)
          throws ExecutionException, InterruptedException {
  
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  Log.v(TAG, "Start loading images from bitmap");
                  long t1 = SystemClock.uptimeMillis();
                  Bitmap bitmap = BitmapFactory.decodeResource(resources, R.drawable.earth);
                  Image image = Image.createFromBitmap(bitmap);
                  image.realize(engine);
                  long t2 = SystemClock.uptimeMillis() - t1;
                  Log.v(TAG, "Loading images from bitmap costs: " + t2);
  
                  writePerformanceData(activity, "ngin3d.image_loading_from_bitmap-time.txt", t2);
                  assertThat(t2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_BITMAP_TIME_CRITERIA)));
                  return true;
              }
          });
      }
  
      public static FutureTask<Boolean> getImageLoadingFromFileTask(
          final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
  
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  Log.v(TAG, "Start loading images fro file");
                  long t1 = SystemClock.uptimeMillis();
                  Image image = Image.createFromFile("/sdcard/a3d/earth.bmp");
                  image.realize(engine);
                  long t2 = SystemClock.uptimeMillis() - t1;
                  Log.v(TAG, "Loading images fro file costs: " + t2);
  
                  writePerformanceData(activity, "ngin3d.image_loading_from_file-time.txt", t2);
                  assertThat(t2, is(lessThanOrEqualTo(IMAGE_LOADING_FROM_FILE_TIME_CRITERIA)));
                  return true;
              }
          });
      }
  
      public static FutureTask<Boolean> getUpdateSystemTextTask(
          final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  Log.v(TAG, "Start update system text");
                  long t1 = SystemClock.uptimeMillis();
                  Text sysText = new Text("MediaTek");
                  sysText.realize(engine);
                  long t2 = SystemClock.uptimeMillis() - t1;
                  Log.v(TAG, "Update system text costs: " + t2);
  
                  writePerformanceData(activity, "ngin3d.update_system_text-time.txt", t2);
                  assertThat(t2, is(lessThanOrEqualTo(SYSTEM_TEXT_CONTENT_UPDATE_TIME_CRITERIA)));
                  return true;
              }
          });
      }
  
      public static FutureTask<Boolean> getUpdateBitmapTextTask(
          final PresentationEngine engine, final Resources resources) throws ExecutionException, InterruptedException {
          return getUpdateBitmapTextTask(engine, null, resources);
      }
  
      public static FutureTask<Boolean> getUpdateBitmapTextTask(
          final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
          return getUpdateBitmapTextTask(engine, activity, activity.getResources());
      }
  
      private static FutureTask<Boolean> getUpdateBitmapTextTask(
          final PresentationEngine engine, final Activity activity, final Resources resources)
          throws ExecutionException, InterruptedException {
  
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  Log.v(TAG, "Start update bitmap text");
                  long t1 = SystemClock.uptimeMillis();
                  BitmapFont font = new BitmapFont(resources, R.raw.bmfont1, R.drawable.bmfont1);
                  BitmapText fontText = new BitmapText("MediaTek", font);
                  fontText.realize(engine);
                  long t2 = SystemClock.uptimeMillis() - t1;
                  Log.v(TAG, "Update bitmap text costs: " + t2);
  
                  writePerformanceData(activity, "ngin3d.update_bitmap_text-time.txt", t2);
                  assertThat(t2, is(lessThanOrEqualTo(BITMAP_FONT_TEXT_CONTENT_UPDATE_TIME_CRITERIA)));
                  return true;
              }
          });
      }
  
      public static FutureTask<Boolean> getRender50ActorsTask(
          final Stage stage, final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
  
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  for (int i = 0; i < 50; i++) {
                      Container c = new Container();
                      stage.add(c);
                  }
                  Log.v(TAG, "Start render 50 Actors");
                  long t1 = SystemClock.uptimeMillis();
                  stage.realize(engine);
                  long t2 = SystemClock.uptimeMillis() - t1;
                  Log.v(TAG, "Render 50 Actors costs: " + t2);
  
                  writePerformanceData(activity, "ngin3d.render_50_actors-time.txt", t2);
                  assertThat(t2, is(lessThanOrEqualTo(RENDER_50_ACTORS_TIME_CRITERIA)));
                  stage.removeAll();
                  stage.realize(engine);
                  return true;
              }
          });
      }
  
      public static FutureTask<Boolean> getRender100ActorsTask(
          final Stage stage, final PresentationEngine engine, final Activity activity) throws ExecutionException, InterruptedException {
  
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  for (int i = 0; i < 100; i++) {
                      Container c = new Container();
                      stage.add(c);
                  }
                  Log.v(TAG, "Start render 100 Actors");
                  long t1 = SystemClock.uptimeMillis();
                  stage.realize(engine);
                  long t2 = SystemClock.uptimeMillis() - t1;
                  Log.v(TAG, "Render 100 Actors costs: " + t2);
  
                  writePerformanceData(activity, "ngin3d.render_100_actors-time.txt", t2);
                  assertThat(t2, is(lessThanOrEqualTo(RENDER_100_ACTORS_TIME_CRITERIA)));
                  stage.removeAll();
                  stage.realize(engine);
                  return true;
              }
          });
      }
  
      public static FutureTask<Boolean> getStart50AnimationsTask(final Activity activity) throws ExecutionException, InterruptedException {
          return new FutureTask<Boolean>(new Callable<Boolean>() {
              public Boolean call() {
                  Empty empty1 = new Empty();
                  AnimationGroup group = new AnimationGroup();
                  Rotation start = new Rotation(0, 0, 0);
                  Rotation end = new Rotation(0, 0, 360);
  
  