on xenial help sign in
Merge lp:~nick-dedekind/unity8/indicator-tests-qt5.2.1.
commitd1fae99b7c02a3365b0ae9925a885dc2c44435bc authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 3 Mar 2014, 13:44 (13 years ago) parent10c6acf53b142d
9 files changed+218−39
po/ast.po+11−9 qml/Panel/IndicatorItem.qml+13−21 tests/mocks/Unity/Indicators/CMakeLists.txt+1 tests/mocks/Unity/Indicators/IndicatorsModel.qml+3−5 tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp+122 tests/mocks/Unity/Indicators/fakeindicatorsmodel.h+61 tests/mocks/Unity/Indicators/fakeplugin.cpp+3 tests/qmltests/Panel/tst_IndicatorRow.qml+3−3 tests/qmltests/Panel/tst_MenuContent.qml+1−1
po/ast.po+11−9
@@ -8,15 +8,15 @@ msgstr ""
88"Project-Id-Version: unity8\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2014-02-13 18:37+0000\n"
11−"PO-Revision-Date: 2013-12-11 20:45+0000\n"
12−"Last-Translator: ivarela <ivarela@ubuntu.com>\n"
11+"PO-Revision-Date: 2014-03-01 16:51+0000\n"
12+"Last-Translator: Xuacu Saturio <xuacusk8@gmail.com>\n"
1313"Language-Team: Asturian <ast@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2014-02-19 05:44+0000\n"
19−"X-Generator: Launchpad (build 16916)\n"
18+"X-Launchpad-Export-Date: 2014-03-02 05:30+0000\n"
19+"X-Generator: Launchpad (build 16948)\n"
2020
2121#: plugins/Unity/Launcher/launcheritem.cpp:43
2222#: plugins/Unity/Launcher/launcheritem.cpp:73
@@ -74,6 +74,8 @@ msgid ""
7474"You have now mastered the edge gestures and can start using the "
7575"phone<br><br>Tap on the screen to start"
7676msgstr ""
77+"Agora domina los xestos de los bordes y pue principiar a usar el "
78+"teléfonu<br><br>Toque la pantalla pa comenzar"
7779
7880#: qml/Components/PageHeader.qml:340
7981msgid "Recent searches"
@@ -81,11 +83,11 @@ msgstr "Busques recientes"
8183
8284#: qml/Components/SeeMore.qml:35
8385msgid "See more"
84−msgstr ""
86+msgstr "Ver más"
8587
8688#: qml/Components/SeeMore.qml:57
8789msgid "See less"
88−msgstr ""
90+msgstr "Ver menos"
8991
9092#: qml/Dash/Apps/AppPreview.qml:136 qml/Dash/Previews/PreviewRating.qml:70
9193msgid "Rate this"
@@ -107,11 +109,11 @@ msgstr[1] "%1 reseñes"
107109
108110#: qml/Dash/Previews/PreviewActionCombo.qml:34
109111msgid "More..."
110−msgstr ""
112+msgstr "Más…"
111113
112114#: qml/Dash/Previews/PreviewActionCombo.qml:34
113115msgid "Less..."
114−msgstr ""
116+msgstr "Menos…"
115117
116118#: qml/Dash/Previews/PreviewRating.qml:114 qml/Dash/Previews/Reviews.qml:74
117119msgid "Add a review"
@@ -168,7 +170,7 @@ msgstr "Amosar contraseña"
168170
169171#: qml/Notifications/NotificationMenuItemFactory.qml:103
170172msgid "Please enter SIM PIN"
171−msgstr ""
173+msgstr "Escriba'l PIN de la SIM"
172174
173175#: qml/Panel/SearchIndicator.qml:27
174176msgid "Search"
qml/Panel/IndicatorItem.qml+13−21
@@ -19,37 +19,29 @@ import Ubuntu.Components 0.1
1919import Unity.Indicators 0.1 as Indicators
2020import "../Components"
2121
22−Item {
23− id: indicatorItem
22+Loader {
23+ id: root
2424
25− property alias widgetSource: loader.source
25+ property alias widgetSource: root.source
2626 property bool dimmed: false
2727 property var indicatorProperties: undefined
28− property bool indicatorVisible: loader.item ? loader.item.enabled : false
28+ property bool indicatorVisible: item ? item.enabled : false
2929 property string identifier
3030
3131 opacity: dimmed ? 0.4 : 1
3232 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
3333
34− width: loader.item ? loader.item.width : 0
35−
36− Loader {
37− id: loader
38−
39− onLoaded: {
40− item.height = Qt.binding(function() { return indicatorItem.height; });
41−
42− for(var pName in indicatorProperties) {
43− if (item.hasOwnProperty(pName)) {
44− item[pName] = indicatorProperties[pName];
45− }
34+ onLoaded: {
35+ for(var pName in indicatorProperties) {
36+ if (item.hasOwnProperty(pName)) {
37+ item[pName] = indicatorProperties[pName];
4638 }
4739 }
40+ }
4841
49− Binding {
50− target: loader.item
51− property: "objectName"
52− value: identifier + "-widget"
53− }
42+ Binding {
43+ target: item
44+ property: "objectName"
45+ value: identifier + "-widget"
5446 }
5547}
tests/mocks/Unity/Indicators/CMakeLists.txt+1
@@ -16,6 +16,7 @@ set(IndicatorsFakeQml_SOURCES
1616 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp
1717 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
1818 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
19+ fakeindicatorsmodel.cpp
1920)
2021
2122set(IndicatorsFakeQml_RESOURCES
tests/mocks/Unity/Indicators/IndicatorsModel.qml+3−5
@@ -17,12 +17,10 @@
1717import QtQuick 2.0
1818import Unity.Indicators 0.1 as Indicators
1919
20−ListModel {
20+Indicators.FakeIndicatorsModel {
2121
22− property var indicatorData : undefined
23−
24− function load() {
25− clear();
22+ function load(profile) {
23+ unload();
2624
2725 append({ "identifier": "indicator-fake1",
2826 "position": 0,
tests/mocks/Unity/Indicators/fakeindicatorsmodel.cppnew file+122
@@ -0,0 +1,122 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18+ */
19+
20+#include "fakeindicatorsmodel.h"
21+#include "indicators.h"
22+
23+#include <paths.h>
24+
25+#include <QQmlContext>
26+#include <QQmlEngine>
27+#include <QDebug>
28+
29+FakeIndicatorsModel::FakeIndicatorsModel(QObject *parent)
30+ : QAbstractListModel(parent)
31+{
32+ QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
33+ QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
34+ QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
35+}
36+
37+/*! \internal */
38+FakeIndicatorsModel::~FakeIndicatorsModel()
39+{
40+ unload();
41+}
42+
43+int FakeIndicatorsModel::count() const
44+{
45+ return rowCount();
46+}
47+
48+void FakeIndicatorsModel::load(const QString&)
49+{
50+}
51+
52+void FakeIndicatorsModel::unload()
53+{
54+ beginResetModel();
55+
56+ qDeleteAll(m_indicators);
57+ m_indicators.clear();
58+
59+ endResetModel();
60+}
61+
62+
63+void FakeIndicatorsModel::append(const QVariantMap& row)
64+{
65+ Indicator* new_row = new QHash<int, QVariant>();
66+ for (auto iter = row.begin(); iter != row.end(); ++iter )
67+ {
68+ int key = roleNames().key(iter.key().toUtf8(), -1);
69+ if (key != -1) {
70+ new_row->insert(key, iter.value());
71+ }
72+ }
73+
74+ beginInsertRows(QModelIndex(), m_indicators.count(), m_indicators.count());
75+
76+ m_indicators.append(new_row);
77+
78+ endInsertRows();
79+}
80+
81+QHash<int, QByteArray> FakeIndicatorsModel::roleNames() const
82+{
83+ static QHash<int, QByteArray> roles;
84+ if (roles.isEmpty())
85+ {
86+ roles[IndicatorsModelRole::Identifier] = "identifier";
87+ roles[IndicatorsModelRole::Position] = "position";
88+ roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
89+ roles[IndicatorsModelRole::PageSource] = "pageSource";
90+ roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
91+ }
92+ return roles;
93+}
94+
95+int FakeIndicatorsModel::columnCount(const QModelIndex &) const
96+{
97+ return 1;
98+}
99+
100+Q_INVOKABLE QVariant FakeIndicatorsModel::data(int row, int role) const
101+{
102+ return data(index(row, 0), role);
103+}
104+
105+QVariant FakeIndicatorsModel::data(const QModelIndex &index, int role) const
106+{
107+ if (!index.isValid() || index.row() >= m_indicators.size())
108+ return QVariant();
109+
110+ Indicator* indicator = m_indicators[index.row()];
111+ return indicator->value(role, QVariant());
112+}
113+
114+QModelIndex FakeIndicatorsModel::parent(const QModelIndex&) const
115+{
116+ return QModelIndex();
117+}
118+
119+int FakeIndicatorsModel::rowCount(const QModelIndex&) const
120+{
121+ return m_indicators.count();
122+}
tests/mocks/Unity/Indicators/fakeindicatorsmodel.hnew file+61
@@ -0,0 +1,61 @@
1+/*
2+ * Copyright 2014 Canonical Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU Lesser General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Authors:
17+ * Nick Dedekind <nick.dedekind@canonical.com>
18+ */
19+
20+#ifndef FAKE_INDICATORSMODEL_H
21+#define FAKE_INDICATORSMODEL_H
22+
23+#include <QAbstractListModel>
24+
25+class IndicatorsManager;
26+
27+class FakeIndicatorsModel : public QAbstractListModel
28+{
29+ Q_OBJECT
30+ Q_ENUMS(Roles)
31+ Q_PROPERTY(int count READ count NOTIFY countChanged)
32+public:
33+
34+ FakeIndicatorsModel(QObject *parent=0);
35+ ~FakeIndicatorsModel();
36+
37+ Q_INVOKABLE void load(const QString& profile);
38+ Q_INVOKABLE void unload();
39+
40+ Q_INVOKABLE void append(const QVariantMap& row);
41+
42+ Q_INVOKABLE QVariant data(int row, int role) const;
43+
44+ /* QAbstractItemModel */
45+ QHash<int, QByteArray> roleNames() const;
46+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
47+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
48+ QModelIndex parent (const QModelIndex &index) const;
49+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
50+
51+Q_SIGNALS:
52+ void countChanged();
53+
54+private:
55+ int count() const;
56+
57+ typedef QHash<int, QVariant> Indicator;
58+ QList<Indicator*> m_indicators;
59+};
60+
61+#endif // FAKE_INDICATORSMODEL_H
tests/mocks/Unity/Indicators/fakeplugin.cpp+3
@@ -23,6 +23,7 @@
2323#include "fakeplugin.h"
2424
2525// local
26+#include "fakeindicatorsmodel.h"
2627#include "indicators.h"
2728#include "menucontentactivator.h"
2829#include "unitymenumodelstack.h"
@@ -32,6 +33,8 @@ void IndicatorsFakePlugin::registerTypes(const char * uri)
3233{
3334 Q_INIT_RESOURCE(indicators_fake);
3435
36+ qmlRegisterType<FakeIndicatorsModel>(uri, 0, 1, "FakeIndicatorsModel");
37+
3538 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
3639 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
3740 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
tests/qmltests/Panel/tst_IndicatorRow.qml+3−3
@@ -70,13 +70,13 @@ Item {
7070 function test_set_current_item() {
7171 init_test();
7272 indicatorRow.setCurrentItemIndex(0);
73− compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
73+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake1", "Incorrect item at position 0");
7474
7575 indicatorRow.setCurrentItemIndex(1);
76− compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
76+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake2", "Incorrect item at position 1");
7777
7878 indicatorRow.setCurrentItemIndex(2);
79− compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
79+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake3", "Incorrect item at position 2");
8080 }
8181
8282 function test_highlight_data() {
tests/qmltests/Panel/tst_MenuContent.qml+1−1
@@ -133,7 +133,7 @@ Item {
133133 var menuIndex = i%menuCount;
134134
135135 activate_content(menuIndex);
136− testTabObjectName = indicatorsModel.get(menuIndex).identifier;
136+ testTabObjectName = indicatorsModel.data(menuIndex, Indicators.IndicatorsModelRole.Identifier);
137137 compare(tabs.selectedTabIndex, menuIndex, "Current tab index does not match selected tab index");
138138 tryCompareFunction(selected_tab_equals_test_tab, true);
139139 }