diff options
author | Roxanne Skelly <roxie@lindenlab.com> | 2009-07-08 00:45:17 +0000 |
---|---|---|
committer | Roxanne Skelly <roxie@lindenlab.com> | 2009-07-08 00:45:17 +0000 |
commit | 9e89819d55a3b6ee7fc56f3efb36f273e4e05c83 (patch) | |
tree | 1585010af9cafd82202c22ef9cb0db4967c74394 /indra/newview/tests/llviewernetwork_test.cpp | |
parent | fe71dd340ab396b93bde45df438041af5d85fd47 (diff) |
DEV-34822 - merge with 1.23
certificate notification code
-r 118191
ignore-dead-branch
Diffstat (limited to 'indra/newview/tests/llviewernetwork_test.cpp')
-rw-r--r-- | indra/newview/tests/llviewernetwork_test.cpp | 224 |
1 files changed, 132 insertions, 92 deletions
diff --git a/indra/newview/tests/llviewernetwork_test.cpp b/indra/newview/tests/llviewernetwork_test.cpp index c7a6b2ad15..f341482d6f 100644 --- a/indra/newview/tests/llviewernetwork_test.cpp +++ b/indra/newview/tests/llviewernetwork_test.cpp @@ -37,7 +37,51 @@ #include "../../llxml/llcontrol.h" #include "llfile.h" -LLControlGroup gSavedSettings; +//---------------------------------------------------------------------------- +// Mock objects for the dependencies of the code we're testing + +LLControlGroup::LLControlGroup(const std::string& name) +: LLInstanceTracker<LLControlGroup, std::string>(name) {} +LLControlGroup::~LLControlGroup() {} +BOOL LLControlGroup::declareString(const std::string& name, + const std::string& initial_val, + const std::string& comment, + BOOL persist) {return TRUE;} +void LLControlGroup::setString(const std::string& name, const std::string& val){} + +std::string gCmdLineLoginURI; +std::string gCmdLineGridChoice; +std::string gCmdLineHelperURI; +std::string gLoginPage; +std::string gCurrentGrid; +std::string LLControlGroup::getString(const std::string& name) +{ + if (name == "CmdLineGridChoice") + return gCmdLineGridChoice; + else if (name == "CmdLineHelperURI") + return gCmdLineHelperURI; + else if (name == "LoginPage") + return gLoginPage; + else if (name == "CurrentGrid") + return gCurrentGrid; + return ""; +} + +LLSD LLControlGroup::getLLSD(const std::string& name) +{ + if (name == "CmdLineLoginURI") + { + if(!gCmdLineLoginURI.empty()) + { + return LLSD(gCmdLineLoginURI); + } + } + return LLSD(); +} + + +LLControlGroup gSavedSettings("test"); + const char *gSampleGridFile = "<llsd><map>" "<key>grid1</key><map>" " <key>favorite</key><integer>1</integer>" @@ -68,13 +112,12 @@ namespace tut { viewerNetworkTest() { - gSavedSettings.cleanup(); - gSavedSettings.cleanup(); - gSavedSettings.declareString("CmdLineGridChoice", "", "", FALSE); - gSavedSettings.declareString("CmdLineHelperURI", "", "", FALSE); - gSavedSettings.declareString("LoginPage", "", "", FALSE); - gSavedSettings.declareString("CurrentGrid", "", "", FALSE); - gSavedSettings.declareLLSD("CmdLineLoginURI", LLSD(), "", FALSE); + LLFile::remove("grid_test.xml"); + gCmdLineLoginURI.clear(); + gCmdLineGridChoice.clear(); + gCmdLineHelperURI.clear(); + gLoginPage.clear(); + gCurrentGrid.clear(); } ~viewerNetworkTest() { @@ -95,20 +138,25 @@ namespace tut void viewerNetworkTestObject::test<1>() { - LLGridManager manager("grid_test.xml"); + LLGridManager *manager = LLGridManager::getInstance(); + // grid file doesn't exist + manager->initialize("grid_test.xml"); // validate that some of the defaults are available. - std::map<std::string, std::string> known_grids = manager.getKnownGrids(); + std::map<std::string, std::string> known_grids = manager->getKnownGrids(); #ifndef LL_RELEASE_FOR_DOWNLOAD ensure_equals("Known grids is a string-string map of size 18", known_grids.size(), 18); + ensure_equals("Agni has the right name and label", + known_grids[std::string("util.agni.lindenlab.com")], std::string("Agni")); #else // LL_RELEASE_FOR_DOWNLOAD - ensure_equals("Known grids is a string-string map of size 18", known_grids.size(), 2); + ensure_equals("Known grids is a string-string map of size 2", known_grids.size(), 2); + ensure_equals("Agni has the right name and label", + known_grids[std::string("util.agni.lindenlab.com")], std::string("Secondlife.com")); #endif // LL_RELEASE_FOR_DOWNLOAD - ensure_equals("Agni has the right name and label", - known_grids[std::string("util.agni.lindenlab.com")], std::string("Agni")); + ensure_equals("None exists", known_grids[""], "None"); - LLSD grid = manager.getGridInfo("util.agni.lindenlab.com"); + LLSD grid = LLGridManager::getInstance()->getGridInfo("util.agni.lindenlab.com"); ensure("Grid info for agni is a map", grid.isMap()); ensure_equals("name is correct for agni", grid[GRID_NAME_VALUE].asString(), std::string("util.agni.lindenlab.com")); @@ -130,8 +178,8 @@ namespace tut ensure_equals("Agni login page is correct", grid[GRID_LOGIN_PAGE_VALUE].asString(), std::string("http://secondlife.com/app/login/")); - ensure("Agni is not a favorite", - !grid.has(GRID_IS_FAVORITE_VALUE)); + ensure("Agni is a favorite", + grid.has(GRID_IS_FAVORITE_VALUE)); ensure("Agni is a system grid", grid.has(GRID_IS_SYSTEM_GRID_VALUE)); ensure("Grid file wasn't greated as it wasn't saved", @@ -146,20 +194,25 @@ namespace tut gridfile << gSampleGridFile; gridfile.close(); - LLGridManager manager("grid_test.xml"); - std::map<std::string, std::string> known_grids = manager.getKnownGrids(); + LLGridManager::getInstance()->initialize("grid_test.xml"); + std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); #ifndef LL_RELEASE_FOR_DOWNLOAD ensure_equals("adding a grid via a grid file increases known grid size", known_grids.size(), 19); + ensure_equals("Agni is still there after we've added a grid via a grid file", + known_grids["util.agni.lindenlab.com"], std::string("Agni")); + #else ensure_equals("adding a grid via a grid file increases known grid size", known_grids.size(), 3); -#endif ensure_equals("Agni is still there after we've added a grid via a grid file", - known_grids["util.agni.lindenlab.com"], std::string("Agni")); + known_grids["util.agni.lindenlab.com"], std::string("Secondlife.com")); + +#endif + // assure Agni doesn't get overwritten - LLSD grid = manager.getGridInfo("util.agni.lindenlab.com"); + LLSD grid = LLGridManager::getInstance()->getGridInfo("util.agni.lindenlab.com"); #ifndef LL_RELEASE_FOR_DOWNLOAD ensure_equals("Agni grid label was not modified by grid file", grid[GRID_LABEL_VALUE].asString(), std::string("Agni")); @@ -181,14 +234,14 @@ namespace tut ensure_equals("Agni login page the same after grid file", grid[GRID_LOGIN_PAGE_VALUE].asString(), std::string("http://secondlife.com/app/login/")); - ensure("Agni still not favorite after grid file", - !grid.has(GRID_IS_FAVORITE_VALUE)); + ensure("Agni still a favorite after grid file", + grid.has(GRID_IS_FAVORITE_VALUE)); ensure("Agni system grid still set after grid file", grid.has(GRID_IS_SYSTEM_GRID_VALUE)); ensure_equals("Grid file adds to name<->label map", known_grids["grid1"], std::string("mylabel")); - grid = manager.getGridInfo("grid1"); + grid = LLGridManager::getInstance()->getGridInfo("grid1"); ensure_equals("grid file grid name is set", grid[GRID_NAME_VALUE].asString(), std::string("grid1")); ensure_equals("grid file label is set", @@ -217,22 +270,16 @@ namespace tut template<> template<> void viewerNetworkTestObject::test<3>() { - LLSD loginURI = std::string("https://my.login.uri/cgi-bin/login.cgi"); - gSavedSettings.setLLSD("CmdLineLoginURI", loginURI); - LLGridManager manager("grid_test.xml"); + gCmdLineLoginURI = "https://my.login.uri/cgi-bin/login.cgi"; + LLGridManager::getInstance()->initialize("grid_test.xml"); // with single login uri specified. - std::map<std::string, std::string> known_grids = manager.getKnownGrids(); -#ifndef LL_RELEASE_FOR_DOWNLOAD + std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); ensure_equals("adding a command line grid increases known grid size", known_grids.size(), 19); -#else - ensure_equals("adding a command line grid increases known grid size", - known_grids.size(), 3); -#endif ensure_equals("Command line grid is added to the list of grids", known_grids["my.login.uri"], std::string("my.login.uri")); - LLSD grid = manager.getGridInfo("my.login.uri"); + LLSD grid = LLGridManager::getInstance()->getGridInfo("my.login.uri"); ensure_equals("Command line grid name is set", grid[GRID_NAME_VALUE].asString(), std::string("my.login.uri")); ensure_equals("Command line grid label is set", @@ -254,19 +301,14 @@ namespace tut !grid.has(GRID_IS_SYSTEM_GRID_VALUE)); // now try a command line with a custom grid identifier - gSavedSettings.setString("CmdLineGridChoice", "mycustomgridchoice"); - manager = LLGridManager("grid_test.xml"); - known_grids = manager.getKnownGrids(); -#ifndef LL_RELEASE_FOR_DOWNLOAD + gCmdLineGridChoice = "mycustomgridchoice"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + known_grids = LLGridManager::getInstance()->getKnownGrids(); ensure_equals("adding a command line grid with custom name increases known grid size", known_grids.size(), 19); -#else - ensure_equals("adding a command line grid with custom name inceases known grid size", - known_grids.size(), 3); -#endif ensure_equals("Custom Command line grid is added to the list of grids", known_grids["mycustomgridchoice"], std::string("mycustomgridchoice")); - grid = manager.getGridInfo("mycustomgridchoice"); + grid = LLGridManager::getInstance()->getGridInfo("mycustomgridchoice"); ensure_equals("Custom Command line grid name is set", grid[GRID_NAME_VALUE].asString(), std::string("mycustomgridchoice")); ensure_equals("Custom Command line grid label is set", @@ -278,16 +320,16 @@ namespace tut std::string("https://my.login.uri/cgi-bin/login.cgi")); // add a helperuri - gSavedSettings.setString("CmdLineHelperURI", "myhelperuri"); - manager = LLGridManager("grid_test.xml"); - grid = manager.getGridInfo("mycustomgridchoice"); + gCmdLineHelperURI = "myhelperuri"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + grid = LLGridManager::getInstance()->getGridInfo("mycustomgridchoice"); ensure_equals("Validate command line helper uri", grid[GRID_HELPER_URI_VALUE].asString(), std::string("myhelperuri")); // add a login page - gSavedSettings.setString("LoginPage", "myloginpage"); - manager = LLGridManager("grid_test.xml"); - grid = manager.getGridInfo("mycustomgridchoice"); + gLoginPage = "myloginpage"; + LLGridManager::getInstance()->initialize("grid_test.xml"); + grid = LLGridManager::getInstance()->getGridInfo("mycustomgridchoice"); ensure_equals("Validate command line helper uri", grid[GRID_LOGIN_PAGE_VALUE].asString(), std::string("myloginpage")); } @@ -301,36 +343,34 @@ namespace tut // adding a grid with simply a name will populate the values. grid[GRID_NAME_VALUE] = "myaddedgrid"; - loginURI.append(std::string("https://my.login.uri/cgi-bin/login.cgi")); - gSavedSettings.setLLSD("CmdLineLoginURI", loginURI); - LLGridManager manager("grid_test.xml"); - manager.addGrid(grid); - manager.setGridChoice("util.agni.lindenlab.com"); + LLGridManager::getInstance()->initialize("grid_test.xml"); + LLGridManager::getInstance()->addGrid(grid); + LLGridManager::getInstance()->setGridChoice("util.agni.lindenlab.com"); #ifndef LL_RELEASE_FOR_DOWNLOAD - ensure_equals("getGridLabel", manager.getGridLabel(), std::string("Agni")); + ensure_equals("getGridLabel", LLGridManager::getInstance()->getGridLabel(), std::string("Agni")); #else // LL_RELEASE_FOR_DOWNLOAD - ensure_equals("getGridLabel", manager.getGridLabel(), std::string("Secondlife.com")); + ensure_equals("getGridLabel", LLGridManager::getInstance()->getGridLabel(), std::string("Secondlife.com")); #endif // LL_RELEASE_FOR_DOWNLOAD - ensure_equals("getGridName", manager.getGridName(), + ensure_equals("getGridName", LLGridManager::getInstance()->getGridName(), std::string("util.agni.lindenlab.com")); - ensure_equals("getHelperURI", manager.getHelperURI(), + ensure_equals("getHelperURI", LLGridManager::getInstance()->getHelperURI(), std::string("https://secondlife.com/helpers/")); - ensure_equals("getLoginPage", manager.getLoginPage(), + ensure_equals("getLoginPage", LLGridManager::getInstance()->getLoginPage(), std::string("http://secondlife.com/app/login/")); - ensure_equals("getLoginPage2", manager.getLoginPage("util.agni.lindenlab.com"), + ensure_equals("getLoginPage2", LLGridManager::getInstance()->getLoginPage("util.agni.lindenlab.com"), std::string("http://secondlife.com/app/login/")); - ensure("Is Agni a production grid", manager.isInProductionGrid()); + ensure("Is Agni a production grid", LLGridManager::getInstance()->isInProductionGrid()); std::vector<std::string> uris; - manager.getLoginURIs(uris); + LLGridManager::getInstance()->getLoginURIs(uris); ensure_equals("getLoginURIs size", uris.size(), 1); ensure_equals("getLoginURIs", uris[0], std::string("https://login.agni.lindenlab.com/cgi-bin/login.cgi")); - manager.setGridChoice("myaddedgrid"); - ensure_equals("getGridLabel", manager.getGridLabel(), std::string("myaddedgrid")); - ensure("Is myaddedgrid a production grid", !manager.isInProductionGrid()); + LLGridManager::getInstance()->setGridChoice("myaddedgrid"); + ensure_equals("getGridLabel", LLGridManager::getInstance()->getGridLabel(), std::string("myaddedgrid")); + ensure("Is myaddedgrid a production grid", !LLGridManager::getInstance()->isInProductionGrid()); - manager.setFavorite(); - grid = manager.getGridInfo("myaddedgrid"); + LLGridManager::getInstance()->setFavorite(); + grid = LLGridManager::getInstance()->getGridInfo("myaddedgrid"); ensure("setting favorite", grid.has(GRID_IS_FAVORITE_VALUE)); } @@ -338,12 +378,12 @@ namespace tut template<> template<> void viewerNetworkTestObject::test<5>() { - LLGridManager manager("grid_test.xml"); + LLGridManager::getInstance()->initialize("grid_test.xml"); LLSD grid = LLSD::emptyMap(); // adding a grid with simply a name will populate the values. grid[GRID_NAME_VALUE] = "myaddedgrid"; - manager.addGrid(grid); - grid = manager.getGridInfo("myaddedgrid"); + LLGridManager::getInstance()->addGrid(grid); + grid = LLGridManager::getInstance()->getGridInfo("myaddedgrid"); ensure_equals("name based grid has name value", grid[GRID_NAME_VALUE].asString(), @@ -380,29 +420,29 @@ namespace tut { // try with initial grid list without a grid file, // without setting the grid to a saveable favorite. - LLGridManager manager("grid_test.xml"); + LLGridManager::getInstance()->initialize("grid_test.xml"); LLSD grid = LLSD::emptyMap(); grid[GRID_NAME_VALUE] = std::string("mynewgridname"); - manager.addGrid(grid); - manager.saveFavorites(); + LLGridManager::getInstance()->addGrid(grid); + LLGridManager::getInstance()->saveFavorites(); ensure("Grid file exists after saving", LLFile::isfile("grid_test.xml")); - manager = LLGridManager("grid_test.xml"); + LLGridManager::getInstance()->initialize("grid_test.xml"); // should not be there - std::map<std::string, std::string> known_grids = manager.getKnownGrids(); + std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); ensure("New grid wasn't added to persisted list without being marked a favorite", known_grids.find(std::string("mynewgridname")) == known_grids.end()); // mark a grid a favorite to make sure it's persisted - manager.addGrid(grid); - manager.setGridChoice("mynewgridname"); - manager.setFavorite(); - manager.saveFavorites(); + LLGridManager::getInstance()->addGrid(grid); + LLGridManager::getInstance()->setGridChoice("mynewgridname"); + LLGridManager::getInstance()->setFavorite(); + LLGridManager::getInstance()->saveFavorites(); ensure("Grid file exists after saving", LLFile::isfile("grid_test.xml")); - manager = LLGridManager("grid_test.xml"); + LLGridManager::getInstance()->initialize("grid_test.xml"); // should not be there - known_grids = manager.getKnownGrids(); + known_grids = LLGridManager::getInstance()->getKnownGrids(); ensure("New grid wasn't added to persisted list after being marked a favorite", known_grids.find(std::string("mynewgridname")) != known_grids.end()); @@ -417,28 +457,28 @@ namespace tut gridfile << gSampleGridFile; gridfile.close(); - LLGridManager manager("grid_test.xml"); + LLGridManager::getInstance()->initialize("grid_test.xml"); LLSD grid = LLSD::emptyMap(); grid[GRID_NAME_VALUE] = std::string("mynewgridname"); - manager.addGrid(grid); - manager.saveFavorites(); + LLGridManager::getInstance()->addGrid(grid); + LLGridManager::getInstance()->saveFavorites(); // validate we didn't lose existing favorites - manager = LLGridManager("grid_test.xml"); - std::map<std::string, std::string> known_grids = manager.getKnownGrids(); + LLGridManager::getInstance()->initialize("grid_test.xml"); + std::map<std::string, std::string> known_grids = LLGridManager::getInstance()->getKnownGrids(); ensure("New grid wasn't added to persisted list after being marked a favorite", known_grids.find(std::string("grid1")) != known_grids.end()); // add a grid - manager.addGrid(grid); - manager.setGridChoice("mynewgridname"); - manager.setFavorite(); - manager.saveFavorites(); - known_grids = manager.getKnownGrids(); + LLGridManager::getInstance()->addGrid(grid); + LLGridManager::getInstance()->setGridChoice("mynewgridname"); + LLGridManager::getInstance()->setFavorite(); + LLGridManager::getInstance()->saveFavorites(); + known_grids = LLGridManager::getInstance()->getKnownGrids(); ensure("New grid wasn't added to persisted list after being marked a favorite", known_grids.find(std::string("grid1")) != known_grids.end()); - known_grids = manager.getKnownGrids(); + known_grids = LLGridManager::getInstance()->getKnownGrids(); ensure("New grid wasn't added to persisted list after being marked a favorite", known_grids.find(std::string("mynewgridname")) != known_grids.end()); |