~saviq/qtmir/fix-focus-dbus-path

« back to all changes in this revision

Viewing changes to tests/framework/fake_surface.h

  • Committer: CI Train Bot
  • Author(s): Daniel d'Andrada
  • Date: 2016-05-25 13:54:36 UTC
  • mfrom: (489.2.2 fixActiveFocusUpdate)
  • Revision ID: ci-train-bot@canonical.com-20160525135436-nu4f5jy18fogsxtu
Fix mir::scene::Surface focus attribute updates
Approved by: Unity8 CI Bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2014-2015 Canonical, Ltd.
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify it under
5
 
 * the terms of the GNU Lesser General Public License version 3, as published by
6
 
 * the Free Software Foundation.
7
 
 *
8
 
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 
 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
 
 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
 
 * Lesser General Public License for more details.
12
 
 *
13
 
 * You should have received a copy of the GNU Lesser General Public License
 
2
 * Copyright © 2014,2016 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,
 
6
 * as 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
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Original file authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
15
17
 */
16
18
 
17
 
#ifndef MIR_TEST_DOUBLES_STUB_SCENE_SURFACE_H_
18
 
#define MIR_TEST_DOUBLES_STUB_SCENE_SURFACE_H_
 
19
#ifndef MIR_SCENE_FAKESURFACE_H_
 
20
#define MIR_SCENE_FAKESURFACE_H_
19
21
 
20
 
#include "mir/scene/surface.h"
 
22
#include <mir/scene/surface.h>
21
23
#include "stub_input_channel.h"
22
24
 
23
25
#include <memory>
24
26
#include <gmock/gmock.h>
25
27
 
26
 
namespace mir
27
 
