summaryrefslogtreecommitdiff
path: root/indra/test/test.cpp
diff options
context:
space:
mode:
authorCallum Prentice <callum@lindenlab.com>2014-06-16 13:22:19 -0700
committerCallum Prentice <callum@lindenlab.com>2014-06-16 13:22:19 -0700
commitf11dd1d8a3dc4ba9a3c23563126e11ee971e219f (patch)
treecc2798f96eafb50f42d097da7ac53e152777c402 /indra/test/test.cpp
parent483bd134162ffeef8760173aa223daee81c0f9e3 (diff)
parent977476171ddcc057d7c28b6c14ae988b8189ed75 (diff)
Merge with head of viewer-release
Diffstat (limited to 'indra/test/test.cpp')
-rwxr-xr-xindra/test/test.cpp62
1 files changed, 45 insertions, 17 deletions
diff --git a/indra/test/test.cpp b/indra/test/test.cpp
index 10f71a2843..e42374d56b 100755
--- a/indra/test/test.cpp
+++ b/indra/test/test.cpp
@@ -95,25 +95,20 @@ public:
virtual void replay(std::ostream&) {}
};
-class LLReplayLogReal: public LLReplayLog, public LLError::Recorder, public boost::noncopyable
+class RecordToTempFile : public LLError::Recorder, public boost::noncopyable
{
public:
- LLReplayLogReal(LLError::ELevel level, apr_pool_t* pool):
- mOldSettings(LLError::saveAndResetSettings()),
- mProxy(new RecorderProxy(this)),
- mTempFile("log", "", pool), // create file
- mFile(mTempFile.getName().c_str()) // open it
+ RecordToTempFile(apr_pool_t* pPool)
+ : LLError::Recorder(),
+ boost::noncopyable(),
+ mTempFile("log", "", pPool),
+ mFile(mTempFile.getName().c_str())
{
- LLError::setFatalFunction(wouldHaveCrashed);
- LLError::setDefaultLevel(level);
- LLError::addRecorder(mProxy);
}
- virtual ~LLReplayLogReal()
+ virtual ~RecordToTempFile()
{
- LLError::removeRecorder(mProxy);
- delete mProxy;
- LLError::restoreSettings(mOldSettings);
+ mFile.close();
}
virtual void recordMessage(LLError::ELevel level, const std::string& message)
@@ -121,13 +116,13 @@ public:
mFile << message << std::endl;
}
- virtual void reset()
+ void reset()
{
mFile.close();
mFile.open(mTempFile.getName().c_str());
}
- virtual void replay(std::ostream& out)
+ void replay(std::ostream& out)
{
mFile.close();
std::ifstream inf(mTempFile.getName().c_str());
@@ -139,12 +134,45 @@ public:
}
private:
- LLError::Settings* mOldSettings;
- LLError::Recorder* mProxy;
NamedTempFile mTempFile;
std::ofstream mFile;
};
+class LLReplayLogReal: public LLReplayLog, public boost::noncopyable
+{
+public:
+ LLReplayLogReal(LLError::ELevel level, apr_pool_t* pool)
+ : LLReplayLog(),
+ boost::noncopyable(),
+ mOldSettings(LLError::saveAndResetSettings()),
+ mRecorder(new RecordToTempFile(pool))
+ {
+ LLError::setFatalFunction(wouldHaveCrashed);
+ LLError::setDefaultLevel(level);
+ LLError::addRecorder(mRecorder);
+ }
+
+ virtual ~LLReplayLogReal()
+ {
+ LLError::removeRecorder(mRecorder);
+ LLError::restoreSettings(mOldSettings);
+ }
+
+ virtual void reset()
+ {
+ boost::dynamic_pointer_cast<RecordToTempFile>(mRecorder)->reset();
+ }
+
+ virtual void replay(std::ostream& out)
+ {
+ boost::dynamic_pointer_cast<RecordToTempFile>(mRecorder)->replay(out);
+ }
+
+private:
+ LLError::SettingsStoragePtr mOldSettings;
+ LLError::RecorderPtr mRecorder;
+};
+
class LLTestCallback : public tut::callback
{
public: