Java 类org.robolectric.shadows.ShadowSystemClock 实例源码

项目:Fabric-Example-App-Android    文件:VisibilityTrackerTest.java   
@Before
public void setUp() throws Exception {
    trackedViews = new WeakHashMap<View, TrackingInfo>();
    visibilityChecker = new VisibilityChecker();
    activity = Robolectric.buildActivity(Activity.class).create().get();
    view = createViewMock(View.VISIBLE, 100, 100, 100, 100, true, true);
    view2 = createViewMock(View.VISIBLE, 100, 100, 100, 100, true, true);

    // Add a proxy listener to that makes a safe copy of the listener args.
    VisibilityTrackerListener proxyListener = new VisibilityTrackerListener() {
        @Override
        public void onVisibilityChanged(List<View> visibleViews, List<View> invisibleViews) {
            ArrayList<View> safeVisibleViews = new ArrayList<View>(visibleViews);
            ArrayList<View> safeInVisibleViews = new ArrayList<View>(invisibleViews);
            visibilityTrackerListener.onVisibilityChanged(safeVisibleViews, safeInVisibleViews);
        }
    };
    subject = new VisibilityTracker(activity, trackedViews, visibilityChecker, visibilityHandler);
    subject.setVisibilityTrackerListener(proxyListener);

    // XXX We need this to ensure that our SystemClock starts
    ShadowSystemClock.uptimeMillis();
}
项目:Fabric-Example-App-Android    文件:ImpressionTrackerTest.java   
@Before
public void setUp() {
    view = VisibilityTrackerTest.createViewMock(View.VISIBLE, 100, 100, 100, 100, true, true);
    view2 = VisibilityTrackerTest.createViewMock(View.VISIBLE, 100, 100, 100, 100, true, true);

    pollingViews = new HashMap<View, TimestampWrapper<NativeResponse>>(10);
    trackedViews = new HashMap<View, NativeResponse>(10);
    final VisibilityChecker visibilityChecker = new VisibilityChecker();
    subject = new ImpressionTracker(trackedViews, pollingViews, visibilityChecker,
            visibilityTracker, handler);

    timeStampWrapper = new TimestampWrapper<NativeResponse>(nativeResponse);

    when(nativeResponse.getImpressionMinPercentageViewed()).thenReturn(50);
    when(nativeResponse.getImpressionMinTimeViewed()).thenReturn(1000);
    when(nativeResponse2.getImpressionMinPercentageViewed()).thenReturn(50);
    when(nativeResponse2.getImpressionMinTimeViewed()).thenReturn(1000);

    // XXX We need this to ensure that our SystemClock starts
    ShadowSystemClock.uptimeMillis();
}
项目:Fabric-Example-App-Android    文件:NativeAdSourceTest.java   
@Before
public void setUp() {
    nativeAdCache = new ArrayList<TimestampWrapper<NativeResponse>>(2);
    subject = new NativeAdSource(nativeAdCache, mockReplenishCacheHandler);
    subject.setAdSourceListener(mockAdSourceListener);

    requestParameters = new RequestParameters.Builder().build();

    defaultRetryTime = 1000;
    maxRetryTime = 5*60*1000;

    // XXX We need this to ensure that our SystemClock starts
    ShadowSystemClock.uptimeMillis();
}