summaryrefslogtreecommitdiff
path: root/indra/llxml
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2019-03-01 02:24:00 +0200
committerAndreyL ProductEngine <alihatskiy@productengine.com>2019-03-01 02:24:00 +0200
commit36cb6933e6c1ad92e1887503b74a05c32988b0f1 (patch)
tree80739997a9b1e00f93af4e273058ab52a761e36a /indra/llxml
parent599e08181544f214142703928a6d242a0ae72e60 (diff)
parent03db2ddc9c27cf842c6185826617b0da0d2b87f5 (diff)
Merged in lindenlab/viewer-release
Diffstat (limited to 'indra/llxml')
-rw-r--r--indra/llxml/tests/llcontrol_test.cpp39
1 files changed, 17 insertions, 22 deletions
diff --git a/indra/llxml/tests/llcontrol_test.cpp b/indra/llxml/tests/llcontrol_test.cpp
index 2b691ffbb1..f7e43d6def 100644
--- a/indra/llxml/tests/llcontrol_test.cpp
+++ b/indra/llxml/tests/llcontrol_test.cpp
@@ -27,43 +27,31 @@
#include "linden_common.h"
#include "llsdserialize.h"
+#include "llfile.h"
+#include "stringize.h"
#include "../llcontrol.h"
#include "../test/lltut.h"
+#include <memory>
+#include <vector>
namespace tut
{
-
struct control_group
{
- LLControlGroup* mCG;
+ std::unique_ptr<LLControlGroup> mCG;
std::string mTestConfigDir;
std::string mTestConfigFile;
+ std::vector<std::string> mCleanups;
static bool mListenerFired;
control_group()
{
- mCG = new LLControlGroup("foo");
+ mCG.reset(new LLControlGroup("foo"));
LLUUID random;
random.generate();
// generate temp dir
- std::ostringstream oStr;
-
-#ifdef LL_WINDOWS
- char* tmp_dir = getenv("TMP");
- if(tmp_dir)
- {
- oStr << tmp_dir << "/llcontrol-test-" << random << "/";
- }
- else
- {
- oStr << "c:/tmp/llcontrol-test-" << random << "/";
- }
-#else
- oStr << "/tmp/llcontrol-test-" << random << "/";
-#endif
-
- mTestConfigDir = oStr.str();
+ mTestConfigDir = STRINGIZE(LLFile::tmpdir() << "llcontrol-test-" << random << "/");
mTestConfigFile = mTestConfigDir + "settings.xml";
LLFile::mkdir(mTestConfigDir);
LLSD config;
@@ -76,7 +64,12 @@ namespace tut
~control_group()
{
//Remove test files
- delete mCG;
+ for (auto filename : mCleanups)
+ {
+ LLFile::remove(filename);
+ }
+ LLFile::remove(mTestConfigFile);
+ LLFile::rmdir(mTestConfigDir);
}
void writeSettingsFile(const LLSD& config)
{
@@ -118,6 +111,7 @@ namespace tut
ensure_equals("value of changed setting", mCG->getU32("TestSetting"), 13);
LLControlGroup test_cg("foo2");
std::string temp_test_file = (mTestConfigDir + "setting_llsd_temp.xml");
+ mCleanups.push_back(temp_test_file);
mCG->saveToFile(temp_test_file.c_str(), TRUE);
results = test_cg.loadFromFile(temp_test_file.c_str());
ensure("number of changed settings loaded", (results == 1));
@@ -139,6 +133,7 @@ namespace tut
ensure_equals("value of changed setting", mCG->getU32("TestSetting"), 13);
LLControlGroup test_cg("foo3");
std::string temp_test_file = (mTestConfigDir + "setting_llsd_persist_temp.xml");
+ mCleanups.push_back(temp_test_file);
mCG->saveToFile(temp_test_file.c_str(), TRUE);
results = test_cg.loadFromFile(temp_test_file.c_str());
//If we haven't changed any settings, then we shouldn't have any settings to load
@@ -153,7 +148,7 @@ namespace tut
ensure("number of settings", (results == 1));
mCG->getControl("TestSetting")->getSignal()->connect(boost::bind(&this->handleListenerTest));
mCG->setU32("TestSetting", 13);
- ensure("listener fired on changed setting", mListenerFired);
+ ensure("listener fired on changed setting", mListenerFired);
}
}