static boolean isValid(NativeAdResponse response) { if (response != null && !response.hasExpired()) { return true; } Clog.d(Clog.nativeLogTag, "NativeAdResponse is not valid"); return false; } }
@Test public void requestNativeSuccess() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.anNative())); adRequest.loadAd(); Lock.pause(1000); waitForTasks(); Robolectric.flushForegroundThreadScheduler(); Robolectric.flushBackgroundThreadScheduler(); waitForTasks(); Robolectric.getBackgroundThreadScheduler().advanceToNextPostedRunnable(); Robolectric.getForegroundThreadScheduler().advanceToNextPostedRunnable(); //Robolectric.flushForegroundThreadScheduler(); //Lock.pause(2000); assertAdLoaded(true); nativeAdView = DummyView.getDummyView(activity); attachToWindow(nativeAdView); NativeAdSDK.registerTracking(response, nativeAdView, this); //@TODO can do perform Click and Test but issue with roboelectric https://github.com/robolectric/robolectric/issues/2372 //Shadows.shadowOf(nativeAdView).checkedPerformClick(); //Robolectric.getForegroundThreadScheduler().advanceToNextPostedRunnable(); //assertTrue(adWasClicked); assertFalse(response.hasExpired()); }