Merge lp:~aacid/unity8/static_cast_instead_of_unchecked_dynamic_cast into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Daniel d'Andrada
Approved revision: 2410
Merged at revision: 2467
Proposed branch: lp:~aacid/unity8/static_cast_instead_of_unchecked_dynamic_cast
Merge into: lp:unity8
Diff against target: 115 lines (+9/-9)
9 files modified
tests/mocks/Unity/fake_previewmodel.cpp (+1/-1)
tests/mocks/Unity/fake_scope.cpp (+1/-1)
tests/mocks/Unity/fake_scopesoverview.cpp (+1/-1)
tests/plugins/Dash/horizontaljournaltest.cpp (+1/-1)
tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp (+1/-1)
tests/plugins/Dash/listviewwithpageheadersectiontest.cpp (+1/-1)
tests/plugins/Dash/listviewwithpageheadertest.cpp (+1/-1)
tests/plugins/Dash/organicgridtest.cpp (+1/-1)
tests/plugins/Dash/verticaljournaltest.cpp (+1/-1)
To merge this branch: bzr merge lp:~aacid/unity8/static_cast_instead_of_unchecked_dynamic_cast
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve
Daniel d'Andrada (community) Approve
Review via email: mp+295827@code.launchpad.net

Commit message

Tests: Do not use dynamic_cast if we're not going to test it anyway

We know those things are those things, so static_cast is enough

Description of the change

 * Are there any related MPs required for this MP to build/function as expected?

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2410
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1301/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/1725
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/830
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/830
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/830
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1751
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1699
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1699
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1699
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1692/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1692/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1692/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1692/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1692/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1692/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1692/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1692/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1692
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1692/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1301/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Agreed.

