Mir

Merge lp:~robertcarr/mir/dedupe-mock-session into lp:~mir-team/mir/trunk

Proposed by Robert Carr
Status: Merged
Approved by: Robert Carr
Approved revision: no longer in the source branch.
Merged at revision: 485
Proposed branch: lp:~robertcarr/mir/dedupe-mock-session
Merge into: lp:~mir-team/mir/trunk
Diff against target: 196 lines (+74/-53)
3 files modified
include/mir_test_doubles/mock_session.h (+51/-0)
tests/integration-tests/cucumber/test_session_management_context.cpp (+5/-16)
tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp (+18/-37)
To merge this branch: bzr merge lp:~robertcarr/mir/dedupe-mock-session
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Review via email: mp+152287@code.launchpad.net

Commit message

Dedupe mock session definition in cucumber bridge test and single visibility focus mechanism test. Style cleanup to single visibility focus mechanism test in the process.

Description of the change

Dedupe mock session definition in cucumber bridge test and single visibility focus mechanism test. Style cleanup to single visibility focus mechanism test in the process.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:468
http://jenkins.qa.ubuntu.com/job/mir-ci/17/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-quantal-amd64-ci/17//console

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/mir-ci/17//rebuild/?

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:468
http://jenkins.qa.ubuntu.com/job/mir-ci/21/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-quantal-amd64-ci/21//console

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/mir-ci/21//rebuild/?

review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good (had to resubmit the build because of a spurious jenkins failure).

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

59 +++ tests/integration-tests/cucumber/test_session_management_context.cpp 2013-03-07 21:37:23 +0000
...
64 +#include "mir_test_doubles/mock_session.h"
...
72 +namespace mtd = mir::test::doubles;

No need for these changes

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> 59 +++ tests/integration-
> tests/cucumber/test_session_management_context.cpp 2013-03-07 21:37:23 +0000
> ...
> 64 +#include "mir_test_doubles/mock_session.h"
> ...
> 72 +namespace mtd = mir::test::doubles;
>
> No need for these changes

Sorry, bad cut & paste. That sould be:

126 +++ tests/unit-tests/frontend/test_application_mediator.cpp 2013-03-07 21:37:23 +0000
...
131 +#include "mir/shell/surface_creation_parameters.h"
...
138 +#include "mir_test_doubles/mock_session.h"

Revision history for this message
Robert Carr (robertcarr) wrote :

Removed unnecessary changes.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:469
http://jenkins.qa.ubuntu.com/job/mir-ci/29/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-quantal-amd64-ci/29//console

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/mir-ci/29//rebuild/?

review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

changes look ok

187 + EXPECT_CALL(app1, show()).Times(1);
188 + EXPECT_CALL(app2, hide()).Times(1);
189 + EXPECT_CALL(app3, hide()).Times(1);
obviously existing prior to these changes, but is the ordering of this important?

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/mir-autolanding/20/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/mir-quantal-amd64-autolanding/21//console

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:470
http://jenkins.qa.ubuntu.com/job/mir-ci/41/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/mir-quantal-amd64-ci/42//console

Click here to trigger a rebuild:
http://jenkins.qa.ubuntu.com/job/mir-ci/41//rebuild/?

