diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e640e4ed9..0f9144f42 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,6 +12,22 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) +# -Wold-style-cast \ +set(CUSTOM_FLAGS "\ +-Wcast-align \ +-Wconversion \ +-Wextra \ +-Wfloat-equal \ +-Winit-self \ +-Winline \ +-Wlogical-op \ +-Woverloaded-virtual \ +-Wpointer-arith \ +-Wuninitialized \ +-Wunused \ +") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CUSTOM_FLAGS}") + # -------------------------------------------------------------------- # Define packages, libs, sources, headers, resources and languages # -------------------------------------------------------------------- diff --git a/tests/resources.qrc b/tests/resources.qrc index dab9cb87e..a61a34a38 100644 --- a/tests/resources.qrc +++ b/tests/resources.qrc @@ -140,11 +140,13 @@ ui/modules/Linphone/Styles/qmldir ui/modules/Linphone/Styles/TimelineStyle.qml ui/modules/Linphone/Timeline.qml + ui/scripts/LinphoneUtils/linphone-utils.js + ui/scripts/LinphoneUtils/qmldir ui/scripts/Utils/qmldir ui/scripts/Utils/uri-tools.js ui/scripts/Utils/utils.js + ui/views/App/Calls/AbstractCall.qml ui/views/App/Calls/Calls.qml - ui/views/App/Calls/StartingCall.qml ui/views/App/Calls/StartingIncomingCall.qml ui/views/App/Calls/StartingOutgoingCall.qml ui/views/App/MainWindow/Contact.qml diff --git a/tests/src/components/chat/ChatModel.cpp b/tests/src/components/chat/ChatModel.cpp index e817982a4..077d87e11 100644 --- a/tests/src/components/chat/ChatModel.cpp +++ b/tests/src/components/chat/ChatModel.cpp @@ -20,6 +20,10 @@ QHash ChatModel::roleNames () const { return roles; } +int ChatModel::rowCount (const QModelIndex &) const { + return m_entries.count(); +} + QVariant ChatModel::data (const QModelIndex &index, int role) const { int row = index.row(); @@ -88,7 +92,9 @@ void ChatModel::fillMessageEntry ( const shared_ptr &message ) { dest["type"] = EntryType::MessageEntry; - dest["timestamp"] = QDateTime::fromTime_t(message->getTime()); + dest["timestamp"] = QDateTime::fromMSecsSinceEpoch( + static_cast(message->getTime()) * 1000 + ); dest["content"] = Utils::linphoneStringToQString( message->getText() ); @@ -97,9 +103,11 @@ void ChatModel::fillMessageEntry ( void ChatModel::fillCallStartEntry ( QVariantMap &dest, - const std::shared_ptr &call_log + const shared_ptr &call_log ) { - QDateTime timestamp = QDateTime::fromTime_t(call_log->getStartDate()); + QDateTime timestamp = QDateTime::fromMSecsSinceEpoch( + static_cast(call_log->getStartDate()) * 1000 + ); dest["type"] = EntryType::CallEntry; dest["timestamp"] = timestamp; @@ -110,10 +118,10 @@ void ChatModel::fillCallStartEntry ( void ChatModel::fillCallEndEntry ( QVariantMap &dest, - const std::shared_ptr &call_log + const shared_ptr &call_log ) { - QDateTime timestamp = QDateTime::fromTime_t( - call_log->getStartDate() + call_log->getDuration() + QDateTime timestamp = QDateTime::fromMSecsSinceEpoch( + static_cast(call_log->getStartDate() + call_log->getDuration()) * 1000 ); dest["type"] = EntryType::CallEntry; @@ -139,7 +147,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) { // WARNING: Unable to remove symmetric call here. (start/end) // We are between `beginRemoveRows` and `endRemoveRows`. // A solution is to schedule a `removeEntry` call in the Qt main loop. - std::shared_ptr linphone_ptr = pair.second; + shared_ptr linphone_ptr = pair.second; QTimer::singleShot(0, this, [this, linphone_ptr]() { auto it = find_if( m_entries.begin(), m_entries.end(), @@ -149,7 +157,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) { ); if (it != m_entries.end()) - removeEntry(distance(m_entries.begin(), it)); + removeEntry(static_cast(distance(m_entries.begin(), it))); }); } diff --git a/tests/src/components/chat/ChatModel.hpp b/tests/src/components/chat/ChatModel.hpp index 44cb0d4e4..e5fd948c0 100644 --- a/tests/src/components/chat/ChatModel.hpp +++ b/tests/src/components/chat/ChatModel.hpp @@ -47,9 +47,7 @@ public: ChatModel (QObject *parent = Q_NULLPTR) : QAbstractListModel(parent) {} - int rowCount (const QModelIndex &index = QModelIndex()) const { - return m_entries.count(); - } + int rowCount (const QModelIndex &index = QModelIndex()) const; QHash roleNames () const; QVariant data (const QModelIndex &index, int role) const; diff --git a/tests/src/components/chat/ChatProxyModel.hpp b/tests/src/components/chat/ChatProxyModel.hpp index 6079d0445..e0054c0f4 100644 --- a/tests/src/components/chat/ChatProxyModel.hpp +++ b/tests/src/components/chat/ChatProxyModel.hpp @@ -75,7 +75,7 @@ private: ChatModelFilter m_chat_model_filter; - unsigned int m_n_max_displayed_entries = ENTRIES_CHUNK_SIZE; + int m_n_max_displayed_entries = ENTRIES_CHUNK_SIZE; static const unsigned int ENTRIES_CHUNK_SIZE; }; diff --git a/tests/src/components/contacts/ContactsListModel.cpp b/tests/src/components/contacts/ContactsListModel.cpp index b67063627..0af38c443 100644 --- a/tests/src/components/contacts/ContactsListModel.cpp +++ b/tests/src/components/contacts/ContactsListModel.cpp @@ -24,6 +24,10 @@ ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(paren } } +int ContactsListModel::rowCount (const QModelIndex &) const { + return m_list.count(); +} + QHash ContactsListModel::roleNames () const { QHash roles; roles[Qt::DisplayRole] = "$contact"; diff --git a/tests/src/components/contacts/ContactsListModel.hpp b/tests/src/components/contacts/ContactsListModel.hpp index 9c34b1d94..3f09033e6 100644 --- a/tests/src/components/contacts/ContactsListModel.hpp +++ b/tests/src/components/contacts/ContactsListModel.hpp @@ -16,9 +16,7 @@ class ContactsListModel : public QAbstractListModel { public: ContactsListModel (QObject *parent = Q_NULLPTR); - int rowCount (const QModelIndex &index = QModelIndex()) const { - return m_list.count(); - } + int rowCount (const QModelIndex &index = QModelIndex()) const; QHash roleNames () const; QVariant data (const QModelIndex &index, int role) const; diff --git a/tests/src/components/contacts/ContactsListProxyModel.cpp b/tests/src/components/contacts/ContactsListProxyModel.cpp index 98e920297..9569070d9 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.cpp +++ b/tests/src/components/contacts/ContactsListProxyModel.cpp @@ -6,14 +6,14 @@ #include "ContactsListProxyModel.hpp" -#define USERNAME_WEIGHT 50.0 -#define MAIN_SIP_ADDRESS_WEIGHT 25.0 -#define OTHER_SIP_ADDRESSES_WEIGHT 25.0 +#define USERNAME_WEIGHT 50.0f +#define MAIN_SIP_ADDRESS_WEIGHT 25.0f +#define OTHER_SIP_ADDRESSES_WEIGHT 25.0f -#define FACTOR_POS_1 0.90 -#define FACTOR_POS_2 0.80 -#define FACTOR_POS_3 0.70 -#define FACTOR_POS_OTHER 0.60 +#define FACTOR_POS_1 0.90f +#define FACTOR_POS_2 0.80f +#define FACTOR_POS_3 0.70f +#define FACTOR_POS_OTHER 0.60f using namespace std; @@ -63,7 +63,9 @@ bool ContactsListProxyModel::filterAcceptsRow ( index.data() ); - int weight = m_weights[contact] = computeContactWeight(*contact); + unsigned int weight = m_weights[contact] = static_cast( + computeContactWeight(*contact) + ); return weight > 0 && ( !m_use_connected_filter || @@ -79,8 +81,8 @@ bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelInde sourceModel()->data(right) ); - float weight_a = m_weights[contact_a]; - float weight_b = m_weights[contact_b]; + unsigned int weight_a = m_weights[contact_a]; + unsigned int weight_b = m_weights[contact_b]; // Sort by weight and name. return ( @@ -139,8 +141,7 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel &contact) ); // Compute for other addresses. - int size = addresses.size(); - + float size = static_cast(addresses.size()); for (++it; it != addresses.cend(); ++it) weight += computeStringWeight( Utils::linphoneStringToQString((*it)->asString()), diff --git a/tests/src/components/contacts/ContactsListProxyModel.hpp b/tests/src/components/contacts/ContactsListProxyModel.hpp index 9b9414bf1..57511983d 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.hpp +++ b/tests/src/components/contacts/ContactsListProxyModel.hpp @@ -50,7 +50,7 @@ private: // It's just a cache to save values computed by `filterAcceptsRow` // and reused by `lessThan`. - mutable QHash m_weights; + mutable QHash m_weights; bool m_use_connected_filter; }; diff --git a/tests/src/components/core/CoreManager.cpp b/tests/src/components/core/CoreManager.cpp index 4a24ab115..184a8941c 100644 --- a/tests/src/components/core/CoreManager.cpp +++ b/tests/src/components/core/CoreManager.cpp @@ -6,7 +6,7 @@ CoreManager *CoreManager::m_instance = nullptr; -CoreManager::CoreManager (QObject *parent) : m_core( +CoreManager::CoreManager (QObject *parent) : QObject(parent), m_core( linphone::Factory::get()->createCore(nullptr, "", "", nullptr) ) { setDatabasesPaths(); diff --git a/tests/src/components/timeline/TimelineModel.cpp b/tests/src/components/timeline/TimelineModel.cpp index 61b3f38dc..c30eb43fa 100644 --- a/tests/src/components/timeline/TimelineModel.cpp +++ b/tests/src/components/timeline/TimelineModel.cpp @@ -81,7 +81,9 @@ void TimelineModel::init_entries () { // Insert event message in timeline entries. QVariantMap map; - map["timestamp"] = QDateTime::fromTime_t(message->getTime()); + map["timestamp"] = QDateTime::fromMSecsSinceEpoch( + static_cast(message->getTime()) * 1000 + ); map["sipAddresses"] = Utils::linphoneStringToQString( chat_room->getPeerAddress()->asString() ); @@ -104,8 +106,8 @@ void TimelineModel::init_entries () { // Make a new map. QVariantMap map; - map["timestamp"] = QDateTime::fromTime_t( - call_log->getStartDate() + call_log->getDuration() + map["timestamp"] = QDateTime::fromMSecsSinceEpoch( + static_cast(call_log->getStartDate() + call_log->getDuration()) * 1000 ); map["sipAddresses"] = address; diff --git a/tests/src/utils.hpp b/tests/src/utils.hpp index db22ff0c6..65b93705a 100644 --- a/tests/src/utils.hpp +++ b/tests/src/utils.hpp @@ -3,9 +3,11 @@ #include +// =================================================================== + namespace Utils { inline QString linphoneStringToQString (const std::string &string) { - return QString::fromLocal8Bit(string.c_str(), string.size()); + return QString::fromLocal8Bit(string.c_str(), static_cast(string.size())); } inline std::string qStringToLinphoneString (const QString &string) { diff --git a/tests/ui/modules/Linphone/Contact/Contact.qml b/tests/ui/modules/Linphone/Contact/Contact.qml index a1b36ddbd..9b014ad17 100644 --- a/tests/ui/modules/Linphone/Contact/Contact.qml +++ b/tests/ui/modules/Linphone/Contact/Contact.qml @@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3 import Common 1.0 import Linphone 1.0 +import LinphoneUtils 1.0 import Linphone.Styles 1.0 import Utils 1.0 @@ -39,9 +40,7 @@ Rectangle { Layout.preferredWidth: ContactStyle.contentHeight image: contact.avatar || '' presenceLevel: contact.presenceLevel || Presence.White - username: Utils.isString(contact) - ? contact.substring(4, contact.indexOf('@')) // 4 = length("sip:") - : contact.username + username: LinphoneUtils.getContactUsername(contact) } ContactDescription { diff --git a/tests/ui/views/App/Calls/Calls.qml b/tests/ui/views/App/Calls/Calls.qml index e289713a2..7ec75df7a 100644 --- a/tests/ui/views/App/Calls/Calls.qml +++ b/tests/ui/views/App/Calls/Calls.qml @@ -26,44 +26,49 @@ Window { // Calls list. // --------------------------------------------------------------- - childA: ColumnLayout { + childA: Rectangle { anchors.fill: parent - spacing: 0 - - Rectangle { - Layout.fillWidth: true - Layout.preferredHeight: 50 - color: '#FFFFFF' - - ActionBar { - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 10 - anchors.left: parent.left - iconSize: 30 - spacing: 16 - - ActionButton { - icon: 'call' - } - - ActionButton { - icon: 'conference' - } - } - } - - ScrollableListView { - Layout.fillWidth: true - Layout.fillHeight: true - spacing: 1 - delegate: CallControls { - width: parent.width - } - - model: callsList - } + color: 'yellow' } + /* childA: ColumnLayout { */ + /* anchors.fill: parent */ + /* spacing: 0 */ + + /* Rectangle { */ + /* Layout.fillWidth: true */ + /* Layout.preferredHeight: 50 */ + /* color: '#FFFFFF' */ + + /* ActionBar { */ + /* anchors.verticalCenter: parent.verticalCenter */ + /* anchors.leftMargin: 10 */ + /* anchors.left: parent.left */ + /* iconSize: 30 */ + /* spacing: 16 */ + + /* ActionButton { */ + /* icon: 'call' */ + /* } */ + + /* ActionButton { */ + /* icon: 'conference' */ + /* } */ + /* } */ + /* } */ + + /* ScrollableListView { */ + /* Layout.fillWidth: true */ + /* Layout.fillHeight: true */ + /* spacing: 1 */ + /* delegate: CallControls { */ + /* width: parent.width */ + /* } */ + + /* model: callsList */ + /* } */ + /* } */ + // --------------------------------------------------------------- // Content. // --------------------------------------------------------------- @@ -78,14 +83,20 @@ Window { resizeAInPriority: true // Call. - childA: Rectangle { + childA: AbstractCall { anchors.fill: parent + callTypeLabel: 'INCOMING VIDEO CALL' + } + + childB: Rectangle { + anchors.fill: parent + color: 'green' } // Chat. - childB: Chat { - anchors.fill: parent - } + //childB: Chat { + // anchors.fill: parent + //} } } diff --git a/tests/ui/views/App/Calls/StartingCall.qml b/tests/ui/views/App/Calls/StartingCall.qml deleted file mode 100644 index 72f74cfad..000000000 --- a/tests/ui/views/App/Calls/StartingCall.qml +++ /dev/null @@ -1,93 +0,0 @@ -import QtQuick 2.7 -import QtQuick.Layouts 1.3 - -import Common 1.0 -import Linphone 1.0 - -Rectangle { - property alias callType: callType.text - property alias sipAddress: contactDescription.sipAddress - property alias username: contactDescription.username - property alias avatarImage: image.source - - default property alias _actionArea: actionArea.data - - color: '#EAEAEA' - - ColumnLayout { - anchors { - fill: parent - margins: 20 - } - - spacing: 0 - - // Call type. - Column { - Layout.fillWidth: true - - Text { - id: callType - - color: '#8E8E8E' - font.bold: true - font.pointSize: 17 - horizontalAlignment: Text.AlignHCenter - width: parent.width - } - - CaterpillarAnimation { - anchors.horizontalCenter: parent.horizontalCenter - } - } - - // Contact area. - Item { - id: contactContainer - - Layout.fillWidth: true - Layout.fillHeight: true - - Item { - anchors.verticalCenter: parent.verticalCenter - implicitHeight: contactDescription.height + image.height - width: parent.width - - ContactDescription { - id: contactDescription - - height: 60 - horizontalTextAlignment: Text.AlignHCenter - width: parent.width - } - - RoundedImage { - id: image - - function _computeImageSize () { - var height = contactContainer.height - contactDescription.height - var width = contactContainer.width - - var size = height < 400 ? height : 400 - return size < width ? size : width - } - - anchors.top: contactDescription.bottom - anchors.horizontalCenter: parent.horizontalCenter - height: _computeImageSize() - width: height - } - } - } - - // Actions area. - Item { - id: actionArea - - Layout.alignment: Qt.AlignHCenter - Layout.fillWidth: true - Layout.preferredHeight: 80 - Layout.topMargin: 20 - } - } -} diff --git a/tests/ui/views/App/MainWindow/Conversation.qml b/tests/ui/views/App/MainWindow/Conversation.qml index 45193fb50..322558600 100644 --- a/tests/ui/views/App/MainWindow/Conversation.qml +++ b/tests/ui/views/App/MainWindow/Conversation.qml @@ -3,6 +3,7 @@ import QtQuick.Layouts 1.3 import Common 1.0 import Linphone 1.0 +import LinphoneUtils 1.0 import Utils 1.0 import App.Styles 1.0 @@ -57,9 +58,7 @@ ColumnLayout { Layout.preferredHeight: ConversationStyle.bar.avatarSize Layout.preferredWidth: ConversationStyle.bar.avatarSize presenceLevel: _contact.presenceLevel || Presence.White - username: Utils.isString(_contact) - ? _contact.substring(4, _contact.indexOf('@')) // 4 = length("sip:") - : _contact.username + username: LinphoneUtils.getContactUsername(_contact) } ContactDescription {