~alan-griffiths/mir/knee-jerk-mir_surface_state_automatic

« back to all changes in this revision

Viewing changes to tests/unit-tests/frontend/test_single_visibility_focus_mechanism.cpp

  • Committer: Kevin DuBois
  • Date: 2012-11-13 01:36:29 UTC
  • mfrom: (245 trunk)
  • mto: This revision was merged to the branch mainline in revision 246.
  • Revision ID: kevin.dubois@canonical.com-20121113013629-q4496w4mp5e33auk
merge in base branch. move the demo clients to a new directory, examples/

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
 
5
 * it under the terms of the GNU 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,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored By: Robert Carr <racarr@canonical.com>
 
17
 */
 
18
 
 
19
#include "mir/compositor/buffer_bundle.h"
 
20
#include "mir/frontend/application_session.h"
 
21
#include "mir/frontend/application_session_model.h"
 
22
#include "mir/frontend/registration_order_focus_selection_strategy.h"
 
23
#include "mir/frontend/single_visibility_focus_mechanism.h"
 
24
#include "mir/surfaces/surface.h"
 
25
#include "mir_test/mock_buffer_bundle.h"
 
26
#include "mir_test/empty_deleter.h"
 
27
#include "mir_test/mock_application_surface_organiser.h"
 
28
 
 
29
#include <gmock/gmock.h>
 
30
#include <gtest/gtest.h>
 
31
#include <string>
 
32
 
 
33
namespace mc = mir::compositor;
 
34
namespace mf = mir::frontend;
 
35
namespace ms = mir::surfaces;
 
36
 
 
37
namespace
 
38
{
 
39
 
 
40
struct MockApplicationSession : public mf::ApplicationSession
 
41
{
 
42
  MockApplicationSession(std::shared_ptr<ms::ApplicationSurfaceOrganiser> organiser,
 
43
                         std::string name) : ApplicationSession(organiser, name)
 
44
  {
 
45
  }
 
46
  MOCK_METHOD0(hide,void());
 
47
  MOCK_METHOD0(show,void());
 
48
};
 
49
 
 
50
}
 
51
 
 
52
TEST(SingleVisibilityFocusMechanism, mechanism_sets_visibility)
 
53
{
 
54
    using namespace ::testing;
 
55
    std::shared_ptr<ms::ApplicationSurfaceOrganiser> organiser(new ms::MockApplicationSurfaceOrganiser);
 
56
    std::shared_ptr<mf::ApplicationSessionModel> model(new mf::ApplicationSessionModel);
 
57
    
 
58
    MockApplicationSession m1(organiser, "Visual Studio 7");
 
59
    MockApplicationSession m2(organiser, "Visual Studio 8");
 
60
    MockApplicationSession m3(organiser, "Visual Studio 9");
 
61
    
 
62
    std::shared_ptr<mf::ApplicationSession> app1(&m1, mir::EmptyDeleter());
 
63
    std::shared_ptr<mf::ApplicationSession> app2(&m2, mir::EmptyDeleter());
 
64
    std::shared_ptr<mf::ApplicationSession> app3(&m3, mir::EmptyDeleter());
 
65
 
 
66
    mf::SingleVisibilityFocusMechanism focus_mechanism(model);
 
67
    
 
68
    EXPECT_CALL(m1, show()).Times(1);
 
69
    EXPECT_CALL(m2, hide()).Times(1);
 
70
    EXPECT_CALL(m3, hide()).Times(1);
 
71
 
 
72
    model->insert_session(app1);
 
73
    model->insert_session(app2);
 
74
    model->insert_session(app3);
 
75
 
 
76
    focus_mechanism.set_focus_to(app1);
 
77
}
 
78