summaryrefslogtreecommitdiffstats
path: root/src/svnqt/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/svnqt/tests')
-rw-r--r--src/svnqt/tests/CMakeLists.txt23
-rw-r--r--src/svnqt/tests/ckpath.cpp24
-rw-r--r--src/svnqt/tests/crepo.cpp63
-rw-r--r--src/svnqt/tests/lsdir.cpp78
-rw-r--r--src/svnqt/tests/testconfig.h.in7
-rw-r--r--src/svnqt/tests/testlistener.h37
6 files changed, 232 insertions, 0 deletions
diff --git a/src/svnqt/tests/CMakeLists.txt b/src/svnqt/tests/CMakeLists.txt
new file mode 100644
index 0000000..8aef2d5
--- /dev/null
+++ b/src/svnqt/tests/CMakeLists.txt
@@ -0,0 +1,23 @@
+SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
+
+MACRO(BUILD_TEST tname)
+ SET(${tname}-src ${tname}.cpp)
+ IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${tname}.h)
+ SET(${tname}-src ${${tname}-src} ${tname}.h)
+ ENDIF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${tname}.h)
+ ADD_EXECUTABLE(${tname} ${${tname}-src})
+ TARGET_LINK_LIBRARIES(${tname} ${svnqt-name} ${QT_LIBRARIES})
+ ADD_TEST(${tname} ${CMAKE_CURRENT_BINARY_DIR}/${tname})
+ENDMACRO(BUILD_TEST)
+
+IF (BUILD_TESTS)
+ CONFIGURE_FILE(
+ ${CMAKE_CURRENT_SOURCE_DIR}/testconfig.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/testconfig.h
+ )
+ ADD_TEST(rmrepo "/bin/rm" "-rvf" "${CMAKE_CURRENT_BINARY_DIR}/repo")
+ ADD_TEST(rmco "/bin/rm" "-rvf" "${CMAKE_CURRENT_BINARY_DIR}/co")
+ BUILD_TEST(crepo)
+ BUILD_TEST(lsdir)
+ BUILD_TEST(ckpath)
+ENDIF(BUILD_TESTS)
diff --git a/src/svnqt/tests/ckpath.cpp b/src/svnqt/tests/ckpath.cpp
new file mode 100644
index 0000000..ca4fe3e
--- /dev/null
+++ b/src/svnqt/tests/ckpath.cpp
@@ -0,0 +1,24 @@
+#include "src/svnqt/path.hpp"
+#include <iostream>
+
+int main(int,char**)
+{
+ svn::Path pa("/test/foo/bar/");
+ if (pa.path()!=QString("/test/foo/bar")) {
+ std::cout << "No cleanup of components" << std::endl;
+ return -1;
+ }
+ pa.removeLast();
+ if (pa.path()!=QString("/test/foo")) {
+ std::cout<<"removeLast didn't work." << std::endl;
+ return -1;
+ }
+ unsigned j = 0;
+ while (pa.length()>0) {
+ std::cout << pa.path() << std::endl;
+ pa.removeLast();
+ ++j;
+ }
+ return 0;
+}
+
diff --git a/src/svnqt/tests/crepo.cpp b/src/svnqt/tests/crepo.cpp
new file mode 100644
index 0000000..604e4e9
--- /dev/null
+++ b/src/svnqt/tests/crepo.cpp
@@ -0,0 +1,63 @@
+#include "src/svnqt/client.hpp"
+#include "src/svnqt/tests/testconfig.h"
+#include "src/svnqt/repository.hpp"
+#include "src/svnqt/repositorylistener.hpp"
+#include "src/svnqt/targets.hpp"
+
+#include "testlistener.h"
+
+#include <iostream>
+#include <unistd.h>
+#include <qstringlist.h>
+
+class Listener:public svn::repository::RepositoryListener
+{
+ public:
+ Listener(){}
+ virtual ~Listener(){}
+ virtual void sendWarning(const QString&msg)
+ {
+ std::cout << msg << std::endl;
+ }
+ virtual void sendError(const QString&msg)
+ {
+ std::cout << msg << std::endl;
+ }
+ virtual bool isCanceld(){return false;}
+};
+
+int main(int,char**)
+{
+ QString p = TESTREPOPATH;
+ Listener ls;
+ svn::repository::Repository rp(&ls);
+ try {
+ rp.CreateOpen(p,"fsfs");
+ } catch (svn::ClientException e) {
+ QString ex = e.msg();
+ std::cout << ex.TOUTF8() << std::endl;
+ return -1;
+ }
+
+ svn::ContextP m_CurrentContext;
+ svn::Client* m_Svnclient;
+ m_Svnclient=svn::Client::getobject(0,0);
+ TestListener tl;
+ m_CurrentContext = new svn::Context();
+ m_CurrentContext->setListener(&tl);
+ p = "file://"+p;
+
+ m_Svnclient->setContext(m_CurrentContext);
+ QStringList s; s.append(p+"/trunk"); s.append(p+"/branches"); s.append(p+"/tags");
+
+ try {
+ m_Svnclient->mkdir(svn::Targets(s),"Test mkdir");
+ m_Svnclient->checkout(p,TESTCOPATH,svn::Revision::HEAD,svn::Revision::HEAD,svn::DepthInfinity,false);
+ } catch (svn::ClientException e) {
+ QString ex = e.msg();
+ std::cout << ex.TOUTF8() << std::endl;
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/src/svnqt/tests/lsdir.cpp b/src/svnqt/tests/lsdir.cpp
new file mode 100644
index 0000000..c458f31
--- /dev/null
+++ b/src/svnqt/tests/lsdir.cpp
@@ -0,0 +1,78 @@
+
+#include "src/svnqt/client.hpp"
+#include "src/svnqt/tests/testconfig.h"
+#include "src/svnqt/status.hpp"
+#include "src/svnqt/svnqttypes.hpp"
+#include <iostream>
+
+int main(int,char**)
+{
+ svn::ContextP m_CurrentContext;
+ svn::Client* m_Svnclient;
+ m_Svnclient=svn::Client::getobject(0,0);
+ m_CurrentContext = new svn::Context();
+
+ m_Svnclient->setContext(m_CurrentContext);
+ svn::DirEntries dlist;
+
+ QString p = QString("file://%1").arg(TESTREPOPATH);
+ QString l = QString("%1").arg(TESTCOPATH);
+
+ try {
+ dlist = m_Svnclient->list(svn::Path(p),svn::Revision::HEAD,svn::Revision::HEAD,svn::DepthInfinity,true);
+ } catch (svn::ClientException e) {
+ QString ex = e.msg();
+ std::cout << ex.TOUTF8() << std::endl;
+ return -1;
+ }
+ std::cout << "List 1 "<<dlist.size()<<std::endl;
+ for (unsigned int i=0; i < dlist.size();++i) {
+ QDateTime dt = svn::DateTime(dlist[i]->time());
+ std::cout << dlist[i]->name() << " "
+ << dlist[i]->lastAuthor() << " "
+ << dlist[i]->size() << " "
+ << dt.toTime_t() << std::endl;
+ }
+ try {
+ dlist = m_Svnclient->list(svn::Path(p),svn::Revision::HEAD,svn::Revision::HEAD,svn::DepthImmediates,false);
+ } catch (svn::ClientException e) {
+ QString ex = e.msg();
+ std::cout << ex.TOUTF8() << std::endl;
+ return -1;
+ }
+ std::cout << "================"<<std::endl;
+ std::cout << "List 2 "<<dlist.size()<<std::endl;
+ for (unsigned int i=0; i < dlist.size();++i) {
+ QDateTime dt = svn::DateTime(dlist[i]->time());
+ std::cout << dlist[i]->name() << " "
+ << dlist[i]->lastAuthor() << " "
+ << dlist[i]->size() << " "
+ << dt.toTime_t() << std::endl;
+ }
+ std::cout << "================"<<std::endl;
+ svn::StatusEntries slist;
+ try {
+ slist = m_Svnclient->status(svn::Path(p),svn::DepthInfinity,true,true,true,svn::Revision::HEAD,true,false);
+ } catch (svn::ClientException e) {
+ QString ex = e.msg();
+ std::cout << ex.TOUTF8() << std::endl;
+ return -1;
+ }
+ for (unsigned int i=0; i < slist.size();++i) {
+ std::cout << slist[i]->path()<< std::endl;
+ }
+ std::cout << "================"<<std::endl;
+ std::cout << "Second status:"<<std::endl;
+ try {
+ slist = m_Svnclient->status(svn::Path(l),svn::DepthInfinity,true,true,true,svn::Revision::WORKING,true,false);
+ } catch (svn::ClientException e) {
+ QString ex = e.msg();
+ std::cout << ex.TOUTF8() << std::endl;
+ return -1;
+ }
+ for (unsigned int i=0; i < slist.size();++i) {
+ std::cout << slist[i]->path()<< std::endl;
+ }
+
+ return 0;
+}
diff --git a/src/svnqt/tests/testconfig.h.in b/src/svnqt/tests/testconfig.h.in
new file mode 100644
index 0000000..5ffff3e
--- /dev/null
+++ b/src/svnqt/tests/testconfig.h.in
@@ -0,0 +1,7 @@
+#ifndef __TEST_CONFIG_H
+#define __TEST_CONFIG_H
+
+#define TESTREPOPATH "@CMAKE_CURRENT_BINARY_DIR@/repo"
+#define TESTCOPATH "@CMAKE_CURRENT_BINARY_DIR@/co"
+
+#endif
diff --git a/src/svnqt/tests/testlistener.h b/src/svnqt/tests/testlistener.h
new file mode 100644
index 0000000..0c38a43
--- /dev/null
+++ b/src/svnqt/tests/testlistener.h
@@ -0,0 +1,37 @@
+#ifndef _TESTLISTENER_
+#define _TESTLISTENER_
+
+#include "src/svnqt/context_listener.hpp"
+
+class TestListener:public svn::ContextListener
+{
+ public:
+ TestListener(){}
+ virtual ~TestListener(){}
+
+ virtual void contextProgress(long long int current, long long int max){};
+ virtual bool contextSslClientCertPwPrompt (QString &,const QString &, bool &){return false;}
+ virtual bool contextLoadSslClientCertPw(QString&,const QString&){return false;}
+ virtual bool contextSslClientCertPrompt (QString &){return false;}
+ virtual svn::ContextListener::SslServerTrustAnswer
+ contextSslServerTrustPrompt (const SslServerTrustData &,
+ apr_uint32_t & ){return svn::ContextListener::SslServerTrustAnswer();}
+ virtual bool contextGetLogMessage (QString &,const svn::CommitItemList&){return false;}
+ virtual bool contextCancel(){return false;}
+ virtual void contextNotify (const svn_wc_notify_t *){}
+ virtual void contextNotify (const char *,svn_wc_notify_action_t,
+ svn_node_kind_t,
+ const char *,
+ svn_wc_notify_state_t,
+ svn_wc_notify_state_t,
+ svn_revnum_t){}
+ virtual bool contextGetSavedLogin (const QString & realm,QString & username,QString & password){return false;}
+ virtual bool contextGetCachedLogin (const QString & realm,QString & username,QString & password){return false;}
+ virtual bool contextGetLogin (const QString & realm,
+ QString & username,
+ QString & password,
+ bool & maySave){maySave=false;return false;}
+
+};
+
+#endif