Gittyup/test/Test.h

55 lines
1.1 KiB
C
Raw Normal View History

2018-12-13 02:22:04 +03:00
//
// Copyright (c) 2016, Scientific Toolworks, Inc.
//
// This software is licensed under the MIT License. The LICENSE.md file
// describes the conditions under which this software may be distributed.
//
// Author: Jason Haslam
//
#ifndef TEST_H
#define TEST_H
#include "app/Application.h"
#include "git/Repository.h"
#include <QTemporaryDir>
#include <QtTest/QtTest>
#define TEST_MAIN(TestClass) \
int main(int argc, char *argv[]) \
{ \
int orig_argc = argc;\
Application app = Test::createApp(argc, argv); \
2018-12-13 02:22:04 +03:00
TestClass test; \
QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&test, orig_argc, argv); \
2018-12-13 02:22:04 +03:00
}
class RepoView;
namespace Test {
class ScratchRepository
{
public:
ScratchRepository(bool autoRemove = true);
// Treat this class a wrapper.
operator git::Repository();
git::Repository *operator->();
private:
QTemporaryDir mDir;
git::Repository mRepo;
};
void refresh(RepoView *repoView, bool expectDirty = true);
void fetch(RepoView *repoView, git::Remote remote);
QString extractRepository(const QString &filename, bool useTempDir);
2018-12-13 02:22:04 +03:00
Application createApp(int &argc, char *argv[]);
2018-12-13 02:22:04 +03:00
} // namespace Test
#endif