当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionHelpers.getStaticField方法代码示例

本文整理汇总了Java中org.robolectric.util.ReflectionHelpers.getStaticField方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionHelpers.getStaticField方法的具体用法?Java ReflectionHelpers.getStaticField怎么用?Java ReflectionHelpers.getStaticField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.robolectric.util.ReflectionHelpers的用法示例。


在下文中一共展示了ReflectionHelpers.getStaticField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getType

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private String getType(Config config) {
	try {
		return ReflectionHelpers.getStaticField(config.constants(), "BUILD_TYPE");
	} catch (Throwable e) {
		return null;
	}
}
 
开发者ID:bpatrik,项目名称:mobsoft-lab,代码行数:8,代码来源:RobolectricDaggerTestRunner.java

示例2: getFlavor

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private String getFlavor(Config config) {
	try {
		return ReflectionHelpers.getStaticField(config.constants(), "FLAVOR");
	} catch (Throwable e) {
		return null;
	}
}
 
开发者ID:bpatrik,项目名称:mobsoft-lab,代码行数:8,代码来源:RobolectricDaggerTestRunner.java

示例3: getApplicationId

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private String getApplicationId(Config config) {
	try {
		return ReflectionHelpers.getStaticField(config.constants(), "APPLICATION_ID");
	} catch (Throwable e) {
		return null;
	}
}
 
开发者ID:bpatrik,项目名称:mobsoft-lab,代码行数:8,代码来源:RobolectricDaggerTestRunner.java

示例4: resetWindowManager

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@After
public void resetWindowManager() throws Exception {
    // https://github.com/robolectric/robolectric/pull/1741
    final Class<?> btclass = Class.forName("com.android.internal.os.BackgroundThread");
    Object backgroundThreadSingleton = ReflectionHelpers.getStaticField(btclass,"sInstance");
    if (backgroundThreadSingleton!=null) {
        btclass.getMethod("quit").invoke(backgroundThreadSingleton);
        ReflectionHelpers.setStaticField(btclass, "sInstance", null);
        ReflectionHelpers.setStaticField(btclass, "sHandler", null);
    }

    // https://github.com/robolectric/robolectric/issues/2068
    Class clazz = ReflectionHelpers.loadClass(getClass().getClassLoader(), "android.view.WindowManagerGlobal");
    Object instance = ReflectionHelpers.callStaticMethod(clazz, "getInstance");

    // We essentially duplicate what's in {@link WindowManagerGlobal#closeAll} with what's below.
    // The closeAll method has a bit of a bug where it's iterating through the "roots" but
    // bases the number of objects to iterate through by the number of "views." This can result in
    // an {@link java.lang.IndexOutOfBoundsException} being thrown.
    Object lock = ReflectionHelpers.getField(instance, "mLock");

    ArrayList<Object> roots = ReflectionHelpers.getField(instance, "mRoots");
    //noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (lock) {
        for (int i = 0; i < roots.size(); i++) {
            ReflectionHelpers.callInstanceMethod(instance, "removeViewLocked",
                    ReflectionHelpers.ClassParameter.from(int.class, i),
                    ReflectionHelpers.ClassParameter.from(boolean.class, false));
        }
    }

    // Views will still be held by this array. We need to clear it out to ensure
    // everything is released.
    ArraySet<View> dyingViews = ReflectionHelpers.getField(instance, "mDyingViews");
    dyingViews.clear();
}
 
开发者ID:sourceallies,项目名称:zonebeacon,代码行数:38,代码来源:ZoneBeaconRobolectricSuite.java

示例5: getType

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private static String getType(Config config) {
    try {
        return ReflectionHelpers.getStaticField(config.constants(), "BUILD_TYPE");
    } catch (Throwable e) {
        return null;
    }
}
 
开发者ID:AndruByrne,项目名称:rx-daggered-robogradler,代码行数:8,代码来源:RoboTestRunner.java

示例6: getFlavor

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private static String getFlavor(Config config) {
    try {
        return ReflectionHelpers.getStaticField(config.constants(), "FLAVOR");
    } catch (Throwable e) {
        return null;
    }
}
 
开发者ID:AndruByrne,项目名称:rx-daggered-robogradler,代码行数:8,代码来源:RoboTestRunner.java

示例7: getPackageName

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private static String getPackageName(Config config) {
    try {
        final String packageName = config.packageName();
        if (packageName != null && !packageName.isEmpty()) {
            return packageName;
        } else {
            return ReflectionHelpers.getStaticField(config.constants(), "APPLICATION_ID");
        }
    } catch (Throwable e) {
        return null;
    }
}
 
开发者ID:AndruByrne,项目名称:rx-daggered-robogradler,代码行数:13,代码来源:RoboTestRunner.java

