OLD | NEW |
1 // Copyright (c) 2011 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 "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 5 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
11 #include "dbus/mock_bus.h" | 11 #include "dbus/mock_bus.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_path.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
17 | 18 |
18 using ::testing::Eq; | 19 using ::testing::Eq; |
19 using ::testing::Invoke; | 20 using ::testing::Invoke; |
20 using ::testing::Return; | 21 using ::testing::Return; |
21 | 22 |
22 namespace chromeos { | 23 namespace chromeos { |
23 | 24 |
(...skipping 17 matching lines...) Expand all Loading... |
41 mock_bus_ = new dbus::MockBus(options); | 42 mock_bus_ = new dbus::MockBus(options); |
42 | 43 |
43 // ShutdownAndBlock() will be called in TearDown(). | 44 // ShutdownAndBlock() will be called in TearDown(). |
44 EXPECT_CALL(*mock_bus_, ShutdownAndBlock()).WillOnce(Return()); | 45 EXPECT_CALL(*mock_bus_, ShutdownAndBlock()).WillOnce(Return()); |
45 | 46 |
46 // Create a mock exported object that behaves as | 47 // Create a mock exported object that behaves as |
47 // org.chromium.CrosDBusService. | 48 // org.chromium.CrosDBusService. |
48 mock_exported_object_ = | 49 mock_exported_object_ = |
49 new dbus::MockExportedObject(mock_bus_.get(), | 50 new dbus::MockExportedObject(mock_bus_.get(), |
50 kLibCrosServiceName, | 51 kLibCrosServiceName, |
51 kLibCrosServicePath); | 52 dbus::ObjectPath(kLibCrosServicePath)); |
52 | 53 |
53 // |mock_bus_|'s GetExportedObject() will return mock_exported_object_| | 54 // |mock_bus_|'s GetExportedObject() will return mock_exported_object_| |
54 // for the given service name and the object path. | 55 // for the given service name and the object path. |
55 EXPECT_CALL(*mock_bus_, GetExportedObject( | 56 EXPECT_CALL(*mock_bus_, GetExportedObject( |
56 kLibCrosServiceName, kLibCrosServicePath)) | 57 kLibCrosServiceName, dbus::ObjectPath(kLibCrosServicePath))) |
57 .WillOnce(Return(mock_exported_object_.get())); | 58 .WillOnce(Return(mock_exported_object_.get())); |
58 | 59 |
59 // Create a mock proxy resolution service. | 60 // Create a mock proxy resolution service. |
60 MockProxyResolutionService* mock_proxy_resolution_service_provider = | 61 MockProxyResolutionService* mock_proxy_resolution_service_provider = |
61 new MockProxyResolutionService; | 62 new MockProxyResolutionService; |
62 | 63 |
63 // Start() will be called with |mock_exported_object_|. | 64 // Start() will be called with |mock_exported_object_|. |
64 EXPECT_CALL(*mock_proxy_resolution_service_provider, | 65 EXPECT_CALL(*mock_proxy_resolution_service_provider, |
65 Start(Eq(mock_exported_object_))).WillOnce(Return()); | 66 Start(Eq(mock_exported_object_))).WillOnce(Return()); |
66 | 67 |
(...skipping 16 matching lines...) Expand all Loading... |
83 }; | 84 }; |
84 | 85 |
85 TEST_F(CrosDBusServiceTest, Start) { | 86 TEST_F(CrosDBusServiceTest, Start) { |
86 // Simply start the service and see if mock expectations are met: | 87 // Simply start the service and see if mock expectations are met: |
87 // - The service object is exported by GetExportedObject() | 88 // - The service object is exported by GetExportedObject() |
88 // - The proxy resolution service is started. | 89 // - The proxy resolution service is started. |
89 cros_dbus_service_->Start(); | 90 cros_dbus_service_->Start(); |
90 } | 91 } |
91 | 92 |
92 } // namespace chromeos | 93 } // namespace chromeos |
OLD | NEW |