Commit 347bd2b4 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix tests

parent 186b043d
Pipeline #68811 canceled with stage
......@@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "trackmodel.hpp"
#include "transitions/transitionsrepository.hpp"
#include "mainwindow.h"
#include "project/projectmanager.h"
#include <QApplication>
#include <QDebug>
......@@ -60,7 +61,9 @@ RTTR_REGISTRATION
using namespace rttr;
registration::class_<TimelineFunctions>("TimelineFunctions")
.method("requestClipCut", select_overload<bool(std::shared_ptr<TimelineItemModel>, int, int)>(&TimelineFunctions::requestClipCut))(
parameter_names("timeline", "clipId", "position"));
parameter_names("timeline", "clipId", "position"))
.method("requestDeleteBlankAt", select_overload<bool(const std::shared_ptr<TimelineItemModel>&, int, int, bool)>(&TimelineFunctions::requestDeleteBlankAt))(
parameter_names("timeline", "trackId", "position", "affectAllTracks"));
}
#else
#define TRACE_STATIC(...)
......@@ -434,8 +437,8 @@ bool TimelineFunctions::requestSpacerEndOperation(const std::shared_ptr<Timeline
if (moveGuides) {
GenTime fromPos(startPosition, pCore->getCurrentFps());
GenTime toPos(endPosition, pCore->getCurrentFps());
QList<CommentedTime> guides = pCore->currentDoc()->getGuideModel()->getMarkersInRange(startPosition, -1);
pCore->currentDoc()->getGuideModel()->moveMarkers(guides, fromPos, toPos, undo, redo);
QList<CommentedTime> guides = pCore->projectManager()->getGuideModel()->getMarkersInRange(startPosition, -1);
pCore->projectManager()->getGuideModel()->moveMarkers(guides, fromPos, toPos, undo, redo);
}
std::unordered_set<int> clips = timeline->getGroupElements(itemId);
......
......@@ -2,20 +2,14 @@
/*
* FakeIt - A Simplified C++ Mocking Framework
* Copyright (c) Eran Pe'er 2013
* Generated: 2018-08-17 00:22:40.428924
* Generated: 2021-05-12 13:47:05.726214
* Distributed under the MIT License. Please refer to the LICENSE file at:
* https://github.com/eranpeer/FakeIt
*/
#ifndef fakeit_h__
#define fakeit_h__
#if defined __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wcast-function-type"
# pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#include <functional>
#include <memory>
......@@ -988,7 +982,19 @@ namespace fakeit {
}
};
}
#include <exception>
namespace fakeit {
#if __cplusplus >= 201703L || defined(__cpp_lib_uncaught_exceptions)
inline bool UncaughtException () {
return std::uncaught_exceptions() >= 1;
}
#else
inline bool UncaughtException () {
return std::uncaught_exception();
}
#endif
struct FakeitException {
std::exception err;
......@@ -1127,65 +1133,59 @@ namespace fakeit {
namespace fakeit {
struct VerificationException : public FakeitException {
virtual ~VerificationException() = default;
struct VerificationException : public std::exception {
virtual ~VerificationException() NO_THROWS{};
void setFileInfo(const char *file, int line, const char *callingMethod) {
_file = file;
_callingMethod = callingMethod;
_line = line;
VerificationException(std::string format) :
_format(format) {
}
const char *file() const {
return _file;
friend std::ostream &operator<<(std::ostream &os, const VerificationException &val) {
os << val.what();
return os;
}
void setFileInfo(std::string aFile, int aLine, std::string aCallingMethod) {
_file = aFile;
_callingMethod = aCallingMethod;
_line = aLine;
}
const std::string& file() const {
return _file;
}
int line() const {
return _line;
}
const char *callingMethod() const {
const std::string& callingMethod() const {
return _callingMethod;
}
const char* what() const NO_THROWS override{
return _format.c_str();
}
private:
const char *_file;
std::string _file;
int _line;
const char *_callingMethod;
std::string _callingMethod;
std::string _format;
};
struct NoMoreInvocationsVerificationException : public VerificationException {
NoMoreInvocationsVerificationException(std::string format) :
_format(format) {
}
virtual std::string what() const override {
return _format;
VerificationException(format) {
}
private:
std::string _format;
};
struct SequenceVerificationException : public VerificationException {
SequenceVerificationException(const std::string &format) :
_format(format)
{
}
virtual std::string what() const override {
return _format;
SequenceVerificationException(std::string format) :
VerificationException(format) {
}
private:
std::string _format;
};
class CatchAdapter : public EventHandler {
EventFormatter &_formatter;
struct StandaloneAdapter : public EventHandler {
std::string formatLineNumber(std::string file, int num) {
std::string formatLineNumner(std::string file, int num){
#ifndef __GNUG__
return file + std::string("(") + fakeit::to_string(num) + std::string(")");
#else
......@@ -1193,82 +1193,62 @@ namespace fakeit {
#endif
}
public:
virtual ~StandaloneAdapter() = default;
virtual ~CatchAdapter() = default;
CatchAdapter(EventFormatter &formatter)
: _formatter(formatter) {}
void fail(
std::string vetificationType,
Catch::SourceLineInfo sourceLineInfo,
std::string failingExpression,
std::string fomattedMessage,
Catch::ResultWas::OfType resultWas = Catch::ResultWas::OfType::ExpressionFailed ){
Catch::AssertionHandler catchAssertionHandler( vetificationType, sourceLineInfo, failingExpression, Catch::ResultDisposition::Normal );
INTERNAL_CATCH_TRY { \
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
catchAssertionHandler.handleMessage(resultWas, fomattedMessage); \
CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
} INTERNAL_CATCH_CATCH(catchAssertionHandler) { \
INTERNAL_CATCH_REACT(catchAssertionHandler) \
}
StandaloneAdapter(EventFormatter &formatter)
: _formatter(formatter) {
}
virtual void handle(const UnexpectedMethodCallEvent &evt) override {
std::string format = _formatter.format(evt);
fail("UnexpectedMethodCall",::Catch::SourceLineInfo("Unknown file",0),"",format, Catch::ResultWas::OfType::ExplicitFailure);
UnexpectedMethodCallException ex(format);
throw ex;
}
virtual void handle(const SequenceVerificationEvent &evt) override {
std::string format(formatLineNumber(evt.file(), evt.line()) + ": " + _formatter.format(evt));
std::string expectedPattern {DefaultEventFormatter::formatExpectedPattern(evt.expectedPattern())};
fail("Verify",::Catch::SourceLineInfo(evt.file(),evt.line()),expectedPattern,format);
std::string format(formatLineNumner(evt.file(), evt.line()) + ": " + _formatter.format(evt));
SequenceVerificationException e(format);
e.setFileInfo(evt.file(), evt.line(), evt.callingMethod());
throw e;
}
virtual void handle(const NoMoreInvocationsVerificationEvent &evt) override {
std::string format(formatLineNumber(evt.file(), evt.line()) + ": " + _formatter.format(evt));
fail("VerifyNoMoreInvocations",::Catch::SourceLineInfo(evt.file(),evt.line()),"",format);
std::string format(formatLineNumner(evt.file(), evt.line()) + ": " + _formatter.format(evt));
NoMoreInvocationsVerificationException e(format);
e.setFileInfo(evt.file(), evt.line(), evt.callingMethod());
throw e;
}
private:
EventFormatter &_formatter;
};
class CatchFakeit : public DefaultFakeit {
class StandaloneFakeit : public DefaultFakeit {
public:
virtual ~StandaloneFakeit() = default;
virtual ~CatchFakeit() = default;
CatchFakeit() : _formatter(), _catchAdapter(_formatter) {}
StandaloneFakeit() : _standaloneAdapter(*this) {
}
static CatchFakeit &getInstance() {
static CatchFakeit instance;
static StandaloneFakeit &getInstance() {
static StandaloneFakeit instance;
return instance;
}
protected:
fakeit::EventHandler &accessTestingFrameworkAdapter() override {
return _catchAdapter;
}
EventFormatter &accessEventFormatter() override {
return _formatter;
return _standaloneAdapter;
}
private:
DefaultEventFormatter _formatter;
CatchAdapter _catchAdapter;
StandaloneAdapter _standaloneAdapter;
};
}
static fakeit::DefaultFakeit& Fakeit = fakeit::CatchFakeit::getInstance();
static fakeit::DefaultFakeit& Fakeit = fakeit::StandaloneFakeit::getInstance();
#include <type_traits>
......@@ -5305,9 +5285,16 @@ namespace fakeit {
};
}
#if defined(__GNUG__) && !defined(__clang__)
#define FAKEIT_NO_DEVIRTUALIZE_ATTR [[gnu::optimize("no-devirtualize")]]
#else
#define FAKEIT_NO_DEVIRTUALIZE_ATTR
#endif
namespace fakeit {
template<typename TARGET, typename SOURCE>
FAKEIT_NO_DEVIRTUALIZE_ATTR
TARGET union_cast(SOURCE source) {
union {
......@@ -5329,12 +5316,19 @@ namespace fakeit {
class VTUtils {
public:
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif
template<typename C, typename R, typename ... arglist>
static unsigned int getOffset(R (C::*vMethod)(arglist...)) {
auto sMethod = reinterpret_cast<unsigned int (VirtualOffsetSelector::*)(int)>(vMethod);
VirtualOffsetSelector offsetSelctor;
return (offsetSelctor.*sMethod)(0);
}
#if defined(__GNUG__) && !defined(__clang__) && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
template<typename C>
static typename std::enable_if<std::has_virtual_destructor<C>::value, unsigned int>::type
......@@ -5364,12 +5358,12 @@ namespace fakeit {
template<typename C>
static unsigned int getVTSize() {
struct Derived : public C {
struct Derrived : public C {
virtual void endOfVt() {
}
};
unsigned int vtSize = getOffset(&Derived::endOfVt);
unsigned int vtSize = getOffset(&Derrived::endOfVt);
return vtSize;
}
};
......@@ -5473,6 +5467,7 @@ namespace fakeit {
signature(0), offset(0), cdOffset(0),
typeDescriptorOffset(0), classDescriptorOffset(0)
{
(void)unused;
}
dword_ signature;
......@@ -5822,73 +5817,78 @@ namespace fakeit {
}
#include <new>
namespace fakeit {
#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#endif
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4200 )
#endif
namespace fakeit
{
namespace details
{
template <int instanceAreaSize, typename C, typename... BaseClasses>
class FakeObjectImpl
{
public:
void initializeDataMembersArea()
{
for (size_t i = 0; i < instanceAreaSize; ++i)
{
instanceArea[i] = (char) 0;
}
}
template<typename C, typename ... baseclasses>
class FakeObject {
protected:
VirtualTable<C, BaseClasses...> vtable;
char instanceArea[instanceAreaSize];
};
VirtualTable<C, baseclasses...> vtable;
template <typename C, typename... BaseClasses>
class FakeObjectImpl<0, C, BaseClasses...>
{
public:
void initializeDataMembersArea()
{}
static const size_t SIZE = sizeof(C) - sizeof(VirtualTable<C, baseclasses...>);
char instanceArea[SIZE ? SIZE : 0];
protected:
VirtualTable<C, BaseClasses...> vtable;
};
}
FakeObject(FakeObject const &) = delete;
FakeObject &operator=(FakeObject const &) = delete;
template <typename C, typename... BaseClasses>
class FakeObject
: public details::FakeObjectImpl<sizeof(C) - sizeof(VirtualTable<C, BaseClasses...>), C, BaseClasses...>
{
FakeObject(FakeObject const&) = delete;
FakeObject& operator=(FakeObject const&) = delete;
public:
FakeObject() : vtable() {
initializeDataMembersArea();
}
~FakeObject() {
vtable.dispose();
FakeObject()
{
this->initializeDataMembersArea();
}
void initializeDataMembersArea() {
for (size_t i = 0; i < SIZE; ++i) instanceArea[i] = (char) 0;
~FakeObject()
{
this->vtable.dispose();
}
void setMethod(unsigned int index, void *method) {
vtable.setMethod(index, method);
void setMethod(unsigned int index, void* method)
{
this->vtable.setMethod(index, method);
}
VirtualTable<C, baseclasses...> &getVirtualTable() {
return vtable;
VirtualTable<C, BaseClasses...>& getVirtualTable()
{
return this->vtable;
}
void setVirtualTable(VirtualTable<C, baseclasses...> &t) {
vtable = t;
void setVirtualTable(VirtualTable<C, BaseClasses...>& t)
{
this->vtable = t;
}
void setDtor(void *dtor) {
vtable.setDtor(dtor);
void setDtor(void* dtor)
{
this->vtable.setDtor(dtor);
}
};
#ifdef _MSC_VER
#pragma warning( pop )
#endif
#ifdef __GNUG__
#ifndef __clang__
#pragma GCC diagnostic pop
#endif
#endif
}
namespace fakeit {
......@@ -6190,31 +6190,31 @@ namespace fakeit {
template<int N>
struct apply_func {
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t, Args &... args) {
return apply_func<N - 1>::template applyTuple(f, t, std::get<N - 1>(t), args...);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> &t, Args &... args) {
return apply_func<N - 1>::template applyTuple<R>(std::forward<FunctionType>(f), t, std::get<N - 1>(t), args...);
}
};
template<>
struct apply_func < 0 > {
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> & , Args &... args) {
return f(args...);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename ... Args, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> & , Args &... args) {
return std::forward<FunctionType>(f)(args...);
}
};
struct TupleDispatcher {
template<typename R, typename ... ArgsF, typename ... ArgsT>
static R applyTuple(std::function<R(ArgsF &...)> f, std::tuple<ArgsT...> &t) {
return apply_func<sizeof...(ArgsT)>::template applyTuple(f, t);
template<typename R, typename ... ArgsF, typename ... ArgsT, typename FunctionType>
static R applyTuple(FunctionType&& f, std::tuple<ArgsT...> &t) {
return apply_func<sizeof...(ArgsT)>::template applyTuple<R>(std::forward<FunctionType>(f), t);
}
template<typename R, typename ...arglist>
static R invoke(std::function<R(arglist &...)> func, const std::tuple<arglist...> &arguments) {
template<typename R, typename ...arglist, typename FunctionType>
static R invoke(FunctionType&& func, const std::tuple<arglist...> &arguments) {
std::tuple<arglist...> &args = const_cast<std::tuple<arglist...> &>(arguments);
return applyTuple(func, args);
return applyTuple<R>(std::forward<FunctionType>(func), args);
}
template<typename TupleType, typename FunctionType>
......@@ -7034,7 +7034,7 @@ namespace fakeit {
template<int q>
struct Times : public Quantity {
Times<q>() : Quantity(q) { }
Times() : Quantity(q) { }
template<typename R>
static Quantifier<R> of(const R &value) {
......@@ -8480,7 +8480,7 @@ namespace fakeit {
virtual ~StubbingChange() THROWS {
if (std::uncaught_exception()) {
if (UncaughtException()) {
return;
}
......@@ -8740,7 +8740,7 @@ namespace fakeit {
friend class SequenceVerificationProgress;
~SequenceVerificationExpectation() THROWS {
if (std::uncaught_exception()) {
if (UncaughtException()) {
return;
}
VerifyExpectation(_fakeit);
......@@ -9088,7 +9088,7 @@ namespace fakeit {
friend class VerifyNoOtherInvocationsVerificationProgress;
~VerifyNoOtherInvocationsExpectation() THROWS {
if (std::uncaught_exception()) {
if (UncaughtException()) {
return;
}
......@@ -9341,7 +9341,7 @@ namespace fakeit {
#endif
#define MOCK_TYPE(mock) \
std::remove_reference<decltype(mock.get())>::type
std::remove_reference<decltype((mock).get())>::type
#define OVERLOADED_METHOD_PTR(mock, method, prototype) \
fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::get(&MOCK_TYPE(mock)::method)
......@@ -9350,16 +9350,16 @@ namespace fakeit {
fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::getconst(&MOCK_TYPE(mock)::method)
#define Dtor(mock) \
mock.dtor().setMethodDetails(#mock,"destructor")
(mock).dtor().setMethodDetails(#mock,"destructor")
#define Method(mock, method) \
mock.template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)
#define OverloadedMethod(mock, method, prototype) \
mock.template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
#define ConstOverloadedMethod(mock, method, prototype) \
mock.template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
#define Verify(...) \
Verify( __VA_ARGS__ ).setFileInfo(__FILE__, __LINE__, __func__)
......@@ -9376,16 +9376,3 @@ namespace fakeit {
#define When(call) \
When(call)
#ifdef __clang__
//# ifdef __ICC // icpc defines the __clang__ macro
//# pragma warning(pop)
//# else
//# pragma clang diagnostic pop
//# endif
#endif
#if defined __GNUC__
# pragma GCC diagnostic pop
#endif
#endif
......@@ -544,6 +544,7 @@ TEST_CASE("Insert/delete", "[Trimming2]")
Mock<ProjectManager> pmMock;
When(Method(pmMock, undoStack)).AlwaysReturn(undoStack);
When(Method(pmMock, getGuideModel)).AlwaysReturn(guideModel);
ProjectManager &mocked = pmMock.get();
pCore->m_projectManager = &mocked;
......@@ -1069,3 +1070,4 @@ TEST_CASE("Copy/paste", "[CP]")
binModel->clean();
pCore->m_projectManager = nullptr;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment