Java 类org.robolectric.SdkConfig 实例源码

项目:injectview    文件:InjectViewTestRunner.java   
@Override protected ClassLoader createRobolectricClassLoader(Setup setup, SdkConfig sdkConfig) {
  URL[] urls = getJarResolver().getLocalArtifactUrls(sdkConfig.getSdkClasspathDependencies());
  return new AsmInstrumentingClassLoader(setup, urls) {
    @Override protected byte[] getByteCode(String className) throws ClassNotFoundException {
      if (className.startsWith("com.github.stephanenicolas.injectview")) {
        try {
          CtClass dummyClass = ClassPool.getDefault().get(className);
          if (processor.shouldTransform(dummyClass)) {
            log.debug("Intercepting via InjectView " + className);
            processor.applyTransformations(dummyClass);
            byte[] bytes = dummyClass.toBytecode();
            System.out.println("Size of weaved byte code :" + bytes.length);
            FileOutputStream fileOutputStream = new FileOutputStream("/tmp/" + className + ".class");
            fileOutputStream.write(bytes);
            fileOutputStream.close();
            return bytes;
          }
        } catch (Exception e) {
          throw new RuntimeException("Impossible to transform class " + className, e);
        }
      }
      return super.getByteCode(className);
    }
  };
}
项目:simplefragment    文件:CustomRobolectricRunner.java   
@Override
protected SdkConfig pickSdkVersion(
        AndroidManifest appManifest, Config config) {
    // current Robolectric supports not the latest android SDK version
    // so we must downgrade to simulate the latest supported version.
    config = overwriteConfig(config, "emulateSdk", "18");
    return super.pickSdkVersion(appManifest, config);
}
项目:easy-a    文件:LxgLifeCycleTestRunner.java   
@Override
protected ClassLoader createRobolectricClassLoader(Setup setup, SdkConfig sdkConfig) {
  URL[] urls = getJarResolver().getLocalArtifactUrls(sdkConfig.getSdkClasspathDependencies());
  return new AsmInstrumentingClassLoader(setup, urls) {
    @Override
    protected byte[] getByteCode(String className) throws ClassNotFoundException {
      if (className.startsWith("com.github.stephanenicolas.lxglifecycle")) {
        try {
          CtClass dummyClass = ClassPool.getDefault().get(className);
          if (processor.shouldTransform(dummyClass)) {
            log.debug("Intercepting via InjectExtra " + className);
            processor.applyTransformations(dummyClass);
            byte[] bytes = dummyClass.toBytecode();
            System.out.println("Size of weaved byte code :" + bytes.length);
            FileOutputStream fileOutputStream =
                new FileOutputStream("/tmp/" + className + ".class");
            fileOutputStream.write(bytes);
            fileOutputStream.close();
            return bytes;
          }
        } catch (Exception e) {
          throw new RuntimeException("Impossible to transform class " + className, e);
        }
      }
      return super.getByteCode(className);
    }
  };
}
项目:FullRobolectricTestSample    文件:ShadowWrangler.java   
private Constructor<?> findSdkConfigConstructor(Class<?> shadowClass) {

    Constructor constructor = null;
    try {
      constructor = shadowClass.getConstructor(SdkConfig.class);
    } catch (NoSuchMethodException e) {
      // expected
    }
    return constructor;
  }
