Merge lp:~smspillaz/unity/mock_switcher_view into lp:unity

Proposed by Sam Spilsbury
Status: Rejected
Rejected by: Brandon Schaefer
Proposed branch: lp:~smspillaz/unity/mock_switcher_view
Merge into: lp:unity
Prerequisite: lp:~smspillaz/unity/switcher_view_interface
Diff against target: 184 lines (+103/-4)
5 files modified
launcher/SwitcherController.cpp (+8/-2)
launcher/SwitcherView.h (+1/-1)
shortcuts/ShortcutController.cpp (+8/-1)
tests/MockSwitcherView.h (+72/-0)
tests/test_switcher_controller.cpp (+14/-0)
To merge this branch: bzr merge lp:~smspillaz/unity/mock_switcher_view
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Disapprove
Unity Team Pending
Review via email: mp+140684@code.launchpad.net

Commit message

Implement a MockSwitcherView in Google Mock.

Description of the change

Implement a MockSwitcherView in Google Mock.

To post a comment you must log in.
3007. By Sam Spilsbury

Merged extract_switcher_view_interface into mock_switcher_view.

3008. By Sam Spilsbury

Update mock

3009. By Sam Spilsbury

Merged extract_switcher_view_interface into mock_switcher_view.

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Not working on this as we're not putting any more substantial effort into UnityNux. Somebody please reject this so it can be removed from the merge queue.

review: Disapprove

Unmerged revisions

3009. By Sam Spilsbury

Merged extract_switcher_view_interface into mock_switcher_view.

3008. By Sam Spilsbury

Update mock

3007. By Sam Spilsbury

Merged extract_switcher_view_interface into mock_switcher_view.

3006. By Sam Spilsbury

Merged extract_switcher_view_interface into mock_switcher_view.

3005. By Sam Spilsbury

Add switcher::View google mock

3004. By Sam Spilsbury

