2 * This file is part of QMAFW
4 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights
7 * Contact: Visa Smolander <visa.smolander@nokia.com>
9 * This software, including documentation, is protected by copyright controlled
10 * by Nokia Corporation. All rights are reserved. Copying, including
11 * reproducing, storing, adapting or translating, any or all of this material
12 * requires the prior written consent of Nokia Corporation. This material also
13 * contains confidential information which may not be disclosed to others
14 * without the prior written consent of Nokia.
18 #ifndef MAFWSTUBHELPER_H_
19 #define MAFWSTUBHELPER_H_
28 * This class is meant to help implementing stubs needed in unit testing.
30 * Usage: Create instance of MafwStubHelper and provide your stub access
31 * to it. Initialize MafwStubHelper with function calls the stub is
32 * expected to get. Implement your stub to ask for return values from
33 * MafwStubHelper. At the end of a test case, check if all expected
45 * expect - Adds call to expected calls
47 * @param function Name of the expected function call, without paranthesis.
48 * @param params List of expected parameters given to function call.
49 * @param returns List of return values to be given to the stub.
51 void expect(const QString function, const QList<QVariant> params, const QList<QVariant> returns);
54 * expect - Adds call to expected calls
56 * @param function Name of the expected function call, without paranthesis.
57 * @param returnVal The return value to be given to the stub.
59 void expect(const QString& function, QVariant returnVal);
62 * getReturn - Consumes call from expected calls
64 * @param function Name of the function call, without paranthesis.
65 * @param params List of parameters given to function call.
66 * @param returns Empty list for getting the return values.
67 * List is empty at return if function wasn't the next expected function call.
69 void getReturn(const QString function, const QList<QVariant> params, QList<QVariant>& returns);
72 * getReturn - Consumes call from expected calls
74 * @param function Name of the function call, without paranthesis.
75 * @return return value is invalid if function wasn't the next expected function call.
77 QVariant getReturn(const QString& function);
80 * allCallsConsumed - Checks if all expected calls are consumed
82 * @return true, if all expected calls are consumed
85 bool allCallsConsumed() const;
88 * clear - Clears all data
93 void printExpects() const;
100 QString expectedName;
101 QList<QVariant> expectedParams;
102 QList<QVariant> returnValues;
105 QQueue<ExpectedItem*> m_expectedCalls;
108 #endif /*MAFWSTUBHELPER_H_*/