项目:injectresource    文件:InjectResourceTestRunner.java   
@Override
protected ClassLoader createRobolectricClassLoader(Setup setup, SdkConfig sdkConfig) {
  URL[] urls = getJarResolver().getLocalArtifactUrls(sdkConfig.getSdkClasspathDependencies());
  return new AsmInstrumentingClassLoader(setup, urls) {
    @Override
    protected byte[] getByteCode(String className) throws ClassNotFoundException {
      if (className.startsWith("com.github.stephanenicolas.injectresource")) {
        try {
          CtClass dummyClass = ClassPool.getDefault().get(className);
          if (processor.shouldTransform(dummyClass)) {
            log.debug("Intercepting via InjectResource " + className);
            processor.applyTransformations(dummyClass);
            byte[] bytes = dummyClass.toBytecode();
            System.out.println("Size of weaved byte code :" + bytes.length);
            FileOutputStream fileOutputStream =
                new FileOutputStream("/tmp/" + className + ".class");
            fileOutputStream.write(bytes);
            fileOutputStream.close();
            return bytes;
          }
        } catch (Exception e) {
          throw new RuntimeException("Impossible to transform class " + className, e);
        }
      }
      return super.getByteCode(className);
    }
  };
}
项目:injectextra    文件:InjectExtraTestRunner.java   
@Override
protected ClassLoader createRobolectricClassLoader(Setup setup, SdkConfig sdkConfig) {
  URL[] urls = getJarResolver().getLocalArtifactUrls(sdkConfig.getSdkClasspathDependencies());
  return new AsmInstrumentingClassLoader(setup, urls) {
    @Override
    protected byte[] getByteCode(String className) throws ClassNotFoundException {
      if (className.startsWith("com.github.stephanenicolas.injectextra")) {
        try {
          CtClass dummyClass = ClassPool.getDefault().get(className);
          if (processor.shouldTransform(dummyClass)) {
            log.debug("Intercepting via InjectExtra " + className);
            processor.applyTransformations(dummyClass);
            byte[] bytes = dummyClass.toBytecode();
            System.out.println("Size of weaved byte code :" + bytes.length);
            FileOutputStream fileOutputStream =
                new FileOutputStream("/tmp/" + className + ".class");
            fileOutputStream.write(bytes);
            fileOutputStream.close();
            return bytes;
          }
        } catch (Exception e) {
          throw new RuntimeException("Impossible to transform class " + className, e);
        }
      }
      return super.getByteCode(className);
    }
  };
}
项目:loglifecycle    文件:LogLifeCycleTestRunner.java   
@Override
protected ClassLoader createRobolectricClassLoader(Setup setup, SdkConfig sdkConfig) {
  URL[] urls = getJarResolver().getLocalArtifactUrls(sdkConfig.getSdkClasspathDependencies());
  return new AsmInstrumentingClassLoader(setup, urls) {
    @Override
    protected byte[] getByteCode(String className) throws ClassNotFoundException {
      if (className.startsWith("com.github.stephanenicolas.loglifecycle")) {
        try {
          CtClass dummyClass = ClassPool.getDefault().get(className);
          if (processor.shouldTransform(dummyClass)) {
            log.debug("Intercepting via InjectExtra " + className);
            processor.applyTransformations(dummyClass);
            byte[] bytes = dummyClass.toBytecode();
            System.out.println("Size of weaved byte code :" + bytes.length);
            FileOutputStream fileOutputStream =
                new FileOutputStream("/tmp/" + className + ".class");
            fileOutputStream.write(bytes);
            fileOutputStream.close();
            return bytes;
          }
        } catch (Exception e) {
          throw new RuntimeException("Impossible to transform class " + className, e);
        }
      }
      return super.getByteCode(className);
    }
  };
}
项目:FullRobolectricTestSample    文件:ShadowContextImpl.java   
public ShadowContextImpl(SdkConfig sdkConfig) {
  this.sdkConfig = sdkConfig;
}
项目:FullRobolectricTestSample    文件:ParallelUniverse.java   
@Override
public void setSdkConfig(SdkConfig sdkConfig) {
  this.sdkConfig = sdkConfig;
}
项目:FullRobolectricTestSample    文件:ShadowWrangler.java   
public ShadowWrangler(ShadowMap shadowMap, SdkConfig sdkConfig) {
  this.shadowMap = shadowMap;
  this.sdkConfig = sdkConfig;
}
项目:FullRobolectricTestSample    文件:ShadowWranglerUnitTest.java   
@Before
public void setup() throws Exception {
  shadowWrangler = new ShadowWrangler(ShadowMap.EMPTY, SdkConfig.getDefaultSdk());
}
项目:FullRobolectricTestSample    文件:ParallelUniverseInterface.java   
void setSdkConfig(SdkConfig sdkConfig);