Merge lp:~jonas-drange/ubuntu-ui-extras/improve-devicename into lp:~phablet-team/ubuntu-ui-extras/printer-staging

Proposed by Jonas G. Drange
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 148
Merged at revision: 150
Proposed branch: lp:~jonas-drange/ubuntu-ui-extras/improve-devicename
Merge into: lp:~phablet-team/ubuntu-ui-extras/printer-staging
Diff against target: 33 lines (+9/-2)
2 files modified
modules/Ubuntu/Components/Extras/Printers/structs.h (+7/-0)
tests/unittests/Printers/tst_printerdevice.cpp (+2/-2)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-ui-extras/improve-devicename
Reviewer Review Type Date Requested Status
Andrew Hayzen (community) Approve
Review via email: mp+320073@code.launchpad.net

Commit message

improves the deviceName by dropping the CMD (note that the full string remains accessible from device.id)

Description of the change

improves the deviceName by dropping the CMD (note that the full string remains accessible from device.id)

To post a comment you must log in.
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

How do I test this? Do I need to pick a specific printer to make this happen, as I didn't notice any difference with my printers.

review: Needs Information
Revision history for this message
Andrew Hayzen (ahayzen) wrote :

LGTM, as discussed it is difficult to test, but the unit tests pass and there are no regressions - so approving :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Extras/Printers/structs.h'
2--- modules/Ubuntu/Components/Extras/Printers/structs.h 2017-03-09 12:35:04 +0000
3+++ modules/Ubuntu/Components/Extras/Printers/structs.h 2017-03-16 15:36:28 +0000
4@@ -145,6 +145,13 @@
5 }
6 auto mfg = idMap.value("MFG", "");
7 auto mdl = idMap.value("MDL", "");
8+
9+ /* If the MDL field contains CMD, somebody forgot to terminate, and we
10+ remove it. */
11+ if (mdl.contains("CMD")) {
12+ mdl = mdl.split("CMD")[0];
13+ }
14+
15 return QString("%1 %2").arg(mfg).arg(mdl);
16 }
17
18
19=== modified file 'tests/unittests/Printers/tst_printerdevice.cpp'
20--- tests/unittests/Printers/tst_printerdevice.cpp 2017-03-08 16:55:21 +0000
21+++ tests/unittests/Printers/tst_printerdevice.cpp 2017-03-16 15:36:28 +0000
22@@ -100,9 +100,9 @@
23
24 {
25 Device d;
26- QTest::newRow("a hp printer")
27+ QTest::newRow("a hp printer (remove CMD)")
28 << "MFG:HP;MDL:Color LaserJet 4500CMD:PDF,PS,JPEG,PNG,PWG,URF"
29- << "HP Color LaserJet 4500CMD";
30+ << "HP Color LaserJet 4500";
31 }
32 {
33 Device d; ;

Subscribers

People subscribed via source and target branches