Пример #1
0
void mediadataclient_object_t::test<1>()
{
    //
    // Test fetchMedia()
    //
    LOG_TEST(1);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(DATA);
    int num_refs_start = o->getNumRefs();
    {
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD);
        mdc->fetchMedia(o);

        // Make sure no posts happened yet...
        ensure("post records", gPostRecords->size(), 0);

        ::pump_timers();

        ensure("post records", gPostRecords->size(), 1);
        ensure("post url", (*gPostRecords)[0]["url"], FAKE_OBJECT_MEDIA_CAP_URL);
        ensure("post GET", (*gPostRecords)[0]["body"]["verb"], "GET");
        ensure("post object id", (*gPostRecords)[0]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID));
        ensure("queue empty", mdc->isEmpty());
    }

    // Make sure everyone's destroyed properly
    ensure("REF COUNT", o->getNumRefs(), num_refs_start);
}
Пример #2
0
void mediadataclient_object_t::test<5>()
{
    //
    // Test fetchMedia() getting a 503 error
    //
    LOG_TEST(5);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(
        _DATA_URLS(VALID_OBJECT_ID,
                   "1.0","true",
                   FAKE_OBJECT_MEDIA_CAP_URL_503,
                   FAKE_OBJECT_MEDIA_NAVIGATE_CAP_URL));
    int num_refs_start = o->getNumRefs();
    {
        const int NUM_RETRIES = 5;
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD,NUM_RETRIES);

        // This should generate a retry
        mdc->fetchMedia(o);

        // Make sure no posts happened yet...
        ensure("post records before", gPostRecords->size(), 0);

        // Once, causes retry
        // Second, fires retry timer
        // Third, fires queue timer again
        for (int i=0; i<NUM_RETRIES; ++i)
        {
            ::pump_timers();  // Should pump (fire) the queue timer, causing a retry timer to be scheduled
            // XXX This ensure is not guaranteed, because scheduling a timer might actually get it pumped in the same loop
            //ensure("post records " + STR(i), gPostRecords->size(), i+1);
            ::pump_timers();  // Should pump (fire) the retry timer, scheduling the queue timer
        }

        // Do some extra pumps to make sure no other timer work occurs.
        ::pump_timers();
        ::pump_timers();
        ::pump_timers();

        // Make sure there were 2 posts
        ensure("post records after", gPostRecords->size(), NUM_RETRIES);
        for (int i=0; i<NUM_RETRIES; ++i)
        {
            ensure("[" + STR(i) + "] post url", (*gPostRecords)[i]["url"], FAKE_OBJECT_MEDIA_CAP_URL_503);
            ensure("[" + STR(i) + "] post GET", (*gPostRecords)[i]["body"]["verb"], "GET");
            ensure("[" + STR(i) + "] post object id", (*gPostRecords)[i]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID));
        }
        ensure("queue empty", mdc->isEmpty());
    }

    // Make sure everyone's destroyed properly
    ensure("REF COUNT", o->getNumRefs(), num_refs_start);
}
Пример #3
0
void mediadataclient_object_t::test<6>()
{
    //
    // Test navigate() with a bounce back
    //
    LOG_TEST(6);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(
        _DATA_URLS(VALID_OBJECT_ID,
                   "1.0","true",
                   FAKE_OBJECT_MEDIA_CAP_URL,
                   FAKE_OBJECT_MEDIA_NAVIGATE_CAP_URL_ERROR));
    {
        LLPointer<LLObjectMediaNavigateClient> mdc = new LLObjectMediaNavigateClient(NO_PERIOD,NO_PERIOD);
        const char *TEST_URL = "http://example.com";
        mdc->navigate(o, 0, TEST_URL);
        ensure("post records", gPostRecords->size(), 0);
        ::pump_timers();

        // ensure bounce back
        ensure("bounce back",
               dynamic_cast<LLMediaDataClientObjectTest*>(static_cast<LLMediaDataClientObject*>(o))->getNumBounceBacks(),
               1);

        ensure("post records", gPostRecords->size(), 1);
        ensure("post url", (*gPostRecords)[0]["url"], FAKE_OBJECT_MEDIA_NAVIGATE_CAP_URL_ERROR);
        ensure("post object id", (*gPostRecords)[0]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID));
        ensure("post data", (*gPostRecords)[0]["body"][LLTextureEntry::TEXTURE_INDEX_KEY], 0);
        ensure("post data", (*gPostRecords)[0]["body"][LLMediaEntry::CURRENT_URL_KEY], TEST_URL);
        ensure("queue empty", mdc->isEmpty());
    }
    ensure("REF COUNT", o->getNumRefs(), 1);
}
Пример #4
0
void mediadataclient_object_t::test<2>()
{
    //
    // Test updateMedia()
    //
    LOG_TEST(2);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(DATA);
    {
        // queue time w/ no delay ensures that ::pump_timers() will hit the tick()
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD);
        mdc->updateMedia(o);
        ensure("post records", gPostRecords->size(), 0);
        ::pump_timers();

        ensure("post records", gPostRecords->size(), 1);
        ensure("post url", (*gPostRecords)[0]["url"], FAKE_OBJECT_MEDIA_CAP_URL);
        ensure("post UPDATE", (*gPostRecords)[0]["body"]["verb"], "UPDATE");
        ensure("post object id", (*gPostRecords)[0]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID));
        ensure_llsd("post data llsd", (*gPostRecords)[0]["body"][LLTextureEntry::OBJECT_MEDIA_DATA_KEY],
                    "<llsd>" MEDIA_DATA "</llsd>");
        ensure("queue empty", mdc->isEmpty());
    }

    ensure("REF COUNT", o->getNumRefs(), 1);
}
Пример #5
0
void mediadataclient_object_t::test<11>()
{
    //
    // Test LLMediaDataClient's destructor
    //
    LOG_TEST(11);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(DATA);
    int num_refs_start = o->getNumRefs();
    {
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD);
        mdc->fetchMedia(o);
        // must tick enough times to clear refcount of mdc
        ::pump_timers();
    }
    // Make sure everyone's destroyed properly
    ensure("REF COUNT", o->getNumRefs(), num_refs_start);
}