summaryrefslogtreecommitdiff
path: root/indra/llimage/tests
diff options
context:
space:
mode:
authorHoward Stearns <howard.stearns@gmail.com>2022-08-30 10:20:15 -0700
committerHoward Stearns <howard.stearns@gmail.com>2022-08-30 10:20:15 -0700
commit3b70c9d49c2a963439b3811e80d24576f390552b (patch)
tree11461161da7c92d76a36d921247158230e4052f2 /indra/llimage/tests
parent6fbc733c9779454f2f1ebade494323e315917851 (diff)
parent197ac7cc2048fe4c259858f48946cd954782dfc2 (diff)
Merge branch 'DRTVWR-559' of bitbucket.org:lindenlab/viewer into initscapade
Diffstat (limited to 'indra/llimage/tests')
-rw-r--r--indra/llimage/tests/llimageworker_test.cpp99
1 files changed, 1 insertions, 98 deletions
diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp
index 9011ac615c..0a97b739b0 100644
--- a/indra/llimage/tests/llimageworker_test.cpp
+++ b/indra/llimage/tests/llimageworker_test.cpp
@@ -125,42 +125,11 @@ namespace tut
}
};
- // Test wrapper declaration : image worker
- // Note: this class is not meant to be instantiated outside an LLImageDecodeThread instance
- // but it's not a bad idea to get its public API a good shake as part of a thorough unit test set.
- // Some gotcha with the destructor though (see below).
- struct imagerequest_test
- {
- // Instance to be tested
- LLImageDecodeThread::ImageRequest* mRequest;
- bool done;
-
- // Constructor and destructor of the test wrapper
- imagerequest_test()
- {
- done = false;
-
- mRequest = new LLImageDecodeThread::ImageRequest(0, 0,
- LLQueuedThread::PRIORITY_NORMAL, 0, FALSE,
- new responder_test(&done));
- }
- ~imagerequest_test()
- {
- // We should delete the object *but*, because its destructor is protected, that cannot be
- // done from outside an LLImageDecodeThread instance... So we leak memory here... It's fine...
- //delete mRequest;
- }
- };
-
// Tut templating thingamagic: test group, object and test instance
typedef test_group<imagedecodethread_test> imagedecodethread_t;
typedef imagedecodethread_t::object imagedecodethread_object_t;
tut::imagedecodethread_t tut_imagedecodethread("LLImageDecodeThread");
- typedef test_group<imagerequest_test> imagerequest_t;
- typedef imagerequest_t::object imagerequest_object_t;
- tut::imagerequest_t tut_imagerequest("LLImageRequest");
-
// ---------------------------------------------------------------------------------------
// Test functions
// Notes:
@@ -172,64 +141,18 @@ namespace tut
// ---------------------------------------------------------------------------------------
// Test the LLImageDecodeThread interface
// ---------------------------------------------------------------------------------------
- //
- // Note on Unit Testing Queued Thread Classes
- //
- // Since methods on such a class are called on a separate loop and that we can't insert tut
- // ensure() calls in there, we exercise the class with 2 sets of tests:
- // - 1: Test as a single threaded instance: We declare the class but ask for no thread
- // to be spawned (easy with LLThreads since there's a boolean argument on the constructor
- // just for that). We can then unit test each public method like we do on a normal class.
- // - 2: Test as a threaded instance: We let the thread launch and check that its external
- // behavior is as expected (i.e. it runs, can accept a work order and processes
- // it). Typically though there's no guarantee that this exercises all the methods of the
- // class which is why we also need the previous "non threaded" set of unit tests for
- // complete coverage.
- //
- // ---------------------------------------------------------------------------------------
template<> template<>
void imagedecodethread_object_t::test<1>()
{
- // Test a *non threaded* instance of the class
- mThread = new LLImageDecodeThread(false);
- ensure("LLImageDecodeThread: non threaded constructor failed", mThread != NULL);
- // Test that we start with an empty list right at creation
- ensure("LLImageDecodeThread: non threaded init state incorrect", mThread->tut_size() == 0);
- // Insert something in the queue
- bool done = false;
- LLImageDecodeThread::handle_t decodeHandle = mThread->decodeImage(NULL, LLQueuedThread::PRIORITY_NORMAL, 0, FALSE, new responder_test(&done));
- // Verifies we got a valid handle
- ensure("LLImageDecodeThread: non threaded decodeImage(), returned handle is null", decodeHandle != 0);
- // Verifies that we do now have something in the queued list
- ensure("LLImageDecodeThread: non threaded decodeImage() insertion in threaded list failed", mThread->tut_size() == 1);
- // Trigger queue handling "manually" (on a threaded instance, this is done on the thread loop)
- S32 res = mThread->update(0);
- // Verifies that we successfully handled the list
- ensure("LLImageDecodeThread: non threaded update() list handling test failed", res == 0);
- // Verifies that the list is now empty
- ensure("LLImageDecodeThread: non threaded update() list emptying test failed", mThread->tut_size() == 0);
- }
-
- template<> template<>
- void imagedecodethread_object_t::test<2>()
- {
// Test a *threaded* instance of the class
mThread = new LLImageDecodeThread(true);
ensure("LLImageDecodeThread: threaded constructor failed", mThread != NULL);
- // Test that we start with an empty list right at creation
- ensure("LLImageDecodeThread: threaded init state incorrect", mThread->tut_size() == 0);
// Insert something in the queue
bool done = false;
- LLImageDecodeThread::handle_t decodeHandle = mThread->decodeImage(NULL, LLQueuedThread::PRIORITY_NORMAL, 0, FALSE, new responder_test(&done));
+ LLImageDecodeThread::handle_t decodeHandle = mThread->decodeImage(NULL, 0, FALSE, new responder_test(&done));
// Verifies we get back a valid handle
ensure("LLImageDecodeThread: threaded decodeImage(), returned handle is null", decodeHandle != 0);
- // Wait a little so to simulate the main thread doing something on its main loop...
- ms_sleep(500); // 500 milliseconds
- // Verifies that the responder has *not* been called yet in the meantime
- ensure("LLImageDecodeThread: responder creation failed", done == false);
- // Ask the thread to update: that means tells the queue to check itself and creates work requests
- mThread->update(1);
// Wait till the thread has time to handle the work order (though it doesn't do much per work order...)
const U32 INCREMENT_TIME = 500; // 500 milliseconds
const U32 MAX_TIME = 20 * INCREMENT_TIME; // Do the loop 20 times max, i.e. wait 10 seconds but no more
@@ -242,24 +165,4 @@ namespace tut
// Verifies that the responder has now been called
ensure("LLImageDecodeThread: threaded work unit not processed", done == true);
}
-
- // ---------------------------------------------------------------------------------------
- // Test the LLImageDecodeThread::ImageRequest interface
- // ---------------------------------------------------------------------------------------
-
- template<> template<>
- void imagerequest_object_t::test<1>()
- {
- // Test that we start with a correct request at creation
- ensure("LLImageDecodeThread::ImageRequest::ImageRequest() constructor test failed", mRequest->tut_isOK());
- bool res = mRequest->processRequest();
- // Verifies that we processed the request successfully
- ensure("LLImageDecodeThread::ImageRequest::processRequest() processing request test failed", res == true);
- // Check that we can call the finishing call safely
- try {
- mRequest->finishRequest(false);
- } catch (...) {
- fail("LLImageDecodeThread::ImageRequest::finishRequest() test failed");
- }
- }
}