~vanvugt/unity/fix-865006

« back to all changes in this revision

Viewing changes to tests/test_hud_controller.cpp

  • Committer: Tarmac
  • Author(s): Andrea Azzarone
  • Date: 2012-06-12 14:35:38 UTC
  • mfrom: (2388.1.4 hud-reset)
  • Revision ID: tarmac-20120612143538-igkcxpuc2ly14ghk
Fix HUD flickering when showing up after closing previous search. Included with respective unit test and required changes.. Fixes: https://bugs.launchpad.net/bugs/1011507. Approved by Łukasz Zemczak.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 Lesser General Public License version 3, as
 
6
 * published 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 applicable version of the GNU Lesser General Public
 
12
 * License for more details.
 
13
 *
 
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/>
 
17
 *
 
18
 * Authored by: Andrea Azzarone <azzaronea@gmail.com>
 
19
 *
 
20
 */
 
21
 
 
22
#include <gmock/gmock.h>
 
23
using namespace testing;
 
24
 
 
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;
 
32
 
 
33
namespace
 
34
{
 
35
 
 
36
class MockHudView : public hud::AbstractView
 
37
{
 
38
public:
 
39
  typedef nux::ObjectPtr<MockHudView> Ptr;
 
40
 
 
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));
 
54
 
 
55
};
 
56
 
 
57
class TestHudController : public Test
 
58
{
 
59
public:
 
60
  virtual void SetUp()
 
61
  {
 
62
    WindowManager::SetDefault(WindowManager::Default());
 
63
    view = new MockHudView;
 
64
    controller.reset(new hud::Controller([&view]{ return view.GetPointer(); }));
 
65
  }
 
66
 
 
67
  Settings unity_settings;
 
68
  dash::Style dash_style;
 
69
  panel::Style panel_style;
 
70
 
 
71
  hud::Controller::Ptr controller;
 
72
  MockHudView::Ptr view;
 
73
};
 
74
 
 
75
TEST_F(TestHudController, TestHideHud)
 
76
{
 
77
  controller->ShowHud();
 
78
 
 
79
  EXPECT_CALL(*view, ResetToDefault())
 
80
    .Times(1);
 
81
 
 
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);
 
85
}
 
86
 
 
87
}