data: bookmark refactoring
* implemented handling of aggregations in bookmarks * split index Storage and bookmark storage * each sqlite database has its own version now * added bookmark tests * fixed creating bookmark tables when project can be loaded but bookmark db does not exist * fixed font size for bookmarkview tooltips * using bookmark cache now * using default category name when none specified by the user * raising bookmark windows when they should be shown * clearing a bookmark or category in the editor will now update the star icon accordingly * non-persistent bookmarks use ids of nodes and edges now (instead of names) * git ignore .srctrlbm files
This commit is contained in:
@@ -24,7 +24,8 @@ add_files(
|
||||
SettingsMigratorTestSuite.h
|
||||
SearchIndexTestSuite.h
|
||||
SourceLocationCollectionTestSuite.h
|
||||
SqliteStorageTestSuite.h
|
||||
SqliteBookmarkStorageTestSuite.h
|
||||
SqliteIndexStorageTestSuite.h
|
||||
StorageTestSuite.h
|
||||
TaskSchedulerTestSuite.h
|
||||
TextAccessTestSuite.h
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "boost/filesystem.hpp"
|
||||
|
||||
#include "data/bookmark/EdgeBookmark.h"
|
||||
#include "data/bookmark/NodeBookmark.h"
|
||||
#include "data/SqliteBookmarkStorage.h"
|
||||
|
||||
class SqliteBookmarkStorageTestSuite: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_add_bookmarks()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/bookmarkTest.sqlite";
|
||||
int bookmarkCount = 4;
|
||||
int result = -1;
|
||||
{
|
||||
boost::filesystem::remove(databasePath);
|
||||
SqliteBookmarkStorage storage(databasePath);
|
||||
storage.setup();
|
||||
|
||||
for (unsigned int i = 0; i < bookmarkCount; i++)
|
||||
{
|
||||
const Id categoryId = storage.addBookmarkCategory("test category");
|
||||
storage.addBookmark("test bookmark", "test comment", TimePoint::now().toString(), categoryId);
|
||||
}
|
||||
|
||||
result = storage.getAllBookmarks().size();
|
||||
}
|
||||
|
||||
boost::filesystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(result, bookmarkCount);
|
||||
}
|
||||
|
||||
void test_add_bookmarked_node()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/bookmarkTest.sqlite";
|
||||
int bookmarkCount = 4;
|
||||
int result = -1;
|
||||
{
|
||||
boost::filesystem::remove(databasePath);
|
||||
SqliteBookmarkStorage storage(databasePath);
|
||||
storage.setup();
|
||||
|
||||
const Id categoryId = storage.addBookmarkCategory("test category");
|
||||
const Id bookmarkId = storage.addBookmark("test bookmark", "test comment", TimePoint::now().toString(), categoryId);
|
||||
|
||||
for (unsigned int i = 0; i < bookmarkCount; i++)
|
||||
{
|
||||
storage.addBookmarkedNode(bookmarkId, "test name");
|
||||
}
|
||||
|
||||
result = storage.getAllBookmarkedNodes().size();
|
||||
}
|
||||
|
||||
boost::filesystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(result, bookmarkCount);
|
||||
}
|
||||
|
||||
void test_remove_bookmark_also_removes_bookmarked_node()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/bookmarkTest.sqlite";
|
||||
int bookmarkCount = 4;
|
||||
int result = -1;
|
||||
{
|
||||
boost::filesystem::remove(databasePath);
|
||||
SqliteBookmarkStorage storage(databasePath);
|
||||
storage.setup();
|
||||
|
||||
const Id categoryId = storage.addBookmarkCategory("test category");
|
||||
const Id bookmarkId = storage.addBookmark("test bookmark", "test comment", TimePoint::now().toString(), categoryId);
|
||||
const Id bookmarkedNodeId = storage.addBookmarkedNode(bookmarkId, "test name");
|
||||
|
||||
storage.removeBookmark(bookmarkId);
|
||||
|
||||
result = storage.getAllBookmarkedNodes().size();
|
||||
}
|
||||
|
||||
boost::filesystem::remove(databasePath);
|
||||
|
||||
TS_ASSERT_EQUALS(result, 0);
|
||||
}
|
||||
|
||||
void test_edit_nodeBookmark()
|
||||
{
|
||||
std::string databasePath = "data/SQLiteTestSuite/bookmarkTest.sqlite";
|
||||
|
||||
const std::string updatedName = "updated name";
|
||||
const std::string updatedComment = "updated comment";
|
||||
|
||||
StorageBookmark storageBookmark;
|
||||
{
|
||||
boost::filesystem::remove(databasePath);
|
||||
SqliteBookmarkStorage storage(databasePath);
|
||||
storage.setup();
|
||||
|
||||
const Id categoryId = storage.addBookmarkCategory("test category");
|
||||
const Id bookmarkId = storage.addBookmark("test bookmark", "test comment", TimePoint::now().toString(), categoryId);
|
||||
const Id bookmarkedNodeId = storage.addBookmarkedNode(bookmarkId, "test name");
|
||||
|
||||
storage.updateBookmark(bookmarkId, updatedName, updatedComment, categoryId);
|
||||
|
||||
storageBookmark = storage.getAllBookmarks().front();
|
||||
}
|
||||
|
||||
TS_ASSERT_EQUALS(updatedName, storageBookmark.name);
|
||||
TS_ASSERT_EQUALS(updatedComment, storageBookmark.comment);
|
||||
}
|
||||
};
|
||||
@@ -3,9 +3,9 @@
|
||||
#include "boost/filesystem.hpp"
|
||||
|
||||
#include "sqlite/CppSQLite3.h"
|
||||
#include "data/SqliteStorage.h"
|
||||
#include "data/SqliteIndexStorage.h"
|
||||
|
||||
class SqliteStorageTestSuite: public CxxTest::TestSuite
|
||||
class SqliteIndexStorageTestSuite: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_storage_adds_node_successfully()
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int nodeCount = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
SqliteIndexStorage storage(databasePath);
|
||||
storage.setup();
|
||||
storage.beginTransaction();
|
||||
storage.addNode(0, "a");
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int nodeCount = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
SqliteIndexStorage storage(databasePath);
|
||||
storage.setup();
|
||||
storage.beginTransaction();
|
||||
int nodeId = storage.addNode(0, "a");
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int edgeCount = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
SqliteIndexStorage storage(databasePath);
|
||||
storage.setup();
|
||||
storage.beginTransaction();
|
||||
int sourceNodeId = storage.addNode(0, "a");
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
std::string databasePath = "data/SQLiteTestSuite/test.sqlite";
|
||||
int edgeCount = -1;
|
||||
{
|
||||
SqliteStorage storage(databasePath);
|
||||
SqliteIndexStorage storage(databasePath);
|
||||
storage.setup();
|
||||
storage.beginTransaction();
|
||||
int sourceNodeId = storage.addNode(0, "a");
|
||||
@@ -232,7 +232,7 @@ private:
|
||||
{
|
||||
public:
|
||||
TestStorage()
|
||||
: PersistentStorage("data/test.sqlite")
|
||||
: PersistentStorage("data/test.sqlite", "data/testBookmarks.sqlite")
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
---------
|
||||
Debugging
|
||||
---------
|
||||
To debug unit tests remove the post-build event, set the execution directory for 'Coati_test' to '.../Coati/bin/test' and run 'Coati_test' as startup project
|
||||
|
||||
|
||||
Post build event (if you manage to delete it without saving it somewhere):
|
||||
|
||||
setlocal
|
||||
cd $(ProjectDir)../../bin/test/
|
||||
$(OutDir)$(TargetName)$(TargetExt)
|
||||
if %errorlevel% neq 0 goto :cmEnd
|
||||
:cmEnd
|
||||
endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone
|
||||
:cmErrorLevel
|
||||
exit /b %1
|
||||
:cmDone
|
||||
if %errorlevel% neq 0 goto :VCEnd
|
||||
Reference in New Issue
Block a user