review: Approve (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

Jenkins error was spurious hostname resolution failure.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'include/mir_test_doubles/mock_session.h'
2--- include/mir_test_doubles/mock_session.h 1970-01-01 00:00:00 +0000
3+++ include/mir_test_doubles/mock_session.h 2013-03-11 17:50:24 +0000
4@@ -0,0 +1,51 @@
5+/*
6+ * Copyright © 2013 Canonical Ltd.
7+ *
8+ * This program is free software: you can redistribute it and/or modify
9+ * it under the terms of the GNU General Public License version 3 as
10+ * published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ *
20+ * Authored by: Robert Carr <robert.carr@canonical.com>
21+ */
22+
23+#ifndef MIR_TEST_DOUBLES_MOCK_SESSION_H_
24+#define MIR_TEST_DOUBLES_MOCK_SESSION_H_
25+
26+#include "mir/shell/session.h"
27+
28+#include <gmock/gmock.h>
29+
30+namespace mir
31+{
32+namespace test
33+{
34+namespace doubles
35+{
36+
37+struct MockSession : public shell::Session
38+{
39+ MOCK_METHOD1(create_surface, shell::SurfaceId(shell::SurfaceCreationParameters const&));
40+ MOCK_METHOD1(destroy_surface, void(shell::SurfaceId));
41+ MOCK_CONST_METHOD1(get_surface, std::shared_ptr<shell::Surface>(shell::SurfaceId));
42+
43+ MOCK_METHOD0(name, std::string());
44+ MOCK_METHOD0(shutdown, void());
45+
46+ MOCK_METHOD0(hide, void());
47+ MOCK_METHOD0(show, void());
48+};
49+
50+}
51+}
52+} // namespace mir
53+
54+
55+#endif // MIR_TEST_DOUBLES_MOCK_SESSION_H_
56
57=== modified file 'tests/integration-tests/cucumber/test_session_management_context.cpp'
58--- tests/integration-tests/cucumber/test_session_management_context.cpp 2013-03-06 16:48:33 +0000
59+++ tests/integration-tests/cucumber/test_session_management_context.cpp 2013-03-11 17:50:24 +0000
60@@ -24,6 +24,7 @@
61 #include "mir/shell/surface_creation_parameters.h"
62 #include "mir/graphics/viewable_area.h"
63
64+#include "mir_test_doubles/mock_session.h"
65 #include "mir_test/fake_shared.h"
66
67 #include <gtest/gtest.h>
68@@ -36,6 +37,7 @@
69 namespace msh = mir::shell;
70 namespace geom = mir::geometry;
71 namespace mt = mir::test;
72+namespace mtd = mir::test::doubles;
73 namespace mtc = mt::cucumber;
74
75 namespace
76@@ -61,19 +63,6 @@
77 MOCK_METHOD0(shutdown, void());
78 };
79
80-struct MockSession : public msh::Session
81-{
82- MOCK_METHOD1(create_surface, msh::SurfaceId(msh::SurfaceCreationParameters const&));
83- MOCK_METHOD1(destroy_surface, void(msh::SurfaceId));
84- MOCK_CONST_METHOD1(get_surface, std::shared_ptr<msh::Surface>(msh::SurfaceId));
85-
86- MOCK_METHOD0(name, std::string());
87- MOCK_METHOD0(shutdown, void());
88-
89- MOCK_METHOD0(hide, void());
90- MOCK_METHOD0(show, void());
91-};
92-
93 struct MockSurface : public msh::Surface
94 {
95 MOCK_METHOD0(hide, void());
96@@ -166,7 +155,7 @@
97 {
98 using namespace ::testing;
99
100- MockSession session;
101+ mtd::MockSession session;
102
103 EXPECT_CALL(session_store, open_session(test_window_name)).Times(1)
104 .WillOnce(Return(mt::fake_shared<msh::Session>(session)));
105@@ -182,7 +171,7 @@
106 {
107 using namespace ::testing;
108
109- MockSession session;
110+ mtd::MockSession session;
111
112 EXPECT_CALL(session_store, open_session(test_window_name)).Times(1)
113 .WillOnce(Return(mt::fake_shared<msh::Session>(session)));
114@@ -197,7 +186,7 @@
115 {
116 using namespace ::testing;
117
118- MockSession session;
119+ mtd::MockSession session;
120 MockSurface surface;
121
122 EXPECT_CALL(session_store, open_session(test_window_name)).Times(1)
123
124=== modified file 'tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp'
125--- tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-03-06 12:54:33 +0000
126+++ tests/unit-tests/shell/test_single_visibility_focus_mechanism.cpp 2013-03-11 17:50:24 +0000
127@@ -26,6 +26,7 @@
128 #include "mir_test_doubles/mock_buffer_bundle.h"
129 #include "mir_test/fake_shared.h"
130 #include "mir_test_doubles/mock_surface_factory.h"
131+#include "mir_test_doubles/mock_session.h"
132
133 #include <gmock/gmock.h>
134 #include <gtest/gtest.h>
135@@ -37,45 +38,25 @@
136 namespace mt = mir::test;
137 namespace mtd = mir::test::doubles;
138
139-namespace
140-{
141-
142-struct MockApplicationSession : public msh::ApplicationSession
143-{
144- MockApplicationSession(std::shared_ptr<msh::SurfaceFactory> factory,
145- std::string name) : ApplicationSession(factory, name)
146- {
147- }
148- MOCK_METHOD0(hide,void());
149- MOCK_METHOD0(show,void());
150-};
151-
152-}
153-
154 TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility)
155 {
156 using namespace ::testing;
157- std::shared_ptr<msh::SurfaceFactory> factory(new mtd::MockSurfaceFactory);
158- std::shared_ptr<msh::SessionContainer> model(new msh::SessionContainer);
159-
160- MockApplicationSession m1(factory, "Visual Studio 7");
161- MockApplicationSession m2(factory, "Visual Studio 8");
162- MockApplicationSession m3(factory, "Visual Studio 9");
163-
164- auto app1 = mt::fake_shared(m1);
165- auto app2 = mt::fake_shared(m2);
166- auto app3 = mt::fake_shared(m3);
167-
168- msh::SingleVisibilityFocusMechanism focus_mechanism(model);
169-
170- EXPECT_CALL(m1, show()).Times(1);
171- EXPECT_CALL(m2, hide()).Times(1);
172- EXPECT_CALL(m3, hide()).Times(1);
173-
174- model->insert_session(app1);
175- model->insert_session(app2);
176- model->insert_session(app3);
177-
178- focus_mechanism.set_focus_to(app1);
179+
180+ mtd::MockSession app1;
181+ mtd::MockSession app2;
182+ mtd::MockSession app3;
183+
184+ msh::SessionContainer model;
185+ msh::SingleVisibilityFocusMechanism focus_mechanism(mt::fake_shared(model));
186+
187+ EXPECT_CALL(app1, show()).Times(1);
188+ EXPECT_CALL(app2, hide()).Times(1);
189+ EXPECT_CALL(app3, hide()).Times(1);
190+
191+ model.insert_session(mt::fake_shared(app1));
192+ model.insert_session(mt::fake_shared(app2));
193+ model.insert_session(mt::fake_shared(app3));
194+
195+ focus_mechanism.set_focus_to(mt::fake_shared(app1));
196 }
197

Subscribers

People subscribed via source and target branches