2
* Copyright 2012 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
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 applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Andrea Azzarone <azzaronea@gmail.com>
22
#include <gmock/gmock.h>
23
using namespace testing;
25
#include "HudController.h"
26
#include "unity-shared/DashStyle.h"
27
#include "unity-shared/PanelStyle.h"
28
#include "unity-shared/UnitySettings.h"
29
#include "unity-shared/WindowManager.h"
30
#include "test_utils.h"
31
using namespace unity;
36
class MockHudView : public hud::AbstractView
39
typedef nux::ObjectPtr<MockHudView> Ptr;
41
MOCK_METHOD0(AboutToShow, void());
42
MOCK_METHOD0(AboutToHide, void());
43
MOCK_METHOD0(Relayout, void());
44
MOCK_METHOD0(ResetToDefault, void());
45
MOCK_METHOD0(SearchFinished, void());
46
MOCK_METHOD4(SetIcon, void(std::string const&, unsigned int tile_size, unsigned int size, unsigned int padding));
47
MOCK_METHOD1(SetQueries, void(hud::Hud::Queries queries));
48
MOCK_METHOD2(SetWindowGeometry, void(nux::Geometry const& absolute_geo, nux::Geometry const& geo));
49
MOCK_METHOD1(ShowEmbeddedIcon, void(bool show));
50
MOCK_CONST_METHOD0(default_focus, nux::View*());
51
MOCK_CONST_METHOD0(GetName, std::string());
52
MOCK_METHOD1(AddProperties, void(GVariantBuilder*));
53
MOCK_METHOD2(Draw, void(nux::GraphicsEngine&, bool));
57
class TestHudController : public Test
62
WindowManager::SetDefault(WindowManager::Default());
63
view = new MockHudView;
64
controller.reset(new hud::Controller([&view]{ return view.GetPointer(); }));
67
Settings unity_settings;
68
dash::Style dash_style;
69
panel::Style panel_style;
71
hud::Controller::Ptr controller;
72
MockHudView::Ptr view;
75
TEST_F(TestHudController, TestHideHud)
77
controller->ShowHud();
79
EXPECT_CALL(*view, ResetToDefault())
82
controller->HideHud();
83
// view->ResetToDefault should be called at the end of the fade out effect. So wait for it.
84
Utils::WaitForTimeout(2);