Skip to content
Snippets Groups Projects
Commit 61c63727 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#3883] Fix history unit test failure

parent 07667e10
No related branches found
Tags android/release_346
No related merge requests found
...@@ -273,6 +273,8 @@ ConfigTree::setConfigTreeItem (const std::string& section, ...@@ -273,6 +273,8 @@ ConfigTree::setConfigTreeItem (const std::string& section,
bool bool
ConfigTree::saveConfigTree (const std::string& fileName) ConfigTree::saveConfigTree (const std::string& fileName)
{ {
_debug ("ConfigTree: Save %s", fileName.c_str());
if (fileName.empty() && _sections.begin() == _sections.end()) { if (fileName.empty() && _sections.begin() == _sections.end()) {
return false; return false;
} }
...@@ -321,6 +323,8 @@ ConfigTree::populateFromFile (const std::string& fileName) ...@@ -321,6 +323,8 @@ ConfigTree::populateFromFile (const std::string& fileName)
{ {
bool out = false; bool out = false;
_debug ("ConfigTree: Populate from file %s", fileName.c_str());
if (fileName.empty()) { if (fileName.empty()) {
return 0; return 0;
} }
...@@ -378,6 +382,7 @@ ConfigTree::populateFromFile (const std::string& fileName) ...@@ -378,6 +382,7 @@ ConfigTree::populateFromFile (const std::string& fileName)
val = line.substr (pos + 1, line.length() - pos); val = line.substr (pos + 1, line.length() - pos);
if (key.length() > 0 && val.length() > 0) { if (key.length() > 0 && val.length() > 0) {
_debug ("setconfigtreeitem %s, %s", section.c_str(), val.c_str());
setConfigTreeItem (section, key, val); setConfigTreeItem (section, key, val);
} }
......
...@@ -77,12 +77,14 @@ bool HistoryManager::save_history (void) ...@@ -77,12 +77,14 @@ bool HistoryManager::save_history (void)
bool HistoryManager::load_history_from_file (Conf::ConfigTree *history_list) bool HistoryManager::load_history_from_file (Conf::ConfigTree *history_list)
{ {
bool exist; int exist;
exist = history_list->populateFromFile (_history_path); _debug ("HistoryManager: Load history from file %s", _history_path.c_str());
exist = history_list->populateFromFile (_history_path.c_str());
_history_loaded = (exist == 2) ? false : true; _history_loaded = (exist == 2) ? false : true;
return exist; return _history_loaded;
} }
int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int limit) int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int limit)
...@@ -97,6 +99,8 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int ...@@ -97,6 +99,8 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int
int history_limit; int history_limit;
time_t current_timestamp; time_t current_timestamp;
_debug ("HistoryManager: Load history items");
// We want to save only the items recent enough (ie compared to CONFIG_HISTORY_LIMIT) // We want to save only the items recent enough (ie compared to CONFIG_HISTORY_LIMIT)
// Get the current timestamp // Get the current timestamp
(void) time (&current_timestamp); (void) time (&current_timestamp);
......
...@@ -154,12 +154,9 @@ void ConfigurationTest::testYamlParser() ...@@ -154,12 +154,9 @@ void ConfigurationTest::testYamlParser()
try { try {
parser = new Conf::YamlParser ("sequence2.yml"); parser = new Conf::YamlParser ("ymlParser.yml");
parser->serializeEvents(); parser->serializeEvents();
parser->composeEvents(); parser->composeEvents();
parser->constructNativeData(); parser->constructNativeData();
delete parser; delete parser;
...@@ -276,7 +273,7 @@ void ConfigurationTest::testYamlEmitter() ...@@ -276,7 +273,7 @@ void ConfigurationTest::testYamlEmitter()
tlsmap.setKeyValue (verifyServerKey, &verifyserver); tlsmap.setKeyValue (verifyServerKey, &verifyserver);
try { try {
emitter = new Conf::YamlEmitter ("/tmp/sequenceEmiter.txt"); emitter = new Conf::YamlEmitter ("/tmp/ymlEmiter.txt");
emitter->serializeAccount (&accountmap); emitter->serializeAccount (&accountmap);
emitter->serializeAccount (&accountmap); emitter->serializeAccount (&accountmap);
......
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
#define YES_STR "1" #define YES_STR "1"
#define NO_STR "0" #define NO_STR "0"
#define HISTORY_SAMPLE "history-sample" #define HISTORY_SAMPLE "history-sample.tpl"
#define HISTORY_SAMPLE_SIZE 3 #define HISTORY_SAMPLE_SIZE 3
#define CONFIG_SAMPLE "sflphoned-sample.yml" #define CONFIG_SAMPLE "sflphoned-sample.yml"
#define HUGE_HISTORY_LIMIT 20000 #define HUGE_HISTORY_LIMIT 999999999
#endif /* CONSTANTS_H_ */ #endif /* CONSTANTS_H_ */
[144562436]
accountid=
name=Savoir-faire Linux
number=514-276-5468
timestamp_stop=144562458
type=0
[747638685]
accountid=Account:1239059899
name=Emmanuel Milou
number=136
timestamp_stop=747638765
type=2
[775354456]
accountid=Account:43789459478
name=
number=5143848557
timestamp_stop=775354987
type=1
[144562436] [144562436]
number=514-276-5468 accountid=
name=Savoir-faire Linux name=Savoir-faire Linux
type=0 number=514-276-5468
timestamp_stop=144562458 timestamp_stop=144562458
accountid= type=0
[747638685] [747638685]
accountid=Account:1239059899
name=Emmanuel Milou name=Emmanuel Milou
timestamp_stop=747638765
number=136 number=136
timestamp_stop=747638765
type=2 type=2
accountid=Account:1239059899
[775354456] [775354456]
number=5143848557 accountid=Account:43789459478
name= name=
number=5143848557
timestamp_stop=775354987 timestamp_stop=775354987
type=1 type=1
accountid=Account:43789459478
...@@ -54,13 +54,13 @@ class HistoryTest : public CppUnit::TestCase { ...@@ -54,13 +54,13 @@ class HistoryTest : public CppUnit::TestCase {
*/ */
CPPUNIT_TEST_SUITE (HistoryTest); CPPUNIT_TEST_SUITE (HistoryTest);
CPPUNIT_TEST (test_create_history_path); CPPUNIT_TEST (test_create_history_path);
CPPUNIT_TEST (test_save_history_to_file);
CPPUNIT_TEST (test_save_history_items_map); CPPUNIT_TEST (test_save_history_items_map);
CPPUNIT_TEST (test_load_history_from_file); CPPUNIT_TEST (test_load_history_from_file);
CPPUNIT_TEST (test_load_history_items_map); CPPUNIT_TEST (test_load_history_items_map);
CPPUNIT_TEST (test_get_history_serialized); CPPUNIT_TEST (test_get_history_serialized);
CPPUNIT_TEST (test_set_serialized_history); CPPUNIT_TEST (test_set_serialized_history);
CPPUNIT_TEST (test_set_serialized_history_with_limit); CPPUNIT_TEST (test_set_serialized_history_with_limit);
CPPUNIT_TEST (test_save_history_to_file);
CPPUNIT_TEST_SUITE_END (); CPPUNIT_TEST_SUITE_END ();
public: public:
......
accounts:
- id: 1234
alias: sfl-181
username: 181
password: sfl-181pw
hostname: sflphone.org
enable: true
type: sip
- id: 2345
alias: sfl-431
username: 431
password: alexandre
hostname: 192.168.50.3
enable: true
type: sip
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment