#include "ClientTests.h" #include <QDebug> #include <algorithm> namespace test { using namespace hws; using namespace std; //------------------------------------------------------------------------ // QTest Framework Setup //------------------------------------------------------------------------ void ClientTests::initTestCase() { mHelper.mTests = this; initClient(); } void ClientTests::init() { mSession.reset(NULL); mLogInDone = false; mExecuteMethodDone = false; mMethod = ""; mPath = ""; mData.reset(NULL); mRequestError.reset(NULL); } //------------------------------------------------------------------------ // Test Methods //------------------------------------------------------------------------ void ClientTests::logIn() { mClient->logIn("jdoe", "johndoe1A!"); waitForLogIn(); QVERIFY(mSession.isNull() == false); QVERIFY(mSession->user() == "jdoe"); } void ClientTests::logInError() { mClient->logIn("jdoe", "illegal"); waitForLogIn(); QVERIFY(mRequestError->code() == RequestError::AUTHENTICATION_ERROR); } void ClientTests::listDepots() { mClient->logIn("jdoe", "johndoe1A!"); waitForLogIn(); mClient->executeMethod("GET", "/helix_versioning_engine/v78/depots"); waitForExecuteMethod(); QVERIFY(mMethod == "GET"); QVERIFY(mPath == "/helix_versioning_engine/v78/depots"); // TODO verify a depot } void ClientTests::listProjects() { mClient->addRequestConfig("HVE_PROJECTS_PATH", "//depot/main"); mClient->logIn("jdoe", "johndoe1A!"); waitForLogIn(); mClient->executeMethod("GET", "/projects/v1"); waitForExecuteMethod(); QVERIFY(mMethod == "GET"); QVERIFY(mPath == "/projects/v1"); QString projectId = "My~20Project"; bool exists = false; foreach(QVariantMap map, *mData) { if (map["value"] == projectId) { exists = true; break; } } QVERIFY2(exists, "Did not locate project"); } //------------------------------------------------------------------------ // Test Helpers //------------------------------------------------------------------------ void ClientTests::initClient() { mClient.reset(new hws::Client(this)); QString urlString = QProcessEnvironment::systemEnvironment() .value("HWS_URL", "http://localhost:9000"); mClient->setUrl(QUrl(urlString)); // This will, by default, not go through the nginx prefix path convention QString prefix = QProcessEnvironment::systemEnvironment().value("HWS_PREFIX", ""); mClient->setHWSPrefixPath(prefix); connect(mClient.data(), &hws::Client::logInDone, &mHelper, &ClientHelper::logInDone); connect(mClient.data(), &hws::Client::executeMethodDone, &mHelper, &ClientHelper::executeMethodDone); } void ClientHelper::logInDone(RequestErrorPtr err, SessionPtr session) { if (!err) { qDebug() << "session " << session->toString(); mTests->mSession = session; } else { qDebug() << "Received RequestErrorPtr" << err->messageText(); mTests->mRequestError = err; } mTests->mLogInDone = true; } void ClientHelper::executeMethodDone(hws::RequestErrorPtr error, const QString & method, const QString & path, const QSharedPointer<hws::Client::QVariantMapList> data) { if (!error) { qDebug() << method << " " << path; if (data) qDebug() << ": " << *data; mTests->mData = data; mTests->mMethod = method; mTests->mPath = path; } else { qDebug() << "Received RequestErrorPtr" << error->messageText(); mTests->mRequestError = error; } mTests->mExecuteMethodDone = true; } void ClientTests::waitForLogIn() { for (int retries = 0; !mLogInDone && retries < 50; retries++) { QTest::qWait(250); } } void ClientTests::waitForExecuteMethod() { for (int retries = 0; !mExecuteMethodDone && retries < 50; retries++) { QTest::qWait(250); } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 15741 | ptomiak | Branch HWS for my use. | ||
//guest/perforce_software/helix-web-services/main/source/helix_web_services_client_qt/test/ClientTests.cpp | |||||
#1 | 15622 | tjuricek |
Move source code to 'source/' subdirectory of branch. build/ will remain where it is. |
||
//guest/perforce_software/helix-web-services/main/helix_web_services_client_qt/test/ClientTests.cpp | |||||
#7 | 15578 | tjuricek |
Removing QSettings* usage from hws::Client. The way QSettings was being used only is relevant for one connection at a time, and, it didn't seem to work on windows nicely anyway. |
||
#6 | 15445 | tjuricek | Allow per-request overrides to be set via addRequestConfig | ||
#5 | 15437 | tjuricek |
Basic "HVE Project" implementation. This will allow directories in a HVE instance to host 'projects' for use by helix sync. There are no methods defined for creating the projects, however. This does not include any specialization or testing in the Qt API yet. I may investigate creating a "higher level" interface for Qt client apps. |
||
#4 | 15423 | tjuricek |
Revised HWS Qt API. This is a major revision of the API, which removes most of the "typed" data, replacing it with a more generic "executeMethodDone" callback. The main benefit here is to allow the API to interop with different versions of p4d, and not restrict the methods it can call. We may add more helpers in the future. |
||
#3 | 14055 | tjuricek | Updating helix_web_services_client build for new 'my' vs 'all' projects feature | ||
#2 | 14049 | tjuricek |
Add methods to generate client workspaces for a user. The Qt SDK was updated based on immediate need. Also, add Ruby client SDK documentation to the docs site. Everything is early, but there's *some* reference available at least. |
||
#1 | 14025 | tjuricek |
Revise Qt SDK to a single 'helix_web_services_client' project. Most references to "Phoenix" have now been removed. Additionally, this is more similar to the other platform client SDKs in Ruby and JavaScript. Documentation via Doxygen is now available, and will be how much of the SDK reference should occur. |
||
//guest/perforce_software/helix-web-services/main/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.cpp | |||||
#7 | 13508 | tjuricek | Replace use of C++11 'nullptr' with NULL | ||
#6 | 13506 | tjuricek |
Change to a C++03 build. Major changes: 1. QSharedPointer::create(...) is much more restricted than in C++11, so just use the .reset() method unless you're passing in a single const reference argument to the constructor. 2. Using Qt's foreach. 3. Replace lambdas with simpler helper methods. This seems to work, but we may have subtle memory issues I'm not 100% on top of yet. |
||
#5 | 13460 | tjuricek |
Call out authentication problems with a specific application error code. This allows Qt clients to easily know when they should recreate a new session. |
||
#4 | 13459 | tjuricek |
Return the created project when creating a new project, since default values will often be filled out. Allow new projects to be created only with names set. We'll generate an ID at the moment, when I have better indexing, I'll double check for uniqueness. |
||
#3 | 13455 | tjuricek | Basic Phoenix project metadata (the project name) can now be created and read back. | ||
#2 | 13454 | tjuricek |
First cut at SDK implementation of the Create-Read lifecycle of Phoenix projects. (Bugs on the server side may be the issue, we'll see. TBD.) |
||
#1 | 13443 | tjuricek |
Reorganized the Qt libraries into a separate part of the tree, to make it easier for CMake configuration. Added 'qt_build' and 'qt_test' tasks to at least execute tests and fail the build if they don't pass. Started the implementation of the project library interaction. Change: 1018651 Date: 3/4/15 11:43 AM Client: tjuricek_dhcp-141-n100_5959 User: tjuricek Status: pending Type: public Description: Reorganized the Qt libraries into a separate part of the tree, to make it easier for CMake configuration. Added 'qt_build' and 'qt_test' tasks to at least execute tests and fail the build if they don't pass. Started the implementation of the project library interaction. JobStatus: Jobs: Files: //web-services/p4ws-main/Rakefile //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/CMakeLists.txt //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/PhoenixIntegrationTests.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/README //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/PhoenixProject.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/PhoenixProject.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/PhoenixServicesClient.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/PhoenixServicesClient.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/RequestError.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/RequestError.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/Session.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/phoenix/Session.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.h //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/SessionTests.cpp //web-services/p4ws-main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/SessionTests.h //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/CMakeLists.txt //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services.h //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Branch.cpp //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Branch.h //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Project.cpp //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/Project.h //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/View.cpp //web-services/p4ws-main/p4_project_services/clients/qt/p4_project_services_client/p4_project_services/View.h //web-services/p4ws-main/qt/CMakeLists.txt //web-services/p4ws-main/qt/p4_phoenix_services_client/CMakeLists.txt //web-services/p4ws-main/qt/p4_phoenix_services_client/PhoenixIntegrationTests.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/README //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix.h //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/PhoenixProject.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/PhoenixProject.h //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/PhoenixServicesClient.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/PhoenixServicesClient.h //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/RequestError.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/RequestError.h //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/Session.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/phoenix/Session.h //web-services/p4ws-main/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.h //web-services/p4ws-main/qt/p4_phoenix_services_client/test/SessionTests.cpp //web-services/p4ws-main/qt/p4_phoenix_services_client/test/SessionTests.h //web-services/p4ws-main/qt/p4_project_services_client/CMakeLists.txt //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeCache.txt //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeCCompiler.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeCXXCompiler.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeDetermineCompilerABI_C.bin //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeDetermineCompilerABI_CXX.bin //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CMakeSystem.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CompilerIdC/CMakeCCompilerId.c //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CompilerIdC/a.out //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CompilerIdCXX/CMakeCXXCompilerId.cpp //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/2.8.12/CompilerIdCXX/a.out //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/CMakeDirectoryInformation.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/CMakeOutput.log //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/Makefile.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/Makefile2 //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/TargetDirectories.txt //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/cmake.check_cache //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/DependInfo.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/build.make //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/cmake_clean.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/cmake_clean_target.cmake //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/depend.make //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/flags.make //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/link.txt //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/p4_project_services_client.dir/progress.make //web-services/p4ws-main/qt/p4_project_services_client/build/CMakeFiles/progress.marks //web-services/p4ws-main/qt/p4_project_services_client/build/Makefile //web-services/p4ws-main/qt/p4_project_services_client/build/cmake_install.cmake //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services.h //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/Branch.cpp //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/Branch.h //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/Project.cpp //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/Project.h //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/View.cpp //web-services/p4ws-main/qt/p4_project_services_client/p4_project_services/View.h |
||
//guest/perforce_software/helix-web-services/main/p4_phoenix_services/clients/qt/p4_phoenix_services_client/test/PhoenixServicesClientTests.cpp | |||||
#2 | 13441 | tjuricek |
As an interim step, allow the application/json Accept type to return the p4d ticket for the server. In the future, there will likely be an adjustment to the POST request to store a separate host we attempt to generate a ticket for. Right now, these are host unlocked tickets, and not the production solution. |
||
#1 | 13439 | tjuricek |
Added a *very trivial* logIn implementation. This just makes the *current* POST request to /p4_phoenix_services/v1/sessions, which *does not* include the ability to create a host locked P4 ticket for the user. So it's not quite usable yet. But, I've made several tweaks to the API which should be stablizing. |