Unity Scopes API
MockRegistry.h
1 /*
2  * Copyright (C) 2013 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it 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,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 
19 #pragma once
20 
21 #include <unity/scopes/Registry.h>
22 #include <unity/scopes/testing/MockObject.h>
23 
24 #pragma GCC diagnostic push
25 #pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
26 #include <gmock/gmock.h>
27 #pragma GCC diagnostic pop
28 
29 namespace unity
30 {
31 
32 namespace scopes
33 {
34 
35 namespace testing
36 {
37 
39 
40 class MockRegistry : public Registry, public virtual MockObject
41 {
42 public:
43  MockRegistry() = default;
44 
45  MOCK_METHOD1(get_metadata, ScopeMetadata(std::string const&));
46  MOCK_METHOD0(list, MetadataMap());
47  MOCK_METHOD1(list_if, MetadataMap(std::function<bool(ScopeMetadata const&)>));
48  MOCK_METHOD1(is_scope_running, bool(std::string const&));
49  core::ScopedConnection set_scope_state_callback(std::string const&, std::function<void(bool is_running)>) override
50  {
51  return core::Signal<>().connect([]{});
52  }
53  core::ScopedConnection set_list_update_callback(std::function<void()>) override
54  {
55  return core::Signal<>().connect([]{});
56  }
57 };
58 
60 
61 } // namespace testing
62 
63 } // namespace scopes
64 
65 } // namespace unity
Definition: OnlineAccountClient.h:39
Top-level namespace for all things Unity-related.
Definition: Version.h:49
std::map< std::string, ScopeMetadata > MetadataMap
Map for scope ID and metadata pairs.
Definition: Registry.h:43