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


Java Robolectric.flushForegroundThreadScheduler方法代码示例

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


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

示例1: testNoBidForUnregisteredAd

import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Test
public void testNoBidForUnregisteredAd() throws Exception {
    // Cache a bid
    ArrayList<BidResponse> bids = new ArrayList<>();
    BidResponse testBid = new BidResponse(TestConstants.cpm3, ServerResponses.ut_url);
    testBid.addCustomKeyword("pb_cache_id", "14y3834yq5iu5");
    testBid.addCustomKeyword("hb_pb", "0.54");
    testBid.addCustomKeyword("hb_bidder", "mock_bidder");
    bids.add(testBid);
    MockServer.addTestSetup(TestConstants.configID1, bids);
    ArrayList<AdUnit> adUnits = new ArrayList<AdUnit>();
    adUnits.add(adUnit1);
    Prebid.init(activity.getApplicationContext(), adUnits, TestConstants.accountId);
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    ArrayList<BidResponse> bidForAdUnit = BidManager.getWinningBids(adUnit1.getCode());
    assertNotNull(bidForAdUnit);
    BannerAdUnit randomAdUnit = new BannerAdUnit("Random", TestConstants.configID1);
    bidForAdUnit = BidManager.getWinningBids(randomAdUnit.getCode());
    assertNull(bidForAdUnit);
}
 
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:22,代码来源:BidManagerTest.java

示例2: setup

import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Before
    public void setup() {
        activity = Robolectric.buildActivity(MockMainActivity.class).create().get();
//        activity = Robolectric.setupActivity(MockMainActivity.class);
        shadowOf(activity).grantPermissions("android.permission.INTERNET");
        server = new MockWebServer();
        try {
            server.start();
            successfulMockServerStarted = true;
        } catch (IOException e) {
            e.printStackTrace();
        }
        FakeHttp.getFakeHttpLayer().interceptHttpRequests(true);
        FakeHttp.getFakeHttpLayer().interceptResponseContent(true);
        bgScheduler = Robolectric.getBackgroundThreadScheduler();
        uiScheduler = Robolectric.getForegroundThreadScheduler();
        Robolectric.flushBackgroundThreadScheduler();
        Robolectric.flushForegroundThreadScheduler();
        bgScheduler.pause();
        uiScheduler.pause();
    }
 
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:22,代码来源:BaseSetup.java

示例3: testCachingOfBidsInit

import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Test
public void testCachingOfBidsInit() throws Exception {
    // Check that at the beginning response for identifier is empty
    ArrayList<BidResponse> nullBidResponseForAdSlot1 = BidManager.getWinningBids(adUnit1.getCode());
    assertNull(nullBidResponseForAdSlot1);
    ArrayList<BidResponse> nullBidResponseForAdSlot2 = BidManager.getWinningBids(adUnit2.getCode());
    assertNull(nullBidResponseForAdSlot2);
    // Start running auctions,should get immediate response
    ArrayList<AdUnit> adUnits = new ArrayList<AdUnit>();
    adUnits.add(adUnit1);
    adUnits.add(adUnit2);
    // Set up test responses
    ArrayList<BidResponse> bids = new ArrayList<>();
    BidResponse testBid = new BidResponse(TestConstants.cpm1, ServerResponses.ut_url);
    bids.add(testBid);
    ArrayList<BidResponse> bids2 = new ArrayList<>();
    BidResponse testBid2 = new BidResponse(TestConstants.cpm2, ServerResponses.ut_url);
    bids2.add(testBid2);
    MockServer.addTestSetup(TestConstants.configID1, bids);
    MockServer.addTestSetup(TestConstants.configID2, bids2);
    // Init prebid with ad units
    Prebid.init(activity.getApplicationContext(), adUnits, TestConstants.accountId);
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();

    // Check a response is cached
    ArrayList<BidResponse> bidForAdSlot1 = BidManager.getWinningBids(adUnit1.getCode());
    assertNotNull(bidForAdSlot1);
    assertEquals(TestConstants.cpm1, bidForAdSlot1.get(0).getCpm());

    ArrayList<BidResponse> bidForAdSlot2 = BidManager.getWinningBids(adUnit2.getCode());
    assertNotNull(bidForAdSlot2);
    assertEquals(TestConstants.cpm2, bidForAdSlot2.get(0).getCpm());
}
 
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:35,代码来源:BidManagerTest.java

示例4: testStartNewAuction

import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Test
public void testStartNewAuction() throws Exception {
    // Cache a bid
    ArrayList<AdUnit> adUnits = new ArrayList<AdUnit>();
    adUnits.add(adUnit1);
    Prebid.init(activity.getApplicationContext(), adUnits, TestConstants.accountId);

    // Here is where we call start new Auction.
    ArrayList<BidResponse> bids = new ArrayList<>();
    bids.add(new BidResponse(TestConstants.cpm3, ServerResponses.ut_url));
    MockServer.addTestSetup(TestConstants.configID1, bids);
    BidManager.startNewAuction(activity.getApplicationContext(), adUnit1);
    // Run tasks
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    ArrayList<BidResponse> bidForAdSlot_1 = BidManager.getWinningBids(adUnit1.getCode());
    assertNotNull(bidForAdSlot_1);
    assertEquals(TestConstants.cpm3, bidForAdSlot_1.get(0).getCpm());

    MockServer.clearSetUps();
    ArrayList<BidResponse> bids2 = new ArrayList<>();
    bids2.add(new BidResponse(TestConstants.cpm2, ServerResponses.ut_url));
    MockServer.addTestSetup(TestConstants.configID1, bids2);
    BidManager.startNewAuction(activity.getApplicationContext(), adUnit1);
    // Run tasks
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    bidForAdSlot_1 = BidManager.getWinningBids(adUnit1.getCode());
    assertNotNull(bidForAdSlot_1);
    assertEquals(TestConstants.cpm2, bidForAdSlot_1.get(0).getCpm());
}
 
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:32,代码来源:BidManagerTest.java

示例5: testKeywordString

import org.robolectric.Robolectric; //导入方法依赖的package包/类
@Test
public void testKeywordString() throws Exception {
    //Registering a list of adUnits test
    ArrayList<BidResponse> bids = new ArrayList<>();
    BidResponse testBid = new BidResponse(TestConstants.cpm3, ServerResponses.ut_url);
    testBid.addCustomKeyword("pb_cache_id", "14y3834yq5iu5");
    testBid.addCustomKeyword("hb_pb", "0.54");
    testBid.addCustomKeyword("hb_bidder", "mock_bidder");
    bids.add(testBid);
    MockServer.addTestSetup(TestConstants.configID1, bids);
    ArrayList<AdUnit> adUnits = new ArrayList<AdUnit>();
    adUnits.add(adUnit1);
    Prebid.init(activity.getApplicationContext(), adUnits, TestConstants.accountId);
    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();
    ArrayList<Pair<String, String>> keywords = BidManager.getKeywordsForAdUnit(adUnit1.getCode(), activity.getApplicationContext());
    for (Pair keywordPair : keywords) {
        if ("pb_cache_id".equals(keywordPair.first)) {
            assertEquals("14y3834yq5iu5", keywordPair.second);
        } else if ("hb_pb".equals(keywordPair.first)) {
            assertEquals("0.54", keywordPair.second);
        } else if ("hb_bidder".equals(keywordPair.first)) {
            assertEquals("mock_bidder", keywordPair.second);
        }
    }
}
 
开发者ID:prebid,项目名称:prebid-mobile-android,代码行数:27,代码来源:BidManagerTest.java


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