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); }
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); }
void LLMediaDataClient::request(const LLMediaDataClientObject::ptr_t &object, const LLSD &payload) { if (object.isNull() || ! object->hasMedia()) return; // Push the object on the queue enqueue(new Request(getCapabilityName(), payload, object, this)); }
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); }
bool LLMediaDataClient::isInQueue(const LLMediaDataClientObject::ptr_t &object) { if(find_matching_request(mQueue, object->getID()) != mQueue.end()) return true; if(find_matching_request(mUnQueuedRequests, object->getID()) != mUnQueuedRequests.end()) return true; return false; }
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); }
void LLObjectMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr_t &object) { // First, call parent impl. LLMediaDataClient::removeFromQueue(object); remove_matching_requests(mRoundRobinQueue, object->getID()); }
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); }
bool LLObjectMediaDataClient::isInQueue(const LLMediaDataClientObject::ptr_t &object) { // First, call parent impl. if(LLMediaDataClient::isInQueue(object)) return true; if(find_matching_request(mRoundRobinQueue, object->getID()) != mRoundRobinQueue.end()) return true; return false; }
//static LLMediaDataClient::request_ptr_t LLMediaDataClient::findOrRemove(request_queue_t &queue, const LLMediaDataClientObject::ptr_t &obj, bool remove, LLMediaDataClient::Request::Type type) { request_ptr_t result; request_queue_t::iterator iter = queue.begin(); request_queue_t::iterator end = queue.end(); while (iter != end) { if (obj->getID() == (*iter)->getObject()->getID() && (type == LLMediaDataClient::Request::ANY || type == (*iter)->getType())) { result = *iter; if (remove) queue.erase(iter); break; } iter++; } return result; }
void LLMediaDataClient::removeFromQueue(const LLMediaDataClientObject::ptr_t &object) { LL_DEBUGS("LLMediaDataClient") << "removing requests matching ID " << object->getID() << LL_ENDL; remove_matching_requests(mQueue, object->getID()); remove_matching_requests(mUnQueuedRequests, object->getID()); }