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
=== modified file 'launcher/SwitcherController.cpp'
--- launcher/SwitcherController.cpp 2012-12-23 10:03:25 +0000
+++ launcher/SwitcherController.cpp 2012-12-23 10:03:25 +0000
@@ -387,8 +387,6 @@
387 last_active_selection_ = nullptr;387 last_active_selection_ = nullptr;
388388
389 view_.reset();389 view_.reset();
390 nux_view_ = nullptr;
391 introspectable_view_ = nullptr;
392390
393 if (view_window_)391 if (view_window_)
394 {392 {
@@ -396,7 +394,15 @@
396 view_window_->ShowWindow(false);394 view_window_->ShowWindow(false);
397 view_window_->PushToBack();395 view_window_->PushToBack();
398 view_window_->EnableInputWindow(false);396 view_window_->EnableInputWindow(false);
397
398 /* We must do this here, as SetInputFocusArea causes the
399 * nux::BaseWindow to hang on to a reference to the
400 * nux::View when it is initially called */
401 view_window_->SetEnterFocusInputArea(nullptr);
399 }402 }
403
404 nux_view_ = nullptr;
405 introspectable_view_ = nullptr;
400}406}
401407
402bool ShellController::Visible()408bool ShellController::Visible()
403409
=== modified file 'launcher/SwitcherView.h'
--- launcher/SwitcherView.h 2012-12-23 10:03:25 +0000
+++ launcher/SwitcherView.h 2012-12-23 10:03:25 +0000
@@ -305,7 +305,7 @@
305 unsigned int GetTileSize();305 unsigned int GetTileSize();
306 unsigned int GetAnimationLength();306 unsigned int GetAnimationLength();
307307
308 void SetupBackground(bool enabled = true);308 void SetupBackground(bool enabled);
309309
310 nux::Area * GetTopLevelViewWindow();310 nux::Area * GetTopLevelViewWindow();
311 private:311 private:
312312
=== modified file 'shortcuts/ShortcutController.cpp'
--- shortcuts/ShortcutController.cpp 2012-12-14 17:38:35 +0000
+++ shortcuts/ShortcutController.cpp 2012-12-23 10:03:25 +0000
@@ -99,6 +99,8 @@
99 if (!enabled_)99 if (!enabled_)
100 return false;100 return false;
101101
102 view_window_->ShowWindow(true);
103
102 base_window_raiser_->Raise(view_window_);104 base_window_raiser_->Raise(view_window_);
103105
104 nux::Geometry geo;106 nux::Geometry geo;
@@ -146,7 +148,6 @@
146 main_layout_->AddView(view_.GetPointer());148 main_layout_->AddView(view_.GetPointer());
147149
148 view_->SetupBackground(false);150 view_->SetupBackground(false);
149 view_window_->ShowWindow(true);
150 SetOpacity(0.0);151 SetOpacity(0.0);
151}152}
152153
@@ -206,6 +207,12 @@
206void Controller::SetOpacity(double value)207void Controller::SetOpacity(double value)
207{208{
208 view_window_->SetOpacity(value);209 view_window_->SetOpacity(value);
210
211 double finish_value = fade_animator_.GetFinishValue();
212
213 if (finish_value == 0.0f &&
214 value == finish_value)
215 view_window_->ShowWindow(false);
209}216}
210217
211//218//
212219
=== added file 'tests/MockSwitcherView.h'
--- tests/MockSwitcherView.h 1970-01-01 00:00:00 +0000
+++ tests/MockSwitcherView.h 2012-12-23 10:03:25 +0000
@@ -0,0 +1,72 @@
1/*
2 * Copyright 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
16 *
17 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
18 *
19 */
20#ifndef _UNITY_MOCK_SWITCHER_VIEW_H
21#define _UNITY_MOCK_SWITCHER_VIEW_H
22
23#include <gtest/gtest.h>
24#include <gmock/gmock.h>
25
26#include <memory>
27
28#include <SwitcherView.h>
29#include <AbstractLauncherIcon.h>
30
31namespace unity
32{
33namespace switcher
34{
35class MockSwitcherView :
36 public View::Impl
37{
38 public:
39
40 MOCK_METHOD0(ExternalTargets, ui::LayoutWindow::Vector ());
41 MOCK_METHOD1(SetModel, void (SwitcherModel::Ptr));
42 MOCK_METHOD0(GetModel, SwitcherModel::Ptr ());
43 MOCK_METHOD3(ConnectToMouseEvents,
44 View::MouseEventConnections (const View::MouseButtonCallback &mouse_down_callback,
45 const View::MouseButtonCallback &mouse_up_callback,
46 const View::MouseDragCallback &mouse_drag_callback));
47 MOCK_METHOD0(QueueDraw, void ());
48 MOCK_CONST_METHOD0(GetAbsoluteGeometry, nux::Geometry ());
49 MOCK_METHOD2(IconIndexAt, int (int, int));
50 MOCK_METHOD1(SetBackgroundColor, void(nux::Color const&));
51 MOCK_METHOD1(SetupBackground, void(bool));
52
53 MOCK_METHOD1(SetMonitor, void(unsigned int));
54 MOCK_METHOD1(SetBorderSize, void(unsigned int));
55 MOCK_METHOD1(SetFlatSpacing, void(int));
56 MOCK_METHOD1(SetTextSize, void(unsigned int));
57 MOCK_METHOD1(SetTileSize, void(unsigned int));
58 MOCK_METHOD1(SetIconSize, void(unsigned int));
59 MOCK_METHOD1(SetAnimationLength, void(unsigned int));
60 MOCK_METHOD1(SetRenderBoxes, void(bool));
61
62 MOCK_METHOD0(GetBorderSize, unsigned int());
63 MOCK_METHOD0(GetFlatSpacing, unsigned int());
64 MOCK_METHOD0(GetTextSize, unsigned int());
65 MOCK_METHOD0(GetIconSize, unsigned int());
66 MOCK_METHOD0(GetTileSize, unsigned int());
67 MOCK_METHOD0(GetAnimationLength, unsigned int());
68};
69}
70}
71
72#endif
073
=== modified file 'tests/test_switcher_controller.cpp'
--- tests/test_switcher_controller.cpp 2012-12-23 10:03:25 +0000
+++ tests/test_switcher_controller.cpp 2012-12-23 10:03:25 +0000
@@ -24,6 +24,7 @@
24#include "test_utils.h"24#include "test_utils.h"
25#include "StubSwitcherController.h"25#include "StubSwitcherController.h"
26#include "MockSwitcherController.h"26#include "MockSwitcherController.h"
27#include "MockSwitcherView.h"
27#include "SwitcherController.h"28#include "SwitcherController.h"
28#include "DesktopLauncherIcon.h"29#include "DesktopLauncherIcon.h"
29#include "TimeUtil.h"30#include "TimeUtil.h"
@@ -35,6 +36,19 @@
3536
36unsigned int DEFAULT_LAZY_CONSTRUCT_TIMEOUT = 20;37unsigned int DEFAULT_LAZY_CONSTRUCT_TIMEOUT = 20;
3738
39TEST(TestSwitcherView, InstantiateMock)
40{
41 MockSwitcherView mock;
42}
43
44TEST(TestSwitcherView, InstantiateMockThroughNVI)
45{
46 MockSwitcherView *mock = new MockSwitcherView;
47 View view ([&](){
48 return std::unique_ptr<View::Impl> (mock);
49 });
50}
51
38TEST(TestSwitcherController, InstantiateMock)52TEST(TestSwitcherController, InstantiateMock)
39{53{
40 MockSwitcherController mock;54 MockSwitcherController mock;