示例8: getType

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private static String getType(final Config config) {
  try {
    return ReflectionHelpers.getStaticField(config.constants(), "BUILD_TYPE");
  } catch (Throwable e) {
    return null;
  }
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:8,代码来源:KSRobolectricGradleTestRunner.java

示例9: getFlavor

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private static String getFlavor(final Config config) {
  try {
    return ReflectionHelpers.getStaticField(config.constants(), "FLAVOR");
  } catch (Throwable e) {
    return null;
  }
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:8,代码来源:KSRobolectricGradleTestRunner.java

示例10: getPackageName

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private static String getPackageName(final Config config) {
  try {
    final String packageName = config.packageName();
    if (packageName != null && !packageName.isEmpty()) {
      return packageName;
    } else {
      return ReflectionHelpers.getStaticField(config.constants(), "APPLICATION_ID");
    }
  } catch (Throwable e) {
    return null;
  }
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:13,代码来源:KSRobolectricGradleTestRunner.java

示例11: getType

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private String getType(Config config) {
    try {
        return ReflectionHelpers.getStaticField(config.constants(), "BUILD_TYPE");
    } catch (Throwable e) {
        return null;
    }
}
 
开发者ID:maskarade,项目名称:Robolectric-Instrumentation,代码行数:8,代码来源:AndroidJUnit4.java

示例12: getFlavor

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private String getFlavor(Config config) {
    try {
        return ReflectionHelpers.getStaticField(config.constants(), "FLAVOR");
    } catch (Throwable e) {
        return null;
    }
}
 
开发者ID:maskarade,项目名称:Robolectric-Instrumentation,代码行数:8,代码来源:AndroidJUnit4.java

示例13: __constructor__

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
public void __constructor__(int id, CharSequence label) {
    if (((id & (int)ReflectionHelpers.getStaticField(AccessibilityNodeInfo.class, "ACTION_TYPE_MASK")) == 0) && Integer.bitCount(id) != 1) {
        throw new IllegalArgumentException("Invalid standard action id");
    }
    this.id = id;
    this.label = label;
}
 
开发者ID:google,项目名称:talkback,代码行数:8,代码来源:ShadowAccessibilityNodeInfo.java

示例14: getPackageName

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
private String getPackageName(Config config) {
    try {
        final String packageName = config.packageName();
        if (packageName != null && !packageName.isEmpty()) {
            return packageName;
        } else {
            return ReflectionHelpers.getStaticField(config.constants(), "APPLICATION_ID");
        }
    } catch (Throwable e) {
        return null;
    }
}
 
开发者ID:hoko,项目名称:hoko-android,代码行数:13,代码来源:HokoGradleTestRunner.java

示例15: globalTearDown

import org.robolectric.util.ReflectionHelpers; //导入方法依赖的package包/类
/**
 * Try and avoid Robolectric OOM errors
 * Probably this: https://github.com/robolectric/robolectric/issues/2068
 * Based on code from https://github.com/robolectric/robolectric/issues/1700#issuecomment-163943815
 */
@After
public void globalTearDown() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    // https://github.com/robolectric/robolectric/pull/1741
    final Class<?> btclass = Class.forName("com.android.internal.os.BackgroundThread");
    Object backgroundThreadSingleton = ReflectionHelpers.getStaticField(btclass,"sInstance");
    if (backgroundThreadSingleton!=null) {
        btclass.getMethod("quit").invoke(backgroundThreadSingleton);
        ReflectionHelpers.setStaticField(btclass, "sInstance", null);
        ReflectionHelpers.setStaticField(btclass, "sHandler", null);
    }

    // https://github.com/robolectric/robolectric/issues/2068
    Class clazz = ReflectionHelpers.loadClass(getClass().getClassLoader(), "android.view.WindowManagerGlobal");
    Object instance = ReflectionHelpers.callStaticMethod(clazz, "getInstance");

    // We essentially duplicate what's in {@link WindowManagerGlobal#closeAll} with what's below.
    // The closeAll method has a bit of a bug where it's iterating through the "roots" but
    // bases the number of objects to iterate through by the number of "views." This can result in
    // an {@link java.lang.IndexOutOfBoundsException} being thrown.
    Object lock = ReflectionHelpers.getField(instance, "mLock");

    ArrayList<Object> roots = ReflectionHelpers.getField(instance, "mRoots");
    //noinspection SynchronizationOnLocalVariableOrMethodParameter
    synchronized (lock) {
        for (int i = 0; i < roots.size(); i++) {
            ReflectionHelpers.callInstanceMethod(instance, "removeViewLocked",
                    ReflectionHelpers.ClassParameter.from(int.class, i),
                    ReflectionHelpers.ClassParameter.from(boolean.class, false));
        }
    }

    // Views will still be held by this array. We need to clear it out to ensure
    // everything is released.
    Collection<View> dyingViews = ReflectionHelpers.getField(instance, "mDyingViews");
    dyingViews.clear();
}
 
开发者ID:the-blue-alliance,项目名称:the-blue-alliance-android,代码行数:42,代码来源:BaseFragmentTest.java


注:本文中的org.robolectric.util.ReflectionHelpers.getStaticField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。