diff options
author | James Cook <james@lindenlab.com> | 2009-11-25 12:31:24 -0800 |
---|---|---|
committer | James Cook <james@lindenlab.com> | 2009-11-25 12:31:24 -0800 |
commit | 957055396d2ffa3a76b09c60cb9c3e1f73870cbf (patch) | |
tree | 632ecbdc0c21b0e14eb72f74faa8c04765f54489 /indra/newview/tests | |
parent | ef46d4077ca4aad322aabfe545885be136577c8a (diff) | |
parent | 59eb8a43a467ecaa5a8c2b58bf1abfb8350c0202 (diff) |
merge in changes from viewer-2-0, manually fixed conflict in llviewermessages.cpp
Diffstat (limited to 'indra/newview/tests')
-rw-r--r-- | indra/newview/tests/llmediadataclient_test.cpp | 93 |
1 files changed, 92 insertions, 1 deletions
diff --git a/indra/newview/tests/llmediadataclient_test.cpp b/indra/newview/tests/llmediadataclient_test.cpp index 217889c390..6ff2c9446e 100644 --- a/indra/newview/tests/llmediadataclient_test.cpp +++ b/indra/newview/tests/llmediadataclient_test.cpp @@ -191,6 +191,12 @@ public: virtual bool isDead() const { return mDead; } + void setDistanceFromAvatar(F64 val) + { mRep["distance"] = val; } + + void setTotalMediaInterest(F64 val) + { mRep["interest"] = val; } + int getNumBounceBacks() const { return mNumBounceBacks; } @@ -593,6 +599,91 @@ namespace tut ensure("queue empty", mdc->isEmpty()); } - + ensure("refcount of o1", o1->getNumRefs(), 1); + ensure("refcount of o2", o2->getNumRefs(), 1); + ensure("refcount of o3", o3->getNumRefs(), 1); + ensure("refcount of o4", o4->getNumRefs(), 1); + } + + ////////////////////////////////////////////////////////////////////////////////////////// + + template<> template<> + void mediadataclient_object_t::test<9>() + { + // + // Test queue re-ordering + // + LOG_TEST(9); + + LLMediaDataClientObject::ptr_t o1 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_1,"10.0","1.0")); + LLMediaDataClientObject::ptr_t o2 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_2,"20.0","1.0")); + LLMediaDataClientObject::ptr_t o3 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_3,"30.0","1.0")); + LLMediaDataClientObject::ptr_t o4 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_4,"40.0","1.0")); + { + LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD); + + // queue up all 4 objects. They should now be in the queue in + // order 1 through 4, with 4 being at the front of the queue + mdc->fetchMedia(o1); + mdc->fetchMedia(o2); + mdc->fetchMedia(o3); + mdc->fetchMedia(o4); + + int test_num = 0; + + ensure(STR(test_num) + ". is in queue 1", mdc->isInQueue(o1)); + ensure(STR(test_num) + ". is in queue 2", mdc->isInQueue(o2)); + ensure(STR(test_num) + ". is in queue 3", mdc->isInQueue(o3)); + ensure(STR(test_num) + ". is in queue 4", mdc->isInQueue(o4)); + ensure(STR(test_num) + ". post records", gPostRecords->size(), 0); + + ::pump_timers(); + ++test_num; + + // The first tick should remove the first one + ensure(STR(test_num) + ". is not in queue 1", !mdc->isInQueue(o1)); + ensure(STR(test_num) + ". is in queue 2", mdc->isInQueue(o2)); + ensure(STR(test_num) + ". is in queue 3", mdc->isInQueue(o3)); + ensure(STR(test_num) + ". is in queue 4", mdc->isInQueue(o4)); + ensure(STR(test_num) + ". post records", gPostRecords->size(), 1); + + // Now, pretend that object 4 moved relative to the avatar such + // that it is now closest + static_cast<LLMediaDataClientObjectTest*>( + static_cast<LLMediaDataClientObject*>(o4))->setDistanceFromAvatar(5.0); + + ::pump_timers(); + ++test_num; + + // The second tick should still pick off item 2, but then re-sort + // have picked off object 4 + ensure(STR(test_num) + ". is in queue 2", mdc->isInQueue(o2)); + ensure(STR(test_num) + ". is in queue 3", mdc->isInQueue(o3)); + ensure(STR(test_num) + ". is not in queue 4", !mdc->isInQueue(o4)); + ensure(STR(test_num) + ". post records", gPostRecords->size(), 2); + + ::pump_timers(); + ++test_num; + + // The third tick should pick off object 2 + ensure(STR(test_num) + ". is not in queue 2", !mdc->isInQueue(o2)); + ensure(STR(test_num) + ". is in queue 3", mdc->isInQueue(o3)); + ensure(STR(test_num) + ". post records", gPostRecords->size(), 3); + + // The fourth tick should pick off object 3 + ::pump_timers(); + ++test_num; + + ensure(STR(test_num) + ". is not in queue 3", !mdc->isInQueue(o3)); + ensure(STR(test_num) + ". post records", gPostRecords->size(), 4); + + ensure("queue empty", mdc->isEmpty()); + } + ensure("refcount of o1", o1->getNumRefs(), 1); + ensure("refcount of o2", o2->getNumRefs(), 1); + ensure("refcount of o3", o3->getNumRefs(), 1); + ensure("refcount of o4", o4->getNumRefs(), 1); + } + } |