Pull a non-virtual interface out of SwitcherView

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/SwitcherController.cpp'
2--- launcher/SwitcherController.cpp 2012-12-23 10:03:25 +0000
3+++ launcher/SwitcherController.cpp 2012-12-23 10:03:25 +0000
4@@ -387,8 +387,6 @@
5 last_active_selection_ = nullptr;
6
7 view_.reset();
8- nux_view_ = nullptr;
9- introspectable_view_ = nullptr;
10
11 if (view_window_)
12 {
13@@ -396,7 +394,15 @@
14 view_window_->ShowWindow(false);
15 view_window_->PushToBack();
16 view_window_->EnableInputWindow(false);
17+
18+ /* We must do this here, as SetInputFocusArea causes the
19+ * nux::BaseWindow to hang on to a reference to the
20+ * nux::View when it is initially called */
21+ view_window_->SetEnterFocusInputArea(nullptr);
22 }
23+
24+ nux_view_ = nullptr;
25+ introspectable_view_ = nullptr;
26 }
27
28 bool ShellController::Visible()
29
30=== modified file 'launcher/SwitcherView.h'
31--- launcher/SwitcherView.h 2012-12-23 10:03:25 +0000
32+++ launcher/SwitcherView.h 2012-12-23 10:03:25 +0000
33@@ -305,7 +305,7 @@
34 unsigned int GetTileSize();
35 unsigned int GetAnimationLength();
36
37- void SetupBackground(bool enabled = true);
38+ void SetupBackground(bool enabled);
39
40 nux::Area * GetTopLevelViewWindow();
41 private:
42
43=== modified file 'shortcuts/ShortcutController.cpp'
44--- shortcuts/ShortcutController.cpp 2012-12-14 17:38:35 +0000
45+++ shortcuts/ShortcutController.cpp 2012-12-23 10:03:25 +0000
46@@ -99,6 +99,8 @@
47 if (!enabled_)
48 return false;
49
50+ view_window_->ShowWindow(true);
51+
52 base_window_raiser_->Raise(view_window_);
53
54 nux::Geometry geo;
55@@ -146,7 +148,6 @@
56 main_layout_->AddView(view_.GetPointer());
57
58 view_->SetupBackground(false);
59- view_window_->ShowWindow(true);
60 SetOpacity(0.0);
61 }
62
63@@ -206,6 +207,12 @@
64 void Controller::SetOpacity(double value)
65 {
66 view_window_->SetOpacity(value);
67+
68+ double finish_value = fade_animator_.GetFinishValue();
69+
70+ if (finish_value == 0.0f &&
71+ value == finish_value)
72+ view_window_->ShowWindow(false);
73 }
74
75 //
76
77=== added file 'tests/MockSwitcherView.h'
78--- tests/MockSwitcherView.h 1970-01-01 00:00:00 +0000
79+++ tests/MockSwitcherView.h 2012-12-23 10:03:25 +0000
80@@ -0,0 +1,72 @@
81+/*
82+ * Copyright 2012 Canonical Ltd.
83+ *
84+ * This program is free software: you can redistribute it and/or modify it
85+ * under the terms of the GNU General Public License version 3, as published
86+ * by the Free Software Foundation.
87+ *
88+ * This program is distributed in the hope that it will be useful, but
89+ * WITHOUT ANY WARRANTY; without even the implied warranties of
90+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
91+ * PURPOSE. See the GNU General Public License for more details.
92+ *
93+ * You should have received a copy of the GNU General Public License
94+ * version 3 along with this program. If not, see
95+ * <http://www.gnu.org/licenses/>
96+ *
97+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
98+ *
99+ */
100+#ifndef _UNITY_MOCK_SWITCHER_VIEW_H
101+#define _UNITY_MOCK_SWITCHER_VIEW_H
102+
103+#include <gtest/gtest.h>
104+#include <gmock/gmock.h>
105+
106+#include <memory>
107+
108+#include <SwitcherView.h>
109+#include <AbstractLauncherIcon.h>
110+
111+namespace unity
112+{
113+namespace switcher
114+{
115+class MockSwitcherView :
116+ public View::Impl
117+{
118+ public:
119+
120+ MOCK_METHOD0(ExternalTargets, ui::LayoutWindow::Vector ());
121+ MOCK_METHOD1(SetModel, void (SwitcherModel::Ptr));
122+ MOCK_METHOD0(GetModel, SwitcherModel::Ptr ());
123+ MOCK_METHOD3(ConnectToMouseEvents,
124+ View::MouseEventConnections (const View::MouseButtonCallback &mouse_down_callback,
125+ const View::MouseButtonCallback &mouse_up_callback,
126+ const View::MouseDragCallback &mouse_drag_callback));
127+ MOCK_METHOD0(QueueDraw, void ());
128+ MOCK_CONST_METHOD0(GetAbsoluteGeometry, nux::Geometry ());
129+ MOCK_METHOD2(IconIndexAt, int (int, int));
130+ MOCK_METHOD1(SetBackgroundColor, void(nux::Color const&));
131+ MOCK_METHOD1(SetupBackground, void(bool));
132+
133+ MOCK_METHOD1(SetMonitor, void(unsigned int));
134+ MOCK_METHOD1(SetBorderSize, void(unsigned int));
135+ MOCK_METHOD1(SetFlatSpacing, void(int));
136+ MOCK_METHOD1(SetTextSize, void(unsigned int));
137+ MOCK_METHOD1(SetTileSize, void(unsigned int));
138+ MOCK_METHOD1(SetIconSize, void(unsigned int));
139+ MOCK_METHOD1(SetAnimationLength, void(unsigned int));
140+ MOCK_METHOD1(SetRenderBoxes, void(bool));
141+
142+ MOCK_METHOD0(GetBorderSize, unsigned int());
143+ MOCK_METHOD0(GetFlatSpacing, unsigned int());
144+ MOCK_METHOD0(GetTextSize, unsigned int());
145+ MOCK_METHOD0(GetIconSize, unsigned int());
146+ MOCK_METHOD0(GetTileSize, unsigned int());
147+ MOCK_METHOD0(GetAnimationLength, unsigned int());
148+};
149+}
150+}
151+
152+#endif
153
154=== modified file 'tests/test_switcher_controller.cpp'
155--- tests/test_switcher_controller.cpp 2012-12-23 10:03:25 +0000
156+++ tests/test_switcher_controller.cpp 2012-12-23 10:03:25 +0000
157@@ -24,6 +24,7 @@
158 #include "test_utils.h"
159 #include "StubSwitcherController.h"
160 #include "MockSwitcherController.h"
161+#include "MockSwitcherView.h"
162 #include "SwitcherController.h"
163 #include "DesktopLauncherIcon.h"
164 #include "TimeUtil.h"
165@@ -35,6 +36,19 @@
166
167 unsigned int DEFAULT_LAZY_CONSTRUCT_TIMEOUT = 20;
168
169+TEST(TestSwitcherView, InstantiateMock)
170+{
171+ MockSwitcherView mock;
172+}
173+
174+TEST(TestSwitcherView, InstantiateMockThroughNVI)
175+{
176+ MockSwitcherView *mock = new MockSwitcherView;
177+ View view ([&](){
178+ return std::unique_ptr<View::Impl> (mock);
179+ });
180+}
181+
182 TEST(TestSwitcherController, InstantiateMock)
183 {
184 MockSwitcherController mock;