Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: chromeos/dbus/services/service_provider_test_helper.h

Issue 2824093003: chromeos: Custom services in ServiceProviderTestHelper. (Closed)
Patch Set: forward-declare dbus::ObjectPath (not that it matters) Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_DBUS_SERVICES_SERVICE_PROVIDER_TEST_HELPER_H_ 5 #ifndef CHROMEOS_DBUS_SERVICES_SERVICE_PROVIDER_TEST_HELPER_H_
6 #define CHROMEOS_DBUS_SERVICES_SERVICE_PROVIDER_TEST_HELPER_H_ 6 #define CHROMEOS_DBUS_SERVICES_SERVICE_PROVIDER_TEST_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "chromeos/dbus/services/cros_dbus_service.h" 11 #include "chromeos/dbus/services/cros_dbus_service.h"
12 #include "dbus/mock_exported_object.h" 12 #include "dbus/mock_exported_object.h"
13 #include "dbus/mock_object_proxy.h" 13 #include "dbus/mock_object_proxy.h"
14 #include "dbus/object_proxy.h" 14 #include "dbus/object_proxy.h"
15 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace dbus { 18 namespace dbus {
19 19
20 class MockBus; 20 class MockBus;
21 class ObjectPath;
21 22
22 } // namespace dbus 23 } // namespace dbus
23 24
24 namespace chromeos { 25 namespace chromeos {
25 26
26 // Helps to implement |CrosDBusService::ServiceProviderInterface| unittests. 27 // Helps to implement |CrosDBusService::ServiceProviderInterface| unittests.
27 // Setups mocking of dbus classes. 28 // Setups mocking of dbus classes.
28 // Class can test only one method call in time. SetUp() must be called before 29 // Class can test only one method call in time. SetUp() must be called before
29 // testing new call to the same method or different method. 30 // testing new call to the same method or different method.
30 // 31 //
31 // Sample usage: 32 // Sample usage:
32 // ServiceProviderTestHelper helper; 33 // ServiceProviderTestHelper helper;
33 // helper.Setup(...); 34 // helper.Setup(...);
34 // helper.SetUpReturnSignal(...); // optional. 35 // helper.SetUpReturnSignal(...); // optional.
35 // helper.CallMethod(...); 36 // helper.CallMethod(...);
36 // helper.TearDown(); 37 // helper.TearDown();
37 class ServiceProviderTestHelper { 38 class ServiceProviderTestHelper {
38 public: 39 public:
39 ServiceProviderTestHelper(); 40 ServiceProviderTestHelper();
40 ~ServiceProviderTestHelper(); 41 ~ServiceProviderTestHelper();
41 42
42 // Sets up helper. Should be called before |CallMethod()|. 43 // Sets up helper. Should be called before |CallMethod()|.
43 void SetUp(const std::string& exported_method_name, 44 void SetUp(const std::string& service_name,
45 const dbus::ObjectPath& service_path,
46 const std::string& interface_name,
47 const std::string& exported_method_name,
44 CrosDBusService::ServiceProviderInterface* service_provider); 48 CrosDBusService::ServiceProviderInterface* service_provider);
45 49
46 // Setups return signal callback. It's optional and don't need to be called 50 // Setups return signal callback. It's optional and don't need to be called
47 // if tested method doesn't use signal to return results. 51 // if tested method doesn't use signal to return results.
48 void SetUpReturnSignal( 52 void SetUpReturnSignal(
49 const std::string& interface_name, 53 const std::string& interface_name,
50 const std::string& signal_name, 54 const std::string& signal_name,
51 dbus::ObjectProxy::SignalCallback signal_callback, 55 dbus::ObjectProxy::SignalCallback signal_callback,
52 dbus::ObjectProxy::OnConnectedCallback on_connected_callback); 56 dbus::ObjectProxy::OnConnectedCallback on_connected_callback);
53 57
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 dbus::ExportedObject::MethodCallCallback method_callback_; 93 dbus::ExportedObject::MethodCallCallback method_callback_;
90 dbus::ObjectProxy::SignalCallback on_signal_callback_; 94 dbus::ObjectProxy::SignalCallback on_signal_callback_;
91 std::unique_ptr<base::MessageLoop> message_loop_; 95 std::unique_ptr<base::MessageLoop> message_loop_;
92 bool response_received_; 96 bool response_received_;
93 std::unique_ptr<dbus::Response> response_; 97 std::unique_ptr<dbus::Response> response_;
94 }; 98 };
95 99
96 } // namespace chromeos 100 } // namespace chromeos
97 101
98 #endif // CHROMEOS_DBUS_SERVICES_SERVICE_PROVIDER_TEST_HELPER_H_ 102 #endif // CHROMEOS_DBUS_SERVICES_SERVICE_PROVIDER_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698