review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:2410
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1358/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/1796
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/887
    UNSTABLE: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/887
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/887
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1820
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1766
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1766
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1766
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1757/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1757/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1757/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1757/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1757/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1757/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1757/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1757/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1757
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1757/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1358/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2410
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1393/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/1859
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/942
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/942
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/942
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/1885
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1823
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/1823
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/1823
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/1814/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1814/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/1814/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/1814/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1814/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/1814/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/1814/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/1814/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1814
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/1814/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/1393/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/mocks/Unity/fake_previewmodel.cpp'
2--- tests/mocks/Unity/fake_previewmodel.cpp 2015-08-19 13:56:21 +0000
3+++ tests/mocks/Unity/fake_previewmodel.cpp 2016-05-26 12:55:18 +0000
4@@ -87,7 +87,7 @@
5
6 void PreviewModel::triggeredSlot(QString const&, QString const&, QVariantMap const&) {
7 if (m_scope) {
8- Scopes *scopes = dynamic_cast<Scopes*>(m_scope->parent());
9+ Scopes *scopes = static_cast<Scopes*>(m_scope->parent());
10 Scope* scope = scopes->getScopeFromAll("MockScope9");
11 scopes->addTempScope(scope);
12 Q_EMIT m_scope->openScope(scope);
13
14=== modified file 'tests/mocks/Unity/fake_scope.cpp'
15--- tests/mocks/Unity/fake_scope.cpp 2016-05-04 18:09:25 +0000
16+++ tests/mocks/Unity/fake_scope.cpp 2016-05-26 12:55:18 +0000
17@@ -198,7 +198,7 @@
18 {
19 qDebug() << "Called activate on scope" << m_id << "with result" << result << "and category" << categoryId;
20 if (result.toString() == "Result.2.2") {
21- Scopes *scopes = dynamic_cast<Scopes*>(parent());
22+ Scopes *scopes = static_cast<Scopes*>(parent());
23 m_openScope = scopes->getScopeFromAll("MockScope9");
24 scopes->addTempScope(m_openScope);
25 Q_EMIT openScope(m_openScope);
26
27=== modified file 'tests/mocks/Unity/fake_scopesoverview.cpp'
28--- tests/mocks/Unity/fake_scopesoverview.cpp 2015-11-23 15:41:34 +0000
29+++ tests/mocks/Unity/fake_scopesoverview.cpp 2016-05-26 12:55:18 +0000
30@@ -43,7 +43,7 @@
31
32 Q_INVOKABLE void ScopesOverview::activate(QVariant const& result, QString const& /*categoryId*/)
33 {
34- Scopes *scopes = dynamic_cast<Scopes*>(parent());
35+ Scopes *scopes = static_cast<Scopes*>(parent());
36 if (scopes->getScope(result.toString())) {
37 Q_EMIT gotoScope(result.toString());
38 } else {
39
40=== modified file 'tests/plugins/Dash/horizontaljournaltest.cpp'
41--- tests/plugins/Dash/horizontaljournaltest.cpp 2015-05-21 15:52:48 +0000
42+++ tests/plugins/Dash/horizontaljournaltest.cpp 2016-05-26 12:55:18 +0000
43@@ -135,7 +135,7 @@
44 view->resize(470, 400);
45 QTest::qWaitForWindowExposed(view);
46
47- hj = dynamic_cast<HorizontalJournal*>(view->rootObject()->findChild<QObject*>("hj"));
48+ hj = static_cast<HorizontalJournal*>(view->rootObject()->findChild<QObject*>("hj"));
49 hj->setModel(model);
50
51 checkInitialPositions();
52
53=== modified file 'tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp'
54--- tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp 2015-05-21 15:52:48 +0000
55+++ tests/plugins/Dash/listviewwithpageheadersectionexternalmodeltest.cpp 2016-05-26 12:55:18 +0000
56@@ -169,7 +169,7 @@
57 {
58 view = new QQuickView();
59 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/listviewwithpageheadertestsectionexternalmodel.qml"));
60- lvwph = dynamic_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
61+ lvwph = static_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
62 QVERIFY(lvwph);
63 view->show();
64 QTest::qWaitForWindowExposed(view);
65
66=== modified file 'tests/plugins/Dash/listviewwithpageheadersectiontest.cpp'
67--- tests/plugins/Dash/listviewwithpageheadersectiontest.cpp 2016-02-29 10:47:10 +0000
68+++ tests/plugins/Dash/listviewwithpageheadersectiontest.cpp 2016-05-26 12:55:18 +0000
69@@ -134,7 +134,7 @@
70 {
71 view = new QQuickView();
72 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/listviewwithpageheadertestsection.qml"));
73- lvwph = dynamic_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
74+ lvwph = static_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
75 model = view->rootObject()->findChild<QQmlListModel*>();
76 otherDelegate = view->rootObject()->findChild<QQmlComponent*>();
77 QVERIFY(lvwph);
78
79=== modified file 'tests/plugins/Dash/listviewwithpageheadertest.cpp'
80--- tests/plugins/Dash/listviewwithpageheadertest.cpp 2016-04-19 15:20:02 +0000
81+++ tests/plugins/Dash/listviewwithpageheadertest.cpp 2016-05-26 12:55:18 +0000
82@@ -120,7 +120,7 @@
83 {
84 view = new QQuickView();
85 view->setSource(QUrl::fromLocalFile(DASHVIEWSTEST_FOLDER "/listviewwithpageheadertest.qml"));
86- lvwph = dynamic_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
87+ lvwph = static_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
88 model = view->rootObject()->findChild<QQmlListModel*>();
89 otherDelegate = view->rootObject()->findChild<QQmlComponent*>();
90 QVERIFY(lvwph);
91
92=== modified file 'tests/plugins/Dash/organicgridtest.cpp'
93--- tests/plugins/Dash/organicgridtest.cpp 2015-05-21 15:52:48 +0000
94+++ tests/plugins/Dash/organicgridtest.cpp 2016-05-26 12:55:18 +0000
95@@ -136,7 +136,7 @@
96 QTest::qWaitForWindowExposed(view);
97 view->resize(470, 400);
98
99- grid = dynamic_cast<OrganicGrid*>(view->rootObject()->findChild<QObject*>("grid"));
100+ grid = static_cast<OrganicGrid*>(view->rootObject()->findChild<QObject*>("grid"));
101 grid->setModel(model);
102 QTRY_COMPARE(grid->width(), 470.);
103
104
105=== modified file 'tests/plugins/Dash/verticaljournaltest.cpp'
106--- tests/plugins/Dash/verticaljournaltest.cpp 2015-05-21 15:52:48 +0000
107+++ tests/plugins/Dash/verticaljournaltest.cpp 2016-05-26 12:55:18 +0000
108@@ -137,7 +137,7 @@
109 QTest::qWaitForWindowExposed(view);
110 view->resize(470, 400);
111
112- vj = dynamic_cast<VerticalJournal*>(view->rootObject()->findChild<QObject*>("vj"));
113+ vj = static_cast<VerticalJournal*>(view->rootObject()->findChild<QObject*>("vj"));
114 vj->setModel(model);
115 QTRY_COMPARE(vj->width(), 470.);
116

Subscribers

People subscribed via source and target branches