Back to index

unity  6.0.0
test_hud_controller.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2012 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License version 3, as
00006  * published by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00012  * License for more details.
00013  *
00014  * You should have received a copy of both the GNU Lesser General Public
00015  * License version 3 along with this program.  If not, see
00016  * <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Andrea Azzarone <azzaronea@gmail.com>
00019  *
00020  */
00021 
00022 #include <gmock/gmock.h>
00023 using namespace testing;
00024 
00025 #include "HudController.h"
00026 #include "unity-shared/DashStyle.h"
00027 #include "unity-shared/PanelStyle.h"
00028 #include "unity-shared/UnitySettings.h"
00029 #include "test_utils.h"
00030 using namespace unity;
00031 
00032 namespace
00033 {
00034 
00035 class MockHudView : public hud::AbstractView
00036 {
00037 public:
00038   typedef nux::ObjectPtr<MockHudView> Ptr;
00039 
00040   MOCK_METHOD0(AboutToShow, void());
00041   MOCK_METHOD0(AboutToHide, void());
00042   MOCK_METHOD0(Relayout, void());
00043   MOCK_METHOD0(ResetToDefault, void());
00044   MOCK_METHOD0(SearchFinished, void());
00045   MOCK_METHOD4(SetIcon, void(std::string const&, unsigned int tile_size, unsigned int size, unsigned int padding));
00046   MOCK_METHOD1(SetQueries, void(hud::Hud::Queries queries));
00047   MOCK_METHOD2(SetWindowGeometry, void(nux::Geometry const& absolute_geo, nux::Geometry const& geo));
00048   MOCK_METHOD1(ShowEmbeddedIcon, void(bool show));
00049   MOCK_CONST_METHOD0(default_focus, nux::View*());
00050   MOCK_CONST_METHOD0(GetName, std::string());
00051   MOCK_METHOD1(AddProperties, void(GVariantBuilder*));
00052   MOCK_METHOD2(Draw, void(nux::GraphicsEngine&, bool));
00053 
00054 };
00055 
00056 class TestHudController : public Test
00057 {
00058 public:
00059   virtual void SetUp()
00060   {
00061     view = new MockHudView;
00062     controller.reset(new hud::Controller([this]{ return view.GetPointer(); }));
00063   }
00064 
00065   Settings unity_settings;
00066   dash::Style dash_style;
00067   panel::Style panel_style;
00068 
00069   hud::Controller::Ptr controller;
00070   MockHudView::Ptr view;
00071 };
00072 
00073 TEST_F(TestHudController, TestHideHud)
00074 {
00075   controller->ShowHud();
00076   Utils::WaitForTimeout(1);
00077 
00078   EXPECT_CALL(*view, ResetToDefault())
00079     .Times(1);
00080 
00081   controller->HideHud();
00082   // view->ResetToDefault should be called at the end of the fade out effect. So wait for it.
00083   Utils::WaitForTimeout(2);
00084 }
00085 
00086 }