OLD | NEW |
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 #include "chromeos/dbus/services/cros_dbus_service.h" | 5 #include "chromeos/dbus/services/cros_dbus_service.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
10 #include "dbus/message.h" | 12 #include "dbus/message.h" |
11 #include "dbus/mock_bus.h" | 13 #include "dbus/mock_bus.h" |
12 #include "dbus/mock_exported_object.h" | 14 #include "dbus/mock_exported_object.h" |
13 #include "dbus/mock_object_proxy.h" | 15 #include "dbus/mock_object_proxy.h" |
14 #include "dbus/object_path.h" | 16 #include "dbus/object_path.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Create a mock proxy resolution service. | 61 // Create a mock proxy resolution service. |
60 MockProxyResolutionService* mock_proxy_resolution_service_provider = | 62 MockProxyResolutionService* mock_proxy_resolution_service_provider = |
61 new MockProxyResolutionService; | 63 new MockProxyResolutionService; |
62 | 64 |
63 // Start() will be called with |mock_exported_object_|. | 65 // Start() will be called with |mock_exported_object_|. |
64 EXPECT_CALL(*mock_proxy_resolution_service_provider, | 66 EXPECT_CALL(*mock_proxy_resolution_service_provider, |
65 Start(Eq(mock_exported_object_))).WillOnce(Return()); | 67 Start(Eq(mock_exported_object_))).WillOnce(Return()); |
66 // Initialize the cros service with the mocks injected. | 68 // Initialize the cros service with the mocks injected. |
67 ScopedVector<CrosDBusService::ServiceProviderInterface> service_providers; | 69 ScopedVector<CrosDBusService::ServiceProviderInterface> service_providers; |
68 service_providers.push_back(mock_proxy_resolution_service_provider); | 70 service_providers.push_back(mock_proxy_resolution_service_provider); |
69 CrosDBusService::InitializeForTesting( | 71 CrosDBusService::InitializeForTesting(mock_bus_.get(), |
70 mock_bus_.get(), service_providers.Pass()); | 72 std::move(service_providers)); |
71 } | 73 } |
72 | 74 |
73 void TearDown() override { | 75 void TearDown() override { |
74 // Shutdown the cros service. | 76 // Shutdown the cros service. |
75 CrosDBusService::Shutdown(); | 77 CrosDBusService::Shutdown(); |
76 | 78 |
77 // Shutdown the bus. | 79 // Shutdown the bus. |
78 mock_bus_->ShutdownAndBlock(); | 80 mock_bus_->ShutdownAndBlock(); |
79 } | 81 } |
80 | 82 |
81 protected: | 83 protected: |
82 scoped_refptr<dbus::MockBus> mock_bus_; | 84 scoped_refptr<dbus::MockBus> mock_bus_; |
83 scoped_refptr<dbus::MockExportedObject> mock_exported_object_; | 85 scoped_refptr<dbus::MockExportedObject> mock_exported_object_; |
84 }; | 86 }; |
85 | 87 |
86 TEST_F(CrosDBusServiceTest, Start) { | 88 TEST_F(CrosDBusServiceTest, Start) { |
87 // Simply start the service and see if mock expectations are met: | 89 // Simply start the service and see if mock expectations are met: |
88 // - The service object is exported by GetExportedObject() | 90 // - The service object is exported by GetExportedObject() |
89 // - The proxy resolution service is started. | 91 // - The proxy resolution service is started. |
90 } | 92 } |
91 | 93 |
92 } // namespace chromeos | 94 } // namespace chromeos |
OLD | NEW |