Merge lp:~tiagosh/messaging-app/text-url-dispatcher into lp:messaging-app

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Bill Filler
Approved revision: 267
Merged at revision: 278
Proposed branch: lp:~tiagosh/messaging-app/text-url-dispatcher
Merge into: lp:messaging-app
Diff against target: 187 lines (+48/-10)
6 files modified
src/messagingapplication.cpp (+11/-1)
src/qml/Messages.qml (+1/-0)
src/qml/messaging-app.qml (+2/-1)
tests/autopilot/messaging_app/emulators.py (+7/-2)
tests/autopilot/messaging_app/tests/__init__.py (+12/-6)
tests/autopilot/messaging_app/tests/test_messaging.py (+15/-0)
To merge this branch: bzr merge lp:~tiagosh/messaging-app/text-url-dispatcher
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+238759@code.launchpad.net

Commit message

Read text property from url-dispatcher.

Description of the change

Read text property from url-dispatcher.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

please add some sort of a test for this.

I wasn't sure how to manually test. I tried url-dispatcher messaging://<phonenumber>/message but the message did not appear.

review: Needs Fixing
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

Try using the following format: message:///<phonenumber>?text=text%20message

267. By Tiago Salem Herrmann

add test for url handler

Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/messagingapplication.cpp'
--- src/messagingapplication.cpp 2014-07-01 18:08:32 +0000
+++ src/messagingapplication.cpp 2014-12-09 17:47:33 +0000
@@ -20,6 +20,7 @@
2020
21#include <QDir>21#include <QDir>
22#include <QUrl>22#include <QUrl>
23#include <QUrlQuery>
23#include <QDebug>24#include <QDebug>
24#include <QStringList>25#include <QStringList>
25#include <QQuickItem>26#include <QQuickItem>
@@ -36,6 +37,7 @@
36#include <QVersitReader>37#include <QVersitReader>
3738
38using namespace QtVersit;39using namespace QtVersit;
40#define Pair QPair<QString,QString>
3941
40static void printUsage(const QStringList& arguments)42static void printUsage(const QStringList& arguments)
41{43{
@@ -184,10 +186,18 @@
184 return;186 return;
185 }187 }
186188
189 QString text;
187 QUrl url(arg);190 QUrl url(arg);
188 QString scheme = url.scheme();191 QString scheme = url.scheme();
189 // Remove the first "/"192 // Remove the first "/"
190 QString value = url.path().right(url.path().length() -1);193 QString value = url.path().right(url.path().length() -1);
194 QUrlQuery query(url);
195 Q_FOREACH(const Pair &item, query.queryItems()) {
196 if (item.first == "text") {
197 text = item.second;
198 break;
199 }
200 }
191201
192 QQuickItem *mainView = m_view->rootObject();202 QQuickItem *mainView = m_view->rootObject();
193 if (!mainView) {203 if (!mainView) {
@@ -196,7 +206,7 @@
196206
197 if (scheme == "message") {207 if (scheme == "message") {
198 if (!value.isEmpty()) {208 if (!value.isEmpty()) {
199 QMetaObject::invokeMethod(mainView, "startChat", Q_ARG(QVariant, value));209 QMetaObject::invokeMethod(mainView, "startChat", Q_ARG(QVariant, value), Q_ARG(QVariant, text));
200 } else {210 } else {
201 QMetaObject::invokeMethod(mainView, "startNewMessage");211 QMetaObject::invokeMethod(mainView, "startNewMessage");
202 }212 }
203213
=== modified file 'src/qml/Messages.qml'
--- src/qml/Messages.qml 2014-10-07 16:57:27 +0000
+++ src/qml/Messages.qml 2014-12-09 17:47:33 +0000
@@ -796,6 +796,7 @@
796796
797 TextArea {797 TextArea {
798 id: messageTextArea798 id: messageTextArea
799 objectName: "messageTextArea"
799 anchors {800 anchors {
800 top: attachments.count == 0 ? textEntry.top : attachmentThumbnails.bottom801 top: attachments.count == 0 ? textEntry.top : attachmentThumbnails.bottom
801 left: parent.left802 left: parent.left
802803
=== modified file 'src/qml/messaging-app.qml'
--- src/qml/messaging-app.qml 2014-09-17 15:35:10 +0000
+++ src/qml/messaging-app.qml 2014-12-09 17:47:33 +0000
@@ -136,10 +136,11 @@
136 mainStack.currentPage.showBottomEdgePage(Qt.resolvedUrl("Messages.qml"))136 mainStack.currentPage.showBottomEdgePage(Qt.resolvedUrl("Messages.qml"))
137 }137 }
138138
139 function startChat(phoneNumber) {139 function startChat(phoneNumber, text) {
140 var properties = {}140 var properties = {}
141 var participants = [phoneNumber]141 var participants = [phoneNumber]
142 properties["participants"] = participants142 properties["participants"] = participants
143 properties["text"] = text
143 emptyStack()144 emptyStack()
144 if (phoneNumber === "") {145 if (phoneNumber === "") {
145 return;146 return;
146147
=== modified file 'tests/autopilot/messaging_app/emulators.py'
--- tests/autopilot/messaging_app/emulators.py 2014-09-10 18:14:43 +0000
+++ tests/autopilot/messaging_app/emulators.py 2014-12-09 17:47:33 +0000
@@ -117,8 +117,9 @@
117 def get_newmessage_textarea(self):117 def get_newmessage_textarea(self):
118 """Return TextArea with blank objectName"""118 """Return TextArea with blank objectName"""
119119
120 return self.get_messages_page().select_single('TextArea',120 return self.get_messages_page().select_single(
121 objectName='')121 'TextArea',
122 objectName='messageTextArea')
122123
123 def get_send_button(self):124 def get_send_button(self):
124 """Return Button with text Send"""125 """Return Button with text Send"""
@@ -481,6 +482,10 @@
481 messages.append((date, text))482 messages.append((date, text))
482 return messages483 return messages
483484
485 def get_text_area_text(self):
486 return self.wait_select_single(
487 'TextArea', objectName='messageTextArea').text
488
484489
485class ListItemWithActions(_common.UbuntuUIToolkitCustomProxyObjectBase):490class ListItemWithActions(_common.UbuntuUIToolkitCustomProxyObjectBase):
486491
487492
=== modified file 'tests/autopilot/messaging_app/tests/__init__.py'
--- tests/autopilot/messaging_app/tests/__init__.py 2014-07-15 16:32:16 +0000
+++ tests/autopilot/messaging_app/tests/__init__.py 2014-12-09 17:47:33 +0000
@@ -37,7 +37,10 @@
3737
38 # Don't use keyboard on desktop38 # Don't use keyboard on desktop
39 if model() == 'Desktop':39 if model() == 'Desktop':
40 subprocess.call(['/sbin/initctl', 'stop', 'maliit-server'])40 try:
41 subprocess.call(['/sbin/initctl', 'stop', 'maliit-server'])
42 except:
43 pass
4144
42 if model() == 'Desktop':45 if model() == 'Desktop':
43 scenarios = [46 scenarios = [
@@ -50,36 +53,39 @@
5053
51 local_location = '../../src/messaging-app'54 local_location = '../../src/messaging-app'
5255
53 def setUp(self):56 def setUp(self, parameter=""):
54 self.pointing_device = Pointer(self.input_device_class.create())57 self.pointing_device = Pointer(self.input_device_class.create())
55 super(MessagingAppTestCase, self).setUp()58 super(MessagingAppTestCase, self).setUp()
5659
57 subprocess.call(['pkill', 'messaging-app'])60 subprocess.call(['pkill', 'messaging-app'])
5861
59 if os.path.exists(self.local_location):62 if os.path.exists(self.local_location):
60 self.launch_test_local()63 self.launch_test_local(parameter)
61 else:64 else:
62 self.launch_test_installed()65 self.launch_test_installed(parameter)
6366
64 self.assertThat(self.main_view.visible, Eventually(Equals(True)))67 self.assertThat(self.main_view.visible, Eventually(Equals(True)))
6568
66 def launch_test_local(self):69 def launch_test_local(self, parameter):
67 self.app = self.launch_test_application(70 self.app = self.launch_test_application(
68 self.local_location,71 self.local_location,
69 '--test-contacts',72 '--test-contacts',
73 parameter,
70 app_type='qt',74 app_type='qt',
71 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)75 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
7276
73 def launch_test_installed(self):77 def launch_test_installed(self, parameter):
74 if model() == 'Desktop':78 if model() == 'Desktop':
75 self.app = self.launch_test_application(79 self.app = self.launch_test_application(
76 'messaging-app',80 'messaging-app',
77 '--test-contacts',81 '--test-contacts',
82 parameter,
78 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)83 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
79 else:84 else:
80 self.app = self.launch_upstart_application(85 self.app = self.launch_upstart_application(
81 'messaging-app',86 'messaging-app',
82 '--test-contacts',87 '--test-contacts',
88 parameter,
83 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)89 emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
8490
85 @property91 @property
8692
=== modified file 'tests/autopilot/messaging_app/tests/test_messaging.py'
--- tests/autopilot/messaging_app/tests/test_messaging.py 2014-09-19 21:50:28 +0000
+++ tests/autopilot/messaging_app/tests/test_messaging.py 2014-12-09 17:47:33 +0000
@@ -342,3 +342,18 @@
342 _, remaining_message_text = remaining_messages[0]342 _, remaining_message_text = remaining_messages[0]
343 self.assertEqual(343 self.assertEqual(
344 remaining_message_text, self.messages[0])344 remaining_message_text, self.messages[0])
345
346
347class MessagingTestCaseWithArgument(MessagingAppTestCase):
348
349 def setUp(self):
350 test_setup = fixture_setup.MessagingTestEnvironment()
351 self.useFixture(test_setup)
352
353 super(MessagingTestCaseWithArgument, self).setUp(
354 parameter="message:///5555559876?text=text%20message")
355
356 def test_launch_app_with_predefined_text(self):
357 self.messages_view = self.main_view.select_single(
358 emulators.Messages,
359 text='text message')

Subscribers

People subscribed via source and target branches