{
28
 
namespace test
29
 
{
30
 
namespace doubles
31
 
{
 
28
namespace mir {
 
29
namespace scene {
32
30
 
33
 
class StubSceneSurface :
34
 
    public mir::scene::Surface
 
31
class FakeSurface : public Surface
35
32
{
36
33
public:
37
 
    std::shared_ptr<StubInputChannel> channel;
 
34
    std::shared_ptr<mir::test::doubles::StubInputChannel> channel;
38
35
    int fd;
39
36
    mir::input::InputReceptionMode input_mode{mir::input::InputReceptionMode::normal};
40
37
 
41
 
    StubSceneSurface(int fd);
42
 
    virtual ~StubSceneSurface();
43
 
 
44
 
    std::shared_ptr<mir::input::InputChannel> input_channel() const override;
45
 
 
46
 
    mir::input::InputReceptionMode reception_mode() const override;
47
 
 
48
 
    std::string name() const override;
49
 
    geometry::Point top_left() const override;
50
 
    geometry::Size client_size() const override;
51
 
    geometry::Size size() const override;
52
 
    geometry::Rectangle input_bounds() const override;
53
 
    bool input_area_contains(mir::geometry::Point const&) const override;
54
 
 
55
 
    graphics::RenderableList generate_renderables(compositor::CompositorID) const override;
56
 
    float alpha() const override;
57
 
    MirSurfaceType type() const override;
58
 
    MirSurfaceState state() const override;
59
 
 
60
 
    void hide() override;
61
 
    void show() override;
62
 
    void move_to(geometry::Point const&) override;
63
 
    void set_input_region(std::vector<geometry::Rectangle> const&) override;
64
 
    void resize(geometry::Size const&) override;
65
 
    void set_transformation(glm::mat4 const&) override;
66
 
    void set_alpha(float) override;
67
 
    void set_orientation(MirOrientation) override;
68
 
 
69
 
    void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) override;
70
 
    void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override;
71
 
 
72
 
    void set_reception_mode(input::InputReceptionMode mode) override;
73
 
    void consume(MirEvent const*) override;
74
 
 
75
 
    void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& /* image */) override;
76
 
    std::shared_ptr<graphics::CursorImage> cursor_image() const override;
77
 
 
78
 
    bool supports_input() const override;
79
 
    int client_input_fd() const override;
80
 
    int configure(MirSurfaceAttrib, int) override;
81
 
    int query(MirSurfaceAttrib) const override;
 
38
    FakeSurface(int fd=123)
 
39
        : channel(std::make_shared<mir::test::doubles::StubInputChannel>(fd)), fd(fd)
 
40
    {
 
41
    }
 
42
 
 
43
    std::shared_ptr<mir::input::InputChannel> input_channel() const override
 
44
    {
 
45
        return channel;
 
46
    }
 
47
 
 
48
    mir::input::InputReceptionMode reception_mode() const override
 
49
    {
 
50
        return input_mode;
 
51
    }
 
52
 
 
53
    std::string name() const override { return {}; }
 
54
    geometry::Point top_left() const override { return {}; }
 
55
    geometry::Size client_size() const override { return {};}
 
56
    geometry::Size size() const override { return {}; }
 
57
    geometry::Rectangle input_bounds() const override { return {{},{}}; }
 
58
    bool input_area_contains(mir::geometry::Point const&) const override { return false; }
 
59
 
 
60
    void set_streams(std::list<scene::StreamInfo> const&) override {}
 
61
    graphics::RenderableList generate_renderables(compositor::CompositorID) const override { return {}; }
 
62
    int buffers_ready_for_compositor(void const*) const override { return 0; }
 
63
 
 
64
    float alpha() const override { return 0.0f;}
 
65
    MirSurfaceType type() const override { return mir_surface_type_normal; }
 
66
    MirSurfaceState state() const override { return mir_surface_state_unknown; }
 
67
 
 
68
    void hide() override {}
 
69
    void show() override {}
 
70
    bool visible() const override { return true; }
 
71
    void move_to(geometry::Point const&) override {}
 
72
    void set_input_region(std::vector<geometry::Rectangle> const&) override {}
 
73
    void resize(geometry::Size const&) override {}
 
74
    void set_transformation(glm::mat4 const&) override {}
 
75
    void set_alpha(float) override {}
 
76
    void set_orientation(MirOrientation) {}
 
77
 
 
78
    void add_observer(std::shared_ptr<scene::SurfaceObserver> const&) override {}
 
79
    void remove_observer(std::weak_ptr<scene::SurfaceObserver> const&) override {}
 
80
 
 
81
    void set_reception_mode(input::InputReceptionMode mode) override { input_mode = mode; }
 
82
    void consume(MirEvent const*) override {}
 
83
 
 
84
    void set_cursor_image(std::shared_ptr<graphics::CursorImage> const& /* image */) {}
 
85
    std::shared_ptr<graphics::CursorImage> cursor_image() const { return {}; }
 
86
 
 
87
    void request_client_surface_close() override {}
 
88
 
 
89
    bool supports_input() const override { return true;}
 
90
    int client_input_fd() const override { return fd;}
 
91
    int configure(MirSurfaceAttrib, int) override { return 0; }
 
92
    int query(MirSurfaceAttrib) const override { return 0; }
 
93
    void with_most_recent_buffer_do(std::function<void(graphics::Buffer&)> const&) {}
 
94
 
 
95
    std::shared_ptr<Surface> parent() const override { return nullptr; }
 
96
 
 
97
    void set_keymap(MirInputDeviceId, std::string const&, std::string const&, std::string const&, std::string const&) override
 
98
    {}
 
99
 
 
100
    void set_cursor_stream(std::shared_ptr<frontend::BufferStream> const&, geometry::Displacement const&) {}
 
101
    void rename(std::string const&) {}
 
102
    std::shared_ptr<frontend::BufferStream> primary_buffer_stream() const override { return nullptr; }
82
103
};
83
104
 
84
 
}
85
 
}
86
 
}
 
105
} // namespace scene
 
106
} // namescape mir
87
107
 
88
 
#endif
 
108
#endif // MIR_SCENE_FAKESURFACE_H_