~aleteoryx/muditaos

ref: 09556d41a686a95f809638ff2de36f1292571442 muditaos/module-apps/application-call/test/mock/CallPresenterMocks.hpp -rw-r--r-- 3.4 KiB
09556d41 — Lefucjusz [MOS-442] No vibrations on incoming call with HFP fix 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <module-apps/application-call/model/CallModel.hpp>
#include <module-apps/application-call/presenter/CallPresenter.hpp>

namespace app::call
{

    class ViewMock : public CallWindowContract::View
    {
      public:
        void updateDuration(const UTF8 &text, bool isVisible = true) override
        {
            duration = text;
        };
        void refreshWindow() override
        {
            windowRefreshed = true;
        };
        void setNavBarForActiveCall() override{};
        void setNavBarForIncomingCall() override{};
        void clearNavBar() override{};
        void setIncomingCallLayout(bool isValidCallerId) override
        {
            layoutShowed = LayoutShowed::Incoming;
        };
        void setActiveCallLayout() override
        {
            layoutShowed = LayoutShowed::Active;
        };
        ;
        void setCallEndedLayout(bool delayedClose = true) override
        {
            layoutShowed = LayoutShowed::Ended;
        };

        void updateNumber(const UTF8 &text) override
        {
            number = text;
        };

        bool windowRefreshed = false;

        enum class LayoutShowed
        {
            Incoming,
            Active,
            Ended,
            None
        };

        LayoutShowed layoutShowed = LayoutShowed::None;
        UTF8 number;
        UTF8 duration;
    };

    class ModelMock : public AbstractCallModel
    {
      public:
        time_t getTime() override
        {
            return callTime;
        };
        void setTime(time_t newTime) override
        {
            callTime = newTime;
        };
        CallState getState() override
        {
            return callState;
        };
        void setState(CallState newState) override
        {
            callState = newState;
        };
        void setPhoneNumber(const utils::PhoneNumber number) override{};
        utils::PhoneNumber getPhoneNumber() override
        {
            return phoneNumber;
        };
        UTF8 getCallerId() override
        {
            return callerId;
        };

        void hangUpCall() override
        {
            hangupCallCalled = true;
        };
        void answerCall() override
        {
            answerCallCalled = true;
        };
        bool sendSms(const UTF8 &smsBody) override
        {
            return true;
        }
        void transmitDtmfTone(const uint32_t &digit) override{};
        void muteCall() override{};
        void unmuteCall() override{};
        void turnLoudspeakerOn() override{};
        void turnLoudspeakerOff() override{};

        void turnOnKeypadBacklight() override{};
        void turnOffKeypadBacklight() override{};

        void clear() override{};
        void attachDurationChangeCallback(std::function<void()> callback) override{};
        void attachCallStateChangeCallback(std::function<void()> callback) override{};

        bool hangupCallCalled = false;
        bool answerCallCalled = false;

      private:
        Application *application;
        CallState callState = CallState::None;
        time_t callTime     = 0;

        std::function<void()> notifyPresenterOnDurationChange;
        std::function<void()> notifyPresenterOnCallStateChange;

        utils::PhoneNumber phoneNumber;
        UTF8 callerId;

        bool callWasRejected = false;
    };
} // namespace app::call