on xenial help sign in
merged with trunk
commit31656ee1102fca22566eca6030a9509b8f2276b2 authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 18 Dec 2013, 14:01 (13 years ago) parent4a45d3db997e66
20 files changed+97−38
CODING+2−2 data/unity8.override+1 debian/unity8-autopilot.install+1 plugins/Unity/Indicators/CMakeLists.txt−1 plugins/Unity/Indicators/plugin.cpp−2 plugins/Unity/Indicators/qml/MenuItemFactory.qml+6−8 plugins/Unity/Indicators/qml/MessageMenuItemFactory.qml+2−2 plugins/Utils/CMakeLists.txt+1 plugins/Utils/plugin.cpp+3 plugins/Unity/Indicators/timeformatter.cpp → plugins/Utils/timeformatter.cpp+30−1 plugins/Unity/Indicators/timeformatter.h → plugins/Utils/timeformatter.h+15−3 tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+7−6 tests/autopilot/unity8/shell/tests/test_lock_screen.py+9−8 tests/mocks/LightDM/demo/CMakeLists.txt−1 tests/mocks/Unity/Application/CMakeLists.txt−1 tests/mocks/Unity/Launcher/CMakeLists.txt−1 tests/plugins/AccountsService/CMakeLists.txt+6−1 tests/plugins/Unity/Indicators/CMakeLists.txt−1 tests/plugins/Utils/CMakeLists.txt+1 tests/plugins/Unity/Indicators/timeformattertest.cpp → tests/plugins/Utils/timeformattertest.cpp+13
CODING+2−2
@@ -1,7 +1,7 @@
11Building Unity 8
22================
33
4−Only Ubuntu 13.10 (saucy) is supported as a developement environment.
4+Only Ubuntu 14.04 (trusty) is supported as a developement environment.
55
66download source
77---------------
@@ -68,7 +68,7 @@ Notes
6868
6969Running Unity 8 on devices
7070==========================
71−- Ubuntu Touch builds are currently only available in 13.10 flavour
71+- Ubuntu Touch builds are currently only available in 14.04 flavour
7272- supported hardware should match one of those listed here
7373 https://wiki.ubuntu.com/Touch/Devices#Running_fine
7474- follow the Ubuntu Touch install instructions for your chosen device
data/unity8.overridenew file+1
@@ -0,0 +1 @@
1+kill timeout 30
debian/unity8-autopilot.install+1
@@ -1 +1,2 @@
11usr/lib/python*/*/unity*
2+data/unity8.override usr/share/upstart/sessions
plugins/Unity/Indicators/CMakeLists.txt−1
@@ -34,7 +34,6 @@ set(IndicatorsQML_SOURCES
3434 unitymenumodelcache.cpp
3535 unitymenumodelstack.cpp
3636 visibleindicatorsmodel.cpp
37− timeformatter.cpp
3837)
3938add_definitions(-DUNITYINDICATORS_LIBRARY)
4039
plugins/Unity/Indicators/plugin.cpp−2
@@ -33,7 +33,6 @@
3333#include "unitymenumodelcache.h"
3434#include "unitymenumodelstack.h"
3535#include "visibleindicatorsmodel.h"
36−#include "timeformatter.h"
3736
3837static QObject* menuModelCacheSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
3938 Q_UNUSED(engine);
@@ -52,7 +51,6 @@ void Indicators2Plugin::registerTypes(const char *uri)
5251 qmlRegisterType<RootActionState>(uri, 0, 1, "RootActionState");
5352 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");
5453 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
55− qmlRegisterType<TimeFormatter>(uri, 0, 1, "TimeFormatter");
5654
5755 qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
5856
plugins/Unity/Indicators/qml/MenuItemFactory.qml+6−8
@@ -20,7 +20,7 @@
2020import QtQuick 2.0
2121import Ubuntu.Settings.Menus 0.1 as Menus
2222import QMenuModel 0.1 as QMenuModel
23−import Unity.Indicators 0.1 as Indicators
23+import Utils 0.1 as Utils
2424import Ubuntu.Components.ListItems 0.1 as ListItems
2525
2626Item {
@@ -221,10 +221,9 @@ Item {
221221 property int menuIndex: -1
222222 property var extendedData: menuData && menuData.ext || undefined
223223 // TODO - bug #1260728
224− property var timeFormatter: Indicators.TimeFormatter {
224+ property var timeFormatter: Utils.GDateTimeFormatter {
225225 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
226−// format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
227− format: "hh:mm - MMM dd"
226+ format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
228227 }
229228
230229 text: menuData && menuData.label || ""
@@ -259,10 +258,9 @@ Item {
259258 property int menuIndex: -1
260259 property var extendedData: menuData && menuData.ext || undefined
261260 // TODO - bug #1260728
262− property var timeFormatter: Indicators.TimeFormatter {
261+ property var timeFormatter: Utils.GDateTimeFormatter {
263262 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
264−// format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
265− format: "hh:mm - MMM dd"
263+ format: getExtendedProperty(extendedData, "xCanonicalTimeFormat", "")
266264 }
267265
268266 text: menuData && menuData.label || ""
@@ -376,7 +374,7 @@ Item {
376374 property var extendedData: menuData && menuData.ext || undefined
377375
378376 text: menuData && menuData.label || ""
379− icon: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
377+ iconSource: getExtendedProperty(extendedData, "icon", "qrc:/indicators/artwork/messaging/default_app.svg")
380378 count: menuData && menuData.actionState.length > 0 ? menuData.actionState[0] : "0"
381379 enabled: menuData && menuData.sensitive || false
382380 removable: true
plugins/Unity/Indicators/qml/MessageMenuItemFactory.qml+2−2
@@ -22,7 +22,7 @@ import QtQuick 2.0
2222import Ubuntu.Components 0.1
2323import Ubuntu.Settings.Menus 0.1 as Menus
2424import QMenuModel 0.1 as QMenuModel
25−import Unity.Indicators 0.1 as Indicators
25+import Utils 0.1 as Utils
2626
2727Item {
2828 id: messageFactoryItem
@@ -38,7 +38,7 @@ Item {
3838 property var actionsDescription: getExtendedProperty(extendedData, "xCanonicalMessageActions", undefined)
3939
4040 // TODO - bug #1260728
41− property var timeFormatter: Indicators.TimeFormatter {
41+ property var timeFormatter: Utils.TimeFormatter {
4242 time: getExtendedProperty(extendedData, "xCanonicalTime", 0)
4343 format: "hh:mm - MMM dd"
4444 }
plugins/Utils/CMakeLists.txt+1
@@ -16,6 +16,7 @@ set(QMLPLUGIN_SRC
1616 mediaartcache.cpp
1717 qlimitproxymodelqml.cpp
1818 qsortfilterproxymodelqml.cpp
19+ timeformatter.cpp
1920 unitymenumodelpaths.cpp
2021 plugin.cpp
2122 )
plugins/Utils/plugin.cpp+3
@@ -30,6 +30,7 @@
3030#include "bottombarvisibilitycommunicatorshell.h"
3131#include "qlimitproxymodelqml.h"
3232#include "qsortfilterproxymodelqml.h"
33+#include "timeformatter.h"
3334#include "unitymenumodelpaths.h"
3435
3536static const char* BOTTOM_BAR_VISIBILITY_COMMUNICATOR_DBUS_PATH = "/BottomBarVisibilityCommunicator";
@@ -42,6 +43,8 @@ void UtilsPlugin::registerTypes(const char *uri)
4243 qmlRegisterType<QLimitProxyModelQML>(uri, 0, 1, "LimitProxyModel");
4344 qmlRegisterType<QSortFilterProxyModelQML>(uri, 0, 1, "SortFilterProxyModel");
4445 qmlRegisterType<UnityMenuModelPaths>(uri, 0, 1, "UnityMenuModelPaths");
46+ qmlRegisterType<TimeFormatter>(uri, 0, 1, "TimeFormatter");
47+ qmlRegisterType<GDateTimeFormatter>(uri, 0, 1, "GDateTimeFormatter");
4548 qmlRegisterUncreatableType<BottomBarVisibilityCommunicatorShell>(uri, 0, 1, "BottomBarVisibilityCommunicatorShell", "Can't create BottomBarVisibilityCommunicatorShell");
4649}
4750
plugins/Unity/Indicators/timeformatter.cpp → plugins/Utils/timeformatter.cpprenamed+30−1
@@ -167,6 +167,35 @@ void TimeFormatter::setTime(qint64 time)
167167
168168void TimeFormatter::update()
169169{
170− priv->timeString = QDateTime::fromMSecsSinceEpoch(priv->time / 1000).toString(priv->format);
170+ priv->timeString = formatTime();
171171 Q_EMIT timeStringChanged(priv->timeString);
172172}
173+
174+QString TimeFormatter::formatTime() const
175+{
176+ return QDateTime::fromMSecsSinceEpoch(time() / 1000).toString(format());
177+}
178+
179+GDateTimeFormatter::GDateTimeFormatter(QObject* parent)
180+: TimeFormatter(parent)
181+{
182+}
183+
184+QString GDateTimeFormatter::formatTime() const
185+{
186+ gchar* time_string;
187+ GDateTime* datetime;
188+ QByteArray formatBytes = format().toUtf8();
189+
190+ datetime = g_date_time_new_from_unix_local(time());
191+ if (!datetime) {
192+ return "";
193+ }
194+
195+ time_string = g_date_time_format(datetime, formatBytes.constData());
196+ QString formattedTime(QString::fromUtf8(time_string));
197+
198+ g_free(time_string);
199+ g_date_time_unref(datetime);
200+ return formattedTime;
201+}
plugins/Unity/Indicators/timeformatter.h → plugins/Utils/timeformatter.hrenamed+15−3
@@ -19,10 +19,10 @@
1919#ifndef TIME_FORMATTER_H
2020#define TIME_FORMATTER_H
2121
22−#include "unityindicatorsglobal.h"
2322#include <QObject>
2423
25−class UNITYINDICATORS_EXPORT TimeFormatter : public QObject
24+// TODO - bug #1260728
25+class TimeFormatter : public QObject
2626{
2727 Q_OBJECT
2828 Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged)
@@ -31,7 +31,7 @@ class UNITYINDICATORS_EXPORT TimeFormatter : public QObject
3131
3232public:
3333 TimeFormatter(QObject *parent = 0);
34− ~TimeFormatter();
34+ virtual ~TimeFormatter();
3535
3636 QString format() const;
3737 QString timeString() const;
@@ -47,8 +47,20 @@ Q_SIGNALS:
4747 void timeStringChanged(const QString &timeString);
4848 void timeChanged(qint64 time);
4949
50+protected:
51+ virtual QString formatTime() const;
52+
5053private:
5154 struct TimeFormatterPrivate *priv;
5255};
5356
57+class GDateTimeFormatter : public TimeFormatter
58+{
59+public:
60+ GDateTimeFormatter(QObject *parent = 0);
61+
62+protected:
63+ virtual QString formatTime() const;
64+};
65+
5466#endif
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+7−6
@@ -21,6 +21,7 @@
2121
2222from __future__ import absolute_import
2323
24+from unity8.process_helpers import unlock_unity
2425from unity8.shell import disable_qml_mocking
2526from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2627
@@ -78,8 +79,8 @@ class ApplicationLifecycleTests(UnityTestCase):
7879 @disable_qml_mocking
7980 def test_can_launch_application(self):
8081 """Must be able to launch an application."""
81− self.launch_unity()
82− self.main_window.get_greeter().swipe()
82+ unity_proxy = self.launch_unity()
83+ unlock_unity(unity_proxy)
8384
8485 app = self._launch_app("messaging-app")
8586
@@ -92,8 +93,8 @@ class ApplicationLifecycleTests(UnityTestCase):
9293 @disable_qml_mocking
9394 def test_can_launch_multiple_applications(self):
9495 """A second application launched must be focused."""
95− self.launch_unity()
96− self.main_window.get_greeter().swipe()
96+ unity_proxy = self.launch_unity()
97+ unlock_unity(unity_proxy)
9798
9899 self._launch_app("messaging-app")
99100 self.assertThat(
@@ -113,8 +114,8 @@ class ApplicationLifecycleTests(UnityTestCase):
113114 brought back to the focused state.
114115
115116 """
116− self.launch_unity()
117− self.main_window.get_greeter().swipe()
117+ unity_proxy = self.launch_unity()
118+ unlock_unity(unity_proxy)
118119
119120 self._launch_app("messaging-app")
120121 self.assertThat(
tests/autopilot/unity8/shell/tests/test_lock_screen.py+9−8
@@ -20,6 +20,7 @@
2020
2121from __future__ import absolute_import
2222
23+from unity8.process_helpers import unlock_unity
2324from unity8.shell import with_lightdm_mock
2425from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
2526
@@ -40,11 +41,11 @@ class TestLockscreen(UnityTestCase):
4041 @with_lightdm_mock("single-pin")
4142 def test_can_unlock_pin_screen(self):
4243 """Must be able to unlock the PIN entry lock screen."""
43− self.launch_unity()
44+ unity_proxy = self.launch_unity()
4445 greeter = self.main_window.get_greeter()
4546
4647 if greeter.narrowMode:
47− greeter.swipe()
48+ unlock_unity(unity_proxy)
4849 lockscreen = self._wait_for_lockscreen()
4950 self._enter_pincode("1234")
5051 self.assertThat(lockscreen.shown, Eventually(Equals(False)))
@@ -55,11 +56,11 @@ class TestLockscreen(UnityTestCase):
5556 @with_lightdm_mock("single-passphrase")
5657 def test_can_unlock_passphrase_screen(self):
5758 """Must be able to unlock the passphrase entry screen."""
58− self.launch_unity()
59+ unity_proxy = self.launch_unity()
5960 greeter = self.main_window.get_greeter()
6061
6162 if greeter.narrowMode:
62− greeter.swipe()
63+ unlock_unity(unity_proxy)
6364 lockscreen = self._wait_for_lockscreen()
6465 self._enter_pin_passphrase("password")
6566 self.assertThat(lockscreen.shown, Eventually(Equals(False)))
@@ -70,11 +71,11 @@ class TestLockscreen(UnityTestCase):
7071 @with_lightdm_mock("single-pin")
7172 def test_pin_screen_wrong_code(self):
7273 """Entering the wrong pin code must not dismiss the lock screen."""
73− self.launch_unity()
74+ unity_proxy = self.launch_unity()
7475 greeter = self.main_window.get_greeter()
7576
7677 if greeter.narrowMode:
77− greeter.swipe()
78+ unlock_unity(unity_proxy)
7879 lockscreen = self._wait_for_lockscreen()
7980 self._enter_pincode("4321")
8081 pinentryField = self.main_window.get_pinentryField()
@@ -89,11 +90,11 @@ class TestLockscreen(UnityTestCase):
8990 @with_lightdm_mock("single-passphrase")
9091 def test_passphrase_screen_wrong_password(self):
9192 """Entering the wrong password must not dismiss the lock screen."""
92− self.launch_unity()
93+ unity_proxy = self.launch_unity()
9394 greeter = self.main_window.get_greeter()
9495
9596 if greeter.narrowMode:
96− greeter.swipe()
97+ unlock_unity(unity_proxy)
9798 lockscreen = self._wait_for_lockscreen()
9899 self._enter_pin_passphrase("foobar")
99100 pinentryField = self.main_window.get_pinentryField()
tests/mocks/LightDM/demo/CMakeLists.txt−1
@@ -1,4 +1,3 @@
1−include(FindPkgConfig)
21pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
32
43set(LibLightDM_SOURCES
tests/mocks/Unity/Application/CMakeLists.txt−1
@@ -1,4 +1,3 @@
1−include(FindPkgConfig)
21pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application)
32
43set(FakeUnityApplicationQml_SOURCES
tests/mocks/Unity/Launcher/CMakeLists.txt−1
@@ -1,4 +1,3 @@
1−include(FindPkgConfig)
21pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
32
43add_definitions(-DTOP_SRCDIR="${CMAKE_SOURCE_DIR}")
tests/plugins/AccountsService/CMakeLists.txt+6−1
@@ -1,6 +1,11 @@
1+if(DEFINED ENV{DEB_BUILD_MULTIARCH})
2+ set(QDBUSXML2CPP_EXECUTABLE "/usr/lib/$ENV{DEB_BUILD_MULTIARCH}/qt5/bin/qdbusxml2cpp")
3+else()
4+ FIND_PROGRAM(QDBUSXML2CPP_EXECUTABLE qdbusxml2cpp)
5+endif()
16macro(make_dbus_class NAME INTERFACE)
27 if(${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor.h)
3− execute_process(COMMAND qdbusxml2cpp -c ${NAME}Adaptor -a ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor ${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml ${INTERFACE})
8+ execute_process(COMMAND ${QDBUSXML2CPP_EXECUTABLE} -c ${NAME}Adaptor -a ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor ${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml ${INTERFACE})
49 endif()
510endmacro(make_dbus_class)
611
tests/plugins/Unity/Indicators/CMakeLists.txt−1
@@ -40,4 +40,3 @@ indicator_test(indicatorsmodeltest ADDITIONAL_LIBS IndicatorsQml)
4040indicator_test(menucontentactivatortest ADDITIONAL_CPPS ${INDICATORS_DIR}/menucontentactivator.cpp)
4141indicator_test(unitymenumodelstacktest ADDITIONAL_CPPS ${TEST_DIR}/mocks/QMenuModel/unitymenumodel.cpp ${INDICATORS_DIR}/unitymenumodelstack.cpp)
4242indicator_test(rootactionstatetest ADDITIONAL_LIBS IndicatorsQml)
43−indicator_test(timeformattertest ADDITIONAL_LIBS IndicatorsQml)
tests/plugins/Utils/CMakeLists.txt+1
@@ -24,4 +24,5 @@ endmacro(run_tests)
2424run_tests(
2525 qlimitproxymodeltest
2626 qsortfilterproxymodeltest
27+ timeformattertest
2728 )
tests/plugins/Unity/Indicators/timeformattertest.cpp → tests/plugins/Utils/timeformattertest.cpprenamed+13
@@ -48,6 +48,19 @@ private Q_SLOTS:
4848
4949 QCOMPARE(formatter.timeString(), time.toString(format));
5050 }
51+
52+ void testFormatStrF()
53+ {
54+ const QString format = "%d-%m-%Y %I:%M%p";
55+
56+ QDateTime time = QDateTime::currentDateTime();
57+
58+ GDateTimeFormatter formatter;
59+ formatter.setTime(time.toMSecsSinceEpoch() / 1000); // strftime in seconds since epoc
60+ formatter.setFormat(format);
61+
62+ QCOMPARE(formatter.timeString(), time.toString("dd-MM-yyyy hh:mmAP"));
63+ }
5164};
5265
5366QTEST_GUILESS_MAIN(TimeFormatterTest)